AsyncOp

A very helpful framework for asynchronous operation related to an Activity or Fragment for Android application

Лицензия

Лицензия

Категории

Категории

GUI Взаимодействие с пользователем
Группа

Группа

com.github.mguidi.asyncop
Идентификатор

Идентификатор

asyncop
Последняя версия

Последняя версия

1.1.0
Дата

Дата

Тип

Тип

aar
Описание

Описание

AsyncOp
A very helpful framework for asynchronous operation related to an Activity or Fragment for Android application
Ссылка на сайт

Ссылка на сайт

https://github.com/mguidi/asyncop
Система контроля версий

Система контроля версий

https://github.com/mguidi/asyncop

Скачать asyncop

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.mguidi.asyncop/asyncop/ -->
<dependency>
    <groupId>com.github.mguidi.asyncop</groupId>
    <artifactId>asyncop</artifactId>
    <version>1.1.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/com.github.mguidi.asyncop/asyncop/
implementation 'com.github.mguidi.asyncop:asyncop:1.1.0'
// https://jarcasting.com/artifacts/com.github.mguidi.asyncop/asyncop/
implementation ("com.github.mguidi.asyncop:asyncop:1.1.0")
'com.github.mguidi.asyncop:asyncop:aar:1.1.0'
<dependency org="com.github.mguidi.asyncop" name="asyncop" rev="1.1.0">
  <artifact name="asyncop" type="aar" />
</dependency>
@Grapes(
@Grab(group='com.github.mguidi.asyncop', module='asyncop', version='1.1.0')
)
libraryDependencies += "com.github.mguidi.asyncop" % "asyncop" % "1.1.0"
[com.github.mguidi.asyncop/asyncop "1.1.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
com.android.support » support-v4 jar 21.0.0

Модули Проекта

Данный проект не имеет модулей.

asyncop

A very helpful framework for asynchronous operation related to an Activity or Fragment for Android application

How to use

With Android Studio add dependency:

compile 'com.github.mguidi.asyncop:asyncop:1.0.0'

Define your async operation extending the AsyncOp Class:

public class LongOp extends AsyncOp {

	@Override
    public Bundle execute(Context context, Bundle args) {
    
	    Bundle result = new Bundle();
    
    	// define your operation here

        return result;
	}

}

Map your operation with an action in your Application class:

public class Application extends android.app.Application {

	@Override
    public void onCreate() {
	    super.onCreate();

    	AsyncOpManager.getInstance(this).mapOp("long_op", LongOp.class);
	}
}

Execute the operation inside an Activity or a Fragment

public class MyActivity extends ActionBarActivity implements AsyncOpCallback, View.OnClickListener {

    private AsyncOpHelper mOpHelper;

	@Override
    protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
    	setContentView(R.layout.activity_my);

		// initialize the Async op helper on the onCreate
        mOpHelper = new AsyncOpHelper(this, savedInstanceState, this);

	    findViewById(R.id.btnHello).setOnClickListener(this);
	}

    @Override
	protected void onResume() {
    	super.onResume();
        mOpHelper.onResume();
	}

    @Override
	protected void onSaveInstanceState(Bundle outState) {
    	super.onSaveInstanceState(outState);
        mOpHelper.onSaveInstanceState(outState);
	}

    @Override
	protected void onPause() {
    	super.onPause();
        mOpHelper.onPause();
	}

    @Override
	public void onAsyncOpFinish(int idRequest, String action, Bundle args, Bundle result) {
    	if (action.equals("long_op")) {

			// handle the result here

    	}
    }

	@Override
    public void onAsyncOpFail(int idRequest, String action) {
    	if (action.equals("long_op")) {
        	
        	// hadle the operaion fail here
        	// the onAscynOpFail is called only in the case that your async op was running when the system killed it
        	
        }
	}

    @Override
	public void onClick(View v) {
    	if (v.getId() == R.id.btnHello) {

			// define a bundle with the async op params
        	Bundle args = new Bundle();
        	
			// execute the async op mapped with the action
			mOpHelper.execute("long_op", args);
    	}
	}
}

Версии библиотеки

Версия
1.1.0
1.0.0