//
        // 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;
        }
Beispiel #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.button1);
            button.Click += button_Click;

            Button button2 = FindViewById<Button>(Resource.Id.button2);
            button2.Click += button2_Click;

            LogOut.Action += LogOut_Action;

            MessHander = new Handler(Msg =>
            {
                FindViewById<TextView>(Resource.Id.textView1).Append(Msg.Obj.ToString() + "\n");

            });


            client = new ClientInfo(GetString(Resource.String.ServerIP), int.Parse(GetString(Resource.String.ServerPort)), int.Parse(GetString(Resource.String.ServerRegPort)), int.Parse(GetString(Resource.String.MinPort)), int.Parse(GetString(Resource.String.MaxPort)), int.Parse(GetString(Resource.String.ResCount)), GetString(Resource.String.MAC));
            client.ConToServer();
            client.ClientDataIn += client_ClientDataIn;
            client.ClientConnToMe += client_ClientConnToMe;
            client.ClientDiscon += client_ClientDiscon;

          
        }
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			mHandler = new Handler ();

			// Inflate our UI from its XML layout description.
			SetContentView (Resource.Layout.voice_recognition);

			// Get display items for later interaction
			Button speakButton = FindViewById <Button> (Resource.Id.btn_speak);

			mList = FindViewById <ListView> (Resource.Id.list);

			mSupportedLanguageView = FindViewById <Spinner> (Resource.Id.supported_languages);

			// Check to see if a recognition activity is present
			PackageManager pm = PackageManager;
			IList<ResolveInfo> activities = pm.QueryIntentActivities (new Intent (RecognizerIntent.ActionRecognizeSpeech), 0);

			if (activities.Count != 0)
				speakButton.Click += speakButton_Click;
			else {
				speakButton.Enabled = false;
				speakButton.Text = "Recognizer not present";
			}

			// Most of the applications do not have to handle the voice settings. If the application
			// does not require a recognition in a specific language (i.e., different from the system
			// locale), the application does not need to read the voice settings.
			RefreshVoiceSettings();
		}
        public void BeginGeofencing(object sender, EventArgs eventArgs)
        {
            if (!apiClient.IsConnected) {
                var myHandler = new Handler ();
                myHandler.Post (() => {
                    Android.Widget.Toast.MakeText (this, "Google API Not Connected. Try Again.", Android.Widget.ToastLength.Long).Show ();
                });
                return;
            }

            try {
                if (connectedGeofences.Count >= 1) {
                    LocationServices.GeofencingApi.AddGeofences(apiClient, getGeofencingRequest(), getGeofencePendingIntent()).SetResultCallback(this);
                    string geofenceAnnounce = "Geofences Active At The Following Locations:\n";
                    foreach (ROMPGeofence geofName in connectedGeofences) {
                        geofenceAnnounce += geofName.Id + "\n";
                    }
                    var myHandler = new Handler ();
                    myHandler.Post (() => {
                        Android.Widget.Toast.MakeText (this, geofenceAnnounce, Android.Widget.ToastLength.Long).Show ();
                    });
                    FindViewById<Button>(Resource.Id.btnBegin).Visibility = ViewStates.Invisible;
                    FindViewById<TextView>(Resource.Id.lblConfirm).SetText("A record that you have checked-in will be made in the log of your education activity for this ROMP rotation when this device enters a 1km radius surrounding the facility of your ROMP rotation.", TextView.BufferType.Normal);
                    geofenceRequestIntent = PendingIntent.GetService (this, 0,
                        new Intent (this, Java.Lang.Class.FromType (typeof(GeofenceTransitionsIntentService))),
                        PendingIntentFlags.UpdateCurrent);
                } else {
                    FindViewById<Button>(Resource.Id.btnBegin).Visibility = ViewStates.Invisible;
                    FindViewById<TextView>(Resource.Id.lblConfirm).SetText("No Rotations Available, Please Try Within Your Scheduled Rotation Dates", TextView.BufferType.Normal);
                }
            } catch (SecurityException securityEx) {
                logSecurityException (securityEx);
            }
        }
		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);
								}
							});
		}
        protected override void OnCreate(Bundle savedInstanceState) {
            base.OnCreate(savedInstanceState);
            
            var pos = 0;
            if (Intent.Extras != null)
                pos = Intent.Extras.GetInt("pos");

            var birds = Resources.GetStringArray(Resource.Array.birds);
            var imgs = Resources.ObtainTypedArray(Resource.Array.birds_img);
            var resId = imgs.GetResourceId(pos, -1);

            Title = birds[pos];
            Window.RequestFeature(WindowFeatures.ActionBarOverlay);
            var color = new ColorDrawable(Color.Black);
            color.SetAlpha(128);
            ActionBar.SetBackgroundDrawable(color);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            _handler = new Handler();

            var imageView = new ImageView(this);
            imageView.SetScaleType(ImageView.ScaleType.CenterInside);
            imageView.SetImageResource(resId);
            imageView.Click += (sender, args) =>
                {
                    ActionBar.Show();
                    HideActionBarDelayed(_handler);
                };
            SetContentView(imageView);
            Window.SetBackgroundDrawableResource(Android.Resource.Color.BackgroundDark);
        }
 public WidgetProvider()
 {
     // Start the worker thread
     workerThread = new HandlerThread (ThreadWorkerName);
     workerThread.Start();
     workerQueue = new Handler (workerThread.Looper);
 }
