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:tv.ouya.sdk.OuyaUnityPlugin.java

public static void contentDelete(final OuyaMod ouyaMod) {
    try {// w w  w  . j  a  v  a  2  s  .c o m
        //Log.i(TAG, "contentDelete");
        final Activity activity = IOuyaActivity.GetActivity();
        if (null != activity) {
            Runnable runnable = new Runnable() {
                public void run() {
                    UnityOuyaFacade unityOuyaFacade = IOuyaActivity.GetUnityOuyaFacade();
                    if (null == unityOuyaFacade) {
                        Log.e(TAG, "unityOuyaFacade is null");
                    } else {
                        unityOuyaFacade.contentDelete(ouyaMod);
                    }
                }
            };
            activity.runOnUiThread(runnable);
        }
    } catch (Exception e) {
        Log.e(TAG, "contentDelete: exception=" + e.toString());
    }
}

From source file:tv.ouya.sdk.OuyaUnityPlugin.java

public static void contentPublish(final OuyaMod ouyaMod) {
    try {// w  ww  .j  a  va  2 s .  c o m
        //Log.i(TAG, "contentPublish");
        final Activity activity = IOuyaActivity.GetActivity();
        if (null != activity) {
            Runnable runnable = new Runnable() {
                public void run() {
                    UnityOuyaFacade unityOuyaFacade = IOuyaActivity.GetUnityOuyaFacade();
                    if (null == unityOuyaFacade) {
                        Log.e(TAG, "unityOuyaFacade is null");
                    } else {
                        unityOuyaFacade.contentPublish(ouyaMod);
                    }
                }
            };
            activity.runOnUiThread(runnable);
        }
    } catch (Exception e) {
        Log.e(TAG, "contentPublish: exception=" + e.toString());
    }
}

From source file:tv.ouya.sdk.OuyaUnityPlugin.java

public static void contentDownload(final OuyaMod ouyaMod) {
    try {/*from   w  w  w  .  j  a  va 2  s  .  c  o m*/
        //Log.i(TAG, "contentDownload");
        final Activity activity = IOuyaActivity.GetActivity();
        if (null != activity) {
            Runnable runnable = new Runnable() {
                public void run() {
                    UnityOuyaFacade unityOuyaFacade = IOuyaActivity.GetUnityOuyaFacade();
                    if (null == unityOuyaFacade) {
                        Log.e(TAG, "unityOuyaFacade is null");
                    } else {
                        unityOuyaFacade.contentDownload(ouyaMod);
                    }
                }
            };
            activity.runOnUiThread(runnable);
        }
    } catch (Exception e) {
        Log.e(TAG, "contentDownload: exception=" + e.toString());
    }
}

From source file:tv.ouya.sdk.OuyaUnityPlugin.java

public static void contentUnpublish(final OuyaMod ouyaMod) {
    try {/* w w w .  jav a  2  s. com*/
        //Log.i(TAG, "contentUnpublish");
        final Activity activity = IOuyaActivity.GetActivity();
        if (null != activity) {
            Runnable runnable = new Runnable() {
                public void run() {
                    UnityOuyaFacade unityOuyaFacade = IOuyaActivity.GetUnityOuyaFacade();
                    if (null == unityOuyaFacade) {
                        Log.e(TAG, "unityOuyaFacade is null");
                    } else {
                        unityOuyaFacade.contentUnpublish(ouyaMod);
                    }
                }
            };
            activity.runOnUiThread(runnable);
        }
    } catch (Exception e) {
        Log.e(TAG, "contentUnpublish: exception=" + e.toString());
    }
}

From source file:tv.ouya.sdk.OuyaUnityPlugin.java

public static void saveOuyaMod(final OuyaMod ouyaMod, final OuyaMod.Editor editor) {
    try {//from  w w w.java2 s .c o m
        //Log.i(TAG, "saveOuyaMod");
        final Activity activity = IOuyaActivity.GetActivity();
        if (null != activity) {
            Runnable runnable = new Runnable() {
                public void run() {
                    UnityOuyaFacade unityOuyaFacade = IOuyaActivity.GetUnityOuyaFacade();
                    if (null == unityOuyaFacade) {
                        Log.e(TAG, "unityOuyaFacade is null");
                    } else {
                        unityOuyaFacade.saveOuyaMod(ouyaMod, editor);
                    }
                }
            };
            activity.runOnUiThread(runnable);
        }
    } catch (Exception e) {
        Log.e(TAG, "saveOuyaMod: exception=" + e.toString());
    }
}

From source file:com.mediatek.contacts.activities.ActivitiesUtils.java

public static boolean checkPhoneBookReady(final Activity activity, Bundle savedState, int subId) {
    if (subId > 0 && !SimCardUtils.isPhoneBookReady(subId)) {
        Log.w(TAG, "[checkPhoneBookReady] phone book is not ready. mSubId:" + subId);
        activity.finish();/*from w w  w  .  j ava 2 s. c o m*/
        return true;
    }

    if ((MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE)
            || MultiChoiceService.isProcessing(MultiChoiceService.TYPE_COPY)
            || VCardService.isProcessing(VCardService.TYPE_IMPORT)
            || MultiGroupPickerFragment.isMoveContactsInProcessing() //M:FixedALPS00567939
    ) && (savedState == null)) {
        Log.d(TAG, "[checkPhoneBookReady]delete or copy is processing ");
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(activity.getApplicationContext(), R.string.phone_book_busy, Toast.LENGTH_SHORT)
                        .show();
            }
        });
        activity.finish();
        return true;
    }
    return false;
}

From source file:com.xperia64.timidityae.ArtFragment.java

public void setArt(final Bitmap art, Activity a) {
    if (artOk) {//  w ww.ja v  a 2 s. c  om
        if (art != null) {
            a.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mImg.setImageBitmap(art);
                    mImg.invalidate();
                }
            });
        } else {
            a.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    mImg.setImageResource(R.drawable.timidity);
                    mImg.invalidate();
                }
            });
        }
    }
}

From source file:com.pusher.PusherModule.java

@Override
public void onDestroy(Activity activity) {
    activity.runOnUiThread(new Runnable() {
        @Override//from   w  w w. j a v a  2  s .  com
        public void run() {
            PusherModule.this.disconnect();
        }
    });
}

From source file:at.madexperts.logmynight.facebook.LoginHandler.java

/**
 * Render the Login page./*from  ww  w  .  ja va 2  s .  co  m*/
 */
public void go() {
    final Activity activity = LoginHandler.this.getActivity();
    activity.runOnUiThread(new Runnable() {
        public void run() {
            // We need to temporarily remove the app's WebView
            // instance because Android apparently doesn't support
            // multiple WebView instances in the same app.
            dispatcher.hideWebView();
            final Facebook fb = new Facebook();
            fb.authorize(getActivity(), FacebookActivity.APPLICATION_ID, PERMISSIONS, new AppLoginListener(fb));
        }
    });
}

From source file:com.autburst.picture.facebook.LoginHandler.java

/**
 * Render the Login page.//from www .j  a  va 2  s . c  o  m
 */
public void go() {
    final Activity activity = LoginHandler.this.getActivity();
    activity.runOnUiThread(new Runnable() {
        public void run() {
            // We need to temporarily remove the app's WebView
            // instance because Android apparently doesn't support
            // multiple WebView instances in the same app.
            dispatcher.hideWebView();
            final Facebook fb = new Facebook();
            fb.authorize(getActivity(), getActivity().getIntent().getStringExtra("application_id"), PERMISSIONS,
                    new AppLoginListener(fb));
        }
    });
}