void Java.Lang.IRunnable.Run() { float f2; FrameLayout.LayoutParams localLayoutParams; ViewGroup.LayoutParams headLayoutParams; if ((!isFinished) && (scale > 1.0D)) { float f1 = ((float)SystemClock.CurrentThreadTimeMillis() - (float)startTime) / (float)duration; f2 = scale - (scale - 1.0F) * pullToZoomScrollView.GetInterpolation(f1); localLayoutParams = (FrameLayout.LayoutParams)_zoomContainer.LayoutParameters; headLayoutParams = _headerContainer.LayoutParameters; if (f2 > 1.0F) { Log.Debug("PullToZoomScrollView", "f2 > 1.0"); localLayoutParams.Height = ((int)(f2 * _zoomHeight)); localLayoutParams.Width = ((int)(f2 * _zoomWidth)); localLayoutParams.Gravity = GravityFlags.Center; _zoomContainer.LayoutParameters = localLayoutParams; headLayoutParams.Height = ((int)(f2 * _zoomHeight)); _headerContainer.LayoutParameters = headLayoutParams; pullToZoomScrollView.Post(this); return; } isFinished = true; } }
/// <summary> /// Execute motion loop thread /// </summary> /// <param name="initVelocity">Initialize velocity.</param> private void motionLoop(float initVelocity) { float velocity = initVelocity; float sumDistance = 0.0f; long preFrameTime = SystemClock.CurrentThreadTimeMillis(); long elapsedTime = 0L; while (!motionState.Equals(MotionState.stopped)) { // Sleep long now = SystemClock.CurrentThreadTimeMillis(); short sleep = (short)Math.Max(SLEEP_TIME - (now - preFrameTime), 0); System.Threading.Thread.Sleep(sleep); preFrameTime = now; // Update accelerate(ref velocity); deaccelerate(ref velocity); float distance = velocity * SLEEP_TIME; sumDistance += distance; elapsedTime += SLEEP_TIME; sendMotionEvent(distance, velocity, elapsedTime); } sendStopEvent(elapsedTime); }
void Java.Lang.IRunnable.Run() { if (_zoomView != null) { float f2; ViewGroup.LayoutParams localLayoutParams; if ((!isFinished) && (scale > 1.0D)) { float f1 = ((float)SystemClock.CurrentThreadTimeMillis() - (float)startTime) / (float)duration; f2 = scale - (scale - 1.0F) * pullToZoomScrollViewEx.GetInterpolation(f1); localLayoutParams = _headerContainer.LayoutParameters; Log.Debug("PullToZoomScrollViewEx", "ScalingRunnable --> f2 = " + f2); if (f2 > 1.0F) { localLayoutParams.Height = ((int)(f2 * _headerHeight)); _headerContainer.LayoutParameters = localLayoutParams; if (_isCusto_headerHeight) { ViewGroup.LayoutParams zoomLayoutParams; zoomLayoutParams = _zoomView.LayoutParameters; zoomLayoutParams.Height = ((int)(f2 * _headerHeight)); _zoomView.LayoutParameters = zoomLayoutParams; } pullToZoomScrollViewEx.Post(this); return; } isFinished = true; } } }
public void StartAnimation(long paramLong) { startTime = SystemClock.CurrentThreadTimeMillis(); duration = paramLong; scale = ((float)(_zoomContainer.Bottom) / _zoomHeight); isFinished = false; pullToZoomScrollView.Post(this); }
/// <summary> /// Broadcasts the productos pendientes. /// </summary> void BroadcastProductosPendientes() { Intent i = new Intent(this, typeof(NotificacionAlert)); PendingIntent pi = PendingIntent.GetBroadcast(this, 0, i, 0); AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService); alarmManager.SetInexactRepeating(AlarmType.ElapsedRealtime, SystemClock.CurrentThreadTimeMillis(), 30000, pi); }
/// <summary> /// Broadcasts the productos pendientes. /// </summary> void BroadcastPendientesNoFinalizados() { Intent i = new Intent(this, typeof(CheckPendingProducts)); PendingIntent pi = PendingIntent.GetBroadcast(this, 0, i, 0); AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService); alarmManager.SetInexactRepeating(AlarmType.ElapsedRealtime, SystemClock.CurrentThreadTimeMillis(), 1000, pi); }
public override void OnStart(Intent intent, int startId) { Intent alarmIntent = new Intent(this, typeof(RepeatingAlarm)); var source = PendingIntent.GetBroadcast(this, 0, alarmIntent, 0); AlarmManager alarmManager = GetSystemService(AlarmService).JavaCast <AlarmManager>(); // SetRepeating([GeneratedEnum] AlarmType type, long triggerAtMillis, long intervalMillis, PendingIntent operation); alarmManager.SetRepeating(AlarmType.Rtc, SystemClock.CurrentThreadTimeMillis(), 500, source); //alarmManager.SetExact(AlarmType.Rtc, SystemClock.CurrentThreadTimeMillis(), source); }
public void StartAnimation(long paramLong) { if (_zoomView != null) { startTime = SystemClock.CurrentThreadTimeMillis(); duration = paramLong; scale = ((float)(_headerContainer.Bottom) / _headerHeight); isFinished = false; pullToZoomListViewEx.Post(this); } }
/// <summary> /// Initializes a new instance of the <see cref="CustomTypefaceSpan" /> class. /// </summary> /// <param name="icon">The icon.</param> /// <param name="type">The type.</param> /// <param name="iconSizePx">The icon size px.</param> /// <param name="iconSizeRatio">The icon size ratio.</param> /// <param name="iconColor">Color of the icon.</param> /// <param name="rotate">if set to <c>true</c> [rotate].</param> /// <param name="baselineAligned">if set to <c>true</c> [baseline aligned].</param> public CustomTypefaceSpan(IIcon icon, Typeface type, Single iconSizePx, Single iconSizeRatio, Int32 iconColor, System.Boolean rotate, System.Boolean baselineAligned) { _rotate = rotate; _baselineAligned = baselineAligned; _icon = icon.Character.ToString(); _type = type; _iconSizePx = iconSizePx; _iconSizeRatio = iconSizeRatio; _iconColor = iconColor; _rotationStartTime = SystemClock.CurrentThreadTimeMillis(); }
/// <summary> /// 调用相册选择 /// </summary> private void SelectImageByImgStore() { Intent _intentCut = new Intent(Intent.ActionGetContent, null); _intentCut.SetType("image/*");// 设置文件类型 var sdcardTempFile = new Java.IO.File("/mnt/sdcard/", "tmp_pic_" + SystemClock.CurrentThreadTimeMillis() + ".jpg"); _intentCut.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(sdcardTempFile)); _intentCut.PutExtra(MediaStore.ExtraVideoQuality, 1); Context.StartActivityForResult(_intentCut, 1); }
public override void OnDestroy() { var restartServiceIntent = new Intent(Application.Context, this.Class); restartServiceIntent.SetPackage(Application.Context.PackageName); var restartServicePendingIntent = PendingIntent.GetService(Application.Context, 3, restartServiceIntent, PendingIntentFlags.OneShot); var alarmService = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService); alarmService.Set( AlarmType.RtcWakeup, SystemClock.CurrentThreadTimeMillis() + 1000, restartServicePendingIntent); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); sdcardTempFile = new Java.IO.File("/mnt/sdcard/", "tmp_pic_" + SystemClock.CurrentThreadTimeMillis() + ".jpg"); //0-相机 1-图库 //if (Intent.GetIntExtra("sourceType", 1) == 0) //{ // CutImageByCamera(); //} //else if (Intent.GetIntExtra("sourceType", 1) == 1) //{ // CutImageByImgStore(); //} CutImageByCamera(); }
public void refresh() { long start = SystemClock.CurrentThreadTimeMillis(); for (int i = 0; i < TYPE_MAX; i++) { long iTime = file[i].LastModified(); if (iTime != lastTime[i]) { read(i); lastTime[i] = iTime; } } }
public void Remind(DateTime dateTime, string title, string message) { Intent alarmIntent = new Intent(Forms.Context, typeof(AlarmReceiver)); alarmIntent.PutExtra("message", message); alarmIntent.PutExtra("title", title); int guid = (int)SystemClock.CurrentThreadTimeMillis(); double timeInMilliseconds = (dateTime - DateTime.Now).TotalSeconds; PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, guid, alarmIntent, PendingIntentFlags.UpdateCurrent); AlarmManager alarmManager = (AlarmManager)Forms.Context.GetSystemService(Context.AlarmService); //TODO: For demo set after 5 seconds. //alarmManager.Set(AlarmType.RtcWakeup, (long)timeInMilliseconds, pendingIntent); alarmManager.Set(AlarmType.ElapsedRealtime, SystemClock.ElapsedRealtime() + (long)timeInMilliseconds * 1000, pendingIntent); }
public void OnClick(View v) { long nowMs = SystemClock.CurrentThreadTimeMillis(); if (lastClickMs != 0 && (nowMs - lastClickMs) < TOO_SOON_DURATION_MS) { Log.Debug(_tag, "onClick: too soon"); return; } Log.Debug(_tag, "onClick: Ok"); lastClickMs = nowMs; onOneClick(v); }
public void scheduleAlarm() //start usługi { try { Intent intent = new Intent(Application.Context, typeof(MyAlarmReceiver)); intent.PutExtra("url", URL); PendingIntent Intent = PendingIntent.GetBroadcast(this, MyAlarmReceiver.REQUEST_CODE, intent, PendingIntentFlags.UpdateCurrent); long firstMillis = SystemClock.CurrentThreadTimeMillis(); AlarmManager Alarm = (AlarmManager)this.GetSystemService(Context.AlarmService); Alarm.SetRepeating(AlarmType.RtcWakeup, firstMillis, 500, Intent); } catch (Exception ex) { logger.createLog("Application error: " + ex.Message, "ErrorLogs.txt"); } }
public override void OnStart(Intent intent, int startId) { var updateViews = new RemoteViews(this.PackageName, Resource.Layout.widget_main); updateViews.SetTextViewText(Resource.Id.test, DateTime.Now.ToString()); ComponentName thisWidget = new ComponentName(this, Java.Lang.Class.FromType(typeof(SimpleWidget)).Name); AppWidgetManager manager = AppWidgetManager.GetInstance(this); manager.UpdateAppWidget(thisWidget, updateViews); Intent alarmIntent = new Intent(this, typeof(RepeatingAlarm)); var source = PendingIntent.GetBroadcast(this, 0, alarmIntent, 0); AlarmManager alarmManager = GetSystemService(AlarmService).JavaCast <AlarmManager>(); alarmManager.SetRepeating(AlarmType.ElapsedRealtimeWakeup, SystemClock.CurrentThreadTimeMillis(), 10000, source); }
public override void OnReceive(Context context, Intent intent) { var restartServiceIntent = new Intent(Application.Context, typeof(GeofencingIntentService)); restartServiceIntent.SetPackage(Application.Context.PackageName); PendingIntent restartServicePendingIntent = PendingIntent.GetService(Application.Context, 3, restartServiceIntent, PendingIntentFlags.OneShot); AlarmManager alarmService = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService); alarmService.Set( AlarmType.RtcWakeup, SystemClock.CurrentThreadTimeMillis() + 1000, restartServicePendingIntent); MvxTrace.TaggedTrace(TAG, "Start after boot completed"); }
public override void OnTaskRemoved(Intent rootIntent) { var restartServiceIntent = new Intent(Application.Context, this.Class); restartServiceIntent.SetPackage(Application.Context.PackageName); var restartServicePendingIntent = PendingIntent.GetService(Application.Context, 3, restartServiceIntent, PendingIntentFlags.OneShot); var alarmService = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService); alarmService.Set( AlarmType.RtcWakeup, SystemClock.CurrentThreadTimeMillis() + 1000, restartServicePendingIntent); MvxTrace.TaggedTrace(TAG, "Start after removed"); }
protected void setNotification(Context context, string message, string title) { Intent alarmIntent = new Intent(context, typeof(AlarmManagerService)); alarmIntent.PutExtra("message", message); alarmIntent.PutExtra("title", title); long now = SystemClock.CurrentThreadTimeMillis(); AlarmManager am = (AlarmManager)context.GetSystemService(Context.AlarmService); Intent intent = new Intent(context, this.Class); PendingIntent pi = PendingIntent.GetBroadcast(context, 0, intent, PendingIntentFlags.UpdateCurrent); //PendingIntent pendingIntent = PendingIntent.GetBroadcast(Forms.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); AlarmManager alarmManager = (AlarmManager)context.GetSystemService(Context.AlarmService); //TODO: For demo set after 5 seconds. alarmManager.Set(AlarmType.RtcWakeup, DateTime.Now.Millisecond + 30000, pi); }
public override ComponentName StartService(Intent service) { Intent restartServiceIntent = new Intent(Application.Context, this.Class); restartServiceIntent.SetPackage(Application.Context.PackageName); PendingIntent restartServicePendingIntent = PendingIntent.GetService(Application.Context, 3, restartServiceIntent, PendingIntentFlags.OneShot); AlarmManager alarmService = (AlarmManager)Application.Context.GetSystemService(Context.AlarmService); alarmService.Set( AlarmType.RtcWakeup, SystemClock.CurrentThreadTimeMillis() + 1000, restartServicePendingIntent); MvxTrace.TaggedTrace(TAG, "StartService"); return(base.StartService(service)); }
/// <summary> /// </summary> /// <param name="canvas">To be added.</param> /// <param name="text">To be added.</param> /// <param name="start">To be added.</param> /// <param name="end">To be added.</param> /// <param name="x">To be added.</param> /// <param name="top">To be added.</param> /// <param name="y">To be added.</param> /// <param name="bottom">To be added.</param> /// <param name="paint">To be added.</param> /// <remarks> /// <para tool="javadoc-to-mdoc" /> /// <para tool="javadoc-to-mdoc"> /// <format type="text/html"> /// <a href="http://developer.android.com/reference/android/text/style/ReplacementSpan.html#draw(android.graphics.Canvas, java.lang.CharSequence, int, int, float, int, int, int, android.graphics.Paint)" target="_blank">[Android Documentation]</a> /// </format> /// </para> /// </remarks> /// <since version="Added in API level 1" /> public override void Draw(Canvas canvas, ICharSequence text, Int32 start, Int32 end, Single x, Int32 top, Int32 y, Int32 bottom, Paint paint) { ApplyCustomTypeFace(paint, _type); paint.GetTextBounds(_icon, 0, 1, TEXT_BOUNDS); canvas.Save(); var baselineRatio = _baselineAligned ? 0f : BASELINE_RATIO; if (_rotate) { var rotation = (SystemClock.CurrentThreadTimeMillis() - _rotationStartTime) / (Single)ROTATION_DURATION * 360f; var centerX = x + TEXT_BOUNDS.Width() / 2f; var centerY = y - TEXT_BOUNDS.Height() / 2f + TEXT_BOUNDS.Height() * baselineRatio; canvas.Rotate(rotation, centerX, centerY); } canvas.DrawText(_icon, x - TEXT_BOUNDS.Left, y - TEXT_BOUNDS.Bottom + TEXT_BOUNDS.Height() * baselineRatio, paint); canvas.Restore(); }
void SetNotificationPlaybackState(NotificationCompat.Builder builder) { if (playbackState == null || !started) { Service.StopForeground(true); return; } if (playbackState.State == PlaybackStateCompat.StatePlaying) { builder.SetWhen(SystemClock.CurrentThreadTimeMillis() - playbackState.Position) .SetShowWhen(true) .SetUsesChronometer(true); } else { builder.SetWhen(0) .SetShowWhen(false) .SetUsesChronometer(false); } builder.SetOngoing(playbackState.State == PlaybackStateCompat.StatePlaying); }
internal void StartTask(BgTasks task, Context context) { Type listenerType; TimeSpan refreshTime; switch (task) { case BgTasks.Notifications: if (!Settings.EnableNotifications || !Credentials.Authenticated || Settings.SelectedApiType == ApiType.Hummingbird) { return; } refreshTime = TimeSpan.FromMinutes(Settings.NotificationsRefreshTime); listenerType = typeof(NotificationCheckBroadcastReceiver); break; case BgTasks.Tiles: return; case BgTasks.ToastActivation: return; case BgTasks.AiredNotification: listenerType = typeof(AiredNotificationCheckReceiver); refreshTime = TimeSpan.FromHours(1); break; default: throw new ArgumentOutOfRangeException(nameof(task), task, null); } long now = SystemClock.CurrentThreadTimeMillis(); var am = (AlarmManager)context.GetSystemService(Context.AlarmService); var intent = new Intent(context, listenerType); var pi = PendingIntent.GetBroadcast(context, 0, intent, PendingIntentFlags.CancelCurrent); am.SetRepeating(AlarmType.RtcWakeup, now, (long)refreshTime.TotalMilliseconds, pi); }
void IRunnable.Run() { if (_headerView != null) { float f2; ViewGroup.LayoutParams localLayoutParams; if ((!isFinished) && (scale > 1.0D)) { float f1 = ((float)SystemClock.CurrentThreadTimeMillis() - (float)startTime) / (float)duration; f2 = scale - (scale - 1.0F) * p.GetInterpolation(f1); localLayoutParams = _headerContainer.LayoutParameters; if (f2 > 1.0F) { Log.Debug("PullToZoomListView", "f2>1.0"); localLayoutParams.Height = ((int)(f2 * _headerHeight)); _headerContainer.LayoutParameters = localLayoutParams; p.Post(this); return; } isFinished = true; } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here SetContentView(Resource.Layout.RootView); if (Settings.USE_RECENT_POSTS) { CreateViewFor(RecentPostsView.NewInstance(), RootViewModel.Home, Resource.Id.content_frame); } else { CreateViewFor(HomeView.NewInstance(), RootViewModel.Home, Resource.Id.content_frame); } SetBehindContentView(Resource.Layout.menu_frame); SlidingMenu.ShadowWidthRes = Resource.Dimension.shadow_width; SlidingMenu.BehindOffsetRes = Resource.Dimension.slidingmenu_offset; SlidingMenu.ShadowDrawableRes = Resource.Drawable.shadow; SlidingMenu.FadeDegree = 0.25f; SlidingMenu.TouchModeAbove = TouchMode.Fullscreen; //TouchMode.Margin; CreateViewFor(MenuView.NewInstance(), RootViewModel.Menu, Resource.Id.menu_frame); if (RootViewModel.Home is RecentPostsViewModel) { ((RecentPostsViewModel)RootViewModel.Home).MenuButtonSelected += (sender, e) => Toggle(); } else { ((HomeViewModel)RootViewModel.Home).MenuButtonSelected += (sender, e) => Toggle(); //top left menu button } RootViewModel.Menu.SignoutSelected += (sender, e) => { //do something Finish(); }; //close activity RootViewModel.Menu.MenuSelected += (sender, e) => { Toggle(); if (Settings.USE_RECENT_POSTS) { MenuEventArgs me = (MenuEventArgs)e; if (me.Object is CategoryOptionItem) { ((RecentPostsViewModel)RootViewModel.Home).ClearData(); CategoryOptionItem cat = (CategoryOptionItem)me.Object; ((RecentPostsViewModel)RootViewModel.Home).Init(cat.Id, cat.Title); ((RecentPostsViewModel)RootViewModel.Home).RefreshData(); ((RecentPostsViewModel)RootViewModel.Home).Title = cat.Title; } } }; RootViewModel.Home.ErrorHandler += (sender, e) => { ErrorEventArgs ee = (ErrorEventArgs)e; var dispatcher = Mvx.Resolve <IMvxMainThreadDispatcher> (); dispatcher.RequestMainThreadAction(() => { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.SetTitle(ee.Title); builder.SetMessage(ee.Message); builder.SetNegativeButton(ee.CloseTitle, (EventHandler <DialogClickEventArgs>)null); builder.Show(); }); }; this.StartCalled += (sender, e) => { if (FromLogin) { FromLogin = false; this.OverridePendingTransition(Resource.Animation.slide_right, Resource.Animation.slide_left); } else { this.OverridePendingTransition(Resource.Animation.slide_left_right, Resource.Animation.slide_right_right); } CatalogNewsView.FromHome = true; if (mLastTime == -1 || SystemClock.CurrentThreadTimeMillis() - mLastTime > Settings.HOME_REFRESH_TIME) { System.Diagnostics.Debug.WriteLine("Refresh Home Page"); mLastTime = SystemClock.CurrentThreadTimeMillis(); RootViewModel.RefreshData(); } }; CatalogNewsView.FromHome = true; }
public override void OnReceive(Context context, Intent intent) { if (playeroffline.gettearinstancia() != null || YoutubePlayerServerActivity.gettearinstancia() != null || Mainmenu.gettearinstancia() != null) { if (intent.Action != Intent.ActionMediaButton && intent.Action != AudioManager.ActionAudioBecomingNoisy) { return; } else { if (intent.Action == Intent.ActionMediaButton) { var keyEvent = (KeyEvent)intent.GetParcelableExtra(Intent.ExtraKeyEvent); if (keyEvent.Action == KeyEventActions.Down) { switch (keyEvent.KeyCode) { case Android.Views.Keycode.Headsethook: if (playeroffline.gettearinstancia() != null) { Android.OS.Handler mHandler = new Android.OS.Handler(); mHandler.PostDelayed(new Action(() => { playeroffline.gettearinstancia().counter = 0; }), 500); playeroffline.gettearinstancia().millis = SystemClock.CurrentThreadTimeMillis(); if (playeroffline.gettearinstancia().counter < 1) { playeroffline.gettearinstancia().counter++; playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().playpause.CallOnClick(); }); } else { playeroffline.gettearinstancia().counter = 0; playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().siguiente.CallOnClick(); }); } } else if (YoutubePlayerServerActivity.gettearinstancia() != null) { Android.OS.Handler mHandler = new Android.OS.Handler(); mHandler.PostDelayed(new Action(() => { YoutubePlayerServerActivity.gettearinstancia().counter = 0; }), 500); YoutubePlayerServerActivity.gettearinstancia().millis = SystemClock.CurrentThreadTimeMillis(); if (YoutubePlayerServerActivity.gettearinstancia().counter < 1) { YoutubePlayerServerActivity.gettearinstancia().counter++; YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick(); }); } else { YoutubePlayerServerActivity.gettearinstancia().counter = 0; YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgNext.CallOnClick(); }); } } break; case Keycode.MediaPlayPause: if (playeroffline.gettearinstancia() != null) { playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().playpause.CallOnClick(); }); } else if (YoutubePlayerServerActivity.gettearinstancia() != null) { YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick(); }); } break; case Keycode.MediaNext: if (playeroffline.gettearinstancia() != null) { playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().siguiente.CallOnClick(); }); } else if (YoutubePlayerServerActivity.gettearinstancia() != null) { YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgNext.CallOnClick(); }); } break; case Keycode.MediaPlay: if (playeroffline.gettearinstancia() != null) { playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().playpause.CallOnClick(); }); } else if (YoutubePlayerServerActivity.gettearinstancia() != null) { YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick(); }); } break; case Keycode.MediaPause: if (playeroffline.gettearinstancia() != null) { playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().playpause.CallOnClick(); }); } else if (YoutubePlayerServerActivity.gettearinstancia() != null) { YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgPlay.CallOnClick(); }); } break; case Keycode.MediaPrevious: if (playeroffline.gettearinstancia() != null) { playeroffline.gettearinstancia().RunOnUiThread(() => { playeroffline.gettearinstancia().anterior.CallOnClick(); }); } else if (YoutubePlayerServerActivity.gettearinstancia() != null) { YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => { YoutubePlayerServerActivity.gettearinstancia().imgBack.CallOnClick(); }); } break; } } } else { if (Clouding_service.gettearinstancia() != null) { if (YoutubePlayerServerActivity.gettearinstancia() != null) { YoutubePlayerServerActivity.gettearinstancia().RunOnUiThread(() => YoutubePlayerServerActivity.gettearinstancia().imgPlay.SetBackgroundResource(Resource.Drawable.playbutton2)); Clouding_service.gettearinstancia().musicaplayer.Pause(); } } else if (Clouding_serviceoffline.gettearinstancia() != null) { if (playeroffline.gettearinstancia() != null) { playeroffline.gettearinstancia().RunOnUiThread(() => playeroffline.gettearinstancia().playpause.SetBackgroundResource(Resource.Drawable.playbutton2)); Clouding_serviceoffline.gettearinstancia().musicaplayer.Pause(); } } } } } else { } }
public static Entry ParseCacheHeaders(NetworkResponse response) { long now = SystemClock.CurrentThreadTimeMillis(); Dictionary <String, String> headers = response.Headers; long serverDate = 0; long lastModified = 0; long serverExpires = 0; long softExpire = 0; long finalExpire = 0; long maxAge = 0; long staleWhileRevalidate = 0; bool hasCacheControl = false; bool mustRevalidate = false; String serverEtag = null; String headerValue; headers.TryGetValue("Date", out headerValue); if (headerValue != null) { serverDate = ParseDateAsEpoch(headerValue); } headers.TryGetValue("Cache-Control", out headerValue); if (headerValue != null) { hasCacheControl = true; String[] tokens = headerValue.Split(','); for (int i = 0; i < tokens.Length; i++) { String token = tokens[i].Trim(); if (token == "no-cache" || token == "no-store") { return(null); } else if (token.StartsWith("max-age=")) { try { maxAge = long.Parse(token.Substring(8)); } catch (Exception) { } } else if (token.StartsWith("stale-while-revalidate=")) { try { staleWhileRevalidate = long.Parse(token.Substring(23)); } catch (Exception) { } } else if (token == "must-revalidate" || token == "proxy-revalidate") { mustRevalidate = true; } } } headers.TryGetValue("Expires", out headerValue); if (headerValue != null) { serverExpires = ParseDateAsEpoch(headerValue); } headers.TryGetValue("Last-Modified", out headerValue); if (headerValue != null) { lastModified = ParseDateAsEpoch(headerValue); } headers.TryGetValue("ETag", out serverEtag); if (hasCacheControl) { softExpire = now + maxAge * 1000; finalExpire = mustRevalidate ? softExpire : softExpire + staleWhileRevalidate * 1000; } else if (serverDate > 0 && serverExpires >= serverDate) { softExpire = now + (serverExpires - serverDate); finalExpire = softExpire; } Entry entry = new Entry(); entry.Data = response.Data; entry.ETag = serverEtag; entry.SoftTtl = softExpire; entry.Ttl = finalExpire; entry.ServerDate = serverDate; entry.LastModified = lastModified; entry.ResponseHeaders = headers; return(entry); }