Beispiel #8
0
 public SkiaView(Activity context) : base(context)
 {
     _context = context;
     SkiaPlatform.Initialize();
     Holder.AddCallback(this);
     _handler = new Handler(context.MainLooper);
 }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			ActionBar.SetTitle (Resource.String.title_devices);

			mHandler = new Handler ();

			// Use this check to determine whether BLE is supported on the device.  Then you can
			// selectively disable BLE-related features.
			if (!PackageManager.HasSystemFeature (Android.Content.PM.PackageManager.FeatureBluetoothLe)) {
				Toast.MakeText (this, Resource.String.ble_not_supported, ToastLength.Short).Show ();
				Finish ();
			}

			// Initializes a Bluetooth adapter.  For API level 18 and above, get a reference to
			// BluetoothAdapter through BluetoothManager.
			BluetoothManager bluetoothManager = (BluetoothManager) GetSystemService (Context.BluetoothService);
			mBluetoothAdapter = bluetoothManager.Adapter;

			// Checks if Bluetooth is supported on the device.
			if (mBluetoothAdapter == null) {
				Toast.MakeText (this, Resource.String.error_bluetooth_not_supported, ToastLength.Short).Show();
				Finish();
				return;
			}
		}
Beispiel #10
0
		private void Peer_PeerConnected (object sender, PeerConnectedEventArgs args)
		{
			using (var h = new Handler (Looper.MainLooper))
				h.Post (() => {
					textView.Text = args.PeerId;
				});
		}
        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();
        }
		protected override void OnLayout (bool changed, int l, int t, int r, int b)
		{
			using (var h = new Handler (Looper.MainLooper)) {
				h.Post (() => {
					double width = base.Context.FromPixels ((double)(r - l));
					double height = base.Context.FromPixels ((double)(b - t));
					var size = new Size (width, height);

					var msw = MeasureSpec.MakeMeasureSpec (r - l, MeasureSpecMode.Exactly);
					var msh = MeasureSpec.MakeMeasureSpec (b - t, MeasureSpecMode.Exactly);
					_nativeView.Measure (msw, msh);
					_nativeView.Layout (0, 0, r - l, b - t);

					//			if (size != _previousSize) {
					var layout = _viewCell.View as Layout<Xamarin.Forms.View>;
					if (layout != null) {
						layout.Layout (new Rectangle (0, 0, width, height));
						layout.ForceLayout ();
						FixChildLayouts (layout);
						_isLaidOut = true;
					}
					_previousSize = size;
				});
			}
			//			}
		}
