本文整理汇总了Java中android.os.Handler.removeCallbacks方法的典型用法代码示例。如果您正苦于以下问题:Java Handler.removeCallbacks方法的具体用法?Java Handler.removeCallbacks怎么用?Java Handler.removeCallbacks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.os.Handler
的用法示例。
在下文中一共展示了Handler.removeCallbacks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryLatLngAddress
import android.os.Handler; //导入方法依赖的package包/类
private void queryLatLngAddress(LatLng latlng) {
if(!TextUtils.isEmpty(addressInfo) && latlng.latitude == latitude && latlng.longitude == longitude) {
return;
}
Handler handler = getHandler();
handler.removeCallbacks(runable);
handler.postDelayed(runable, 20 * 1000);// 20s超时
geocoder.queryAddressNow(latlng.latitude, latlng.longitude);
latitude = latlng.latitude;
longitude = latlng.longitude;
this.addressInfo = null;
setPinInfoPanel(false);
}
示例2: maybeRegisterAutoAdvance
import android.os.Handler; //导入方法依赖的package包/类
private void maybeRegisterAutoAdvance() {
Handler handler = getHandler();
boolean shouldRegisterAutoAdvance = getWindowVisibility() == VISIBLE && handler != null
&& (sAutoAdvanceWidgetIds.indexOfKey(getAppWidgetId()) >= 0);
if (shouldRegisterAutoAdvance != mIsAutoAdvanceRegistered) {
mIsAutoAdvanceRegistered = shouldRegisterAutoAdvance;
if (mAutoAdvanceRunnable == null) {
mAutoAdvanceRunnable = new Runnable() {
@Override
public void run() {
runAutoAdvance();
}
};
}
handler.removeCallbacks(mAutoAdvanceRunnable);
scheduleNextAdvance();
}
}
示例3: startTimerThread
import android.os.Handler; //导入方法依赖的package包/类
private void startTimerThread() {
handler = new Handler();
timer = new Runnable() {
@Override
public void run() {
int progress = (int) (System.currentTimeMillis() / 1000) % 60;
tokenlistadapter.updatePBs(progress);
// refresh OTP values only around the periods
if (progress < 3 || progress > 27 && progress < 33 || progress > 57) {
tokenlistadapter.refreshAllTOTP();
}
handler.postDelayed(this, 1000);
}
};
handler.post(timer);
handler.removeCallbacks(timer);
}
示例4: onCreateView
import android.os.Handler; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
RelativeLayout rootView = (RelativeLayout) inflater.inflate(R.layout.fragment_scan, container, false);
final EssensbonActivity activityReference = (EssensbonActivity) getActivity();
final Button scan = rootView.findViewById(R.id.scan_button);
final Handler handler = new Handler();
final Runnable r = new Runnable() {
@Override
public void run() {
scan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activityReference.scan();
}
});
}
};
handler.postDelayed(r, 100);
if (EssensbonUtils.mensaModeEnabled())
handler.removeCallbacks(r);
return rootView;
}
示例5: onNotificationPosted
import android.os.Handler; //导入方法依赖的package包/类
@Override
public void onNotificationPosted(StatusBarNotification notification) {
logd("onNotificationPosted: %s", notification);
final Handler h = getListView().getHandler();
h.removeCallbacks(mRefreshListRunnable);
h.postDelayed(mRefreshListRunnable, 100);
}
示例6: startScrollIfNeeded
import android.os.Handler; //导入方法依赖的package包/类
private boolean startScrollIfNeeded(int x) {
boolean overscroll;
int deltaX = x - this.mMotionX;
int distance = Math.abs(deltaX);
if (getScrollX() != 0) {
overscroll = true;
} else {
overscroll = false;
}
if (!overscroll && distance <= this.mTouchSlop) {
return false;
}
createScrollingCache();
if (overscroll) {
this.mTouchMode = 5;
this.mMotionCorrection = 0;
} else {
this.mTouchMode = 3;
this.mMotionCorrection = deltaX > 0 ? this.mTouchSlop : -this.mTouchSlop;
}
Handler handler = getHandler();
if (handler != null) {
handler.removeCallbacks(this.mPendingCheckForLongPress);
}
setPressed(false);
View motionView = getChildAt(this.mMotionPosition - this.mFirstPosition);
if (motionView != null) {
motionView.setPressed(false);
}
reportScrollStateChange(1);
ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
scrollIfNeeded(x);
return true;
}
示例7: startScrollIfNeeded
import android.os.Handler; //导入方法依赖的package包/类
private boolean startScrollIfNeeded(int x) {
// Check if we have moved far enough that it looks more like a
// scroll than a tap
final int deltaX = x - mMotionX;
final int distance = Math.abs(deltaX);
final boolean overscroll = getScrollX() != 0;
if (overscroll || distance > mTouchSlop) {
createScrollingCache();
if (overscroll) {
mTouchMode = TOUCH_MODE_OVERSCROLL;
mMotionCorrection = 0;
} else {
mTouchMode = TOUCH_MODE_SCROLL;
mMotionCorrection = deltaX > 0 ? mTouchSlop : -mTouchSlop;
}
final Handler handler = getHandler();
// Handler should not be null unless the AbsListView is not attached
// to a
// window, which would make it very hard to scroll it... but the
// monkeys
// say it's possible.
if (handler != null) {
handler.removeCallbacks(mPendingCheckForLongPress);
}
setPressed(false);
View motionView = getChildAt(mMotionPosition - mFirstPosition);
if (motionView != null) {
motionView.setPressed(false);
}
reportScrollStateChange(OnScrollListener.SCROLL_STATE_TOUCH_SCROLL);
// Time to start stealing events! Once we've stolen them, don't let
// anyone
// steal from us
final ViewParent parent = getParent();
if (parent != null) {
parent.requestDisallowInterceptTouchEvent(true);
}
scrollIfNeeded(x);
return true;
}
return false;
}
示例8: initView
import android.os.Handler; //导入方法依赖的package包/类
private void initView() {
LayoutInflater.from(mContext).inflate(R.layout.item_cycle_banner, this, true);
mViewPager = (ViewPager) findViewById(R.id.cycle_view_pager);
mTitle = (TextView) findViewById(R.id.text_cycle_title);
mIndicatorLayout = (LinearLayout) findViewById(R.id.cycle_indicator);
handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (mViews.size() > 0) {
if (msg.what == WHEEL) {
if (!isScrolling) {
/* 当前为非滚动状态,切换到下一页 */
int position = (mCurrentPosition + 1) % mViews.size();
mViewPager.setCurrentItem(position, true);
}
releaseTime = System.currentTimeMillis();
handler.removeCallbacks(runnable);
handler.postDelayed(runnable, delay);
} else if (msg.what == WHEEL_WAIT) {
handler.removeCallbacks(runnable);
handler.postDelayed(runnable, delay);
}
}
}
};
}
示例9: updateSecondsHandler
import android.os.Handler; //导入方法依赖的package包/类
private void updateSecondsHandler() {
if (mClock == null) return;
if (mShowSeconds && mClock.getDisplay() != null) {
mSecondsHandler = new Handler();
if (mClock.getDisplay().getState() == Display.STATE_ON && !mClockHidden) {
mSecondsHandler.postAtTime(mSecondTick,
SystemClock.uptimeMillis() / 1000 * 1000 + 1000);
}
} else if (mSecondsHandler != null) {
mSecondsHandler.removeCallbacks(mSecondTick);
mSecondsHandler = null;
updateClock();
}
}
示例10: handleVolumeLongPressAbort
import android.os.Handler; //导入方法依赖的package包/类
private static void handleVolumeLongPressAbort(Object phoneWindowManager) {
Handler mHandler = (Handler) getObjectField(phoneWindowManager, "mHandler");
Runnable mVolumeUpLongPress = (Runnable) getAdditionalInstanceField(phoneWindowManager, "mVolumeUpLongPress");
Runnable mVolumeDownLongPress = (Runnable) getAdditionalInstanceField(phoneWindowManager, "mVolumeDownLongPress");
mHandler.removeCallbacks(mVolumeUpLongPress);
mHandler.removeCallbacks(mVolumeDownLongPress);
}
示例11: onNotificationRemoved
import android.os.Handler; //导入方法依赖的package包/类
@Override
public void onNotificationRemoved(StatusBarNotification notification) {
final Handler h = getListView().getHandler();
h.removeCallbacks(mRefreshListRunnable);
h.postDelayed(mRefreshListRunnable, 100);
}
示例12: requestRoot
import android.os.Handler; //导入方法依赖的package包/类
public static void requestRoot(final Context context) {
// Don't request root when read logs permission is already granted
if (haveReadLogsPermission(context)) {
failedToObtainRoot = true;
return;
}
Handler handler = new Handler(Looper.getMainLooper());
Runnable toastRunnable = new Runnable() {
@Override
public void run() {
Toast.makeText(context, R.string.toast_request_root, Toast.LENGTH_LONG).show();
}
};
handler.postDelayed(toastRunnable, 200);
Process process = null;
try {
// Preform su to get root privileges
process = Runtime.getRuntime().exec("su");
// confirm that we have root
DataOutputStream outputStream = new DataOutputStream(process.getOutputStream());
outputStream.writeBytes("echo hello\n");
// Close the terminal
outputStream.writeBytes("exit\n");
outputStream.flush();
process.waitFor();
if (process.exitValue() != 0) {
showWarningDialog(context);
failedToObtainRoot = true;
} else {
// success
PreferenceHelper.setJellybeanRootRan(context);
}
} catch (IOException | InterruptedException e) {
log.w(e, "Cannot obtain root");
showWarningDialog(context);
failedToObtainRoot = true;
}
handler.removeCallbacks(toastRunnable);
}
示例13: brightnessControl
import android.os.Handler; //导入方法依赖的package包/类
private static void brightnessControl(MotionEvent event) {
try {
final int action = event.getAction();
final int x = (int) event.getRawX();
final int y = (int) event.getRawY();
Handler handler = (Handler) XposedHelpers.getObjectField(mPhoneStatusBar, "mHandler");
int statusBarHeaderHeight = (int) XposedHelpers.callMethod(mHeader, "getCollapsedHeight");
if (action == MotionEvent.ACTION_DOWN) {
if (y < statusBarHeaderHeight) {
mLinger = 0;
mInitialTouchX = x;
mInitialTouchY = y;
mJustPeeked = true;
mScreenWidth = (float) mContext.getResources().getDisplayMetrics().widthPixels;
handler.removeCallbacks(mLongPressBrightnessChange);
handler.postDelayed(mLongPressBrightnessChange,
BRIGHTNESS_CONTROL_LONG_PRESS_TIMEOUT);
}
} else if (action == MotionEvent.ACTION_MOVE) {
if (y < statusBarHeaderHeight && mJustPeeked) {
if (mLinger > BRIGHTNESS_CONTROL_LINGER_THRESHOLD) {
adjustBrightness(x);
} else {
final int xDiff = Math.abs(x - mInitialTouchX);
final int yDiff = Math.abs(y - mInitialTouchY);
final int touchSlop = ViewConfiguration.get(mContext).getScaledTouchSlop();
if (xDiff > yDiff) {
mLinger++;
}
if (xDiff > touchSlop || yDiff > touchSlop) {
handler.removeCallbacks(mLongPressBrightnessChange);
}
}
} else {
if (y > mPeekHeight) {
mJustPeeked = false;
}
handler.removeCallbacks(mLongPressBrightnessChange);
}
} else if (action == MotionEvent.ACTION_UP ||
action == MotionEvent.ACTION_CANCEL) {
handler.removeCallbacks(mLongPressBrightnessChange);
}
} catch (Throwable t) {
XposedBridge.log(t);
}
}
示例14: startTimeTask
import android.os.Handler; //导入方法依赖的package包/类
private static void startTimeTask() {
LogUtil.ui("time task start");
Handler handler = Handlers.sharedHandler(DemoCache.getContext());
handler.removeCallbacks(runnable);
handler.postDelayed(runnable, SUBSCRIBE_EXPIRY * 1000);
}
示例15: go
import android.os.Handler; //导入方法依赖的package包/类
public void go(String ip, int port, String msg, CallBack callBack) {
mCallBack = callBack;
Looper.prepare();
handler = new Handler();
cancellable = AsyncServer.getDefault().connectSocket(ip, port, (ex, socket) -> {
if (ex != null) {
handler.removeCallbacks(runnable);
mCallBack.onConnectError(ex.getMessage());
return;
}
socket.setDataCallback((emitter, bb) -> L.iTag("TcpClient", new String(bb.getAllByteArray())));
socket.setClosedCallback(ex1 -> {
if (ex1 != null) {
L.iTag("TcpClient", "setClosedCallback出错");
return;
}
L.iTag("TcpClient", "setClosedCallback");
});
socket.setEndCallback(ex12 -> {
if (ex12 != null) {
L.iTag("TcpClient", "setEndCallback出错");
return;
}
L.iTag("TcpClient", "setEndCallback");
});
socket.setWriteableCallback(() -> Log.d("TcpClient", "onWriteable"));
byte[] dataContent = msg.getBytes();
byte[] end = new byte[]{0x0a};
byte[] start = new byte[]{0x0a};
byte[] data = new byte[dataContent.length + start.length + end.length];
try {
System.arraycopy(start, 0, data, 0, start.length);
System.arraycopy(dataContent, 0, data, start.length, dataContent.length);
System.arraycopy(end, 0, data, start.length + dataContent.length, end.length);
} catch (Exception e) {
L.logFile(e.getMessage() + "\n" + e.getStackTrace().toString());
data = dataContent;
}
L.iTag("TcpClient", data.toString());
L.i("TcpClient", data);
Util.writeAll(socket, data, ex13 -> {
if (ex13 != null) {
L.iTag("TcpClient", "writeAll出错");
handler.removeCallbacks(runnable);
mCallBack.onWriteError(ex13.getMessage());
return;
}
handler.removeCallbacks(runnable);
mCallBack.onSuccess();
L.iTag("TcpClient", "writeAll");
});
});
handler.removeCallbacks(runnable);
handler.postDelayed(runnable, 5000);
Looper.loop();
}