Sync

General

Category
Free
Tag
Background Processing
License
MIT License
Registered
Mar 27, 2017
Favorites
2
Link
https://github.com/leomindez/Sync
See also
NanoTasks
RxBolts
KayThread
ActorLite
Android Deferred Object

Additional

Language
Java
Version
1.0.0 (Mar 16, 2017)
Created
Mar 15, 2017
Updated
Mar 17, 2017 (Retired)
Owner
Leonel Mendez Jimenez (leomindez)
Contributor
Leonel Mendez Jimenez (leomindez)
1
Activity
Badge
Generate
Download
Source code

Sync

Small Android library to handle Async Task methods. Use Interface Segregation Principle to divide the actions into indivual callbacks.

Configuration

 allprojects {
  repositories {
   ...
   maven { url 'https://jitpack.io' }
  }
 }
        
        dependencies {
         compile 'com.github.leomindez:Sync:1.0.0'
 }

Usage

Create a class and extends from Sync class. Sync is generic class, set <Params, Result> types and then implement doInBackground method.

private class SyncExample extends Sync<String, String> {
        @Override
        protected String doInBackground(String... params) {
            return "Example from" + params[0];
    }
 }

Create an instance

SyncExample sync = new SyncExample();

then call execute method

sync.executer("Sync");

Use interface callbacks to handle Sync behavior.

Response Callback

sync.response(new SyncResponseCallback<String>(){
  @Override
public void onSuccess(String s) {
Toast.makeText(MainActivity.this, s, Toast.LENGTH_LONG).show();
}
@Override
public void onError(Error error) {
Toast.makeText(MainActivity.this, error.getMessage(), Toast.LENGTH_LONG).show();
}
});

PreExecute Callback

sync.preExecute(new SyncPreExecuteCallback() {
@Override
public void onPreExecute() {       
}
});    
                

Progress Callback

sync.progress(new SyncProgressCallback() {
@Override
public void onProgress(Integer... progress) {
}
});

Cancel Callback

sync.cancel(new SyncCancelCallback<String>() {
@Override
public void onCancel(String s) {
}
});