Action Queue

Action-Queue

License

License

Apache 2
GroupId

GroupId

in.srain.cube
ArtifactId

ArtifactId

action-queue
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

aar
Description

Description

Action Queue
Action-Queue
Project URL

Project URL

https://github.com/liaohuqiu/android-ActionQueue
Source Code Management

Source Code Management

https://github.com/liaohuqiu/android-ActionQueue

Download action-queue

How to add to project

<!-- https://jarcasting.com/artifacts/in.srain.cube/action-queue/ -->
<dependency>
    <groupId>in.srain.cube</groupId>
    <artifactId>action-queue</artifactId>
    <version>1.0.1</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/in.srain.cube/action-queue/
implementation 'in.srain.cube:action-queue:1.0.1'
// https://jarcasting.com/artifacts/in.srain.cube/action-queue/
implementation ("in.srain.cube:action-queue:1.0.1")
'in.srain.cube:action-queue:aar:1.0.1'
<dependency org="in.srain.cube" name="action-queue" rev="1.0.1">
  <artifact name="action-queue" type="aar" />
</dependency>
@Grapes(
@Grab(group='in.srain.cube', module='action-queue', version='1.0.1')
)
libraryDependencies += "in.srain.cube" % "action-queue" % "1.0.1"
[in.srain.cube/action-queue "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Android Gems

ActionQueue allows you run action one by one.

Import

Repositories:

allprojects {
    repositories {
        mavenCentral()
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots"
        }
        jcenter()
    }
}

Add to dependencies:

compile 'in.srain.cube:action-queue:1.0.1'

Usage

  • create actions

    String[] messageList = new String[]{
            "message 1",
            "message 2",
            "message 3",
    };
    for (int i = 0; i < messageList.length; i++) {
        String message = messageList[i];
        PopDialogAction action = new PopDialogAction(message);
        mActionQueue.add(action);
    }
  • process action

    class PopDialogAction extends ActionQueue.Action<String> {
    
        public PopDialogAction(String badge) {
            super(badge);
        }
    
        @Override
        public void onAction() {
            AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
            Dialog dialog = builder.setMessage(getBadge()).show();
            // notify action is done, and next aciton will be executed
            dialog.setOnDismissListener(mOnDismissListener);
        }
    }
  • notify when action is done

    DialogInterface.OnDismissListener mOnDismissListener = new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            mActionQueue.notifyActionDoneThenTryToPopNext();
        }
    };
  • LICENSE: MIT

Versions

Version
1.0.1