Beispiel #13
0
 protected void RunOnMainThread(Action action)
 {
     Handler handler = new Handler(Looper.MainLooper);
     handler.Post(action);
     handler.Dispose();
     handler = null;
 }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.user_detail, container, false);

            if (_user != null) {
                ((TextView)rootView.FindViewById (Resource.Id.user_name)).Text = $"{_user.FirstName} {_user.LastName}";
                ((TextView)rootView.FindViewById (Resource.Id.mail_header)).Text = $"[Email]";
                ((TextView)rootView.FindViewById (Resource.Id.user_mail)).Text = _user.Email;
                ((TextView)rootView.FindViewById (Resource.Id.phone_header)).Text = $"[Telefon]";
                ((TextView)rootView.FindViewById (Resource.Id.user_phone)).Text = _user.Phone;
                ((TextView)rootView.FindViewById (Resource.Id.cell_header)).Text = $"[Mobil]";
                ((TextView)rootView.FindViewById (Resource.Id.user_cell)).Text = _user.Cell;

                var imageView = (ImageView)rootView.FindViewById (Resource.Id.user_image);

                Handler handler = new Handler (Context.MainLooper);
                Task.Run (() => {
                    var imageBitmap = ((ImageService)ServiceLocator.Current.GetInstance<ImageService>()).GetUserPicture(_user);
                    Runnable runnable = new Runnable (() => {
                        imageView.SetImageBitmap (imageBitmap);
                    });
                    handler.Post (runnable);
                });
            }
            return rootView;
        }
		private void CreateNotifications(Context context, string action, bool isMessageNeeded = true, bool isToastNeeded = true)
		{
			#if DEBUG
			try {
				if (isMessageNeeded)
				{
					Notification notification = new Notification.Builder(context)
						.SetContentTitle ("BluetoothNotify intent received " + action)
						.SetContentText ("message sent at" + System.DateTime.Now.ToLongTimeString ())
						.SetSmallIcon (Resource.Drawable.icon)
						.Build ();

					NotificationManager nMgr = (NotificationManager)context.GetSystemService (Android.Content.ContextWrapper.NotificationService);
					nMgr.Notify (0, notification);
				}

				if (isToastNeeded)
				{
					var myHandler = new Handler ();
					myHandler.Post (() =>  {
						Toast.MakeText (context, "BluetoothNotify intent received " + action, ToastLength.Long).Show ();
					});
				}
				
			} catch (Exception ex) {
				Log.Info ("com.tarabel.bluetoothnotify", "CreateNotification error in IntentReceiver " + ex.ToString());
			}
			#endif
		}
 public void OnClick(View v)
 {
     Handler h = new Handler();
     h.Post(() => {
         this.Img.StartAnimation(this.AniSet);
     });
 }
Beispiel #17
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;
        }
 //--------------------------------------------------------------
 // CONSTRUCTORS
 //--------------------------------------------------------------
 public BluetoothManager()
 {
     _deviceAddress = string.Empty;
     _handler = new MyHandler ();
     _bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
     _state = StateEnum.None;
 }
        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));
            }
        }
Beispiel #20
0
		public JPushUtil (Context _context)
		{
			context = _context;
			handler = new Handler(DealMessage);
			//或得共享实例变量
			sp_userinfo = context.GetSharedPreferences(Global.SHAREDPREFERENCES_USERINFO,FileCreationMode.Private);
			sp_jpushInfo = context.GetSharedPreferences (Global.SHAREDPREFERENCES_JPUSH, FileCreationMode.Private);
		}
		public void Update (object bindingContext)
		{
			using (var h = new Handler (Looper.MainLooper)) {
				h.Post (() => {
					_viewCell.BindingContext = bindingContext;
				});
			}
		}
