FloodMonitoring


Source link: https://github.com/fiskurgit/FloodMonitoring

FloodMonitoring

Android library for the gov.uk Flood Monitoring API: http://environment.data.gov.uk/flood-monitoring/doc/reference

The Flood Monitoring API is RESTful and follows HATEOAS, this means where the Android library requires a url you can use the id of an object: getId()

A couple of apps using this library:
Flood Alerts: https://play.google.com/store/apps/details?id=eu.fiskur.floodmonitor
River Levels: https://play.google.com/store/apps/details?id=eu.fiskur.riverlevels

The library uses RxJava, example usage:

FloodMonitoring.getInstance().getThreeDayForecast()  .observeOn(AndroidSchedulers.mainThread())  .subscribeOn(Schedulers.newThread())  .subscribe(new Observer<ThreeDayForecast>() {

@Override

public void onCompleted() {

}

 @Override

public void onError(Throwable e) {

 //...

}

 @Override

public void onNext(ThreeDayForecast threeDayForecast) {

 outputForecast(threeDayForecast);

}
  
}
);

#Dependency

Add jitpack.io to your root build.gradle, eg:

allprojects {

  repositories {

jcenter()

maven {
 url "https://jitpack.io" 
}

  
}
 
}

then add the dependency to your project build.gradle:

dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.github.fiskurgit:FloodMonitoring:1.5' 
}

You can find the latest version in the releases tab above: https://github.com/fiskurgit/FloodMonitoring/releases

More options at jitpack.io: https://jitpack.io/#fiskurgit/FloodMonitoring

#Licence

Full licence here: https://github.com/fiskurgit/FloodMonitoring/blob/master/LICENSE.md

In short:

The MIT License is a permissive license that is short and to the point. It lets people do anything they want with your code as long as they provide attribution back to you and don’t hold you liable.

#Logging

You can turn on logging to see the network response:

FloodMonitoring.getInstance().logOutput(true);

Then register a log listener:

FloodApiLogger.getInstance().setApiLogListener(new FloodApiLogger.ApiLogListener() {

  @Override
  public void apiLog(String message) {

Log.d(TAG, message);

  
}
 
}
);

#3 Day Forecast

getThreeDayForecast() returns a general overview of the forecast for England and Wales over the next 3 days. A small image of the UK marked with forecast warnings can be fetched using getDayImageBytes(int day) (with 1, 2, or 3) this returns a Retrofit ResponseBody containing the image bytes, a convenience method in the utils class helps populate an ImageView: FloodUtils.loadImage(responseBody, imageView). Alternatively get the image URLs for use with Picasso or similar: getDayImageUrl(int day).

#Flood Warnings

getAllWarnings() returns List<FloodWarning> of all current alerts (including any that have been removed in the last 24 hours, use getSeverityLevel() to build your UI).

getAreaWarnings(double latitude, double longitude, int distance) returns List<FloodWarning> of any flood alerts in the area.

getFloodAreaFromUrl(String url) returns the FloodArea including latitude and longitude for plotting warning locations on a map.

#Water Level Stations

getAreaStations(double latitude, double longitude, int distance) returns List<StationOverview> containing some detail, but you should use the id to fetch the full StationDetail object: getStation(String url).

getReadings(String url, int count) gets the last count Reading objects, normally taken at 15 minute intervals that you can use to create graphs, you can also use getReadingsToday(String url) and getReadingsDays(String url, int days) which will ge the last x days worth of readings (although the API docs state data is held for a month it only seems to return up to two weeks worth of readings).

##Code Coverage

Resources

Parallax everywhere (PEW) is a library with alternative android views using parallax effects.

How it works?

  • Any parallax views (PEW*) needs to be inside a view with scroll events, ej: scrollView, listView, gridView....
  • Parallax effect on views will be related to its position on device screen.
  • Parallax effect in ImageView is calculated with left image in Scale mode centerCrop, centerInside or center. You can't make more parallax effect.
  • Parallax effect in no image views needs a size parallax parameter (read: Attributes)

The TileView widget is a subclass of ViewGroup that provides a mechanism to asynchronously display tile-based images, with additional functionality for 2D dragging, flinging, pinch or double-tap to zoom, adding overlaying Views (markers), built-in Hot Spot support, dynamic path drawing, multiple levels of detail, and support for any relative positioning or coordinate system.

FlowLayout is an opensource Android library that allows developers to easily integrate flow layout into their app. FlowLayout is an layout that display its children in multiple rows depending on their size.

An Android Parallax ListView item (this effect inspired by sound cloud android app).

Android comes with a few "wrapper" classes, like CursorWrapper, that make it relatively easy for you to add just a bit of functionality to an existing object. The wrapper delegates all behaviors to the wrapped object; you just override the specific behaviors you need. This works well in cases where there are many possible underlying implementations, so you could not robustly accomplish these ends by subclassing.

Android lacks such a wrapper for ListAdapter, though. There is a WrappedListAdapter entry in the SDK, but it is an interface, not an implementation.

So, CWAC offers an AdapterWrapper to fill this void.

Sometimes, you want your users to pick a color. A simple approach is to give the user a fixed roster of a handful of colors -- easy, but limited. A fancy approach is to use some form of color wheel, but these can be difficult to use on a touchscreen and perhaps impossible without a touchscreen.

ColorMixer is a widget that provides a simple set of SeekBars to let the user mix red, green, and blue to pick an arbitrary color. It is not very big, so it is easy to fit on a form, and it is still fairly finger-friendly.

It is also packaged as a dialog (ColorMixerDialog), a dialog-themed activity (ColorMixerActivity), and a preference (ColorPreference).

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes