android.os.Handler.removeMessages()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(246)

本文整理了Java中android.os.Handler.removeMessages()方法的一些代码示例,展示了Handler.removeMessages()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler.removeMessages()方法的具体详情如下:
包路径:android.os.Handler
类名称:Handler
方法名:removeMessages

Handler.removeMessages介绍

暂无

代码示例

代码示例来源:origin: google/ExoPlayer

@Override
public void removeMessages(int what) {
 handler.removeMessages(what);
}

代码示例来源:origin: google/ExoPlayer

@Override
public void removeMessages(int what) {
 handler.removeMessages(what);
}

代码示例来源:origin: GitLqr/LQRWeChat

public void stopRefresh() {
  mHandler.removeMessages(1);
  mHandler.sendEmptyMessage(0);
  mState = State.NORMAL;
}

代码示例来源: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: google/ExoPlayer

@Override
public void removeMessages(int what) {
 handler.removeMessages(what);
}

代码示例来源:origin: lingochamp/FileDownloader

public void stopPauseAllLooperCheck() {
  pauseAllHandler.removeMessages(PAUSE_ALL_CHECKER_WHAT);
  pauseAllChecker.quit();
}

代码示例来源:origin: hanks-zyh/HTextView

@Override
  protected void onDetachedFromWindow() {
    super.onDetachedFromWindow();
    handler.removeMessages(INVALIDATE);
  }
}

代码示例来源:origin: sunfusheng/StickyHeaderListView

public void removeBannerLoopMessage() {
  if (mHandler.hasMessages(BANNER_TYPE)) {
    mHandler.removeMessages(BANNER_TYPE);
  }
}

代码示例来源:origin: GitLqr/LQRWeChat

public void startRefresh() {
  if (!isRefreshing()) {
    mHandler.removeMessages(0);
    mHandler.removeMessages(1);
    mHandler.sendEmptyMessage(1);
    mState = State.REFRESHING;
    invokeListner();
  }
}

代码示例来源:origin: lingochamp/FileDownloader

private void ensureCacheToDB(int id) {
  handler.removeMessages(id);
  if (handlingId.get() == id) {
    parkThread = Thread.currentThread();
    handler.sendEmptyMessage(WHAT_CLEAN_LOCK);
    LockSupport.park();
  } else {
    syncCacheToDB(id);
  }
}

代码示例来源:origin: pili-engineering/PLDroidPlayer

public void onStartTrackingTouch(SeekBar bar) {
  mDragging = true;
  show(3600000);
  mHandler.removeMessages(SHOW_PROGRESS);
  if (mInstantSeeking)
    mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
}

代码示例来源: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: lingochamp/FileDownloader

@Override public void updateCompleted(int id, long total) {
  this.cachedDatabase.updateCompleted(id, total);
  if (isNoNeedUpdateToRealDB(id)) {
    handler.removeMessages(id);
    if (handlingId.get() == id) {
      parkThread = Thread.currentThread();
      handler.sendEmptyMessage(WHAT_CLEAN_LOCK);
      LockSupport.park();
      this.realDatabase.updateCompleted(id, total);
    }
  } else {
    this.realDatabase.updateCompleted(id, total);
  }
  freeToDBIdList.remove((Integer) id);
}

代码示例来源:origin: robolectric/robolectric

/**
 * Simulates call to {@link MediaPlayer#_reset()}. Calls {@link #doStop()} to suspend playback
 * event callbacks and sets the state to IDLE.
 */
@Implementation
protected void _reset() {
 checkStateException("reset()", nonEndStates);
 doStop();
 state = IDLE;
 handler.removeMessages(MEDIA_EVENT);
 startOffset = 0;
}

代码示例来源:origin: robolectric/robolectric

/**
 * Simulates call to {@link MediaPlayer#_release()}. Calls {@link #doStop()} to suspend playback
 * event callbacks and sets the state to END.
 */
@Implementation
protected void _release() {
 checkStateException("release()", allStates);
 doStop();
 state = END;
 handler.removeMessages(MEDIA_EVENT);
}

代码示例来源:origin: HotBitmapGG/bilibili-android-client

public void onStartTrackingTouch(SeekBar bar) {
  mDragging = true;
  show(3600000);
  mHandler.removeMessages(SHOW_PROGRESS);
  if (mInstantSeeking) {
    mAM.setStreamMute(AudioManager.STREAM_MUSIC, true);
  }
  if (mInfoView != null) {
    mInfoView.setText("");
    mInfoView.setVisibility(View.VISIBLE);
  }
}

代码示例来源:origin: robolectric/robolectric

@Implementation(minSdk = O)
protected void seekTo(long seekTo, int mode) {
 boolean success = checkStateError("seekTo()", seekableStates);
 // Cancel any pending seek operations.
 handler.removeMessages(MEDIA_EVENT, seekCompleteCallback);
 if (success) {
  // Need to call doStop() before setting pendingSeek,
  // because if pendingSeek is called it changes
  // the behavior of getCurrentPosition(), which doStop()
  // depends on.
  doStop();
  pendingSeek = (int) seekTo;
  if (seekDelay >= 0) {
   postEventDelayed(seekCompleteCallback, seekDelay);
  }
 }
}

代码示例来源: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 removeMessage_withSpecifiedObject() throws Exception {
 ShadowLooper.pauseMainLooper();
 Handler handler = new Handler();
 Message.obtain(handler, 123, "foo").sendToTarget();
 Message.obtain(handler, 123, "bar").sendToTarget();
 assertThat(handler.hasMessages(123)).isTrue();
 assertThat(handler.hasMessages(123, "foo")).isTrue();
 assertThat(handler.hasMessages(123, "bar")).isTrue();
 assertThat(handler.hasMessages(123, "baz")).isFalse();
 handler.removeMessages(123, "foo");
 assertThat(handler.hasMessages(123)).isTrue();
 handler.removeMessages(123, "bar");
 assertThat(handler.hasMessages(123)).isFalse();
}

相关文章