Пример #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            var view = new LinearLayout(this)
            {
                LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent),
                Orientation      = Orientation.Vertical
            };

            button = new Button(this)
            {
                Text = "Click me and wait for crash"
            };
            view.AddView(button, new LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent));
            SetContentView(view);

            toRepeat = LoadHttpPage;

            button.Click += delegate
            {
                handler.Post(toRepeat);
                handler.PostDelayed(toRepeat, 50);
                handler.PostDelayed(toRepeat, 100);
                button.Text    = "...";
                button.Enabled = false;
            };
        }
Пример #2
0
        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
0
		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);
								}
							});
		}
Пример #4
0
        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;
        }
        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));
            }
        }
Пример #6
0
			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);
			}
Пример #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            SetToolBarNavBack();
            shareWidget        = new UMengShareWidget(this);
            wb_content         = FindViewById <WebView>(Resource.Id.wb_content);
            tv_ding            = FindViewById <TextView>(Resource.Id.tv_ding);
            btn_mark           = FindViewById <Button>(Resource.Id.btn_mark);
            btn_comment        = FindViewById <Button>(Resource.Id.btn_comment);
            tv_view            = FindViewById <TextView>(Resource.Id.tv_view);
            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeColors(Resources.GetColor(Resource.Color.primary));
            swipeRefreshLayout.SetOnRefreshListener(this);

            btn_mark.Click += (s, e) =>
            {
                AddBookmarkActivity.Enter(this, string.Format(Constact.KbPage, ID), news.Title, "add");
            };
            btn_comment.Click += (s, e) =>
            {
                NewsCommentActivity.Enter(this, ID);
            };

            wb_content.Settings.DomStorageEnabled       = true;
            wb_content.Settings.JavaScriptEnabled       = true;    //支持js
            wb_content.Settings.DefaultTextEncodingName = "utf-8"; //设置编码方式utf-8
            wb_content.Settings.SetSupportZoom(false);             //不可缩放
            wb_content.Settings.DisplayZoomControls = false;       //隐藏原生的缩放控件
            wb_content.Settings.BuiltInZoomControls = false;       //设置内置的缩放控件
            wb_content.Settings.CacheMode           = CacheModes.CacheElseNetwork;
            wb_content.ScrollBarStyle = ScrollbarStyles.InsideOverlay;
            wb_content.Settings.LoadsImagesAutomatically = true; //支持自动加载图片
            wb_content.Settings.UseWideViewPort          = true; //将图片调整到合适webview的大小
            wb_content.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
            var jsInterface = new  WebViewJSInterface(this);

            wb_content.SetWebViewClient(ContentWebViewClient.Instance(this));
            wb_content.AddJavascriptInterface(jsInterface, "openlistner");
            jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e)
            {
                PhotoActivity.Enter(this, e.Result.Split(','), e.Index);
            };
            ID = Intent.GetIntExtra("id", 0);
            if (ID == 0)
            {
                Android.OS.Handler handle = new Android.OS.Handler();
                handle.PostDelayed(() =>
                {
                    Finish();
                }, 2000);
                AlertUtil.ToastShort(this, "获取id错误立即返回");
            }
            InitNews();

            //shareWidget = new UMengShareWidget(this);
        }
Пример #8
0
        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);			
        }
        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);
                }
            };
        }
Пример #10
0
		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.Debug(TAG, timestamper.GetFormattedTimestamp());
									handler.PostDelayed(runnable, DELAY_BETWEEN_LOG_MESSAGES);
								}
							});
		}
Пример #11
0
        private void StartDownloadWatcher()
        {
            if (_downloadWatcherHandler != null)
            {
                return;
            }

            // Create an instance for a runnable-handler
            _downloadWatcherHandler = new Android.OS.Handler();

            // Create a runnable, restarting itself to update every file in the queue
            _downloadWatcherHandlerRunnable = new Java.Lang.Runnable(() => {
                var queueDownload = Queue.Cast <DownloadFileImplementation>();
                var file          = queueDownload.FirstOrDefault();
                if (file != null)
                {
                    if (file.Status == DownloadFileStatus.PAUSED)
                    {
                        var fileTemp = queueDownload.FirstOrDefault(x => x.Status != DownloadFileStatus.PAUSED);
                        if (fileTemp != null)
                        {
                            file = fileTemp;
                        }
                    }

                    if (file.Status == DownloadFileStatus.INITIALIZED)
                    {
                        string destinationPathName = null;
                        if (PathNameForDownloadedFile != null)
                        {
                            destinationPathName = PathNameForDownloadedFile(file);
                        }
                        file.StartDownload(_downloadManager, destinationPathName, true, NotificationVisibility, IsVisibleInDownloadsUi);
                    }

                    var query = new Android.App.DownloadManager.Query();
                    query.SetFilterById(file.Id);
                    try
                    {
                        using (var cursor = _downloadManager.InvokeQuery(query))
                        {
                            if (cursor != null && cursor.MoveToNext())
                            {
                                UpdateFileProperties(cursor, file);
                            }
                            else
                            {
                                // This file is not listed in the native download manager anymore. Let's mark it as canceled.
                                Abort(file);
                            }
                            cursor?.Close();
                        }
                    }
                    catch (Android.Database.Sqlite.SQLiteException)
                    {
                        // I lately got an exception that the database was unaccessible ...
                    }
                }
                _downloadWatcherHandler?.PostDelayed(_downloadWatcherHandlerRunnable, 1000);
            });
            // Start this playing handler immediately
            _downloadWatcherHandler.Post(_downloadWatcherHandlerRunnable);
        }
Пример #12
0
        public ShowcaseViews AddView(ItemViewProperties properties)
        {
            ShowcaseViewBuilder builder = new ShowcaseViewBuilder(activity)
                .SetText(properties.TitleResId, properties.MessageResId)
                .SetShowcaseIndicatorScale(properties.Scale)
                .SetConfigOptions(properties.ConfigurationOptions);

            if (ShowcaseActionBar(properties))
            {
                builder.SetShowcaseItem((int)properties.ItemType, properties.Id, activity);
            }
            else if (properties.Id == (int)ItemViewProperties.ItemViewType.NoShowcase)
            {
                builder.SetShowcaseNoView();
            }
            else
            {
                builder.SetShowcaseView(activity.FindViewById(properties.Id));
            }

            ShowcaseView showcaseView = builder.Build();
            showcaseView.OverrideButtonClick((s,e) =>
            {
                showcaseView.OnClick(showcaseView); //Needed for TYPE_ONE_SHOT

                int fadeOutTime = showcaseView.ConfigurationOptions.FadeOutDuration;

                if (fadeOutTime > 0)
                {
                    var handler = new Handler();
                    handler.PostDelayed(() =>
                    {
                        ShowNextView(showcaseView);
                    }, fadeOutTime);
                }
                else
                {
                    ShowNextView(showcaseView);
                }
            });

            views.Add(showcaseView);

            animations.Add(null);

            return this;
        }
Пример #13
0
        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);
                }
            };*/
        }
Пример #14
0
        private void generateMessageBarAndAnimate(string message, MessageDB msgList, UserDB contact, bool shutUp = false)
        {
            //RunOnUiThread (delegate {
            bool rpong = false;
            if (shutUp != true) {
                AudioPlayer ap = new AudioPlayer (context);
                Android.Content.Res.AssetManager am = this.Assets;
                ap.playFromAssets (am, "incoming.mp3");
            }
            Guid grabGuid = Guid.Empty;
            RunOnUiThread (() => messageBar.SetPadding ((int)ImageHelper.convertDpToPixel (5f, context), 0, (int)ImageHelper.convertDpToPixel (5f, context),
                                                        (int)ImageHelper.convertDpToPixel (10f, context)));

            int leftOver = Convert.ToInt32 (wowZapp.LaffOutOut.Singleton.ScreenXWidth - (picSize + 40));
            LinearLayout.LayoutParams layParams;
            if (contact == null)
                throw new Exception ("Contact is null in generateMessageBarAndAnimate");

            ImageView profilePic = new ImageView (context);
            using (layParams = new LinearLayout.LayoutParams (picSize, picSize)) {
                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);
            });
        }
 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);
 }
Пример #16
0
 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);
 }
Пример #17
0
        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);
            }
        }
Пример #18
0
 public void RunAfterDelay(Action action, long delayMillisecs)
 {
     var handler = new Handler();
     handler.PostDelayed(action, delayMillisecs);
 }
Пример #19
0
 private void HideActionBarDelayed(Handler handler) {
     handler.PostDelayed(() => ActionBar.Hide(), 2000);
 }
Пример #20
0
        private void PosterAinteraz(object sender, ElapsedEventArgs e)
        {
            Action action = new Action(ActualizadorDeSlider_Elapsed);

            Handler.PostDelayed(action, 1000);
        }
Пример #21
0
        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();
            }), timeout);
        }
        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
            {
            }
        }
Пример #23
0
        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);
        }
