Пример #1
0
 /// <summary>
 /// start auto cycle. </summary>
 /// <param name="delay"> delay time </param>
 /// <param name="duration"> animation duration time. </param>
 /// <param name="autoRecover"> if recover after user touches the slider. </param>
 public virtual void startAutoCycle(long delay, long duration, bool autoRecover)
 {
     if (mCycleTimer != null)
     {
         mCycleTimer.Cancel();
     }
     if (mCycleTask != null)
     {
         mCycleTask.Cancel();
     }
     if (mResumingTask != null)
     {
         mResumingTask.Cancel();
     }
     if (mResumingTimer != null)
     {
         mResumingTimer.Cancel();
     }
     mSliderDuration = duration;
     mCycleTimer     = new Timer();
     mAutoRecover    = autoRecover;
     mCycleTask      = new TimerTaskAnonymousInnerClassHelper(this);
     mCycleTimer.Schedule(mCycleTask, delay, mSliderDuration);
     mCycling   = true;
     mAutoCycle = true;
 }
Пример #2
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     SetContentView(Resource.Layout.Main);
     time      = FindViewById <TextView>(Resource.Id.time);
     startStop = FindViewById <Button>(Resource.Id.start_stop);
     startStop.SetOnClickListener(new MyOnClickListener(() =>
     {
         isRunning = !isRunning;
         if (isRunning)
         {
             ScheduleAtFixedRate();
         }
         else
         {
             timerTask.Cancel();
         }
         UpdateUI();
     }));
     reset = FindViewById <Button>(Resource.Id.reset);
     reset.SetOnClickListener(new MyOnClickListener(() => { ClearTime(); }));
     if (savedInstanceState != null)
     {
         GetValuesFromBundle(savedInstanceState);
         SetTime();
     }
     else
     {
         isRunning = false;
         ClearTime();
     }
 }
Пример #3
0
 /// <summary>
 /// 实现了View组件的点击事件监听器的接口的回调方法
 /// </summary>
 /// <param name="v"></param>
 public void OnClick(View v)
 {
     drawBack(holder);
     cx = X_OFFSET;
     if (task != null)
     {
         task.Cancel();
     }
     task = new MyTimerTask(v, this);
     timer.Schedule(task, 0, 30);
     holder.AddCallback(this);
 }
Пример #4
0
 public void Stop()
 {
     timerTask.Cancel();
 }
Пример #5
0
 protected override void OnPause()
 {
     base.OnPause();
     timerTask.Cancel();
 }