android-ActionQueue 使用 Android 开发包

程序名称:android-ActionQueue 使用

授权协议: 未知

操作系统: Android

开发语言: Java

android-ActionQueue 使用 介绍

ActionQueue 允许你一个一个的执行任务。

导入:

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

加依赖:

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

使用

创建 action:

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);
}

处理 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);
    }
}

action 执行完之后通知提醒:

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

android-ActionQueue 使用 官网

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