Пример #24
0
    protected async override void OnCreate(Bundle bundle)
    {
      base.OnCreate(bundle);

      SetContentView(Resource.Layout.PodcastDetail);

      var showNumber = Intent.GetIntExtra("show_number", 0);
      episode = Activity1.ViewModel.GetPodcast(showNumber);


      var description = FindViewById<TextView>(Resource.Id.descriptionView);
      description.Text = episode.Description;

      var play = FindViewById<Button>(Resource.Id.playButton);
      var pause = FindViewById<Button>(Resource.Id.pauseButton);
      var stop = FindViewById<Button>(Resource.Id.stopButton);
      seekBar = FindViewById<SeekBar>(Resource.Id.seekBar1);
      status = FindViewById<TextView>(Resource.Id.statusText);
      updateHandler = new Handler();

      player = new MediaPlayer();
      player.SetDataSource(this, Android.Net.Uri.Parse(episode.AudioUrl));
      player.PrepareAsync();

      player.Prepared += (sender, e) =>
          {
            initialized = true;
            player.SeekTo(timeToSet * 1000);
            UpdateStatus();
          };

      play.Click += (sender, e) =>
      {
        player.Start();
        updateHandler.PostDelayed(UpdateStatus, 1000);
      };

      pause.Click += (sender, e) => player.Pause();

      stop.Click += (sender, e) =>
      {
        player.Stop();
        player.Reset();
        player.SetDataSource(this, Android.Net.Uri.Parse(episode.AudioUrl));
        player.Prepare();
      };

      seekBar.ProgressChanged += (sender, e) =>
          {
            if (!e.FromUser)
              return;

            player.SeekTo((int)(player.Duration * ((float)seekBar.Progress / 100.0)));
          };

      var updated = await episode.GetTimeAsync();

      if (updated == null || updated.ShowNumber != episode.ShowNumber)
        return;

      if (initialized && player != null)
      {
        player.SeekTo(updated.CurrentTime * 1000);
        UpdateStatus();
      }
      else
      {
        timeToSet = updated.CurrentTime;
      }
    }
 private void UpdateButton_Click (object sender, EventArgs e)
 {
     Handler handler = new Handler(Looper.MainLooper);
     for (int i = 0; i < this.adapter.ItemCount; i++) 
     {
         handler.PostDelayed(() =>
             {
                 this.adapter.NotifyItemChanged(i);
             }, 50);
     }
 }
Пример #26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Create your application here
            StatusBarUtil.SetColorStatusBars(this);
            ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this).WriteDebugLogs().Build();//初始化图片加载框架

            ImageLoader.Instance.Init(configuration);
            //显示图片配置
            options = new DisplayImageOptions.Builder()
                      .ShowImageForEmptyUri(Resource.Drawable.icon_yuanyou)
                      .ShowImageOnFail(Resource.Drawable.icon_yuanyou)
                      .ShowImageOnLoading(Resource.Drawable.icon_user)
                      .CacheInMemory(true)
                      .BitmapConfig(Bitmap.Config.Rgb565)
                      .CacheOnDisk(true)
                      // .Displayer(new DisplayerImageCircle(20))
                      .Build();
            SetToolBarNavBack();
            ID                 = Intent.GetIntExtra("id", 0);
            tv_author          = FindViewById <TextView>(Resource.Id.tv_author);
            tv_postDate        = FindViewById <TextView>(Resource.Id.tv_postDate);
            wb_content         = FindViewById <WebView>(Resource.Id.wb_content);
            iv_avatar          = FindViewById <ImageView>(Resource.Id.iv_avatar);
            tv_articleTitle    = FindViewById <TextView>(Resource.Id.tv_articleTitle);
            btn_comment        = FindViewById <Button>(Resource.Id.btn_comment);
            tv_ding            = FindViewById <TextView>(Resource.Id.tv_ding);
            btn_mark           = FindViewById <Button>(Resource.Id.btn_mark);
            tv_view            = FindViewById <TextView>(Resource.Id.tv_view);
            swipeRefreshLayout = FindViewById <SwipeRefreshLayout>(Resource.Id.swipeRefreshLayout);
            swipeRefreshLayout.SetColorSchemeColors(Resources.GetColor(Resource.Color.primary));
            swipeRefreshLayout.SetOnRefreshListener(this);
            btn_mark.Click += (s, e) =>
            {
                AddBookmarkActivity.Enter(this, article.Url, article.Title, "add");
            };

            btn_comment.Click += (s, e) =>
            {
                ArticleCommentActivity.Enter(this, article.BlogApp, ID);
            };
            wb_content.Settings.DomStorageEnabled       = true;
            wb_content.Settings.JavaScriptEnabled       = true;    //支持js
            wb_content.Settings.DefaultTextEncodingName = "utf-8"; //设置编码方式utf-8
            wb_content.Settings.SetSupportZoom(false);             //不可缩放
            wb_content.Settings.DisplayZoomControls = false;       //隐藏原生的缩放控件
            wb_content.Settings.BuiltInZoomControls = false;       //设置内置的缩放控件
            wb_content.Settings.CacheMode           = CacheModes.CacheElseNetwork;
            wb_content.ScrollBarStyle = ScrollbarStyles.InsideOverlay;
            wb_content.Settings.LoadsImagesAutomatically = true; //支持自动加载图片
            wb_content.Settings.UseWideViewPort          = true; //将图片调整到合适webview的大小
            wb_content.Settings.SetLayoutAlgorithm(WebSettings.LayoutAlgorithm.SingleColumn);
            var jsInterface = new  WebViewJSInterface(this);

            wb_content.SetWebViewClient(ContentWebViewClient.Instance(this));
            wb_content.AddJavascriptInterface(jsInterface, "openlistner");
            jsInterface.CallFromPageReceived += delegate(object sender, WebViewJSInterface.CallFromPageReceivedEventArgs e)
            {
                PhotoActivity.Enter(this, e.Result.Split(','), e.Index);
            };
            if (ID == 0)
            {
                Android.OS.Handler handle = new Android.OS.Handler();
                handle.PostDelayed(() =>
                {
                    Finish();
                }, 2000);
                AlertUtil.ToastShort(this, "获取id错误立即返回");
            }
            InitArticle();
            shareWidget = new UMengShareWidget(this);
        }
