Tabnine Logo
Activity.runOnUiThread
Code IndexAdd Tabnine to your IDE (free)

How to use
runOnUiThread
method
in
android.app.Activity

Best Java code snippets using android.app.Activity.runOnUiThread (Showing top 20 results out of 2,457)

origin: xfumihiro/ViewInspector

@Override public void onProfileDone() {
 ((Activity) mContext).runOnUiThread(new Runnable() {
  @Override public void run() {
   new ProfileResultDialog(
     new ContextThemeWrapper(mContext, BaseDialog.getDialogTheme(mContext)),
     profileProgressbar.getSamples()).show();
   closeProgressbar();
  }
 });
}
origin: xfumihiro/ViewInspector

@Override public void onProgress(final int step) {
 ((Activity) mContext).runOnUiThread(new Runnable() {
  @Override public void run() {
   profileProgressbar.setProgress(step);
  }
 });
}
origin: k9mail/k-9

public void setAlias(String alias) {
  // Note: KeyChainAliasCallback gives back "" on cancel
  if (alias != null && alias.equals("")) {
    alias = null;
  }
  mAlias = alias;
  // Note: KeyChainAliasCallback is a different thread than the UI
  mActivity.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      updateView();
      if (mListener != null) {
        mListener.onClientCertificateChanged(mAlias);
      }
    }
  });
}
origin: android10/Android-CleanArchitecture

/**
 * Run the operation of loading a bitmap on the UI thread.
 *
 * @param bitmap The image to load.
 */
private void loadBitmap(final Bitmap bitmap) {
 ((Activity) getContext()).runOnUiThread(new Runnable() {
  @Override public void run() {
   AutoLoadImageView.this.setImageBitmap(bitmap);
  }
 });
}
origin: android10/Android-CleanArchitecture

/**
 * Loads the image place holder if any has been assigned.
 */
private void loadImagePlaceHolder() {
 if (this.imagePlaceHolderResId != -1) {
  ((Activity) getContext()).runOnUiThread(new Runnable() {
   @Override public void run() {
    AutoLoadImageView.this.setImageResource(
      AutoLoadImageView.this.imagePlaceHolderResId);
   }
  });
 }
}
origin: commonsguy/cw-omnibus

@Override
public void onError(final String message, Exception e) {
 Log.e(getClass().getSimpleName(), message, e);
 getActivity().runOnUiThread(new Runnable() {
  @Override
  public void run() {
   Toast
    .makeText(getActivity(), message, Toast.LENGTH_LONG)
    .show();
  }
 });
}
origin: facebook/facebook-android-sdk

  @Override
  public void run() {
    final FetchedAppSettings settings = FetchedAppSettingsManager.queryAppSettings(appId, false);
    getActivity().runOnUiThread(new Runnable() {
      @Override
      public void run() {
        showToolTipPerSettings(settings);
      }
    });
  }
});
origin: TommyLemon/APIJSON

/** 隐藏加载进度
 */
public static void dismissProgressDialog(Activity context) {
  if(context == null || progressDialog == null || progressDialog.isShowing() == false){
    return;
  }
  context.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      progressDialog.dismiss();
    }
  });
}
//显示与关闭进度弹窗方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
origin: TommyLemon/Android-ZBLibrary

/** 隐藏加载进度
 */
public static void dismissProgressDialog(Activity context) {
  if(context == null || progressDialog == null || progressDialog.isShowing() == false){
    return;
  }
  context.runOnUiThread(new Runnable() {
    @Override
    public void run() {
      progressDialog.dismiss();
    }
  });
}
//显示与关闭进度弹窗方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
origin: cSploit/android

@Override
public void onReceive(final Context context, final Intent intent) {
 if(context instanceof Activity) {
  ((Activity) context).runOnUiThread(new Runnable() {
   @Override
   public void run() {
    notifyIntent(context, intent);
   }
  });
 } else {
  notifyIntent(context, intent);
 }
}
origin: RobotiumTech/robotium

/**
 * Sets the progress of a given {@link ProgressBar}. Examples are SeekBar and RatingBar.
 * @param progressBar the {@code ProgressBar}
 * @param progress the progress that the {@code ProgressBar} should be set to
 */
public void setProgressBar(final ProgressBar progressBar,final int progress) {
  if(progressBar != null){
    Activity activity = activityUtils.getCurrentActivity(false);
    if(activity != null){
      activity.runOnUiThread(new Runnable()
      {
        public void run()
        {
          try{
            progressBar.setProgress(progress);
          }catch (Exception ignored){}
        }
      });
    }
  }
}
origin: googlesamples/android-Camera2Basic

/**
 * Shows a {@link Toast} on the UI thread.
 *
 * @param text The message to show
 */
private void showToast(final String text) {
  final Activity activity = getActivity();
  if (activity != null) {
    activity.runOnUiThread(new Runnable() {
      @Override
      public void run() {
        Toast.makeText(activity, text, Toast.LENGTH_SHORT).show();
      }
    });
  }
}
origin: jMonkeyEngine/jmonkeyengine

