Example usage for android.app Activity runOnUiThread

List of usage examples for android.app Activity runOnUiThread

Introduction

In this page you can find the example usage for android.app Activity runOnUiThread.

Prototype

public final void runOnUiThread(Runnable action) 

Source Link

Document

Runs the specified action on the UI thread.

Usage

From source file:Main.java

public static void gone(Activity r, final View v) {
    r.runOnUiThread(new Runnable() {
        @Override//w  w w  .j av  a  2  s .  co  m
        public void run() {
            v.setVisibility(View.GONE);
        }
    });
}

From source file:Main.java

public static void raiseToastAlertRunningOnUIThread(final String message, final Activity activity) {
    activity.runOnUiThread(new Runnable() {
        @Override/*from   w  ww.  ja v a 2s.  com*/
        public void run() {
            Toast.makeText((Context) activity, message, Toast.LENGTH_LONG).show();
        }
    });
}

From source file:Main.java

public static void visible(Activity r, final View v) {
    r.runOnUiThread(new Runnable() {
        @Override// ww  w .j  ava2 s.  c  o  m
        public void run() {
            v.setVisibility(View.VISIBLE);
        }
    });
}

From source file:Main.java

public static void hideProgressDialog(Activity activity) {
    activity.runOnUiThread(new Runnable() {
        @Override/*  ww w. j  ava  2 s.co  m*/
        public void run() {
            if (progressDialog != null) {
                if (progressDialog.isShowing()) {
                    progressDialog.dismiss();
                }
            }
        }
    });
}

From source file:Main.java

public static void setTransparent(Activity r, final View v) {
    r.runOnUiThread(new Runnable() {
        @Override/*from w  ww . ja  va 2  s. co  m*/
        public void run() {
            v.setBackgroundColor(Color.TRANSPARENT);
        }
    });
}

From source file:Main.java

public static void showPopup(final String msg, final Context context) {
    Activity a = (Activity) context;
    a.runOnUiThread(new Runnable() {
        @Override/*from w  ww . jav  a2 s .com*/
        public void run() {
            Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
        }
    });
}

From source file:Main.java

public static void safeToastMessageShow(Activity pActivity, String pToastMsg, int pToastLength) {
    final String toastMsg = pToastMsg;
    final int toastLength = pToastLength;
    final Activity activity = pActivity;

    activity.runOnUiThread(new Runnable() {
        @Override//w  ww  .ja va2 s .  c om
        public void run() {
            Toast.makeText(activity.getApplicationContext(), toastMsg, toastLength).show();
        }
    });
}

From source file:Main.java

public static void startActivityWithIntent(final Activity activity, final Intent intent) {
    activity.runOnUiThread(new Runnable() {
        public void run() {
            activity.startActivity(intent);
        }/*from ww  w  .j  a va2  s . c  om*/
    });
}

From source file:Main.java

public static void showMessage(final Activity activity, final String message) {
    activity.runOnUiThread(new Runnable() {
        public void run() {
            Toast.makeText(activity, message, Toast.LENGTH_LONG).show();
        }/*w w  w . ja  v  a2  s. c  om*/
    });
}

From source file:Main.java

public static void runInUIThread(Context context, final Toast toast) {
    final Activity activity = (Activity) context;
    activity.runOnUiThread(new Runnable() {
        public void run() {
            toast.show();/*from  w ww  .  j a  v  a  2s. com*/
        }
    });
}