Пример #27
0
        void RefreshItems(IMenuItem item)
        {
            ImageView imageView;

            Animation rotation = AnimationUtils.LoadAnimation (this, Resource.Animation.Rotate);
            rotation.RepeatCount = Animation.Infinite;

            imageView = (ImageView)LayoutInflater.Inflate (Resource.Layout.RefreshImageView, null);
            imageView.StartAnimation (rotation);

            item.SetActionView (imageView);

            appPagerAdapter.RefreshList (appViewPager.CurrentItem);

            Handler handler = new Handler ();
            handler.PostDelayed (() => {
                imageView.ClearAnimation ();
                item.SetActionView (null);
            }, 1000);
        }
Пример #28
0
        private void hideActionBarDelayed(Handler handler)
        {

            handler.PostDelayed(new postclass(this),2000);

            //handler.postDelayed(new Runnable() {
            //    public void run() {
            //        getSupportActionBar().hide();
            //    }
            //}, 2000);
        }
Пример #29
0
 private void reset()
 {
     Android.OS.Handler mHandler = new Android.OS.Handler();
     mHandler.PostDelayed(new Action(() => { hasClicked = false; }), 500);
 }
        //
        // Marker related listeners.
        //
        public bool OnMarkerClick(Marker marker)
        {
            // This causes the marker at Perth to bounce into position when it is clicked.
            if (marker.Equals(mPerth)) {
                Handler handler = new Handler ();
                long start = SystemClock.UptimeMillis ();
                Projection proj = mMap.Projection;
                Point startPoint = proj.ToScreenLocation(PERTH);
                startPoint.Offset(0, -100);
                LatLng startLatLng = proj.FromScreenLocation(startPoint);
                long duration = 1500;

                IInterpolator interpolator = new BounceInterpolator();

                Runnable run = null;
                run = new Runnable (delegate {
                        long elapsed = SystemClock.UptimeMillis () - start;
                        float t = interpolator.GetInterpolation ((float) elapsed / duration);
                        double lng = t * PERTH.Longitude + (1 - t) * startLatLng.Longitude;
                        double lat = t * PERTH.Latitude + (1 - t) * startLatLng.Latitude;
                        marker.Position = (new LatLng(lat, lng));

                        if (t < 1.0) {
                            // Post again 16ms later.
                            handler.PostDelayed(run, 16);
                        }
                });
                handler.Post(run);
            }
            // We return false to indicate that we have not consumed the event and that we wish
            // for the default behavior to occur (which is for the camera to move such that the
            // marker is centered and for the marker's info window to open, if it has one).
            return false;
        }
Пример #31
0
        private void LoadMoreRight(int numberToLoad)
        {
            if (!loadingSchedules)
            {
                loadingSchedules = true;

                Handler loadingHandler = new Handler ();
                loadingHandler.PostDelayed (() => {
                    ScheduleItem lastItem = schedule[schedule.Count - 1];
                    List<ScheduleItem> nextDays = dataStorage.GenerateSchedule(lastItem.Day.Date.AddDays(1), lastItem.Day.Date.AddDays(numberToLoad));

                    for (int i = 0; i < nextDays.Count; i++) {
                        ScheduleItem item = nextDays [i];

                        View view = InflateScheduleItem(this, item);
                        view.Click += (sender, e) => {
                            DateClick(sender, item.Appointments, item.Day.DayOfWeek);
                        };

                        datesLayout.AddView (view);
                    }

                    if (schedule == null)
                    {
                        schedule = new List<ScheduleItem>();
                    }

                    schedule.AddRange(nextDays);

                    loadingSchedules = false;
                }, 1000);
            }
        }