Java Code Examples for android.app.Activity#getMainLooper()

The following examples show how to use android.app.Activity#getMainLooper() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResUtil.java    From Puff-Android with MIT License 6 votes vote down vote up
public AppCompatDialog showProgressbar(Activity activity, long timeout, boolean cancelable) {
    final AppCompatDialog dialog = new AppCompatDialog(activity);
    dialog.setContentView(R.layout.dialog_progress);
    dialog.setCancelable(cancelable);
    dialog.setTitle("Progressing...");
    ProgressBar progressBar = (ProgressBar) dialog.findViewById(R.id.progress);
    if (timeout > 0) {
        Handler handler = new Handler(activity.getMainLooper());
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                dialog.cancel();
                dialog.dismiss();
            }
        }, timeout);
        dialog.show();
    } else {
        dialog.show();
    }
    return dialog;
}
 
Example 2
Source File: AsynLoadImg.java    From letv with Apache License 2.0 5 votes vote down vote up
public AsynLoadImg(Activity activity) {
    this.e = new Handler(this, activity.getMainLooper()) {
        final /* synthetic */ AsynLoadImg a;

        public void handleMessage(Message message) {
            f.a("AsynLoadImg", "handleMessage:" + message.arg1);
            if (message.arg1 == 0) {
                this.a.b.saved(message.arg1, (String) message.obj);
            } else {
                this.a.b.saved(message.arg1, null);
            }
        }
    };
}
 
Example 3
Source File: InAppChatMobileImpl.java    From mobile-messaging-sdk-android with Apache License 2.0 5 votes vote down vote up
public InAppChatMobileImpl(InAppChatWebViewManager inAppChatWebViewManager) {
    this.inAppChatWebViewManager = inAppChatWebViewManager;
    if (inAppChatWebViewManager instanceof Fragment) {
        FragmentActivity activity = ((Fragment) inAppChatWebViewManager).getActivity();
        if (activity != null) {
            this.handler = new Handler(activity.getMainLooper());
        }
    } else if (inAppChatWebViewManager instanceof Activity) {
        Activity inAppChatWebViewManagerActivity = (Activity) inAppChatWebViewManager;
        this.handler = new Handler(inAppChatWebViewManagerActivity.getMainLooper());
    }
}
 
Example 4
Source File: AsynLoadImg.java    From MiBandDecompiled with Apache License 2.0 4 votes vote down vote up
public AsynLoadImg(Activity activity)
{
    g = new b(this);
    a = activity;
    f = new a(this, activity.getMainLooper());
}