public void removeSplashScreen() {
  logger.log(Level.FINE, "Splash Screen Picture Resource ID: {0}", splashPicID);
  if (splashPicID != 0) {
    if (frameLayout != null) {
      if (splashImageView != null) {
        getActivity().runOnUiThread(new Runnable() {
          @Override
          public void run() {
            splashImageView.setVisibility(View.INVISIBLE);
            frameLayout.removeView(splashImageView);
          }
        });
      } else {
        logger.fine("splashImageView is null");
      }
    } else {
      logger.fine("frameLayout is null");
    }
  }
}
origin: RobotiumTech/robotium

/**
 * Sets the date in a given {@link DatePicker}.
 *
 * @param datePicker the {@code DatePicker} object.
 * @param year the year e.g. 2011
 * @param monthOfYear the month which is starting from zero e.g. 03
 * @param dayOfMonth the day e.g. 10
 */
public void setDatePicker(final DatePicker datePicker, final int year, final int monthOfYear, final int dayOfMonth) {
  if(datePicker != null){
    Activity activity = activityUtils.getCurrentActivity(false);
    if(activity != null){
      activity.runOnUiThread(new Runnable()
      {
        public void run()
        {
          try{
            datePicker.updateDate(year, monthOfYear, dayOfMonth);
          }catch (Exception ignored){}
        }
      });
    }
  }
}
origin: RobotiumTech/robotium

public void doScreenshot() {
  View v = getScreenshotView();
  if(v == null) keepRunning = false;
  String final_name = name+"_"+seqno;
  ScreenshotRunnable r = new ScreenshotRunnable(v, final_name, quality);
  Log.d(LOG_TAG, "taking screenshot "+final_name);
  Activity activity = activityUtils.getCurrentActivity(false);
  if(activity != null){
    activity.runOnUiThread(r);
  }
  else {
    instrumentation.runOnMainSync(r);
  }
}
origin: commonsguy/cw-omnibus

@Subscribe
public void onRandomEvent(final RandomEvent event) {
 if (getActivity() != null) {
  getActivity().runOnUiThread(new Runnable() {
   @Override
   public void run() {
    adapter.add(event);
   }
  });
 }
}
origin: cSploit/android

@Override
public void onMenuClick(Activity activity, final MenuItem item) {
 if(isRunning()) {
  stop();
 } else {
  start();
 }
 activity.runOnUiThread(new Runnable() {
  @Override
  public void run() {
   buildMenuItem(item);
  }
 });
}
origin: ACRA/acra

public void finishLastActivity(@Nullable Thread uncaughtExceptionThread) {
  // Trying to solve https://github.com/ACRA/acra/issues/42#issuecomment-12134144
  // Determine the current/last Activity that was started and close
  // it. Activity#finish (and maybe it's parent too).
  final Activity lastActivity = lastActivityManager.getLastActivity();
  if (lastActivity != null) {
    final boolean isMainThread = uncaughtExceptionThread == lastActivity.getMainLooper().getThread();
    if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Finishing the last Activity prior to killing the Process");
    final Runnable finisher = () -> {
      lastActivity.finish();
      if (ACRA.DEV_LOGGING) ACRA.log.d(LOG_TAG, "Finished " + lastActivity.getClass());
    };
    if (isMainThread) {
      finisher.run();
    } else {
      lastActivity.runOnUiThread(finisher);
    }
    // A crashed activity won't continue its lifecycle. So we only wait if something else crashed
    if (!isMainThread) {
      lastActivityManager.waitForActivityStop(100);
    }
    lastActivityManager.clearLastActivity();
  }
}
origin: robolectric/robolectric

@Test
public void shouldRunUiTasksImmediatelyByDefault() throws Exception {
 TestRunnable runnable = new TestRunnable();
 activity = Robolectric.setupActivity(DialogLifeCycleActivity.class);
 activity.runOnUiThread(runnable);
 assertTrue(runnable.wasRun);
}
origin: robolectric/robolectric

@Test
public void shouldQueueUiTasksWhenUiThreadIsPaused() throws Exception {
 ShadowLooper.pauseMainLooper();
 activity = Robolectric.setupActivity(DialogLifeCycleActivity.class);
 TestRunnable runnable = new TestRunnable();
 activity.runOnUiThread(runnable);
 assertFalse(runnable.wasRun);
 ShadowLooper.unPauseMainLooper();
 assertTrue(runnable.wasRun);
}
android.appActivityrunOnUiThread

Popular methods of Activity

  • onCreate
  • getWindow
  • finish
  • onDestroy
  • onResume
  • findViewById
  • startActivity
  • getResources
  • startActivityForResult
  • onPause
  • getSystemService
  • getWindowManager
  • getSystemService,
  • getWindowManager,
  • isFinishing,
  • getString,
  • onStop,
  • getApplicationContext,
  • onStart,
  • onOptionsItemSelected,
  • getPackageName

Popular in Java

  • Finding current android device location
  • getApplicationContext (Context)
  • setRequestProperty (URLConnection)
  • compareTo (BigDecimal)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • JComboBox (javax.swing)
  • JPanel (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now