Java 类android.os.SystemClock 实例源码

项目:WalkGraph    文件:TimeService.java   
public static void setTimeInterval(Context context){
    Log.d(TAG, "Entered set time interval");
    Intent selfIntent = getIntent(context);
    PendingIntent pendingIntent = PendingIntent.getService(context, 0,
            selfIntent, 0);

    AlarmManager manager = (AlarmManager) context.getSystemService
            (Context.ALARM_SERVICE);

    if (isTimeAlarmOn(context)){
        manager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                SystemClock.elapsedRealtime(), REPEAT_TIME,
                pendingIntent);
        Log.d(TAG, "Alarm is not on, starting it now");
    }else {
        manager.cancel(pendingIntent);
        pendingIntent.cancel();
        Log.d(TAG, "Alarm is on, cancelling it now");
    }
}
项目:Building-Android-UIs-with-Custom-Views    文件:FixedTimestepExample.java   
@Override
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
    super.onVisibilityChanged(changedView, visibility);

    // avoid doing this check before View is even visible
    if (timeStart != -1) {
        if ((visibility == View.INVISIBLE || visibility == View.GONE) &&
                previousVisibility == View.VISIBLE) {

            invisibleTimeStart = SystemClock.elapsedRealtime();
        }

        if ((previousVisibility == View.INVISIBLE || previousVisibility == View.GONE) &&
                visibility == View.VISIBLE) {

            timeStart += SystemClock.elapsedRealtime() - invisibleTimeStart;
        }
    } else {
        timeStart = SystemClock.elapsedRealtime();
    }

    previousVisibility = visibility;
}
项目:Slide-RSS    文件:OnSingleClickListener.java   
@Override
public final void onClick(View v) {
    final long lastClickTime = mLastClickTime;
    final long now = SystemClock.uptimeMillis(); //guaranteed 100% monotonic

    if (now - lastClickTime < MIN_DELAY_MS && !override) {
        // Too fast: ignore
        if (Config.LOGD) {
            Log.d(TAG, "onClick Clicked too quickly: ignored");
        }
    } else {
        override = false;
        // Update mLastClickTime and register the click
        mLastClickTime = now;
        onSingleClick(v);
    }
}
项目:PaoMovie    文件:RenderTask.java   
@Override
public void doWork() {
    final long invalidationDelay = mGifDrawable.mNativeInfoHandle.renderFrame(mGifDrawable.mBuffer);
    if (invalidationDelay >= 0) {
        mGifDrawable.mNextFrameRenderTime = SystemClock.uptimeMillis() + invalidationDelay;
        if (mGifDrawable.isVisible()) {
            if (mGifDrawable.mIsRunning && !mGifDrawable.mIsRenderingTriggeredOnDraw) {
                mGifDrawable.mExecutor.schedule(this, invalidationDelay, TimeUnit.MILLISECONDS);
            }
        }
        if (!mGifDrawable.mListeners.isEmpty() && mGifDrawable.getCurrentFrameIndex() == mGifDrawable.mNativeInfoHandle.frameCount - 1) {
            mGifDrawable.scheduleSelf(mNotifyListenersTask, mGifDrawable.mNextFrameRenderTime);
        }
    } else {
        mGifDrawable.mNextFrameRenderTime = Long.MIN_VALUE;
        mGifDrawable.mIsRunning = false;
    }
    if (mGifDrawable.isVisible() && !mGifDrawable.mInvalidationHandler.hasMessages(0)) {
        mGifDrawable.mInvalidationHandler.sendEmptyMessageAtTime(0, 0);
    }
}
项目:Runnest    文件:RunTest.java   
@Test
public void startAndStopRun() {
    onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
    onView(withId(R.id.nav_view)).perform(NavigationViewActions.navigateTo(R.id.nav_run));

    // Jenkins sleep (1/3)
    //
    // Sleep necessary in order to successfully build on Jenkins, I wasn't able to
    // reproduce the failure in local. After a lot of attempts I decided to keep it.
    SystemClock.sleep(FIREBASE_DURATION);

    onView(isRoot()).perform(waitForMatch(withId(R.id.start_run), UI_TEST_TIMEOUT));
    onView(withId(R.id.start_run)).perform(click());

    SystemClock.sleep(MOCK_LOCATION_DURATION);

    onView(isRoot()).perform(waitForMatch(withId(R.id.stop_run), UI_TEST_TIMEOUT));
    onView(withId(R.id.stop_run)).perform(click());

    onView(isRoot()).perform(waitForMatch(withId(R.id.button_history), UI_TEST_TIMEOUT));
    onView(withId(R.id.button_history)).perform(click());
}
项目:RxJavaEspressoSample    文件:RxJava1Activity.java   
@Override
protected void onStart() {
    super.onStart();
    compositeSubscription.add(RxView.clicks(binding.buttonDebounce)
            .observeOn(Schedulers.computation())
            .debounce(3, TimeUnit.SECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(v -> binding.textDebounceResult.setText("Debounce Completed")));

    compositeSubscription.add(RxView.clicks(binding.buttonSleep)
            .observeOn(Schedulers.io())
            .map(v -> {
                SystemClock.sleep(3000L);
                return v;
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(v -> binding.textSleepResult.setText("Sleep Completed")));
}
项目:RxJavaEspressoSample    文件:RxJava2Activity.java   
@Override
protected void onStart() {
    super.onStart();
    compositeDisposable.add(RxView.clicks(binding.buttonDebounce)
            .observeOn(Schedulers.computation())
            .debounce(3, TimeUnit.SECONDS)
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(v -> binding.textDebounceResult.setText("Debounce Completed")));

    compositeDisposable.add(RxView.clicks(binding.buttonSleep)
            .observeOn(Schedulers.io())
            .map(v -> {
                SystemClock.sleep(3000L);
                return v;
            })
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(v -> binding.textSleepResult.setText("Sleep Completed")));
}
项目:ExoPlayer-Offline    文件:ExoHostedTest.java   
@Override
public final void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
  Log.d(tag, "state [" + playWhenReady + ", " + playbackState + "]");
  playerWasPrepared |= playbackState != ExoPlayer.STATE_IDLE;
  if (playbackState == ExoPlayer.STATE_ENDED
      || (playbackState == ExoPlayer.STATE_IDLE && playerWasPrepared)) {
    playerFinished = true;
  }
  boolean playing = playWhenReady && playbackState == ExoPlayer.STATE_READY;
  if (!this.playing && playing) {
    lastPlayingStartTimeMs = SystemClock.elapsedRealtime();
  } else if (this.playing && !playing) {
    totalPlayingTimeMs += SystemClock.elapsedRealtime() - lastPlayingStartTimeMs;
  }
  this.playing = playing;
}
项目:q-mail    文件:Storage.java   
private void loadValues() {
    long startTime = SystemClock.elapsedRealtime();
    Timber.i("Loading preferences from DB into Storage");
    Cursor cursor = null;
    SQLiteDatabase mDb = null;
    try {
        mDb = openDB();

        cursor = mDb.rawQuery("SELECT primkey, value FROM preferences_storage", null);
        while (cursor.moveToNext()) {
            String key = cursor.getString(0);
            String value = cursor.getString(1);
            Timber.d("Loading key '%s', value = '%s'", key, value);
            storage.put(key, value);
        }
    } finally {
        Utility.closeQuietly(cursor);
        if (mDb != null) {
            mDb.close();
        }
        long endTime = SystemClock.elapsedRealtime();
        Timber.i("Preferences load took %d ms", endTime - startTime);
    }
}
项目:boohee_v5.6    文件:d.java   
public void a(int i, String str, String str2, String str3, String str4, Long l, int i2, int
        i3, String str5) {
    long j;
    long elapsedRealtime = SystemClock.elapsedRealtime() - l.longValue();
    if (l.longValue() == 0 || elapsedRealtime < 0) {
        j = 0;
    } else {
        j = elapsedRealtime;
    }
    StringBuffer stringBuffer = new StringBuffer("http://c.isdspeed.qq.com/code.cgi");
    stringBuffer.append("?domain=mobile.opensdk.com&cgi=opensdk&type=").append(i).append
            ("&code=").append(i2).append("&time=").append(j).append("&rate=").append(i3)
            .append("&uin=").append(str2).append("&data=");
    g.a().a(stringBuffer.toString(), "GET", Util.composeHaboCgiReportParams(String.valueOf(i)
            , String.valueOf(i2), String.valueOf(j), String.valueOf(i3), str, str2, str3,
            str4, str5), true);
}
项目:BBSSDK-for-Android    文件:ImageUtils.java   
public void saveImage(String location, Bitmap bmp) {
    if (TextUtils.isEmpty(location)) {
        location = Environment.getExternalStorageDirectory()
                + File.pathSeparator + SystemClock.currentThreadTimeMillis() + ".jpg";
    }
    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    bmp.compress(Bitmap.CompressFormat.JPEG, 40, bytes);
    File file = new File(location);
    try {
        file.createNewFile();
        FileOutputStream outputStream = new FileOutputStream(file);
        outputStream.write(bytes.toByteArray());
        outputStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Weather365    文件:AutoUpdateService.java   
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    updateWeather();
    updateBingPic();
    AlarmManager manager = (AlarmManager) getSystemService(ALARM_SERVICE);
    int anHour = 4 * 60 * 60 * 1000;//4个小时的毫秒数
    long triggerAtTime = SystemClock.elapsedRealtime() + anHour;
    Intent i = new Intent(this, AutoUpdateService.class);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    manager.cancel(pi);
    manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, triggerAtTime, pi);
    return super.onStartCommand(intent, flags, startId);
}
项目:GitHub    文件:ChartViewportAnimatorV8.java   
@Override
public void run() {
    long elapsed = SystemClock.uptimeMillis() - start;
    if (elapsed > duration) {
        isAnimationStarted = false;
        handler.removeCallbacks(runnable);
        chart.setCurrentViewport(targetViewport);
        animationListener.onAnimationFinished();
        return;
    }
    float scale = Math.min(interpolator.getInterpolation((float) elapsed / duration), 1);
    float diffLeft = (targetViewport.left - startViewport.left) * scale;
    float diffTop = (targetViewport.top - startViewport.top) * scale;
    float diffRight = (targetViewport.right - startViewport.right) * scale;
    float diffBottom = (targetViewport.bottom - startViewport.bottom) * scale;
    newViewport.set(startViewport.left + diffLeft, startViewport.top + diffTop,
            startViewport.right + diffRight, startViewport.bottom + diffBottom);
    chart.setCurrentViewport(newViewport);

    handler.postDelayed(this, 16);
}
项目:Sega    文件:ViewPagerEx.java   
/**
 * Start a fake drag of the pager.
 *
 * <p>A fake drag can be useful if you want to synchronize the motion of the ViewPager
 * with the touch scrolling of another view, while still letting the ViewPager
 * control the snapping motion and fling behavior. (e.g. parallax-scrolling tabs.)
 * Call {@link #fakeDragBy(float)} to simulate the actual drag motion. Call
 * {@link #endFakeDrag()} to complete the fake drag and fling as necessary.
 *
 * <p>During a fake drag the ViewPager will ignore all touch events. If a real drag
 * is already in progress, this method will return false.
 *
 * @return true if the fake drag began successfully, false if it could not be started.
 *
 * @see #fakeDragBy(float)
 * @see #endFakeDrag()
 */
public boolean beginFakeDrag() {
    if (mIsBeingDragged) {
        return false;
    }
    mFakeDragging = true;
    setScrollState(SCROLL_STATE_DRAGGING);
    mInitialMotionX = mLastMotionX = 0;
    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    } else {
        mVelocityTracker.clear();
    }
    final long time = SystemClock.uptimeMillis();
    final MotionEvent ev = MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN, 0, 0, 0);
    mVelocityTracker.addMovement(ev);
    ev.recycle();
    mFakeDragBeginTime = time;
    return true;
}
项目:LaunchEnr    文件:Alarm.java   
public void setAlarm(long millisecondsInFuture) {
    long currentTime = SystemClock.uptimeMillis();
    mAlarmPending = true;
    long oldTriggerTime = mAlarmTriggerTime;
    mAlarmTriggerTime = currentTime + millisecondsInFuture;

    // If the previous alarm was set for a longer duration, cancel it.
    if (mWaitingForCallback && oldTriggerTime > mAlarmTriggerTime) {
        mHandler.removeCallbacks(this);
        mWaitingForCallback = false;
    }
    if (!mWaitingForCallback) {
        mHandler.postDelayed(this, mAlarmTriggerTime - currentTime);
        mWaitingForCallback = true;
    }
}
项目:richeditor    文件:MainActivity.java   
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE_IMAGE) {
        final ArrayList<String> pathList =
                data.getStringArrayListExtra(PhotoPickerActivity.EXTRA_RESULT_SELECTION);

        long id;
        // TODO: 2017/9/14 可以在线程中添加这段代码防止主线程卡顿
        for (String path :
                pathList) {
            id = SystemClock.currentThreadTimeMillis();
            long size[] = SizeUtil.getBitmapSize(path);
            mRichTextView.insertImage(path, id, size[0], size[1]);
            mInsertedImages.put(id, path);
            tryUpload(path, id);
        }
        //是否是原图
        final boolean original =
                data.getBooleanExtra(PhotoPickerActivity.EXTRA_RESULT_ORIGINAL, false);
    }
}
项目:Hotspot-master-devp    文件:HttpHandler.java   
@Override
public boolean updateProgress(long total, long current, boolean forceUpdateUI) {
    if (callback != null && !mStopped) {
        //上传图片时添加
        callback.updateProgress(total, current, forceUpdateUI);
        if (forceUpdateUI) {
            this.publishProgress(UPDATE_LOADING, total, current);
        } else {
            long currTime = SystemClock.uptimeMillis();
            if (currTime - lastUpdateTime >= callback.getRate()) {
                lastUpdateTime = currTime;
                this.publishProgress(UPDATE_LOADING, total, current);
            }
        }
    }
    return !mStopped;
}
项目:chromium-for-android-56-debug-video    文件:ChromeApplication.java   
/**
 * Removes all session cookies (cookies with no expiration date) after device reboots.
 * This function will incorrectly clear cookies when Daylight Savings Time changes the clock.
 * Without a way to get a monotonically increasing system clock, the boot timestamp will be off
 * by one hour.  However, this should only happen at most once when the clock changes since the
 * updated timestamp is immediately saved.
 */
