Coder Social home page Coder Social logo

prioritywindow's Introduction

PriorityWindow

按优先级顺序显示弹窗

使用方法

1.直接显示

弹窗集成IWindow,并实现相关方法:

public class DemoDialog extends AlertDialog implements IWindow {
   ...
}

DemoActivity extends Activity implements IWindow{
   ...
}

public class DemoPopupWindow extends PopupWindow implements IWindow {
   ...
}

...

然后创建弹窗任务,最后调用showWindow方法显示即可:

IWindow demoDialog = getDialogWindow();
WindowWrapper windowWrapper = new WindowWrapper.Builder()
        .priority(AD_PRIORITY)
        .windowType(WindowType.DIALOG)
        .window(getDialogWindow())
        .setCanShow(true)
        .setWindowName(demoDialog.getClassName())
        .build();
WindowTaskManager.getInstance().showWindow(TestActivity.this, getSupportFragmentManager(), windowWrapper);

注意setWindowName要与IWindow中的getClassName()一致。

2.等待逻辑处理后显示

弹窗集成IWindow,并实现相关方法:

public class DemoDialog extends AlertDialog implements IWindow {
   ...
}

DemoActivity extends Activity implements IWindow{
   ...
}

public class DemoPopupWindow extends PopupWindow implements IWindow {
   ...
}

...

然后初始化弹窗任务:

IWindow activityWindow = getActivityWindow();
WindowTaskManager.getInstance().addWindow(new WindowWrapper.Builder()
        .priority(ALERT_PRIORITY)
        .windowType(WindowType.ACTIVITY)
        .window(activityWindow)
        .setWindowName(activityWindow.getClassName())
        .setCanShow(true)
        .build());

IWindow popupWindow = getPopupWindow();
WindowTaskManager.getInstance().addWindow(new WindowWrapper.Builder()
        .priority(UPDATE_PRIORITY)
        .windowType(WindowType.POUPOWINDOW)
        .window(getPopupWindow())
        .setWindowName(popupWindow.getClassName())
        .setCanShow(true)
        .build());

在要显示弹窗的地方调用:

 WindowTaskManager.getInstance().continueShow(context, getSupportFragmentManager());

如果不需要显示弹窗了,则调用:

WindowTaskManager.getInstance().disableWindow(windowName);

3.阻塞弹窗

有时候需要阻塞弹窗的显示,比如引导开启系统权限后,会显示系统的权限授权界面,等授权结束后再继续显示其他弹窗。

WindowTaskManager.getInstance().setEnableWindow(false/true);

4.清除弹窗

WindowTaskManager.getInstance().clear();

退出应用的时候将任务栈清空。

Jitpack引入:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
		}
	}
   
dependencies {
	  implementation 'com.github.Geekince:PriorityWindow:Tag'
}
   

prioritywindow's People

Contributors

geekince avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.