Beispiel #22
0
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			handler = new Handler ();
			client = new GoogleApiClientBuilder (this, this, this)
				.AddApi (WearableClass.Api)
				.Build ();
		}
 public PullToRefreshListView(Context context, IAttributeSet attrs, int whichResourceId)
     : base(context, attrs)
 {
     ((IMvxBindingActivity)context).BindingInflate(whichResourceId, this);
     _listView = FindViewById<ListView>(global::Android.Resource.Id.List);
     _uiThreadHandler = new Handler();
     InitializePullToRefreshList();
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            pollingHandler = new Handler();

            InitializeProgressDialog();
        }
Beispiel #25
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);
			}
Beispiel #26
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);
        }
Beispiel #27
0
 public ReproductorFragment(Usuario usuario, ICambiarContenido cambiarContenido)
 {
     CambiarContenido = cambiarContenido;
     Usuario          = usuario;
     Handler          = new Android.OS.Handler(Looper.MainLooper);
     ActualizadorDeInterfaz.Elapsed += PosterAinteraz;
     ActualizadorDeInterfaz.Enabled  = true;
     ActualizadorDeInterfaz.Interval = 500;
 }
        public static void StartBackgroundJob(
            MonitoredActivity activity, string title,
            string message, Action job, Handler handler)
		{
			// Make the progress dialog uncancelable, so that we can gurantee
			// the thread will be done before the activity getting destroyed.
			ProgressDialog dialog = ProgressDialog.Show(activity, title, message, true, false);
			ThreadPool.QueueUserWorkItem((w) => new BackgroundJob(activity, job, dialog, handler).Run());
		}
 public PullToRefreshComponent(View upperView, View lowerView,
                               ListView listView, Handler uiThreadHandler)
 {
     this._upperView = upperView;
     this._lowerView = lowerView;
     this._listView = listView;
     this._uiThreadHandler = uiThreadHandler;
     Initialize();
 }
Beispiel #30
0
 public void Invoke(Action action)
 {
     //Another method
     //http://stackoverflow.com/questions/11123621/running-code-in-main-thread-from-another-thread
     var l = Android.OS.Looper.MainLooper; //Previously Context.GetMainLooper()
     Handler mainHandler = new Handler(l);
     Runnable myRunnable = new Runnable(action);
     mainHandler.Post(myRunnable);
 }
        /// <summary>
        /// Initializes a new instance <see cref="UITestListener"/>
        /// </summary>
        /// <param name="listAdapter"></param>
        public UITestListener(TestResultsListAdapter listAdapter)
        {
            // Create a new thread handler for the main looper.
            // This handler is used to post code from the background thread
            // back to the UI thread.
            _threadHandler = new Handler(Application.Context.MainLooper);

            _listAdapter = listAdapter;
        }
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.ChooseMode);
            try {
                string sessionKey = Intent.GetStringExtra ("SessionKey");
                int groupID = Intent.GetIntExtra ("GroupID", 0);
                int userID = Intent.GetIntExtra ("UserID", 0);
                var locSvc = new ROMPLocation ();
                Button button = FindViewById<Button> (Resource.Id.btnChoose);
                CheckBox cbpassive = FindViewById<CheckBox> (Resource.Id.cbPassive);
                CheckBox cbactive = FindViewById<CheckBox> (Resource.Id.cbActive);

                cbpassive.Click += (o, e) => {
                    if (cbactive.Checked) {
                        cbactive.Checked = false;
                    }
                };

                cbactive.Click += (o, e) => {
                    if (cbpassive.Checked) {
                        cbpassive.Checked = false;
                    }
                };

                button.Click += delegate {
                    if (cbactive.Checked) {
                        var nextActivity = new Intent(this, typeof(CheckInActivity));
                        nextActivity.PutExtra("SessionKey", sessionKey);
                        nextActivity.PutExtra("GroupID", groupID);
                        nextActivity.PutExtra("UserID", userID);
                        StartActivity(nextActivity);
                        Finish();
                    } else if (cbpassive.Checked) {
                        var nextActivity = new Intent(this, typeof(CheckInPassiveActivity));
                        nextActivity.PutExtra("SessionKey", sessionKey);
                        nextActivity.PutExtra("GroupID", groupID);
                        nextActivity.PutExtra("UserID", userID);
                        StartActivity(nextActivity);
                        Finish();
                    } else {
                        string errmsg = "Please choose a check in method before proceeding.";
                        var myHandler = new Handler();
                        myHandler.Post(() => {
                            Toast.MakeText(this, errmsg, ToastLength.Short).Show();
                        });
                    }
                };
            } catch (Exception e) {
                var myHandler = new Handler();
                myHandler.Post(() => {
                    Android.Widget.Toast.MakeText(this, e.Message, Android.Widget.ToastLength.Long).Show();
                });
                System.Diagnostics.Debug.Write (e.Message);
            }
        }