public static void removeSessionCookies() {
    long lastKnownBootTimestamp =
            ContextUtils.getAppSharedPreferences().getLong(PREF_BOOT_TIMESTAMP, 0);
    long bootTimestamp = System.currentTimeMillis() - SystemClock.uptimeMillis();
    long difference = bootTimestamp - lastKnownBootTimestamp;

    // Allow some leeway to account for fractions of milliseconds.
    if (Math.abs(difference) > BOOT_TIMESTAMP_MARGIN_MS) {
        nativeRemoveSessionCookies();

        SharedPreferences prefs = ContextUtils.getAppSharedPreferences();
        SharedPreferences.Editor editor = prefs.edit();
        editor.putLong(PREF_BOOT_TIMESTAMP, bootTimestamp);
        editor.apply();
    }
}
项目:chromium-for-android-56-debug-video    文件:WebappActivity.java   
/**
 * Saves the tab data out to a file.
 */
void saveState(File activityDirectory) {
    String tabFileName = TabState.getTabStateFilename(getActivityTab().getId(), false);
    File tabFile = new File(activityDirectory, tabFileName);

    // Temporarily allowing disk access while fixing. TODO: http://crbug.com/525781
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    StrictMode.allowThreadDiskWrites();
    try {
        long time = SystemClock.elapsedRealtime();
        TabState.saveState(tabFile, getActivityTab().getState(), false);
        RecordHistogram.recordTimesHistogram("Android.StrictMode.WebappSaveState",
                SystemClock.elapsedRealtime() - time, TimeUnit.MILLISECONDS);
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
    }
}
项目:materialprogress    文件:ProgressWheel.java   
@Override public void onRestoreInstanceState(Parcelable state) {
  if (!(state instanceof WheelSavedState)) {
    super.onRestoreInstanceState(state);
    return;
  }

  WheelSavedState ss = (WheelSavedState) state;
  super.onRestoreInstanceState(ss.getSuperState());

  this.mProgress = ss.mProgress;
  this.mTargetProgress = ss.mTargetProgress;
  this.isSpinning = ss.isSpinning;
  this.spinSpeed = ss.spinSpeed;
  this.barWidth = ss.barWidth;
  this.barColor = ss.barColor;
  this.rimWidth = ss.rimWidth;
  this.rimColor = ss.rimColor;
  this.circleRadius = ss.circleRadius;
  this.linearProgress = ss.linearProgress;
  this.fillRadius = ss.fillRadius;

  this.lastTimeAnimated = SystemClock.uptimeMillis();
}
项目:FlickLauncher    文件:UserEventDispatcher.java   
public void dispatchUserEvent(LauncherEvent ev, Intent intent) {
    ev.elapsedContainerMillis = SystemClock.uptimeMillis() - mElapsedContainerMillis;
    ev.elapsedSessionMillis = SystemClock.uptimeMillis() - mElapsedSessionMillis;

    if (!mIsVerbose) {
        return;
    }
    Log.d(TAG, String.format(Locale.US,
            "\naction:%s\n Source child:%s\tparent:%s",
            LoggerUtils.getActionStr(ev.action),
            LoggerUtils.getTargetStr(ev.srcTarget != null ? ev.srcTarget[0] : null),
            LoggerUtils.getTargetStr(ev.srcTarget != null && ev.srcTarget.length > 1 ?
                    ev.srcTarget[1] : null)));
    if (ev.destTarget != null && ev.destTarget.length > 0) {
        Log.d(TAG, String.format(Locale.US,
                " Destination child:%s\tparent:%s",
                LoggerUtils.getTargetStr(ev.destTarget != null ? ev.destTarget[0] : null),
                LoggerUtils.getTargetStr(ev.destTarget != null && ev.destTarget.length > 1 ?
                        ev.destTarget[1] : null)));
    }
    Log.d(TAG, String.format(Locale.US,
            " Elapsed container %d ms session %d ms action %d ms",
            ev.elapsedContainerMillis,
            ev.elapsedSessionMillis,
            ev.actionDurationMillis));
}
项目:android-library    文件:GifImageView.java   
@Override
protected void onDraw(Canvas canvas) {

    long now = SystemClock.uptimeMillis();

    if (mStart == 0) {
        mStart = now;
    }

    if (mMovie != null) {

        int duration = mMovie.duration();
        if (duration == 0) {
            duration = 1000;
        }

        int relTime = (int) ((now - mStart) % duration);

        mMovie.setTime(relTime);

        mMovie.draw(canvas, 0, 0);
        invalidate();
    }
}
项目:AndroidProgramming3e    文件:PollService.java   
public static void setServiceAlarm(Context context, boolean isOn) {
    Intent i = PollService.newIntent(context);
    PendingIntent pi = PendingIntent.getService(
            context, 0, i, 0);

    AlarmManager alarmManager = (AlarmManager)
            context.getSystemService(Context.ALARM_SERVICE);

    if (isOn) {
        alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime(), POLL_INTERVAL_MS, pi);
    } else {
        alarmManager.cancel(pi);
        pi.cancel();
    }
}
项目:boohee_v5.6    文件:HandlerPoster.java   
public void handleMessage(Message msg) {
    try {
        long started = SystemClock.uptimeMillis();
        do {
            PendingPost pendingPost = this.queue.poll();
            if (pendingPost == null) {
                synchronized (this) {
                    pendingPost = this.queue.poll();
                    if (pendingPost == null) {
                        this.handlerActive = false;
                        this.handlerActive = false;
                        return;
                    }
                }
            }
            this.eventBus.invokeSubscriber(pendingPost);
        } while (SystemClock.uptimeMillis() - started < ((long) this.maxMillisInsideHandleMessage));
        if (sendMessage(obtainMessage())) {
            this.handlerActive = true;
            return;
        }
        throw new EventBusException("Could not send handler message");
    } catch (Throwable th) {
        this.handlerActive = false;
    }
}
项目:GitHub    文件:DaoSessionConcurrentTest.java   
/**
 * We could put the statements inside ThreadLocals (fast enough), but it comes with initialization penalty for new
 * threads and costs more memory.
 */
