Java Code Examples for android.os.Handler#removeCallbacksAndMessages()
The following examples show how to use
android.os.Handler#removeCallbacksAndMessages() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressDialogFragment.java From MyBlogDemo with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setStyle(android.support.v4.app.DialogFragment.STYLE_NO_TITLE, R.style.AppTheme_AppCompat_Dialog_Alert); mHandler = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { mProgress.setProgress(progress++); if (mProgress.getProgress() == 100) { mHandler.removeCallbacksAndMessages(null); } else { mHandler.sendEmptyMessageDelayed(1, 100); } super.handleMessage(msg); } }; if (savedInstanceState != null) { progress = savedInstanceState.getInt("PROGRESS"); } }
Example 2
Source File: TextViewLinkHandler.java From Slide with GNU General Public License v3.0 | 6 votes |
public TextViewLinkHandler(ClickableText clickableText, String subreddit, Spannable sequence) { this.clickableText = clickableText; this.subreddit = subreddit; this.sequence = sequence; clickHandled = false; handler = new Handler(); longClicked = new Runnable() { @Override public void run() { // long click clickHandled = true; handler.removeCallbacksAndMessages(null); if (link != null && link.length > 0 && link[0] != null) { TextViewLinkHandler.this.clickableText.onLinkLongClick(link[0].getURL(), event); } } }; }
Example 3
Source File: FallingView.java From SmartSwipe with Apache License 2.0 | 5 votes |
public void startFalling() { stopped = false; Handler handler = getHandler(); if (handler != null) { handler.removeCallbacksAndMessages(runnable); } post(runnable); }
Example 4
Source File: FallingView.java From SmartSwipe with Apache License 2.0 | 5 votes |
public void stopFalling() { stopped = true; Handler handler = getHandler(); if (handler != null) { handler.removeCallbacksAndMessages(runnable); } }
Example 5
Source File: DanmakuView.java From DanDanPlayForAndroid with MIT License | 5 votes |
@Override public void start(long position) { Handler handler = this.handler; if (handler == null) { prepare(); handler = this.handler; } else { handler.removeCallbacksAndMessages(null); } if (handler != null) { handler.obtainMessage(DrawHandler.START, position).sendToTarget(); } }
Example 6
Source File: AppState.java From Chorus-RF-Laptimer with MIT License | 5 votes |
public void startOrStopConnectionTester() { if (mConnectionTester == null) { // start the range tester sendBtCommand("R*I0000"); // turn rssi monitoring off mConnectionTester = new ConnectionTester(); mConnectionTesterSendHandler = new Handler() { public void handleMessage(Message msg) { AppState app = AppState.getInstance(); if (app.isConnected && app.raceState != null && !app.raceState.isStarted && app.mConnectionTester != null) { AppState.getInstance().sendBtCommand("%" + String.format("%04X", mConnectionTester.getNextValueToSend())); mConnectionTester.calcDiffTimes(); emitEvent(DataAction.ConnectionTester); } sendEmptyMessageDelayed(0, mConnectionTester.SEND_DELAY_MS); } }; mConnectionTesterSendHandler.sendEmptyMessage(0); } else { // stop the range tester mConnectionTesterSendHandler.removeCallbacksAndMessages(null); mConnectionTesterSendHandler = null; mConnectionTester = null; sendBtCommand("R*I0064"); // turn rssi monitoring off } }
Example 7
Source File: WeatherView.java From Aurora with Apache License 2.0 | 5 votes |
private void stopAnimAndRemoveCallbacks(){ isStart=false; for (Map.Entry<String, ValueAnimator> entry : animMap.entrySet()) { entry.getValue().end(); } Handler handler=this.getHandler(); if (handler!=null){ handler.removeCallbacksAndMessages(null); } }
Example 8
Source File: OmegaPagerRecyclerView.java From OmegaRecyclerView with MIT License | 5 votes |
private void updateAutoScroll() { Handler handler = getAutoScrollHandler(); handler.removeCallbacksAndMessages(null); if (mIsAutoScrollEnabled && mAutoScrollIntervalInMilliseconds > 0 && getItemCount() > 1 && getLayoutManager() != null) { handler.postDelayed(this, mAutoScrollIntervalInMilliseconds); } }
Example 9
Source File: OmegaPagerRecyclerView.java From OmegaRecyclerView with MIT License | 5 votes |
@Override public void run() { Handler handler = getAutoScrollHandler(); ViewPagerLayoutManager layoutManager = getLayoutManager(); if (layoutManager == null) { handler.removeCallbacksAndMessages(null); return; } layoutManager.smoothScrollToNextPosition(); handler.postDelayed(this, mAutoScrollIntervalInMilliseconds); }
Example 10
Source File: RecordProgressBar.java From RecordVideo with Apache License 2.0 | 5 votes |
/** * 停止进度 */ public void stop() { mState = STATE_PREPARE; invalidate(); Handler handler = getHandler(); if (handler != null) { handler.removeCallbacksAndMessages(null); } }
Example 11
Source File: StandardMediaPlayer.java From android-openslmediaplayer with Apache License 2.0 | 5 votes |
@Override public void reset() { checkIsNotReleased(); if (!mState.canCallReset()) { return; } if (mPlayer != null) { mPlayer.reset(); } if (mHandler != null) { mHandler.removeCallbacksAndMessages(null); } // Clear all messages to avoid unexpected error callback Handler superEventHandler = (mSuperEventHandler != null) ? mSuperEventHandler.get() : null; if (superEventHandler != null) { superEventHandler.removeCallbacksAndMessages(null); } mIsLooping = false; mSeekPosition = SEEK_POS_NOSET; mPendingSeekPosition = SEEK_POS_NOSET; mDuration = 0; mState.transitToIdleState(); }
Example 12
Source File: LogUtils.java From Android-Next with Apache License 2.0 | 5 votes |
public void close() { Handler handler = mAsyncHandler; mAsyncHandler = null; if (handler != null) { handler.removeCallbacksAndMessages(null); } if (mHandlerThread != null) { mHandlerThread.quit(); mHandlerThread = null; } }
Example 13
Source File: MainActivity.java From RxAnimationBinding with Apache License 2.0 | 4 votes |
public void blinkEmissionView(final int position) { Handler handler; switch (position) { case 0: handler = startHandler; break; case 1: handler = endHandler; break; case 2: handler = cancelHandler; break; case 3: handler = repeatHandler; break; case 4: handler = pauseHandler; break; case 5: handler = resumeHandler; break; default: handler = updateHandler; break; } if (emissionViews[position].isSelected()) { handler.removeCallbacksAndMessages(null); emissionViews[position].setSelected(false); } else { emissionViews[position].setSelected(true); handler.removeCallbacksAndMessages(null); handler.postDelayed(new Runnable() { @Override public void run() { if (emissionViews != null && emissionViews[position] != null) { emissionViews[position].setSelected(false); } } }, BLINK_DURATION); } }