List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:me.cpwc.nibblegram.android.NotificationsController.java
public void processLoadedUnreadMessages(HashMap<Long, Integer> dialogs, ArrayList<TLRPC.Message> messages, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats) { MessagesController.getInstance().putUsers(users, true); MessagesController.getInstance().putChats(chats, true); MessagesController.getInstance().putEncryptedChats(encryptedChats, true); pushDialogs.clear();//from ww w . j av a2 s . c o m pushMessages.clear(); pushMessagesDict.clear(); total_unread_count = 0; personal_count = 0; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); HashMap<Long, Boolean> settingsCache = new HashMap<Long, Boolean>(); for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) { long dialog_id = entry.getKey(); Boolean value = settingsCache.get(dialog_id); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (!value) { continue; } int count = entry.getValue(); pushDialogs.put(dialog_id, count); total_unread_count += count; } if (messages != null) { for (TLRPC.Message message : messages) { if (pushMessagesDict.containsKey(message.id)) { continue; } MessageObject messageObject = new MessageObject(message, null, 0); if (isPersonalMessage(messageObject)) { personal_count++; } long dialog_id = messageObject.getDialogId(); Boolean value = settingsCache.get(dialog_id); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } pushMessagesDict.put(messageObject.messageOwner.id, messageObject); pushMessages.add(0, messageObject); } } if (total_unread_count == 0) { popupMessages.clear(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated); } showOrUpdateNotification(SystemClock.uptimeMillis() / 1000 < 60); if (preferences.getBoolean("badgeNumber", true)) { setBadge(ApplicationLoader.applicationContext, total_unread_count); } }
From source file:com.yao.zhihudaily.tool.LazyViewPager.java
/** * Fake drag by an offset in pixels. You must have called {@link #beginFakeDrag()} first. * * @param xOffset Offset in pixels to drag by. * @see #beginFakeDrag()// ww w . j a v a 2s .co m * @see #endFakeDrag() */ public void fakeDragBy(float xOffset) { if (!mFakeDragging) { throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first."); } mLastMotionX += xOffset; float scrollX = getScrollX() - xOffset; final int width = getWidth(); final int widthWithMargin = width + mPageMargin; final float leftBound = Math.max(0, (mCurItem - 1) * widthWithMargin); final float rightBound = Math.min(mCurItem + 1, mAdapter.getCount() - 1) * widthWithMargin; if (scrollX < leftBound) { scrollX = leftBound; } else if (scrollX > rightBound) { scrollX = rightBound; } // Don't lose the rounded component mLastMotionX += scrollX - (int) scrollX; scrollTo((int) scrollX, getScrollY()); if (mOnPageChangeListener != null) { final int position = (int) scrollX / widthWithMargin; final int positionOffsetPixels = (int) scrollX % widthWithMargin; final float positionOffset = (float) positionOffsetPixels / widthWithMargin; mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } // Synthesize an event for the VelocityTracker. final long time = SystemClock.uptimeMillis(); final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE, mLastMotionX, 0, 0); mVelocityTracker.addMovement(ev); ev.recycle(); }
From source file:com.iiordanov.runsoft.bVNC.RemoteCanvasActivity.java
public void showZoomer(boolean force) { if (force || zoomer.getVisibility() != View.VISIBLE) { // zoomer.show(); hideZoomAfterMs = SystemClock.uptimeMillis() + ZOOM_HIDE_DELAY_MS; canvas.handler.postAtTime(hideZoomInstance, hideZoomAfterMs + 10); }/*w ww . j a v a2 s . c o m*/ }
From source file:com.cnpeng.cnpeng_mydemosfrom2016_12.a_12_GetLocalFiles_VP_FM.CustomNoPreLoadViewPager.java
/** * Fake drag by an offset in pixels. You must have called {@link #beginFakeDrag()} first. * * @param xOffset Offset in pixels to drag by. * @see #beginFakeDrag()//from www .j a v a 2s . c o m * @see #endFakeDrag() */ public void fakeDragBy(float xOffset) { if (!mFakeDragging) { throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first."); } mLastMotionX += xOffset; float scrollX = getScrollX() - xOffset; final int width = getWidth(); final int widthWithMargin = width + mPageMargin; final float leftBound = Math.max(0, (mCurItem - 1) * widthWithMargin); final float rightBound = Math.min(mCurItem + 1, mAdapter.getCount() - 1) * widthWithMargin; if (scrollX < leftBound) { scrollX = leftBound; } else if (scrollX > rightBound) { scrollX = rightBound; } // Don't lose the rounded component mLastMotionX += scrollX - (int) scrollX; scrollTo((int) scrollX, getScrollY()); if (mOnPageChangeListener != null) { final int position = (int) scrollX / widthWithMargin; final int positionOffsetPixels = (int) scrollX % widthWithMargin; final float positionOffset = (float) positionOffsetPixels / widthWithMargin; mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } // Synthesize an event for the VelocityTracker. final long time = SystemClock.uptimeMillis(); final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE, mLastMotionX, 0, 0); mVelocityTracker.addMovement(ev); ev.recycle(); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
@Override public void onShutterClick() { if (!CameraController.isRemoteCamera()) { if (shutterOff) return; if (isRecording) { long now = SystemClock.uptimeMillis(); long delta = now - mRecordingStartTime; Handler handler = new Handler(); handler.postDelayed(new Runnable() { public void run() { stopRecording();/*from w w w .ja va 2s. c o m*/ } }, 1500 - delta); } else { this.startRecording(); } } else {//Sony camera pauseVideoButton.setVisibility(View.GONE); if (isRecording) { stopRecordingSonyRemote(); } else { startRecordingSonyRemote(); } } }
From source file:ca.co.rufus.androidboilerplate.ui.DebugDrawerLayout.java
void cancelChildViewTouch() { // Cancel child touches if (!mChildrenCanceledTouch) { final long now = SystemClock.uptimeMillis(); final MotionEvent cancelEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0.0f, 0.0f, 0); final int childCount = getChildCount(); for (int i = 0; i < childCount; i++) { getChildAt(i).dispatchTouchEvent(cancelEvent); }/*from w w w. j av a 2 s . c om*/ cancelEvent.recycle(); mChildrenCanceledTouch = true; } }
From source file:bw.com.yunifangstore.view.LazyViewPager.java
/** * Fake drag by an offset in pixels. You must have called {@link #beginFakeDrag()} first. * * @param xOffset Offset in pixels to drag by. * @see #beginFakeDrag()/*from w ww . j a v a 2s .c om*/ * @see #endFakeDrag() */ public void fakeDragBy(float xOffset) { if (!mFakeDragging) { throw new IllegalStateException("No fake drag in progress. Call beginFakeDrag first."); } mLastMotionX += xOffset; float scrollX = getScrollX() - xOffset; final int width = getWidth(); final int widthWithMargin = width + mPageMargin; final float leftBound = Math.max(0, (mCurItem - 1) * widthWithMargin); final float rightBound = Math.min(mCurItem + 1, mAdapter.getCount() - 1) * widthWithMargin; if (scrollX < leftBound) { scrollX = leftBound; } else if (scrollX > rightBound) { scrollX = rightBound; } // Don't lose the rounded component mLastMotionX += scrollX - (int) scrollX; scrollTo((int) scrollX, getScrollY()); if (mOnPageChangeListener != null) { final int position = (int) scrollX / widthWithMargin; final int positionOffsetPixels = (int) scrollX % widthWithMargin; final float positionOffset = (float) positionOffsetPixels / widthWithMargin; mOnPageChangeListener.onPageScrolled(position, positionOffset, positionOffsetPixels); } // Synthesize an event for the VelocityTracker. final long time = SystemClock.uptimeMillis(); final MotionEvent ev = MotionEvent.obtain(mFakeDragBeginTime, time, MotionEvent.ACTION_MOVE, mLastMotionX, 0, 0); mVelocityTracker.addMovement(ev); ev.recycle(); }
From source file:com.almalence.plugins.capture.video.VideoCapturePlugin.java
private void startRecordingSonyRemote() { ApplicationScreen.getGUIManager().lockControls = true; CameraController.startVideoRecordingSonyRemote(); mRecordingStartTime = SystemClock.uptimeMillis(); isRecording = true;/*ww w. j a v a2 s . c o m*/ showRecordingUI(isRecording); View mainButtonsVideo = (View) ApplicationScreen.instance.guiManager.getMainView() .findViewById(R.id.mainButtonsVideo); mainButtonsVideo.setVisibility(View.VISIBLE); View mainButtons = (View) ApplicationScreen.instance.guiManager.getMainView() .findViewById(R.id.mainButtons); mainButtons.setVisibility(View.INVISIBLE); }
From source file:com.negaheno.android.NotificationsController.java
public void processLoadedUnreadMessages(HashMap<Long, Integer> dialogs, ArrayList<TLRPC.Message> messages, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats) { MessagesController.getInstance().putUsers(users, true); MessagesController.getInstance().putChats(chats, true); MessagesController.getInstance().putEncryptedChats(encryptedChats, true); pushDialogs.clear();/*from w w w. j a va 2 s . c o m*/ pushMessages.clear(); pushMessagesDict.clear(); total_unread_count = 0; personal_count = 0; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); HashMap<Long, Boolean> settingsCache = new HashMap<>(); for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) { long dialog_id = entry.getKey(); Boolean value = settingsCache.get(dialog_id); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); if (notify_override == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { notify_override = 2; } } value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (!value) { continue; } int count = entry.getValue(); pushDialogs.put(dialog_id, count); total_unread_count += count; } if (messages != null) { for (TLRPC.Message message : messages) { if (pushMessagesDict.containsKey(message.id)) { continue; } MessageObject messageObject = new MessageObject(message, null, false); if (isPersonalMessage(messageObject)) { personal_count++; } long dialog_id = messageObject.getDialogId(); Boolean value = settingsCache.get(dialog_id); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); if (notify_override == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { notify_override = 2; } } value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } pushMessagesDict.put(messageObject.messageOwner.id, messageObject); pushMessages.add(0, messageObject); } } if (total_unread_count == 0) { popupMessages.clear(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated); } showOrUpdateNotification(SystemClock.uptimeMillis() / 1000 < 60); if (preferences.getBoolean("badgeNumber", true)) { setBadge(ApplicationLoader.applicationContext, total_unread_count); } }
From source file:org.hermes.android.NotificationsController.java
public void processLoadedUnreadMessages(HashMap<Long, Integer> dialogs, ArrayList<TLRPC.Message> messages, ArrayList<TLRPC.User> users, ArrayList<TLRPC.Chat> chats, ArrayList<TLRPC.EncryptedChat> encryptedChats) { MessagesController.getInstance().putUsers(users, true); MessagesController.getInstance().putChats(chats, true); MessagesController.getInstance().putEncryptedChats(encryptedChats, true); pushDialogs.clear();/*from w w w. j av a2s . c o m*/ pushMessages.clear(); pushMessagesDict.clear(); total_unread_count = 0; personal_count = 0; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); HashMap<Long, Boolean> settingsCache = new HashMap<>(); if (messages != null) { for (TLRPC.Message message : messages) { if (pushMessagesDict.containsKey(message.id)) { continue; } MessageObject messageObject = new MessageObject(message, null, false); if (isPersonalMessage(messageObject)) { personal_count++; } long dialog_id = messageObject.getDialogId(); long original_dialog_id = dialog_id; if ((messageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_MENTION) != 0) { dialog_id = messageObject.messageOwner.from_id; } Boolean value = settingsCache.get(dialog_id); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); if (notify_override == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { notify_override = 2; } } value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (!value || dialog_id == openned_dialog_id && ApplicationLoader.isScreenOn) { continue; } pushMessagesDict.put(messageObject.getId(), messageObject); pushMessages.add(0, messageObject); if (original_dialog_id != dialog_id) { pushDialogsOverrideMention.put(original_dialog_id, 1); } } } for (HashMap.Entry<Long, Integer> entry : dialogs.entrySet()) { long dialog_id = entry.getKey(); Boolean value = settingsCache.get(dialog_id); if (value == null) { int notify_override = preferences.getInt("notify2_" + dialog_id, 0); if (notify_override == 3) { int mute_until = preferences.getInt("notifyuntil_" + dialog_id, 0); if (mute_until >= ConnectionsManager.getInstance().getCurrentTime()) { notify_override = 2; } } Integer override = pushDialogsOverrideMention.get(dialog_id); if (override != null && override == 1) { pushDialogsOverrideMention.put(dialog_id, 0); notify_override = 1; } value = !(notify_override == 2 || (!preferences.getBoolean("EnableAll", true) || ((int) dialog_id < 0) && !preferences.getBoolean("EnableGroup", true)) && notify_override == 0); settingsCache.put(dialog_id, value); } if (!value) { continue; } int count = entry.getValue(); pushDialogs.put(dialog_id, count); total_unread_count += count; } if (total_unread_count == 0) { popupMessages.clear(); NotificationCenter.getInstance().postNotificationName(NotificationCenter.pushMessagesUpdated); } showOrUpdateNotification(SystemClock.uptimeMillis() / 1000 < 60); if (preferences.getBoolean("badgeNumber", true)) { setBadge(ApplicationLoader.applicationContext, total_unread_count); } }