项目: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,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");
}
}
@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;
}
@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);
}
}
@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);
}
}
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,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);
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,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();
}
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," 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," 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);
invalidate();
}
}
项目:AndroidProgramming3e
文件:PollService.java
public static void setServiceAlarm(Context context,boolean isOn) {
Intent i = PollService.newIntent(context);
PendingIntent pi = PendingIntent.getService(
context,0);
AlarmManager alarmManager = (AlarmManager)
context.getSystemService(Context.ALARM_SERVICE);
if (isOn) {
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME,POLL_INTERVAL_MS,pi);
} else {
alarmManager.cancel(pi);
pi.cancel();
}
}
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
项目: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 + "]");
}
}
public void onError(UiError uiError) {
String str = uiError.errorMessage != null ? uiError.errorMessage + this.a : this.a;
g.a().a(this.d + "_H5",uiError.errorCode,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;
}
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
@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;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。