List of usage examples for android.os SystemClock uptimeMillis
@CriticalNative native public static long uptimeMillis();
From source file:org.chromium.chrome.browser.toolbar.ToolbarPhone.java
/** * When entering and exiting the TabSwitcher mode, we fade out or fade in the browsing * mode of the toolbar on top of the TabSwitcher mode version of it. We do this by * drawing all of the browsing mode views on top of the android view. *//* ww w . j a va 2s . c o m*/ private void drawTabSwitcherAnimationOverlay(Canvas canvas, float animationProgress) { if (!isNativeLibraryReady()) return; float floatAlpha = 1 - animationProgress; int rgbAlpha = (int) (255 * floatAlpha); canvas.save(); canvas.translate(0, -animationProgress * mBackgroundOverlayBounds.height()); canvas.clipRect(mBackgroundOverlayBounds); float previousAlpha = 0.f; if (mHomeButton.getVisibility() != View.GONE) { // Draw the New Tab button used in the URL view. previousAlpha = mHomeButton.getAlpha(); mHomeButton.setAlpha(previousAlpha * floatAlpha); drawChild(canvas, mHomeButton, SystemClock.uptimeMillis()); mHomeButton.setAlpha(previousAlpha); } // Draw the location/URL bar. previousAlpha = mLocationBar.getAlpha(); mLocationBar.setAlpha(previousAlpha * floatAlpha); // If the location bar is now fully transparent, do not bother drawing it. if (mLocationBar.getAlpha() != 0) { drawChild(canvas, mLocationBar, SystemClock.uptimeMillis()); } mLocationBar.setAlpha(previousAlpha); // Draw the tab stack button and associated text. translateCanvasToView(this, mToolbarButtonsContainer, canvas); if (mTabSwitcherAnimationTabStackDrawable != null && mToggleTabStackButton != null && mUrlExpansionPercent != 1f) { // Draw the tab stack button image. canvas.save(); translateCanvasToView(mToolbarButtonsContainer, mToggleTabStackButton, canvas); int backgroundWidth = mToggleTabStackButton.getDrawable().getIntrinsicWidth(); int backgroundHeight = mToggleTabStackButton.getDrawable().getIntrinsicHeight(); int backgroundLeft = (mToggleTabStackButton.getWidth() - mToggleTabStackButton.getPaddingLeft() - mToggleTabStackButton.getPaddingRight() - backgroundWidth) / 2; backgroundLeft += mToggleTabStackButton.getPaddingLeft(); int backgroundTop = (mToggleTabStackButton.getHeight() - mToggleTabStackButton.getPaddingTop() - mToggleTabStackButton.getPaddingBottom() - backgroundHeight) / 2; backgroundTop += mToggleTabStackButton.getPaddingTop(); canvas.translate(backgroundLeft, backgroundTop); mTabSwitcherAnimationTabStackDrawable.setAlpha(rgbAlpha); mTabSwitcherAnimationTabStackDrawable.draw(canvas); canvas.restore(); } // Draw the menu button if necessary. if (!mShowMenuBadge && mTabSwitcherAnimationMenuDrawable != null && mUrlExpansionPercent != 1f) { mTabSwitcherAnimationMenuDrawable.setBounds(mMenuButton.getPaddingLeft(), mMenuButton.getPaddingTop(), mMenuButton.getWidth() - mMenuButton.getPaddingRight(), mMenuButton.getHeight() - mMenuButton.getPaddingBottom()); translateCanvasToView(mToolbarButtonsContainer, mMenuButton, canvas); mTabSwitcherAnimationMenuDrawable.setAlpha(rgbAlpha); int color = mUseLightDrawablesForTextureCapture ? mLightModeDefaultColor : mDarkModeDefaultColor; mTabSwitcherAnimationMenuDrawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); mTabSwitcherAnimationMenuDrawable.draw(canvas); } // Draw the menu badge if necessary. Drawable badgeDrawable = mUseLightDrawablesForTextureCapture ? mTabSwitcherAnimationMenuBadgeLightDrawable : mTabSwitcherAnimationMenuBadgeDarkDrawable; if (mShowMenuBadge && badgeDrawable != null && mUrlExpansionPercent != 1f) { badgeDrawable.setBounds(mMenuBadge.getPaddingLeft(), mMenuBadge.getPaddingTop(), mMenuBadge.getWidth() - mMenuBadge.getPaddingRight(), mMenuBadge.getHeight() - mMenuBadge.getPaddingBottom()); translateCanvasToView(mToolbarButtonsContainer, mMenuBadge, canvas); badgeDrawable.setAlpha(rgbAlpha); badgeDrawable.draw(canvas); } mLightDrawablesUsedForLastTextureCapture = mUseLightDrawablesForTextureCapture; canvas.restore(); }
From source file:androidVNC.VncCanvasActivity.java
private void showZoomer(boolean force) { if (force || zoomer.getVisibility() != View.VISIBLE) { zoomer.show();// ww w. j ava 2 s .com hideZoomAfterMs = SystemClock.uptimeMillis() + ZOOM_HIDE_DELAY_MS; vncCanvas.handler.postAtTime(hideZoomInstance, hideZoomAfterMs + 10); } }
From source file:io.requery.android.database.sqlite.SQLiteConnectionPool.java
/** * Dumps debugging information about this connection pool. * * @param printer The printer to receive the dump, not null. * @param verbose True to dump more verbose information. *//*from w ww . j av a2s. co m*/ public void dump(Printer printer, boolean verbose) { synchronized (mLock) { printer.println("Connection pool for " + mConfiguration.path + ":"); printer.println(" Open: " + mIsOpen); printer.println(" Max connections: " + mMaxConnectionPoolSize); printer.println(" Available primary connection:"); if (mAvailablePrimaryConnection != null) { mAvailablePrimaryConnection.dump(printer, verbose); } else { printer.println("<none>"); } printer.println(" Available non-primary connections:"); if (!mAvailableNonPrimaryConnections.isEmpty()) { for (SQLiteConnection connection : mAvailableNonPrimaryConnections) { connection.dump(printer, verbose); } } else { printer.println("<none>"); } printer.println(" Acquired connections:"); if (!mAcquiredConnections.isEmpty()) { for (Map.Entry<SQLiteConnection, AcquiredConnectionStatus> entry : mAcquiredConnections .entrySet()) { final SQLiteConnection connection = entry.getKey(); connection.dumpUnsafe(printer, verbose); printer.println(" Status: " + entry.getValue()); } } else { printer.println("<none>"); } printer.println(" Connection waiters:"); if (mConnectionWaiterQueue != null) { int i = 0; final long now = SystemClock.uptimeMillis(); for (ConnectionWaiter waiter = mConnectionWaiterQueue; waiter != null; waiter = waiter.mNext, i++) { printer.println(i + ": waited for " + ((now - waiter.mStartTime) * 0.001f) + " ms - thread=" + waiter.mThread + ", priority=" + waiter.mPriority + ", sql='" + waiter.mSql + "'"); } } else { printer.println("<none>"); } } }
From source file:com.android.camera.one.v2.OneCameraZslImpl.java
private void startAFCycle() { // Clean up any existing AF cycle's pending callbacks. mCameraHandler.removeCallbacksAndMessages(FOCUS_RESUME_CALLBACK_TOKEN); // Send a single CONTROL_AF_TRIGGER_START capture request. sendAutoFocusTriggerRequest();/*from ww w .j a va2 s .c o m*/ // Immediately send a request for a regular preview stream, but with // CONTROL_AF_MODE_AUTO set so that the focus remains constant after the // AF cycle completes. sendAutoFocusHoldRequest(); // Waits Settings3A.getFocusHoldMillis() milliseconds before sending // a request for a regular preview stream to resume. mCameraHandler.postAtTime(new Runnable() { @Override public void run() { mAERegions = ZERO_WEIGHT_3A_REGION; mAFRegions = ZERO_WEIGHT_3A_REGION; sendRepeatingCaptureRequest(); } }, FOCUS_RESUME_CALLBACK_TOKEN, SystemClock.uptimeMillis() + Settings3A.getFocusHoldMillis()); }
From source file:com.android.gallery3d.app.PhotoPage.java
private void requestDeferredUpdate() { mDeferUpdateUntil = SystemClock.uptimeMillis() + DEFERRED_UPDATE_MS; if (!mDeferredUpdateWaiting) { mDeferredUpdateWaiting = true;/*w w w.j av a 2 s . c om*/ mHandler.sendEmptyMessageDelayed(MSG_UPDATE_DEFERRED, DEFERRED_UPDATE_MS); } }
From source file:org.chromium.chrome.browser.tabmodel.TabPersistentStore.java
private void loadNextTab() { if (mDestroyed) return;/*ww w .ja v a2 s. co m*/ if (mTabsToRestore.isEmpty()) { mNormalTabsRestored = null; mIncognitoTabsRestored = null; mLoadInProgress = false; // If tabs are done being merged into this instance, save the tab metadata file for this // TabPersistentStore and delete the metadata file for the other instance, then notify // observers. if (mPersistencePolicy.isMergeInProgress()) { if (mMergeTabCount != 0) { long timePerTab = (SystemClock.uptimeMillis() - mRestoreMergedTabsStartTime) / mMergeTabCount; RecordHistogram.recordTimesHistogram("Android.TabPersistentStore.MergeStateTimePerTab", timePerTab, TimeUnit.MILLISECONDS); } ThreadUtils.postOnUiThread(new Runnable() { @Override public void run() { // This eventually calls serializeTabModelSelector() which much be called // from the UI thread. #mergeState() starts an async task in the background // that goes through this code path. saveTabListAsynchronously(); } }); deleteFileAsync(mPersistencePolicy.getStateToBeMergedFileName()); if (mObserver != null) mObserver.onStateMerged(); } cleanUpPersistentData(); onStateLoaded(); mLoadTabTask = null; Log.d(TAG, "Loaded tab lists; counts: " + mTabModelSelector.getModel(false).getCount() + "," + mTabModelSelector.getModel(true).getCount()); } else { TabRestoreDetails tabToRestore = mTabsToRestore.removeFirst(); mLoadTabTask = new LoadTabTask(tabToRestore); mLoadTabTask.execute(); } }
From source file:com.jzh.stuapp.view.MyViewPager.java
/** * Fake drag by an offset in pixels. You must have called * {@link #beginFakeDrag()} first.//from ww w.j a v a 2 s . c o m * * @param xOffset * Offset in pixels to drag by. * @see #beginFakeDrag() * @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; } 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); } 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:org.telepatch.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 .ja va 2 s.c o m pushMessages.clear(); pushMessagesDict.clear(); total_unread_count = 0; personal_count = 0; 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.tct.mail.ui.ConversationViewFragment.java
private void renderConversation(MessageCursor messageCursor) { hasRenderContent = true;/*from w w w . j a v a 2 s. c om*/ final String convHtml = renderMessageBodies(messageCursor, mEnableContentReadySignal); timerMark("rendered conversation"); if (DEBUG_DUMP_CONVERSATION_HTML) { java.io.FileWriter fw = null; try { fw = new java.io.FileWriter(getSdCardFilePath()); fw.write(convHtml); } catch (java.io.IOException e) { e.printStackTrace(); } finally { if (fw != null) { try { fw.close(); } catch (java.io.IOException e) { e.printStackTrace(); } } } } // save off existing scroll position before re-rendering if (mWebViewLoadedData) { mWebViewYPercent = calculateScrollYPercent(); } //TS: jian.xu 2016-01-27 EMAIL BUGFIX-1275319 MOD_S try { mWebView.loadDataWithBaseURL(mBaseUri, convHtml, "text/html", "utf-8", null); } catch (OutOfMemoryError e) { LogUtils.e(LOG_TAG, e, "happen out of memory error while execute loadDataWithBaseURL in render conversation."); } //TS: jian.xu 2016-01-27 EMAIL BUGFIX-1275319 MOD_E mWebViewLoadedData = true; mWebViewLoadStartMs = SystemClock.uptimeMillis(); }
From source file:com.iiordanov.bVNC.RemoteCanvasActivity.java
public void showZoomer(boolean force) { if (force || zoomer.getVisibility() != View.VISIBLE) { zoomer.show();// w w w .j a va 2s .c om hideZoomAfterMs = SystemClock.uptimeMillis() + ZOOM_HIDE_DELAY_MS; canvas.handler.postAtTime(hideZoomInstance, hideZoomAfterMs + 10); } }