Beispiel #33
0
        public void StopDownloadWatcher()
        {
            var downloads = Queue.Cast <DownloadFileImplementation>().ToList();

            if (downloads == null || downloads.Count == 0)
            {
                _downloadWatcherHandler.RemoveCallbacks(_downloadWatcherHandlerRunnable);
                _downloadWatcherHandler = null;
            }
        }
 /// <summary>This method helps to fit a column.</summary>
 /// <remarks>
 /// This method helps to fit a column. it will be called when TableView is scrolled on
 /// horizontally.
 /// </remarks>
 public virtual void FitWidthSize(int position, bool scrollingLeft)
 {
     FitSize(position, IgnoreLeft, false);
     if (mNeedSetLeft & scrollingLeft)
     {
         // Works just like invoke later of swing utils.
         Android.OS.Handler handler = new Android.OS.Handler();
         handler.Post(new _Runnable_144(this));
     }
 }
Beispiel #35
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);
        }
Beispiel #36
0
        private void ConsoleCommand()
        {
            AlertDialog commandDialog = null;
            Button      btnSend       = null;
            Button      btnCancel     = null;

            Android.OS.Handler dialogHandler = new Android.OS.Handler(m => { throw new Java.Lang.RuntimeException(); });

            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);

            View content = LayoutInflater.From(this).Inflate(Resource.Layout.edit_option_dialog, null);

            EditText edtKey = content.FindViewById <EditText>(Resource.Id.key);

            edtKey.Text = "";

            btnSend   = content.FindViewById <Button>(Resource.Id.btn_ok);
            btnCancel = content.FindViewById <Button>(Resource.Id.btn_cancel);

            btnSend.Text = Resources.GetString(Resource.String.send);

            btnSend.Enabled   = true;
            btnCancel.Enabled = true;

            btnSend.Click += delegate
            {
                string commandResult = SendConsoleCommand(edtKey.Text);

                if (!commandResult.Equals(""))
                {
                    EddieLogger.Debug(commandResult);

                    logEntry = GetCurrentLog(FormatType.HTML, LogTime.LOCAL);

                    if (logEntry == null)
                    {
                        return;
                    }

                    if (viewMode == ViewMode.ListView)
                    {
                        logListAdapter.DataSet(GetSpannedLog());
                    }
                    else
                    {
                        LoadLogWebView();
                    }
                }

                commandDialog.Dismiss();

                dialogHandler.SendMessage(dialogHandler.ObtainMessage());
            };

            btnCancel.Click += delegate
            {
                commandDialog.Dismiss();

                dialogHandler.SendMessage(dialogHandler.ObtainMessage());
            };

            dialogBuilder.SetTitle(Resources.GetString(Resource.String.console_command_title));
            dialogBuilder.SetView(content);

            commandDialog = dialogBuilder.Create();
            commandDialog.Show();

            try
            {
                Looper.Loop();
            }
            catch (Java.Lang.RuntimeException)
            {
            }
        }
        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
            {
            }
        }
Beispiel #38
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);
        }
Beispiel #39
0
 private void reset()
 {
     Android.OS.Handler mHandler = new Android.OS.Handler();
     mHandler.PostDelayed(new Action(() => { hasClicked = false; }), 500);
 }