List of usage examples for android.os Handler removeCallbacks
public final void removeCallbacks(Runnable r)
From source file:com.mods.grx.settings.utils.Utils.java
public static void send_bc2(final Context context) { Runnable BC = new Runnable() { @Override/*from w w w . j a v a 2 s .c o m*/ public void run() { Intent intent = new Intent(); try { intent.setAction(context.getResources().getString(R.string.gs_grxBc2)); context.sendBroadcast(intent); } catch (Exception e) { e.printStackTrace(); Toast.makeText(context, e.toString(), Toast.LENGTH_SHORT).show(); } } }; Handler handler = new Handler(); handler.removeCallbacks(BC); handler.postDelayed(BC, Long.valueOf(400)); }
From source file:com.android.deskclock.Utils.java
public static void cancelMidnightUpdater(Handler handler, Runnable runnable) { if (handler == null || runnable == null) { return;/*from www . j a va 2s .c o m*/ } handler.removeCallbacks(runnable); }
From source file:com.android.deskclock.Utils.java
public static void cancelQuarterHourUpdater(Handler handler, Runnable runnable) { if (handler == null || runnable == null) { return;/*w w w .j av a 2s. co m*/ } handler.removeCallbacks(runnable); }
From source file:com.android.deskclock.Utils.java
public static void setMidnightUpdater(Handler handler, Runnable runnable) { String timezone = TimeZone.getDefault().getID(); if (handler == null || runnable == null || timezone == null) { return;/*from w w w . jav a 2 s .c o m*/ } long now = System.currentTimeMillis(); Time time = new Time(timezone); time.set(now); long runInMillis = ((24 - time.hour) * 3600 - time.minute * 60 - time.second + 1) * 1000; handler.removeCallbacks(runnable); handler.postDelayed(runnable, runInMillis); }
From source file:com.android.deskclock.Utils.java
public static void setQuarterHourUpdater(Handler handler, Runnable runnable) { String timezone = TimeZone.getDefault().getID(); if (handler == null || runnable == null || timezone == null) { return;//from w ww . j a v a 2 s . c om } long runInMillis = getAlarmOnQuarterHour() - System.currentTimeMillis(); // Ensure the delay is at least one second. if (runInMillis < 1000) { runInMillis = 1000; } handler.removeCallbacks(runnable); handler.postDelayed(runnable, runInMillis); }
From source file:com.lurencun.cfuture09.androidkit.http.Http.java
/** * /* w ww . ja v a2 s . co m*/ * * @param url * ? * @param savePath * ?? * @param overwrite * ? * @param listener * ?? */ public static void downloadAsync(final String url, final File savePath, final boolean overwrite, final HttpSimpleListener listener) { final Handler handler = HandlerFactory.newBackgroundHandler(idGenerator.next() + ""); final Runnable task = new Runnable() { @Override public void run() { try { download(url, savePath, overwrite); listener.onFinish(url); } catch (final IOException e) { listener.onFailed(e.getMessage()); log.w(e.getMessage(), e); } handler.removeCallbacks(this); } }; handler.post(task); }
From source file:com.appnexus.opensdk.mediatednativead.InMobiNativeAdResponse.java
@Override public void destroy() { Handler handler = new Handler(Looper.getMainLooper()); handler.removeCallbacks(runnable); handler.post(runnable);/*from w w w. j a v a 2 s . co m*/ }
From source file:com.appnexus.opensdk.mediatednativead.InMobiNativeAdResponse.java
@Override public boolean registerView(View view, NativeAdEventListener listener) { if (imNative != null && !registered && !expired) { InMobiNative.bind(view, imNative); view.setOnClickListener(clickListener); registeredView = view;/*from w w w . j a va2 s. c om*/ registered = true; Handler handler = new Handler(Looper.getMainLooper()); handler.removeCallbacks(runnable); } this.nativeAdEventlistener = listener; return registered; }
From source file:com.appnexus.opensdk.mediatednativead.InMobiNativeAdResponse.java
@Override public boolean registerViewList(View view, List<View> clickables, NativeAdEventListener listener) { if (imNative != null && !registered && !expired) { InMobiNative.bind(view, imNative); for (View clickable : clickables) { clickable.setOnClickListener(clickListener); }/*from w w w .j a va2s .co m*/ registeredView = view; registeredClickables = clickables; registered = true; Handler handler = new Handler(Looper.getMainLooper()); handler.removeCallbacks(runnable); } this.nativeAdEventlistener = listener; return registered; }
From source file:com.supremainc.biostar2.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); mUserDataProvider = UserDataProvider.getInstance(getApplicationContext()); mUserDataProvider.init(getApplicationContext()); //app once init mLayout = new LoginActivityLayout(this, mLoginActivityLayoutEvent); mLayout.initView();/*from w ww. j a va2 s. c om*/ initCrashReport(); initValue(); checkNotificationStart(); registerBroadcast(); if (mUserDataProvider.isLogined()) { mUserDataProvider.simpleLogin(mLoginListener, mSimpleLoginErrorListener, null); } else { Handler handler = new Handler(); handler.removeCallbacks(mSplash); handler.postDelayed(mSplash, 1000); } }