Groundy


Source link: https://github.com/telly/groundy

Groundy library for Android

@Deprecated

Unfortunatenly this library is no longer maintained, we encourage you to use other widely supported solutions like RxJava.

Groundy is a fun, sexy way to do background work on your Android app; it's specially useful for running tasks that must be executed even if your activities/fragments are destroyed. It allows you to receive notifications from the background task directly to your activity or any object.

It is useful for several scenarios like executing calls to external services (e.g. RESTful web services), download and/or process files, encoding audio/video and any kind of task that could block the main thread.

Basic usage

Create a subclass of GroundyTask:

public class ExampleTask extends GroundyTask {

@Override
protected TaskResult doInBackground() {

  // you can send parameters to the task using a Bundle (optional)
  String exampleParam = getStringArg("arg_name");

// lots of code

// return a TaskResult depending on the success of your task
  // and optionally pass some results back
  return succeeded().add("the_result", "some result");

}
 
}

Whenever you want to execute the task, just do this:

// this is usually performed from within an Activity Groundy.create(ExampleTask.class)
  .callback(callbackObj)

  // required if you want to get notified of your task lifecycle
  .arg("arg_name", "foo")

 // optional
  .queueUsing(YourActivity.this);

You will get results in your callback object(s) (in the main thread):

@OnSuccess(ExampleTask.class) public void onSuccess(@Param("the_result") String result) {

// do something with the result 
}

Do not forget to add GroundyService to the AndroidManifest.xml file:

<service android:name="com.telly.groundy.GroundyService"/>

Extending callback system

There are some already defined onCallback annotations: @OnSuccess, @OnFailed, @OnCancel, @OnProgress and @OnStart, but you can also create your own callback types like:

@OnCallback(task = ChuckTask.class, name = "kick") public void onChuckNorrisAttack(@Param("target") String target) {

Toast.makeText(this, "Chuck Norris kicked your " + target, Toast.LENGTH_SHORT).show();
 
}

Take a look at the custom callbacks example for details on this.

Integration

In order to use this library from you Android project using Maven your pom should look like this:

<dependency>
<groupId>com.telly</groupId>
<artifactId>groundy</artifactId>
<version>(insert latest version)</version> </dependency>  <!-- enables groundy JSR-269 processor which makes everything up to 5 times faster --> <dependency>
<groupId>com.telly</groupId>
<artifactId>groundy-compiler</artifactId>
<version>(insert latest version)</version> </dependency>

For Gradle projects use:

compile 'com.telly:groundy:(insert latest version)' provided 'com.telly:groundy-compiler:(insert latest version)'

Note: provided dependencies are supported by android gradle plugin v0.8 or later.

At this point latest version is 1.5.

Proguard

If you are using proguard, please add these rules

-keepattributes *Annotation*  -keepclassmembers,allowobfuscation class * {

  @com.telly.groundy.annotations.* *;
  <init>();
 
}
  -keepnames class com.telly.groundy.generated.* -keep class com.telly.groundy.generated.* -keep class com.telly.groundy.ResultProxy -keepnames class * extends com.telly.groundy.ResultProxy -keep class * extends com.telly.groundy.GroundyTask 

Resources

Android Ticker Text for real.

Custom ImageView for moving image around the screen.

Custom ImageView for android with polygon shape.

There are 3 basic effects:

  • RegularPolygonShape
  • PaperPolygonShape
  • StarPolygonShape

Custom layout that arranges views in rows and columns automatically. Takes care about padding, margins, gravity and layout child gravities.

Super fast and easy way to create header for Android RecyclerView.

An Android library introducing a stack of Views with the first item being flippable.

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