public void _testThreadLocalSpeed() {
    final Database db = dao.getDatabase();
    ThreadLocal<DatabaseStatement> threadLocal = new ThreadLocal<DatabaseStatement>() {
        @Override
        protected DatabaseStatement initialValue() {
            return db.compileStatement("SELECT 42");
        }
    };
    threadLocal.get();
    long start = SystemClock.currentThreadTimeMillis();
    for (int i = 0; i < 1000; i++) {
        DatabaseStatement sqLiteStatement = threadLocal.get();
        assertNotNull(sqLiteStatement);
    }
    Long time = SystemClock.currentThreadTimeMillis() - start;
    DaoLog.d("TIME: " + time + "ms");
    // Around 1ms on a S3
    assertTrue(time < 10);
}
项目:MiniDownloader    文件:Worker.java   
/**
 * ********************************************************************************************************************************************
 * ********************************************************************************************************************************************
 */

@Override
public void updateProgress() {
    Progress progress = task.getProgress();
    /** Snapshot of progress status. */
    long time = SystemClock.uptimeMillis();
    long downloaded = progress.getDownloaded();
    /** Calculate network speed. */
    double speed = (downloaded - lastUpdatedDownloadedCount) / (time - lastUpdatedTime) / 1.024;
    progress.setNetworkSpeed(NumberUtil.scale(speed, 2));
    /** Update marker. */
    lastUpdatedTime = time;
    lastUpdatedDownloadedCount = downloaded;
    /** Update progress info. */
    taskManager.handleProgress(task);
}
项目:zabbkit-android    文件:GcmServerUtil.java   
private static String send(String content) {
    long backOff = BACKOFF_MILLISECONDS
            + RANDOM.nextInt(BACKOFF_ADD_MILLISECONDS);
    for (int i = 1; i <= MAX_ATTEMPTS; i++) {
        try {
            return post(GCM_APP_SERVER_URL, content);
        } catch (IOException e) {
            if (i == MAX_ATTEMPTS) {
                L.e(e);
                break;
            }
            SystemClock.sleep(backOff);
            backOff *= 2;
        }
    }
    return null;
}
项目:GitHub    文件:CountingMemoryCache.java   
public CountingMemoryCache(
    ValueDescriptor<V> valueDescriptor,
    CacheTrimStrategy cacheTrimStrategy,
    Supplier<MemoryCacheParams> memoryCacheParamsSupplier,
    PlatformBitmapFactory platformBitmapFactory,
    boolean isExternalCreatedBitmapLogEnabled) {
  mValueDescriptor = valueDescriptor;
  mExclusiveEntries = new CountingLruMap<>(wrapValueDescriptor(valueDescriptor));
  mCachedEntries = new CountingLruMap<>(wrapValueDescriptor(valueDescriptor));
  mCacheTrimStrategy = cacheTrimStrategy;
  mMemoryCacheParamsSupplier = memoryCacheParamsSupplier;
  mMemoryCacheParams = mMemoryCacheParamsSupplier.get();
  mLastCacheParamsCheck = SystemClock.uptimeMillis();

  if (isExternalCreatedBitmapLogEnabled) {
    platformBitmapFactory.setCreationListener(
        new PlatformBitmapFactory.BitmapCreationObserver() {
          @Override
          public void onBitmapCreated(
              Bitmap bitmap,
              Object callerContext) {
            mOtherEntries.put(bitmap, callerContext);
          }
        });
  }
}
项目:SmoothRefreshLayout    文件:SmoothRefreshLayout.java   
protected void performRefresh() {
    //loading start milliseconds since boot
    mLoadingStartTime = SystemClock.uptimeMillis();
    mNeedNotifyRefreshComplete = true;
    if (sDebug) {
        SRLog.d(TAG, "onRefreshBegin systemTime: %s", mLoadingStartTime);
    }
    if (isRefreshing()) {
        if (mHeaderView != null)
            mHeaderView.onRefreshBegin(this, mIndicator);
    } else if (isLoadingMore()) {
        if (mFooterView != null)
            mFooterView.onRefreshBegin(this, mIndicator);
    }
    if (mRefreshListener != null)
        mRefreshListener.onRefreshBegin(isRefreshing());
}
项目:TPondof    文件:BarTransitions.java   
public void applyModeBackground(int oldMode, int newMode, boolean animate) {
    if (mMode == newMode) return;
    mMode = newMode;
    mAnimating = animate;
    if (animate) {
        long now = SystemClock.elapsedRealtime();
        mStartTime = now;
        mEndTime = now + BACKGROUND_DURATION;
        mGradientAlphaStart = mGradientAlpha;
        mColorStart = mColor;
    }
    invalidateSelf();
}
项目:HeroVideo-master    文件:CircleProgressView.java   
/**
 * Puts the view on spin mode
 */
