List of usage examples for android.os Handler postDelayed
public final boolean postDelayed(Runnable r, long delayMillis)
From source file:angeloid.sopiane.vegaphoneinfo.Tab_Racer1_Main.java
private void DialogProgressbackup(boolean close) { if (!close) { dialog_backup = ProgressDialog.show(getActivity(), "", "Loading..", true); Handler mHandler = new Handler(); mHandler.postDelayed(new Runnable() { @Override//from w ww . j a v a 2 s. co m public void run() { DialogProgressbackup(true); // . Tab_Racer1_Backup.instantExec_racer_backup(getActivity(), "busybox mount -o rw,remount /system ; "); StringBuilder backup = new StringBuilder(); try { Thread.sleep(2000); backup.append("mount -o rw,remount /system;"); backup.append("mkdir /sdcard/imeibackup;"); backup.append("dd if=/dev/block/mmcblk0p10 of=/sdcard/imeibackup/imei.img;"); backup.append("busybox mount -o ro,remount /system;"); try { Thread.sleep(3000); Tab_Racer1_Backup.instantExec_racer_backup(getActivity(), backup.toString()); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, 10000); } else { dialog_backup.dismiss(); // DialogProgress(true) ,false racer_backup_info.setImageResource(R.drawable.apply); backup.setEnabled(false); backup.setFocusable(false); } }
From source file:angeloid.sopiane.vegaphoneinfo.Tab_Racer1_Main.java
private void DialogProgressrestore(boolean close) { if (!close) { dialog_restore = ProgressDialog.show(getActivity(), "", "Loading..", true); Handler mHandler2 = new Handler(); mHandler2.postDelayed(new Runnable() { @Override// w w w . j a v a2 s.c o m public void run() { DialogProgressrestore(true); // . Tab_Racer1_Restore.instantExec_racer_restore(getActivity(), "busybox mount -o rw,remount /system ; "); StringBuilder restore = new StringBuilder(); try { Thread.sleep(2000); restore.append("mount -o rw,remount /system;"); restore.append("dd if=/sdcard/imeibackup/imei.img of=/dev/block/mmcblk0p10;"); restore.append("busybox mount -o ro,remount /system;"); try { Thread.sleep(3000); Tab_Racer1_Restore.instantExec_racer_restore(getActivity(), restore.toString()); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, 15000); } else { dialog_restore.dismiss(); // DialogProgress(true) ,false racer_backup_info.setImageResource(R.drawable.not_apply); restore.setEnabled(false); restore.setFocusable(false); } }
From source file:com.facebook.internal.FacebookWebFallbackDialog.java
@Override public void dismiss() { WebView webView = getWebView();/*from ww w . j av a 2 s. co m*/ if (isListenerCalled() || webView == null || !webView.isShown()) { // If the listener has been called, or if the WebView isn't visible, we cannot give the dialog a chance // to respond. So defer to the parent implementation. super.dismiss(); return; } // If we have already notified the dialog to close, then ignore this request to dismiss. The timer will // honor the request. if (waitingForDialogToClose) { return; } waitingForDialogToClose = true; // Now fire off the event that will tell the dialog to wind down. String eventJS = "(function() {" + " var event = document.createEvent('Event');" + " event.initEvent('fbPlatformDialogMustClose',true,true);" + " document.dispatchEvent(event);" + "})();"; webView.loadUrl("javascript:" + eventJS); // Set up a timeout for the dialog to respond. If the timer expires, we need to honor the user's desire to // dismiss the dialog. Handler handler = new Handler(Looper.getMainLooper()); handler.postDelayed(new Runnable() { @Override public void run() { if (!isListenerCalled()) { // If we get here, then the dialog did not close quickly enough. So we need to honor the user's // wish to cancel. sendCancelToListener(); } } }, OS_BACK_BUTTON_RESPONSE_TIMEOUT_MILLISECONDS); }
From source file:plugin.google.maps.Environment.java
/** * Set the app background/*from w ww .j av a 2s.c om*/ * @param args Parameters given from JavaScript side * @param callbackContext Callback contect for sending back the result. * @throws JSONException */ @SuppressWarnings("unused") public void setBackGroundColor(final JSONArray args, final CallbackContext callbackContext) throws JSONException { JSONArray rgba = args.getJSONArray(0); int backgroundColor = Color.WHITE; if (rgba != null && rgba.length() == 4) { backgroundColor = PluginUtil.parsePluginColor(rgba); } final int finalBackgroundColor = backgroundColor; final CordovaGoogleMaps googleMaps = (CordovaGoogleMaps) pluginManager.getPlugin("CordovaGoogleMaps"); Handler handler = new Handler(cordova.getActivity().getMainLooper()); handler.postDelayed(new Runnable() { public void run() { googleMaps.mPluginLayout.setBackgroundColor(finalBackgroundColor); sendNoResult(callbackContext); } }, googleMaps.initialized ? 0 : 250); }
From source file:com.cranberrygame.cordova.plugin.navigationbar.NavigationBar.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void _setUp(boolean autoHideNavigationBar) { if (autoHideNavigationBar) { Activity activity = cordova.getActivity(); //http://stackoverflow.com/questions/21164836/immersive-mode-navigation-becomes-sticky-after-volume-press-or-minimise-restore //http://www.youtube.com/watch?v=Xw9TIS_JsPM //https://developer.android.com/training/system-ui/status.html activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); final CordovaInterface cordova_final = cordova; //http://stackoverflow.com/questions/11762306/listen-for-first-touchevent-when-using-system-ui-flag-hide-navigation //http://stackoverflow.com/questions/15103339/android-full-screen-modeics-first-touch-shows-the-navigation-bar //http://developer.android.com/reference/android/view/View.OnSystemUiVisibilityChangeListener.html //webView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener(){//cordova5 build error getView(webView).setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {//fixed cordova5 build error @Override// w w w . j a v a2s . com public void onSystemUiVisibilityChange(int vis) { if (vis == 0) { //http://stackoverflow.com/questions/3072173/how-to-call-a-method-after-a-delay-in-android Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { Activity activity = cordova_final.getActivity(); activity.getWindow().getDecorView() .setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION// | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION //| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN //| View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } }, 3000);//after ms } } }); } }
From source file:com.github.googlecodelabs.icon_shop.CartActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_cart); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//w w w. jav a 2s .com mFloatingActionButton = (FloatingActionButton) findViewById(R.id.fab); mFloatingActionButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { Snackbar.make(view, "Checking out...", Snackbar.LENGTH_LONG).setAction("Action", null).show(); final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { AsyncTask<Void, Void, Void> _ = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... voids) { App.clearCart(); runOnUiThread(new Runnable() { @Override public void run() { mFloatingActionButton.setVisibility(View.GONE); Snackbar.make(view, "Checking completed!", Snackbar.LENGTH_LONG) .setAction("Action", null).show(); handler.postDelayed(new Runnable() { @Override public void run() { NavUtils.navigateUpFromSameTask(CartActivity.this); } }, TimeUnit.SECONDS.toMillis(1)); } }); return null; } }.execute(); } }, TimeUnit.SECONDS.toMillis(2)); // Delay for 2 seconds } }); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mCardContent = App.getCardContent(); RecyclerView recyclerView = getItemsRecycleView(); recyclerView.setHasFixedSize(true); mItemListLayoutManager = new LinearLayoutManager(this); recyclerView.setLayoutManager(mItemListLayoutManager); mAdapter = new ItemsListAdapter(mCardContent, true); recyclerView.setAdapter(mAdapter); mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() { @Override public void onItemRangeRemoved(int positionStart, int itemCount) { super.onItemRangeRemoved(positionStart, itemCount); updateCardInfo(); } @Override public void onItemRangeInserted(int positionStart, int itemCount) { super.onItemRangeInserted(positionStart, itemCount); updateCardInfo(); } }); updateCardInfo(); }
From source file:com.microsoft.rightsmanagement.ui.BaseActivity.java
/** * Start activity end animation and finish activity. *//*w w w .j a va 2 s . com*/ protected void startActivityEndAnimationAndFinishActivity() { int animationDuration = this.getResources().getInteger(R.integer.fragment_slide_duration); // start the background color fader animation if (mBaseContainerView != null) { mBgColorAnimationAtActivityEnd.setDuration(animationDuration); mBgColorAnimationAtActivityEnd.start(); } // delay finish to allow fragment animation to complete //TODO: call finish on animation end Handler handler = new Handler(this.getMainLooper()); handler.postDelayed(new Runnable() { @Override public void run() { finish(); } }, animationDuration); }
From source file:com.triarc.sync.LogCollector.java
private void sendLog(final String url, final String content) { HttpPost httppost = new HttpPost(url + "/ClientLogger/LogMobile"); try {/* w ww .j av a 2 s . co m*/ this.mLastLogs.clear(); httppost.setEntity(new StringEntity(content, HTTP.UTF_8)); DefaultHttpClient httpclient = new DefaultHttpClient(new BasicHttpParams()); HttpResponse response = httpclient.execute(httppost); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { LogCollector.this.sendLog(url, content); } }, 5000); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.xyproto.archfriend.ArchFriendActivity.java
@Override public void onStart() { super.onStart(); // Wait 0.9 sec then close splash screen (replace view context) // TODO: Start loading the list of names Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { setContentView(R.layout.archoverview); }/*from w ww . j a v a2 s .co m*/ }, 900); // TODO: Find the best way to load the data for the spinner in the // background. It's currently broken. try { populateSpinner(); populateNews(); } catch (InterruptedException e) { e.printStackTrace(); } catch (ExecutionException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } TextView tv = (TextView) findViewById(R.id.txtArchNews); tv.setMovementMethod(new ScrollingMovementMethod()); }
From source file:org.apache.taverna.mobile.ui.imagezoom.ImageZoomFragment.java
@Override public void showErrorSnackBar(String error) { final Snackbar snackbar = Snackbar.make(workflowImage, error, Snackbar.LENGTH_INDEFINITE); snackbar.setAction("OK", new View.OnClickListener() { @Override/*from www . j a va 2 s. com*/ public void onClick(View view) { snackbar.dismiss(); getActivity().finish(); } }); snackbar.show(); Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { snackbar.dismiss(); getActivity().finish(); } }, 2000); }