本文整理了Java中android.os.Handler.sendEmptyMessageDelayed()
方法的一些代码示例,展示了Handler.sendEmptyMessageDelayed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.sendEmptyMessageDelayed()
方法的具体详情如下:
包路径:android.os.Handler
类名称:Handler
方法名:sendEmptyMessageDelayed
暂无
代码示例来源:origin: lingochamp/FileDownloader
@Override public void onTaskStart(int id) {
handler.sendEmptyMessageDelayed(id, minInterval);
}
代码示例来源:origin: JZ-Darkal/AndroidHttpCapture
/**
* Turn off spin mode
*/
public void stopSpinning() {
spinHandler.sendEmptyMessageDelayed(1,200);
}
代码示例来源:origin: cymcsg/UltimateAndroid
/**
* Sends a Message containing only the what value, to be delivered after the specified amount of time elapses.
* @param handler
* @param what
* @param delayTime
*/
public static void sendMessageHandlerDelay(Handler handler, int what, long delayTime) {
handler.sendEmptyMessageDelayed(what,delayTime);
}
代码示例来源:origin: rey5137/material
@Override
public void onResume() {
super.onResume();
mHandler.sendEmptyMessageDelayed(MSG_START_PROGRESS, START_DELAY);
}
代码示例来源:origin: lingochamp/FileDownloader
public void startPauseAllLooperCheck() {
pauseAllChecker = new HandlerThread("PauseAllChecker");
pauseAllChecker.start();
pauseAllHandler = new Handler(pauseAllChecker.getLooper(), this);
pauseAllHandler.sendEmptyMessageDelayed(PAUSE_ALL_CHECKER_WHAT, PAUSE_ALL_CHECKER_PERIOD);
}
代码示例来源:origin: lingochamp/FileDownloader
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
uiHandler.removeMessages(WHAT_NEED_AUTO_2_BOTTOM);
needAuto2Bottom = false;
}
if (event.getAction() == MotionEvent.ACTION_UP ||
event.getAction() == MotionEvent.ACTION_CANCEL) {
uiHandler.removeMessages(WHAT_NEED_AUTO_2_BOTTOM);
uiHandler.sendEmptyMessageDelayed(WHAT_NEED_AUTO_2_BOTTOM, 1000);
}
return false;
}
});
代码示例来源:origin: TommyLemon/APIJSON
/**带动画退出,并使退出事件只响应一次
*/
@Override
public void finish() {
Log.d(TAG, "finish >>> isExit = " + isExit);
if (isExit) {
return;
}
isExit = true;
vBaseBottomWindowRoot.startAnimation(AnimationUtils.loadAnimation(context, R.anim.bottom_window_exit));
vBaseBottomWindowRoot.setVisibility(View.GONE);
exitHandler.sendEmptyMessageDelayed(0, 200);
}
代码示例来源:origin: TommyLemon/Android-ZBLibrary
/**带动画退出,并使退出事件只响应一次
*/
@Override
public void finish() {
Log.d(TAG, "finish >>> isExit = " + isExit);
if (isExit) {
return;
}
isExit = true;
vBaseBottomWindowRoot.startAnimation(AnimationUtils.loadAnimation(context, R.anim.bottom_window_exit));
vBaseBottomWindowRoot.setVisibility(View.GONE);
exitHandler.sendEmptyMessageDelayed(0, 200);
}
代码示例来源:origin: Rukey7/MvpApp
/**
* 当屏幕执行翻转操作后调用禁止翻转功能,延迟3000ms再使能翻转,避免不必要的翻转
*/
private void _refreshOrientationEnable() {
if (!mIsForbidOrientation) {
mOrientationListener.disable();
mHandler.removeMessages(MSG_ENABLE_ORIENTATION);
mHandler.sendEmptyMessageDelayed(MSG_ENABLE_ORIENTATION, 3000);
}
}
代码示例来源:origin: jjdxmashl/jjdxm_ijkplayer
/**停止拖动*/
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
long duration = getDuration();
videoView.seekTo((int) ((duration * seekBar.getProgress() * 1.0) / 1000));
mHandler.removeMessages(MESSAGE_SHOW_PROGRESS);
isDragging = false;
mHandler.sendEmptyMessageDelayed(MESSAGE_SHOW_PROGRESS, 1000);
}
};
代码示例来源:origin: pili-engineering/PLDroidPlayer
public void onStopTrackingTouch(SeekBar bar) {
if (!mInstantSeeking)
mPlayer.seekTo(mDuration * bar.getProgress() / 1000);
show(sDefaultTimeout);
mHandler.removeMessages(SHOW_PROGRESS);
mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
mDragging = false;
mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
}
};
代码示例来源:origin: JingYeoh/FragmentRigger
public void onLazyLoadViewCreated(Bundle savedInstanceState) {
((TextView) findViewById(R.id.flc_tv)).setText(mValue);
mHandler.sendEmptyMessageDelayed(1001, 1000);
Rigger.getRigger(LoadContainerFragment.this).startFragment(StartFragment.newInstance(0));
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
public void onStopTrackingTouch(SeekBar bar) {
if (!mInstantSeeking) {
mPlayer.seekTo((mDuration * bar.getProgress()) / 1000);
}
if (mInfoView != null) {
mInfoView.setText("");
mInfoView.setVisibility(View.GONE);
}
show(sDefaultTimeout);
mHandler.removeMessages(SHOW_PROGRESS);
mAM.setStreamMute(AudioManager.STREAM_MUSIC, false);
mDragging = false;
mHandler.sendEmptyMessageDelayed(SHOW_PROGRESS, 1000);
}
};
代码示例来源:origin: lingochamp/FileDownloader
@Override
public boolean handleMessage(Message msg) {
if (PauseAllMarker.isMarked()) {
try {
serviceHandler.pauseAllTasks();
} catch (RemoteException e) {
FileDownloadLog.e(this, e, "pause all failed");
} finally {
PauseAllMarker.clearMarker();
}
}
pauseAllHandler.sendEmptyMessageDelayed(0, PAUSE_ALL_CHECKER_PERIOD);
return true;
}
}
代码示例来源:origin: lingochamp/okdownload
@Test
public void postSyncInfoDelay() {
executor.postSyncInfoDelay(1, 10);
verify(handler).sendEmptyMessageDelayed(eq(1), eq(10L));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void resetThreadLoopers_clears_messages() {
HandlerThread backgroundThread = new HandlerThread("resetTest");
backgroundThread.start();
Looper backgroundLooper = backgroundThread.getLooper();
Handler handler = new Handler(backgroundLooper);
for (int i = 0; i < 5; i++) {
handler.sendEmptyMessageDelayed(1, 100);
ShadowLooper.resetThreadLoopers();
assertThat(handler.hasMessages(1)).isFalse();
}
}
代码示例来源:origin: robolectric/robolectric
@Test
public void removeMessages_takesMessageOutOfQueue() {
ShadowLooper.pauseMainLooper();
Handler handler = new Handler();
handler.sendEmptyMessageDelayed(123, 500);
handler.removeMessages(123);
assertThat(handler.hasMessages(123)).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void removeMessages_removesFromLooperQueueAsWell() {
final boolean[] wasRun = new boolean[1];
ShadowLooper.pauseMainLooper();
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
wasRun[0] = true;
}
};
handler.sendEmptyMessageDelayed(123, 500);
handler.removeMessages(123);
ShadowLooper.unPauseMainLooper();
assertThat(wasRun[0]).isFalse();
}
代码示例来源:origin: robolectric/robolectric
@Test
public void shouldSetWhenOnMessage() throws Exception {
final List<Long> whens = new ArrayList<>();
Handler h = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(Message msg) {
whens.add(msg.getWhen());
return false;
}
});
final long startTime = Robolectric.getForegroundThreadScheduler().getCurrentTime();
h.sendEmptyMessage(0);
h.sendEmptyMessageDelayed(0, 4000L);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
h.sendEmptyMessageDelayed(0, 12000L);
Robolectric.getForegroundThreadScheduler().advanceToLastPostedRunnable();
assertThat(whens).named("whens").containsExactly(startTime, startTime + 4000, startTime + 16000);
}
代码示例来源:origin: robolectric/robolectric
@Test
public void sendEmptyMessageDelayed_sendsMessageAtCorrectTime() {
ShadowLooper.pauseMainLooper();
Handler handler = new Handler();
handler.sendEmptyMessageDelayed(123, 500);
assertThat(handler.hasMessages(123)).isTrue();
ShadowLooper.idleMainLooper(100);
assertThat(handler.hasMessages(123)).isTrue();
ShadowLooper.idleMainLooper(400);
assertThat(handler.hasMessages(123)).isFalse();
}
内容来源于网络,如有侵权,请联系作者删除!