public void spin()
{

    lastTimeAnimated = SystemClock.uptimeMillis();
    isSpinning = true;
    invalidate();
}
项目:ShaddockVideoPlayer    文件:EventLogger.java   
@Override
public void onLoadStarted(int sourceId, long length, int type, int trigger, Format format,
    long mediaStartTimeMs, long mediaEndTimeMs) {
  loadStartTimeMs[sourceId] = SystemClock.elapsedRealtime();
  if (VerboseLogUtil.isTagEnabled(TAG)) {
    Log.v(TAG, "loadStart [" + getSessionTimeString() + ", " + sourceId + ", " + type
        + ", " + mediaStartTimeMs + ", " + mediaEndTimeMs + "]");
  }
}
项目:boohee_v5.6    文件:AuthDialog.java   
public void onError(UiError uiError) {
    String str = uiError.errorMessage != null ? uiError.errorMessage + this.a : this.a;
    g.a().a(this.d + "_H5", SystemClock.elapsedRealtime(), 0, 0, uiError.errorCode, str,
            false);
    this.c.a(str);
    if (this.e != null) {
        this.e.onError(uiError);
        this.e = null;
    }
}
项目:DejaVu    文件:Kalman.java   
public synchronized Location getLocation() {
    Long timeMs = System.currentTimeMillis();
    final Location location = new Location(BackendService.LOCATION_PROVIDER);

    predict(timeMs);
    location.setTime(timeMs);
    if (Build.VERSION.SDK_INT >= 17)
        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
    location.setLatitude(mLatTracker.getPosition());
    location.setLongitude(mLonTracker.getPosition());
    if (mAltTracker != null)
        location.setAltitude(mAltTracker.getPosition());

    float accuracy = (float) (mLatTracker.getAccuracy() * BackendService.DEG_TO_METER);
    if (accuracy < MIN_ACCURACY)
        accuracy = MIN_ACCURACY;
    location.setAccuracy(accuracy);

    // Derive speed from degrees/ms in lat and lon
    double latVeolocity = mLatTracker.getVelocity() * BackendService.DEG_TO_METER;
    double lonVeolocity = mLonTracker.getVelocity() * BackendService.DEG_TO_METER *
            Math.cos(Math.toRadians(location.getLatitude()));
    float speed = (float) Math.sqrt((latVeolocity*latVeolocity)+(lonVeolocity*lonVeolocity));
    location.setSpeed(speed);

    // Compute bearing only if we are moving. Report old bearing
    // if we are below our threshold for moving.
    if (speed > MOVING_THRESHOLD) {
        mBearing = (float) Math.toDegrees(Math.atan2(latVeolocity, lonVeolocity));
    }
    location.setBearing(mBearing);

    Bundle extras = new Bundle();
    extras.putLong("AVERAGED_OF", samples);
    location.setExtras(extras);

    return location;
}
项目:yjPlay    文件:PlaybackControlView.java   
private void hideAfterTimeout() {
    removeCallbacks(hideAction);
    if (showTimeoutMs > 0) {
        hideAtMs = SystemClock.uptimeMillis() + showTimeoutMs;
        if (isAttachedToWindow) {
            postDelayed(hideAction, showTimeoutMs);
        }
    } else {
        hideAtMs = C.TIME_UNSET;
    }
}
项目:LaunchEnr    文件:LauncherAppWidgetHostView.java   
private void scheduleNextAdvance() {
    if (!mIsAutoAdvanceRegistered) {
        return;
    }
    long now = SystemClock.uptimeMillis();
    long advanceTime = now + (ADVANCE_INTERVAL - (now % ADVANCE_INTERVAL)) +
            ADVANCE_STAGGER * sAutoAdvanceWidgetIds.indexOfKey(getAppWidgetId());
    Handler handler = getHandler();
    if (handler != null) {
        handler.postAtTime(mAutoAdvanceRunnable, advanceTime);
    }
}
项目:PlusGram    文件:ChunkSampleSource.java   
private void updateLoadControl() {
  long now = SystemClock.elapsedRealtime();
  long nextLoadPositionUs = getNextLoadPositionUs();
  boolean isBackedOff = currentLoadableException != null;
  boolean loadingOrBackedOff = loader.isLoading() || isBackedOff;

  // If we're not loading or backed off, evaluate the operation if (a) we don't have the next
  // chunk yet and we're not finished, or (b) if the last evaluation was over 2000ms ago.
  if (!loadingOrBackedOff && ((currentLoadableHolder.chunk == null && nextLoadPositionUs != -1)
      || (now - lastPerformedBufferOperation > 2000))) {
    // Perform the evaluation.
    lastPerformedBufferOperation = now;
    doChunkOperation();
    boolean chunksDiscarded = discardUpstreamMediaChunks(currentLoadableHolder.queueSize);
    // Update the next load position as appropriate.
    if (currentLoadableHolder.chunk == null) {
      // Set loadPosition to -1 to indicate that we don't have anything to load.
      nextLoadPositionUs = -1;
    } else if (chunksDiscarded) {
      // Chunks were discarded, so we need to re-evaluate the load position.
      nextLoadPositionUs = getNextLoadPositionUs();
    }
  }

  // Update the control with our current state, and determine whether we're the next loader.
  boolean nextLoader = loadControl.update(this, downstreamPositionUs, nextLoadPositionUs,
      loadingOrBackedOff);

  if (isBackedOff) {
    long elapsedMillis = now - currentLoadableExceptionTimestamp;
    if (elapsedMillis >= getRetryDelayMillis(currentLoadableExceptionCount)) {
      resumeFromBackOff();
    }
    return;
  }

  if (!loader.isLoading() && nextLoader) {
    maybeStartLoading();
  }
}
项目:buildAPKsSamples    文件:CubeWallpaper1.java   
void drawLine(Canvas c, int x1, int y1, int z1, int x2, int y2, int z2) {
    long now = SystemClock.elapsedRealtime();
    float xrot = ((float)(now - mStartTime)) / 1000;
    float yrot = (0.5f - mOffset) * 2.0f;
    float zrot = 0;

    // 3D transformations

    // rotation around X-axis
    float newy1 = (float)(Math.sin(xrot) * z1 + Math.cos(xrot) * y1);
    float newy2 = (float)(Math.sin(xrot) * z2 + Math.cos(xrot) * y2);
    float newz1 = (float)(Math.cos(xrot) * z1 - Math.sin(xrot) * y1);
    float newz2 = (float)(Math.cos(xrot) * z2 - Math.sin(xrot) * y2);

    // rotation around Y-axis
    float newx1 = (float)(Math.sin(yrot) * newz1 + Math.cos(yrot) * x1);
    float newx2 = (float)(Math.sin(yrot) * newz2 + Math.cos(yrot) * x2);
    newz1 = (float)(Math.cos(yrot) * newz1 - Math.sin(yrot) * x1);
    newz2 = (float)(Math.cos(yrot) * newz2 - Math.sin(yrot) * x2);

    // 3D-to-2D projection
    float startX = newx1 / (4 - newz1 / 400);
    float startY = newy1 / (4 - newz1 / 400);
    float stopX =  newx2 / (4 - newz2 / 400);
    float stopY =  newy2 / (4 - newz2 / 400);

    c.drawLine(startX, startY, stopX, stopY, mPaint);
}
项目:bimdroid    文件:BmwIBusService.java   
private void dispatchMediaKeyEvent(int keyCode) {
    KeyEvent eventDown = new KeyEvent(KeyEvent.ACTION_DOWN, keyCode);
    mAudioManager.dispatchMediaKeyEvent(eventDown);
    SystemClock.sleep(2);
    KeyEvent eventUp = new KeyEvent(KeyEvent.ACTION_UP, keyCode);
    mAudioManager.dispatchMediaKeyEvent(eventUp);
}
项目:Exoplayer2Radio    文件:BaseTrackSelection.java   
@Override
public final boolean blacklist(int index, long blacklistDurationMs) {
  long nowMs = SystemClock.elapsedRealtime();
  boolean canBlacklist = isBlacklisted(index, nowMs);
  for (int i = 0; i < length && !canBlacklist; i++) {
    canBlacklist = i != index && !isBlacklisted(i, nowMs);
  }
  if (!canBlacklist) {
    return false;
  }
  blacklistUntilTimes[index] = Math.max(blacklistUntilTimes[index], nowMs + blacklistDurationMs);
  return true;
}