本文整理汇总了C#中Android.OS.Handler.PostDelayed方法的典型用法代码示例。如果您正苦于以下问题:C# Handler.PostDelayed方法的具体用法?C# Handler.PostDelayed怎么用?C# Handler.PostDelayed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Android.OS.Handler
的用法示例。
在下文中一共展示了Handler.PostDelayed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCreate
public override void OnCreate()
{
base.OnCreate();
Log.Info(TAG, "OnCreate: the service is initializing.");
timestamper = new UtcTimestamper();
handler = new Handler();
// This Action is only for demonstration purposes.
runnable = new Action(() =>
{
if (timestamper == null)
{
Log.Wtf(TAG, "Why isn't there a Timestamper initialized?");
}
else
{
string msg = timestamper.GetFormattedTimestamp();
Log.Debug(TAG, msg);
Intent i = new Intent(Constants.NOTIFICATION_BROADCAST_ACTION);
i.PutExtra(Constants.BROADCAST_MESSAGE_KEY, msg);
Android.Support.V4.Content.LocalBroadcastManager.GetInstance(this).SendBroadcast(i);
handler.PostDelayed(runnable, Constants.DELAY_BETWEEN_LOG_MESSAGES);
}
});
}
示例2: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
mPreview = new Preview (this);
RequestWindowFeature(WindowFeatures.NoTitle);
Window.AddFlags (WindowManagerFlags.Fullscreen);
SetContentView (Resource.Layout.CustomCameraLayout);
FrameLayout preview = (FrameLayout)FindViewById (Resource.Id.camera_preview);
preview.AddView (mPreview);
mPicture = new PictureCallback ();
//////////////////////////////////////
Handler mHandler = new Handler ();///
////////////////////////////////////
Button captureButton = FindViewById<Button> (Resource.Id.button_capture);
captureButton.Click += (sender, e) => {
System.Console.WriteLine("About to call take picture");
mCamera.TakePicture(null, null, mPicture);
System.Console.WriteLine("After TakePicture");
Toast.MakeText(this, "Saving picture...", ToastLength.Long).Show();
mHandler.PostDelayed(launchConfirmActivity,1000); //ideally this would be done through asynchronous methods, but this temporary fix will have to do for now
};
View controllers = FindViewById<RelativeLayout> (Resource.Id.CameraControls_layout);
controllers.BringToFront();
}
示例3: CreateMovementAnimation
public static AnimatorSet CreateMovementAnimation(View view, float canvasX, float canvasY, float offsetStartX, float offsetStartY, float offsetEndX, float offsetEndY, EventHandler animationEndHandler)
{
view.Alpha = INVISIBLE;
var alphaIn = ObjectAnimator.OfFloat(view, ALPHA, INVISIBLE, VISIBLE).SetDuration(500);
var setUpX = ObjectAnimator.OfFloat(view, COORD_X, canvasX + offsetStartX).SetDuration(INSTANT);
var setUpY = ObjectAnimator.OfFloat(view, COORD_Y, canvasY + offsetStartY).SetDuration(INSTANT);
var moveX = ObjectAnimator.OfFloat(view, COORD_X, canvasX + offsetEndX).SetDuration(1000);
var moveY = ObjectAnimator.OfFloat(view, COORD_Y, canvasY + offsetEndY).SetDuration(1000);
moveX.StartDelay = 1000;
moveY.StartDelay = 1000;
var alphaOut = ObjectAnimator.OfFloat(view, ALPHA, INVISIBLE).SetDuration(500);
alphaOut.StartDelay = 2500;
var aset = new AnimatorSet();
aset.Play(setUpX).With(setUpY).Before(alphaIn).Before(moveX).With(moveY).Before(alphaOut);
var handler = new Handler();
handler.PostDelayed(() =>
{
animationEndHandler(view, EventArgs.Empty);
}, 3000);
return aset;
}
示例4: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
progress1 = FindViewById<CircleProgressBar>(Resource.Id.progress1);
progress2 = FindViewById<CircleProgressBar>(Resource.Id.progress2);
progressWithArrow = FindViewById<CircleProgressBar>(Resource.Id.progressWithArrow);
progressWithoutBg = FindViewById<CircleProgressBar>(Resource.Id.progressWithoutBg);
progress2.SetColorSchemeResources(Android.Resource.Color.HoloGreenLight);
progressWithArrow.SetColorSchemeResources(Android.Resource.Color.HoloOrangeLight);
progressWithoutBg.SetColorSchemeResources(Android.Resource.Color.HoloRedLight);
handler = new Handler();
for (int i = 0; i < 10; i++)
{
int finalI = i;
handler.PostDelayed(() =>
{
if (finalI * 10 >= 90)
{
progress2.Visibility = ViewStates.Invisible;
}
else
{
progress2.Progress = finalI * 10;
}
}, 1000 * (i + 1));
}
}
示例5: OnCreate
protected override void OnCreate(Bundle bundle)
{
RequestWindowFeature(WindowFeatures.NoTitle);
base.OnCreate(bundle);
SetContentView(Resource.Layout.SplashLayout);
Handler handler = new Handler();
handler.PostDelayed(CallHomeActivity, SPLASH_TIME_OUT);
}
示例6: OnCreate
protected override void OnCreate(Bundle savedInstance)
{
base.OnCreate(savedInstance);
var window = GetWindow();
window.AddFlags(IWindowManager_LayoutParams.FLAG_SHOW_WHEN_LOCKED | IWindowManager_LayoutParams.FLAG_TURN_SCREEN_ON | IWindowManager_LayoutParams.FLAG_DISMISS_KEYGUARD);
SetContentView(R.Layout.MainLayout);
var handler = new Handler();
handler.PostDelayed(this, 200);
}
示例7: MediaPlayerService
public MediaPlayerService ()
{
// Create an instance for a runnable-handler
PlayingHandler = new Handler ();
// Create a runnable, restarting itself if the status still is "playing"
PlayingHandlerRunnable = new Java.Lang.Runnable (() => {
OnPlaying (EventArgs.Empty);
if (MediaPlayerState == PlaybackStateCompat.StatePlaying) {
PlayingHandler.PostDelayed (PlayingHandlerRunnable, 250);
}
});
// On Status changed to PLAYING, start raising the Playing event
StatusChanged += (object sender, EventArgs e) => {
if(MediaPlayerState == PlaybackStateCompat.StatePlaying){
PlayingHandler.PostDelayed (PlayingHandlerRunnable, 0);
}
};
}
示例8: OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate (savedInstanceState);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.main);
topLayer = FindViewById<FrameLayout> (Resource.Id.top_layer);
handler = new Handler ();
if (!Utils.IsKitKatWithStepCounter(PackageManager)) {
//no step detector detected :(
var counter_layout = FindViewById<FrameLayout> (Resource.Id.counter_layout);
var no_sensor = FindViewById<LinearLayout> (Resource.Id.no_sensor_box);
var sensor_image = FindViewById<ImageView> (Resource.Id.no_sensor_image);
sensor_image.SetImageResource (Resource.Drawable.ic_unsupporteddevice);
no_sensor.Visibility = Android.Views.ViewStates.Visible;
counter_layout.Visibility = Android.Views.ViewStates.Gone;
this.Title = Resources.GetString (Resource.String.app_name);
handler.PostDelayed (() => AnimateTopLayer (0), 500);
return;
}
stepCount = FindViewById<TextView> (Resource.Id.stepcount);
calorieCount = FindViewById<TextView> (Resource.Id.calories);
distance = FindViewById<TextView> (Resource.Id.distance);
percentage = FindViewById<TextView> (Resource.Id.percentage);
progressView = FindViewById<ProgressView> (Resource.Id.progressView);
highScore = FindViewById<ImageView> (Resource.Id.high_score);
calorieString = Resources.GetString (Resource.String.calories);
distanceString = Resources.GetString (Helpers.Settings.UseKilometeres ? Resource.String.kilometeres : Resource.String.miles);
percentString = Resources.GetString (Resource.String.percent_complete);
completedString = Resources.GetString (Resource.String.completed);
this.Title = Utils.DateString;
handler.PostDelayed (() => UpdateUI (), 500);
StartStepService ();
//for testing
/*stepCount.Clickable = true;
stepCount.Click += (object sender, EventArgs e) => {
if(binder != null)
{
if(testSteps == 1)
testSteps = (int)binder.StepService.StepsToday;
testSteps += 500;
if(testSteps > 10000)
testSteps += 10000;
binder.StepService.AddSteps(testSteps);
}
};*/
}
示例9: StartDelayedFinishTrip
void StartDelayedFinishTrip(int id, long timeout)
{
TripDebugLog.DeferredBikeTripEnd ();
var handler = new Handler ();
handler.PostDelayed (() => {
if ((currentBikingState == BikingState.MovingNotOnBike || currentBikingState == BikingState.InGrace)
&& id == graceID)
FinishTrip ();
}, timeout);
}
示例10: ScrollTo
private void ScrollTo(int index, EndlessScrollView scrollView)
{
if (index >= 0)
{
Handler handler = new Handler ();
handler.PostDelayed (() => {
View today = datesLayout.GetChildAt (index);
if (today != null)
{
today.PerformClick ();
int currentScroll = scrollView.ScrollX;
int[] viewLocation = new int[2];
today.GetLocationOnScreen(viewLocation);
int scrollViewWidth = scrollView.Width / 2;
int clickedOffetX = viewLocation[0] + currentScroll;
if (clickedOffetX > scrollViewWidth)
{
int scrollX = clickedOffetX - scrollViewWidth + today.Width / 2;
scrollView.SmoothScrollTo(scrollX, 0);
}
if (activeView == null && counter <= 10) {
ScrollTo(index, scrollView);
counter++;
}
}
}, 100);
}
}
示例11: OnCreate
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
LaffOutOut l = new LaffOutOut(Application.Context);
if (wowZapp.LaffOutOut.Singleton == null)
Toast.MakeText(Application.Context, "Singleton is null. Bah!", ToastLength.Long);
else
Toast.MakeText(Application.Context, "Starting normally - phew!", ToastLength.Long);
wowZapp.LaffOutOut.Singleton.ScreenXWidth = WindowManager.DefaultDisplay.Width;
wowZapp.LaffOutOut.Singleton.ScreenYHeight = WindowManager.DefaultDisplay.Height;
wowZapp.LaffOutOut.Singleton.resizeFonts = (float)wowZapp.LaffOutOut.Singleton.ScreenXWidth == 480f ? false : true;
wowZapp.LaffOutOut.Singleton.bigger = (((float)wowZapp.LaffOutOut.Singleton.ScreenXWidth - 480f) / 100f) / 2f;
AndroidData.IsAppActive = true;
int timeout = 2500;
if (string.IsNullOrEmpty(wowZapp.LaffOutOut.Singleton.ContentDirectory))
wowZapp.LaffOutOut.Singleton.ContentDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
if (!Directory.Exists(wowZapp.LaffOutOut.Singleton.ContentDirectory))
{
try
{
Directory.CreateDirectory(wowZapp.LaffOutOut.Singleton.ContentDirectory);
/*#if DEBUG
System.Diagnostics.Debug.WriteLine ("Created lol data directory - {0}", wowZapp.LaffOutOut.Singleton.ContentDirectory);
#endif*/
} catch (IOException e)
{
Toast.MakeText(this, "Unable to create data directory", ToastLength.Short).Show();
}
}
/*#if DEBUG
else
System.Diagnostics.Debug.WriteLine ("Lol data directory - ", wowZapp.LaffOutOut.Singleton.ContentDirectory);
#endif
#if DEBUG
System.Diagnostics.Debug.WriteLine ("DeviceID before = {0}", AndroidData.DeviceID);
#endif*/
if (AndroidData.DeviceID != null)
{
int t = AndroidData.DeviceID.Length, r = 0;
string dupe = AndroidData.DeviceID;
for (int m = 0; m < t; ++m)
{
if (dupe [m] == '0')
r++;
}
if (r == t)
{
AndroidData.NewDeviceID = createNewDeviceID();
} else
AndroidData.NewDeviceID = AndroidData.DeviceID;
} else
AndroidData.NewDeviceID = createNewDeviceID();
//});
#if DEBUG
//System.Diagnostics.Debug.WriteLine ("DeviceID after = {0}", AndroidData.NewDeviceID);
#endif
//grabCerts();
string path = Path.Combine(wowZapp.LaffOutOut.Singleton.ContentDirectory, "INSTALL");
if (!File.Exists(path))
{
AndroidData.LastConvChecked = new DateTime(1900, 1, 1);
AndroidData.IsNewInstall = true;
AndroidData.user = WZCommon.UserType.NewUser;
try
{
File.Create(path).Close();
} catch (IOException)
{
Toast.MakeText(Application.Context, Resource.String.debugFailToCreateInstall, ToastLength.Short).Show();
}
} else
{
AndroidData.IsNewInstall = false;
AndroidData.user = WZCommon.UserType.ExistingUser;
}
//});
Handler handler = new Handler();
handler.PostDelayed(new Action(() =>
{
if (AndroidData.IsLoggedIn)
{
StartActivity(typeof(HomeActivity));
} else
{
StartActivity(typeof(LoginChoiceActivity));
}//end if else
Finish();
//.........这里部分代码省略.........
示例12: OnOptionsItemSelected
public override bool OnOptionsItemSelected(IMenuItem item)
{
if (item.ItemId == 1) {
Intent intent = new Intent (this, typeof(AddMovieToCatalogActivity));
intent.PutExtra ("Name", catalog.Name);
intent.PutExtra ("Id", catalog.Id);
StartActivityForResult (intent, 16);
} else if (item.ItemId == 2) {
Animation rotation = AnimationUtils.LoadAnimation (this, Resource.Animation.Rotate);
rotation.RepeatCount = Animation.Infinite;
ImageView imageView = (ImageView)LayoutInflater.Inflate (Resource.Layout.RefreshImageView, null);
imageView.StartAnimation (rotation);
item.SetActionView (imageView);
ActualizarLista ();
Handler handler = new Handler ();
handler.PostDelayed (() => {
imageView.ClearAnimation ();
item.SetActionView (null);
}, 1000);
} else if (item.ItemId == 3) {
Intent intent = new Intent (this, typeof(AuthActivity));
StartActivityForResult (intent, 13);
} else if (item.ItemId == Android.Resource.Id.Home) {
OnBackPressed ();
}
return base.OnOptionsItemSelected (item);
}
示例13: HideActionBarDelayed
private void HideActionBarDelayed(Handler handler) {
handler.PostDelayed(() => ActionBar.Hide(), 2000);
}
示例14: SwitchContent
public void SwitchContent(Android.Support.V4.App.Fragment fragment)
{
_content = fragment;
SupportFragmentManager
.BeginTransaction()
.Replace(Resource.Id.content_frame, fragment)
.Commit();
var h = new Handler();
h.PostDelayed(() => SlidingMenu.ShowContent(), 50);
}
示例15: generateMessageBarAndAnimate
//.........这里部分代码省略.........
layParams.SetMargins ((int)ImageHelper.convertDpToPixel (15f, context), (int)ImageHelper.convertDpToPixel (20f, context), 0, 0);
profilePic.LayoutParameters = layParams;
}
profilePic.SetBackgroundResource (Resource.Drawable.defaultuserimage);
profilePic.Tag = new Java.Lang.String ("profilepic_" + contact.AccountID);
RunOnUiThread (() => messageBar.AddView (profilePic));
if (Contacts.ContactsUtil.contactFilenames.Contains (contact.AccountGuid)) {
rpong = true;
using (Bitmap bm = BitmapFactory.DecodeFile (System.IO.Path.Combine (wowZapp.LaffOutOut.Singleton.ImageDirectory, contact.AccountGuid))) {
using (MemoryStream ms = new MemoryStream ()) {
bm.Compress (Bitmap.CompressFormat.Jpeg, 80, ms);
byte[] image = ms.ToArray ();
displayImage (image, profilePic);
}
}
} else {
if (contact.Picture.Length == 0)
grabGuid = contact.AccountID;
else {
if (contact.Picture.Length > 0)
loadProfilePicture (contact, profilePic);
}
}
LinearLayout fromTVH = new LinearLayout (context);
fromTVH.Orientation = Orientation.Vertical;
fromTVH.LayoutParameters = new ViewGroup.LayoutParams (LinearLayout.LayoutParams.FillParent, LinearLayout.LayoutParams.FillParent);
float textNameSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? (int)ImageHelper.convertPixelToDp (((25 * picSize) / 100), context) : 16f;
TextView textFrom = new TextView (context);
using (layParams = new LinearLayout.LayoutParams (leftOver, (int)textNameSize)) {
layParams.SetMargins ((int)ImageHelper.convertDpToPixel (9.3f, context), (int)ImageHelper.convertPixelToDp (textNameSize - 1, context), 0, 0);
textFrom.LayoutParameters = layParams;
}
float fontSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((12 * picSize) / 100), context) : ImageHelper.convertPixelToDp (14f, context);
textFrom.SetTextSize (Android.Util.ComplexUnitType.Dip, fontSize);
textFrom.SetTextColor (Color.Black);
if (contact != null)
textFrom.Text = contact.FirstName + " " + contact.LastName;
else
textFrom.Text = "Ann Onymouse";
RunOnUiThread (() => fromTVH.AddView (textFrom));
float textMessageSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((70 * picSize) / 100), context) : ImageHelper.convertDpToPixel (39f, context);
TextView textMessage = new TextView (context);
using (layParams = new LinearLayout.LayoutParams (leftOver, (int)textMessageSize)) {
layParams.SetMargins ((int)ImageHelper.convertDpToPixel (10f, context), 0, (int)ImageHelper.convertDpToPixel (10, context), 0);
textMessage.LayoutParameters = layParams;
}
float fontSize2 = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((12 * picSize) / 100), context) : ImageHelper.convertPixelToDp (16f, context);
textMessage.SetTextSize (Android.Util.ComplexUnitType.Dip, fontSize2);
textMessage.SetTextColor (Color.White);
textMessage.SetPadding ((int)ImageHelper.convertDpToPixel (20f, context), 0, (int)ImageHelper.convertDpToPixel (10f, context), 0);
if (!string.IsNullOrEmpty (message))
textMessage.SetBackgroundResource (Resource.Drawable.bubblesolidleft);
textMessage.Text = message != string.Empty ? message : "";
textMessage.ContentDescription = msgList.MessageGuid;
textMessage.Click += new EventHandler (textMessage_Click);
RunOnUiThread (() => fromTVH.AddView (textMessage));
//}
if (msgList != null) {
LinearLayout messageItems = new LinearLayout (context);
messageItems.Orientation = Orientation.Horizontal;
float messageBarSize = wowZapp.LaffOutOut.Singleton.resizeFonts == true ? ImageHelper.convertPixelToDp (((35 * picSize) / 100), context) : ImageHelper.convertDpToPixel (40f, context);
using (layParams = new LinearLayout.LayoutParams (leftOver, (int)messageBarSize)) {
layParams.SetMargins ((int)ImageHelper.convertDpToPixel (14f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (12.7f, context), (int)ImageHelper.convertDpToPixel (4f, context));
messageItems.LayoutParameters = layParams;
}
messageItems.SetPadding ((int)ImageHelper.convertDpToPixel (10f, context), (int)ImageHelper.convertDpToPixel (3.3f, context), (int)ImageHelper.convertDpToPixel (10f, context), 0);
messageItems.SetGravity (GravityFlags.Left);
messageItems = createMessageBar (messageItems, msgList, leftOver);
RunOnUiThread (() => fromTVH.AddView (messageItems));
}
RunOnUiThread (() => messageBar.AddView (fromTVH));
RunOnUiThread (delegate {
hsv.RemoveAllViews ();
hsv.AddView (messageBar);
});
if (grabGuid != null) {
LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
service.UserGetImageDataCompleted += Service_UserGetImageDataCompleted;
service.UserGetImageDataAsync (AndroidData.CurrentUser.AccountID, grabGuid, new Guid (AndroidData.ServiceAuthToken));
}
//});
RunOnUiThread (delegate {
Handler handler = new Handler ();
handler.PostDelayed (new Action (() =>
{
hsv.SmoothScrollTo (newX, 0);
}), 2000);
});
}