public static synchronized void triggerUpdate() { if (backgroundHandler != null) { uiHandler.removeCallbacksAndMessages(null); backgroundHandler.removeCallbacksAndMessages(null); uiHandler.post(updateRunnable); } }
private void cacheHidenSubtitle() { if (getTag() == null || !(getTag() instanceof Element)) return; Element currElement = (Element) getTag(); long currTime = getCurrentTime(); long endTime = currElement.getEndTime().getTime(); if (currTime >= endTime + SUBTITLE_DELAY_TIME_MAX / 10) { // for Fast Forward mHandler.removeCallbacksAndMessages(null); mHandler.sendEmptyMessage(MESSAGE_SUBTITLE_START); } else { if (endTime - currTime > SUBTITLE_DELAY_TIME_MAX) { Element preElement = getElement(currTime); if (preElement != null && preElement.getStartTime().getTime() < endTime - SUBTITLE_DELAY_TIME_MAX) { // for Fast back mHandler.removeCallbacksAndMessages(null); mHandler.sendEmptyMessage(MESSAGE_SUBTITLE_START); return; } mHandler.sendEmptyMessageDelayed(MESSAGE_SUBTITLE_HIDEN_CACHE, SUBTITLE_DELAY_TIME_MAX); } else { mHandler.sendEmptyMessageDelayed(MESSAGE_SUBTITLE_END_HIDEN, endTime - currTime); } } }
@Override public void onClick(View v) { Button guessButton = ((Button) v); String guess = guessButton.getText().toString(); String answer = getStateName(correctAnswer); ++totalGuesses; ++questionNumber; if (guess.equals(answer)) { // rightAnswer = true; finalScore += questionScore; answerTextView.setText(answer + "!"); answerTextView.setTextColor(getResources().getColor(R.color.correct)); disableButtons(); if (questionNumber == NUMBER_OF_QUESTIONS) { finalScore += questionScore; // scoreHandler.removeCallbacks(scoreRunnable); // handler.removeCallbacks(guessRunnable); scoreHandler.removeCallbacksAndMessages(null); handler.removeCallbacksAndMessages(null); // Toast.makeText(getContext(), "Quiz is over!", // Toast.LENGTH_LONG).show(); // Toast.makeText(getContext(), "Final Score = " + // Integer.toString(finalScore), Toast.LENGTH_LONG).show(); Intent k = new Intent(getActivity(), ScoreSubmission.class); k.putExtra("quiz", "Flag Quiz"); k.putExtra("score", finalScore); startActivity(k); } else { scoreHandler.removeCallbacks(scoreRunnable); handler.postDelayed(guessRunnable, 2000); } } else { // flagView.startAnimation(shakeAnimation); answerTextView.setText(answer); answerTextView.setTextColor(getResources().getColor(R.color.incorrect)); guessButton.setEnabled(false); disableButtons(); if (questionNumber == NUMBER_OF_QUESTIONS) { finalScore += questionScore; // scoreHandler.removeCallbacks(scoreRunnable); // handler.removeCallbacks(guessRunnable); scoreHandler.removeCallbacksAndMessages(null); handler.removeCallbacksAndMessages(null); // Toast.makeText(getContext(), "Quiz is over!", // Toast.LENGTH_LONG).show(); // Toast.makeText(getContext(), "Final Score = " + // Integer.toString(finalScore), Toast.LENGTH_LONG).show(); Intent k = new Intent(getActivity(), ScoreSubmission.class); k.putExtra("quiz", "Flag Quiz"); k.putExtra("score", finalScore); startActivity(k); } else { scoreHandler.removeCallbacks(scoreRunnable); handler.postDelayed(guessRunnable, 2000); } } }
public boolean onTouchEvent(TextView widget, final Spannable buffer, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) position = event.getY(); // used to see if the user scrolled or not if (!(event.getAction() == MotionEvent.ACTION_UP || event.getAction() == MotionEvent.ACTION_DOWN)) { if (Math.abs((position - event.getY())) > 10) { handler.removeCallbacksAndMessages(null); Log.v(LogUtil.getTag(), "POSITION NOT CLICK IS " + event.getY()); } return super.onTouchEvent(widget, buffer, event); } Log.v(LogUtil.getTag(), "POSITION IS " + position); comm = (SpoilerRobotoTextView) widget; int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); final int off = layout.getOffsetForHorizontal(line, x); link = buffer.getSpans(off, off, URLSpan.class); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: clickHandled = false; if (link.length != 0) { handler.postDelayed(longClicked, android.view.ViewConfiguration.getLongPressTimeout()); } break; case MotionEvent.ACTION_UP: handler.removeCallbacksAndMessages(null); if (!clickHandled) { // regular click if (link.length != 0) { int i = 0; if (sequence != null) { i = ((Spannable) sequence).getSpanEnd(link[0]); } onLinkClick(link[0].getURL(), i); } } break; } return true; }
@Override public void onDestroy() { scoreHandler.removeCallbacksAndMessages(null); handler.removeCallbacksAndMessages(null); Intent k = new Intent(getActivity(), ChooseQuiz.class); startActivity(k); super.onDestroy(); }
@Override public void onBackPressed() { Log.d(TAG, "override onBackPressed()"); super.onBackPressed(); sonidoCosas.release(); mHandler.removeCallbacksAndMessages(null); nHandler.removeCallbacksAndMessages(null); aHandler.removeCallbacksAndMessages(null); bHandler.removeCallbacksAndMessages(null); System.gc(); kill_activity(); }
@Override public int onStartCommand(Intent intent, int flags, int startId) { TAG = Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(getApplicationContext(), Aware_Preferences.DEBUG_TAG) : TAG; if (Aware.getSetting(this, Aware_Preferences.FREQUENCY_ACCELEROMETER).length() == 0) { Aware.setSetting(this, Aware_Preferences.FREQUENCY_ACCELEROMETER, SAMPLING_RATE); } if (SAMPLING_RATE != Integer.parseInt( Aware.getSetting( getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER))) { // changed parameters SAMPLING_RATE = Integer.parseInt( Aware.getSetting(getApplicationContext(), Aware_Preferences.FREQUENCY_ACCELEROMETER)); sensorHandler.removeCallbacksAndMessages(null); mSensorManager.unregisterListener(this, mAccelerometer); mSensorManager.registerListener(this, mAccelerometer, SAMPLING_RATE, sensorHandler); } if (Aware.DEBUG) Log.d(TAG, "Accelerometer service active at " + SAMPLING_RATE + " microseconds..."); return START_STICKY; }
@Override public void afterTextChanged(Editable s) { if (s.length() == 0) { // Text is empty; TextView label should be invisible hidePending = true; hideDelayer.removeCallbacksAndMessages(null); hideDelayer.sendEmptyMessageDelayed(0, 150); } else if (!mLabelShowing) { // Text is nonempty; TextView label should be visible mLabelShowing = true; mLabelAnimator.onDisplayLabel(mLabel); } else if (hidePending) { hideDelayer.removeCallbacksAndMessages(null); hidePending = false; } }
@Override public void onPause() { super.onPause(); mHandler.removeCallbacksAndMessages(null); pv_circular_determinate_in_out.setVisibility(View.GONE); }
public void a(int paramInt, bs parambs) { for (;;) { synchronized (b) { if (f(parambs)) { bt.a(d, paramInt); c.removeCallbacksAndMessages(d); a(d); return; } if (g(parambs)) { bt.a(e, paramInt); if ((d == null) || (!a(d, 4))) { break; } return; } } e = new bt(paramInt, parambs); } d = null; b(); }
@Override protected void onSaveInstanceState(Bundle outState) { // Ensure no fragment transaction attempt will occur after onSaveInstanceState() handler.removeCallbacksAndMessages(null); super.onSaveInstanceState(outState); outState.putInt(STATE_CURRENT_SECTION, currentSection.ordinal()); }
@Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_PRESSED: mHandler.removeMessages(MSG_TIMEOUT); if (mPressedCount < Integer.MAX_VALUE) { mPressedCount++; } break; case MSG_TIMEOUT: mHandler.removeCallbacksAndMessages(null); switch (mPressedCount) { case SINGLE_CLICK: sendMediaCommand((Context) msg.obj, CMDTOGGLEPAUSE); break; case DOUBLE_CLICK: sendMediaCommand((Context) msg.obj, CMDNEXT); break; case TRIPLE_CLICK: sendMediaCommand((Context) msg.obj, CMDPREVIOUS); break; } mPressedCount = 0; break; } }
@Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); if (videoPlayerInterface != null) { videoPlayerInterface.onDestroy(); } videoPlayerInterface = null; if (controlsHandler != null) { controlsHandler.removeCallbacksAndMessages(null); } controlsHandler = null; appOffer = null; Drawable drawable = ctaImage.getDrawable(); if (drawable instanceof BitmapDrawable) { BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable; Bitmap bitmap = bitmapDrawable.getBitmap(); bitmap.recycle(); } ctaImage.setImageDrawable(null); ctaImage.destroyDrawingCache(); ctaImage = null; ingamewallVideoLayout.removeAllViews(); ingamewallVideoLayout = null; System.gc(); }
/** Stops the ringtone and/or vibrator if any of these are actually ringing/vibrating. */ void stopRing() { synchronized (this) { if (DBG) log("stopRing()..."); try { mHardwareService.setAttentionLight(false); } catch (RemoteException ex) { // the other end of this binder call is in the system process. } if (mRingHandler != null) { mRingHandler.removeCallbacksAndMessages(null); Message msg = mRingHandler.obtainMessage(STOP_RING); msg.obj = mRingtone; mRingHandler.sendMessage(msg); PhoneUtils.setAudioMode(mContext, AudioManager.MODE_NORMAL); mRingThread = null; mRingHandler = null; mRingtone = null; mFirstRingEventTime = -1; mFirstRingStartTime = -1; } else { if (DBG) log("- stopRing: null mRingHandler!"); } if (mVibratorThread != null) { if (DBG) log("- stopRing: cleaning up vibrator thread..."); mContinueVibrating = false; mVibratorThread = null; } // Also immediately cancel any vibration in progress. mVibrator.cancel(); } }
private void processHeadsetHookEvent(Context context, int action, long eventtime) { switch (action) { case KeyEvent.ACTION_DOWN: if (!mPressedDown) { mPressedDown = true; mFirstTime = eventtime; mHandler.sendEmptyMessage(MSG_PRESSED); } else if (!mLongPressed) { if (eventtime - mFirstTime >= LONG_PRESS_DELAY) { mPressedCount = 0; mLongPressed = true; sendMediaCommand(context, CMDTOGGLEFAVORITE); mHandler.removeCallbacksAndMessages(null); } } break; case KeyEvent.ACTION_UP: if (!mLongPressed) { mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_TIMEOUT, context), CLICK_DELAY); } mPressedDown = false; mLongPressed = false; break; default: break; } }
@Override public void onPause() { mHasPaused = true; mHandler.removeCallbacksAndMessages(null); mVideoPosition = mVideoView.getCurrentPosition(); mVideoView.suspend(); super.onPause(); }
@Override public void run() { cameraManager.close(); // cancel background thread cameraHandler.removeCallbacksAndMessages(null); cameraThread.quit(); }
@Override public void onDestroy() { stopForeground(true); mHandler.removeCallbacksAndMessages(null); FlashDevice.instance(this).setFlashMode(FlashDevice.OFF); updateState(false); super.onDestroy(); }
@Override public void run() { if (downView == null) { return; } handler.removeCallbacksAndMessages(downView); handler.postAtTime(this, downView, SystemClock.uptimeMillis() + normalInterval); clickListener.onClick(downView); }
@Override public void onDestroy() { mHandler.removeCallbacksAndMessages(null); mMediaPlayerController.destroy(); mMediaPlayerController = null; super.onDestroy(); }
@Override public void onStop() { super.onStop(); mTimeHandler.removeCallbacksAndMessages(null); mTimeHandler = null; SharedPreferences prefs = getSharedPreferences(Constants.Keys.SPF_GAME_STATE, Context.MODE_PRIVATE); prefs.edit().putLong(Constants.Keys.TIME, mElapsedTime).commit(); }
public void stopPollingOnChangeEndpoint() { mOnChangePollingEnabled = false; mRestartOnChangePollingHandler.removeCallbacksAndMessages(null); if (mOnChangePollingClient != null) { mOnChangePollingClient.cancel(this); mOnChangePollingClient = null; } mOnServerContentChangeListener = null; }
public void c(bs parambs) { synchronized (b) { if (f(parambs)) { c.removeCallbacksAndMessages(d); } return; } }
public void start() { if (null == mDataLists || mDataLists.size() <= 0) { return; } mViewPager.setBackgroundColor(Color.TRANSPARENT); if (mAllowScroll) { handler.removeCallbacksAndMessages(null); handler.sendEmptyMessageDelayed(TAG_SCORLL, mContinuedTime * 1000); } }
public void setEnabled(boolean enabled) { mEnabled = enabled; if (!mEnabled) { int count = mCount.getAndSet(0); if (count > 0) { LogUtils.e(LOG_TAG, "Disable UiHandler. Dropping %d Runnables.", count); } mHandler.removeCallbacksAndMessages(null); } }
private void showChathead(Message message) { if (isDetached()) { return; } if (chatheadNotificationIsVisible || chatheadView == null) { return; } chatheadView.setMessage(message); final IConversation conversation = message.getConversation(); chatheadView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (chatheadNotificationIsVisible) { getStoreFactory() .getConversationStore() .setCurrentConversation(conversation, ConversationChangeRequester.CHAT_HEAD); } } }); hideChatheadHandler.removeCallbacksAndMessages(null); if (MathUtils.floatEqual(chatheadView.getAlpha(), 1f)) { scheduleChatheadHide(); } else { if (isDetached()) { return; } chatheadView .animate() .alpha(1) .translationX(0) .setDuration( getResources().getInteger(R.integer.notification__chathead_animation__duration)) .withStartAction( new Runnable() { @Override public void run() { chatheadNotificationIsVisible = true; chatheadView.setTranslationX(-chatheadView.getMeasuredWidth()); } }) .withEndAction( new Runnable() { @Override public void run() { scheduleChatheadHide(); } }) .start(); } }
private boolean a(bt parambt, int paramInt) { bs localbs = (bs)bt.a(parambt).get(); if (localbs != null) { c.removeCallbacksAndMessages(parambt); localbs.a(paramInt); return true; } return false; }
@Override public final void onWalletChanged(final WalletAccount pocket) { if (relevant.getAndSet(false)) { handler.removeCallbacksAndMessages(null); final long now = System.currentTimeMillis(); if (now - lastMessageTime.get() > throttleMs) handler.post(runnable); else handler.postDelayed(runnable, throttleMs); } }
private void searchTimer() { if (handler != null) handler.removeCallbacksAndMessages(null); handler.postDelayed( new Runnable() { @Override public void run() { if (searchMode == Var.SEARCH_YOUTUBE) searchYoutube(); if (searchMode == Var.SEARCH_TWITTER) searchTwitter(); } }, 800); }
@Override protected void onStop() { super.onStop(); abortImageLoading(); getContentResolver().unregisterContentObserver(contentObserver); contentObserver = null; handler.removeCallbacksAndMessages(null); handler = null; }