Esempio n. 1
0
 public SimpleStringRecyclerViewAdapter(Android.App.Activity context, List <String> items)
 {
     parent = context;
     context.Theme.ResolveAttribute(Resource.Attribute.selectableItemBackground, typedValue, true);
     background = typedValue.ResourceId;
     values     = items;
 }
Esempio n. 2
0
        public override void OnDestroyView()
        {
            base.OnDestroyView();

            // Clean markers
            foreach (Marker marker in transportMarkers.Values)
            {
                Activity.RunOnUiThread(marker.Remove);
            }

            transportMarkers.Clear();
            markerSteps.Clear();

            // Stop and clean animators
            foreach (ValueAnimator valueAnimator in markerAnimators.Values)
            {
                Activity.RunOnUiThread(valueAnimator.Pause);
            }

            markerAnimators.Clear();

            // Dispose map
            googleMap.Clear();
            googleMap.Dispose();
            mapFragment.Dispose();
            mapFragment = null;
        }
Esempio n. 3
0
 public NewsAdapter(Android.App.Activity amContext, List <News> aData, AssetManager asset)
 {
     _mContext = amContext;
     _data.AddRange(aData);
     _type  = Typeface.CreateFromAsset(asset, "SourceSansPro-Regular.ttf");
     _light = Typeface.CreateFromAsset(asset, "SourceSansPro-Light.ttf");
 }
Esempio n. 4
0
        private void RefreshMarkers()
        {
            // Update each marker position
            foreach (var pair in transportMarkers)
            {
                Transport transport = pair.Key;
                Marker    marker    = pair.Value;

                // Compute quick position
                Position quickFrom     = transport.Step.Stop.Position;
                Position quickTo       = transport.TimeStep.Step.Stop.Position;
                LatLng   quickPosition = new LatLng(quickFrom.Latitude + (quickTo.Latitude - quickFrom.Latitude) * transport.Progress, quickFrom.Longitude + (quickTo.Longitude - quickFrom.Longitude) * transport.Progress);

                // Update marker
                ValueAnimator valueAnimator;
                if (!markerAnimators.TryGetValue(marker, out valueAnimator))
                {
                    valueAnimator = new ValueAnimator();

                    valueAnimator.AddUpdateListener(new MarkerAnimator(Activity, marker, transport, p => SetMarkerPosition(transport, marker, p), refreshCancellationTokenSource));
                    valueAnimator.SetInterpolator(new LinearInterpolator());
                    valueAnimator.SetFloatValues(0, 1);
                    valueAnimator.SetDuration(1000);

                    markerAnimators.Add(marker, valueAnimator);
                }
                else
                {
                    Activity.RunOnUiThread(valueAnimator.Cancel);
                }

                Activity.RunOnUiThread(valueAnimator.Start);
            }
        }
Esempio n. 5
0
        protected void LoadView(Context context)
        {
            SetCancelable(false);
            _activity = context as Android.App.Activity;
            if (_activity != null)
            {
                _view = _activity.LayoutInflater.Inflate(Resource.Layout.custom_progress, null);
                SetView(_view);
                _progressBar = _view.FindViewById <ProgressBar>(Resource.Id.progressBar);
                _progressBar.Indeterminate = true;
                _progressBar.Max           = 100;
                _progressBar.Progress      = 0;

                _layoutProgressText           = _view.FindViewById <LinearLayout>(Resource.Id.layoutProgressText);
                _textViewProgressMessage      = _view.FindViewById <TextView>(Resource.Id.textViewProgressMessage);
                _textViewProgressMessage.Text = string.Empty;
                _textViewProgressLeft         = _view.FindViewById <TextView>(Resource.Id.textViewProgressLeft);
                _textViewProgressRight        = _view.FindViewById <TextView>(Resource.Id.textViewProgressRight);

                _buttonAbort        = _view.FindViewById <Button>(Resource.Id.buttonAbort);
                _buttonAbort.Click += (sender, args) =>
                {
                    AbortClick?.Invoke(this);
                };
                UpdateText();
            }
        }
Esempio n. 6
0
        private void onItemChosen(object sender, DialogClickEventArgs args)
        {
            onChosen(options[args.Which].Item);

            dialog.Dismiss();
            activity = null;
        }
Esempio n. 7
0
        /// <summary>
        /// Gets the necessary UI for the user to sign in to their account.
        /// </summary>
        /// <returns>
        /// A platform-specific UI type for the user to present.
        /// </returns>
        /// <param name="context">The context for the UI.</param>
        /// <param name="completedHandler">A callback for when authentication has completed successfuly.</param>
        public AuthenticateUIType GetAuthenticateUI(UIContext context, Action <Account> completedHandler)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            var auth = GetAuthenticator();

            if (auth == null)
            {
                throw new NotSupportedException("Account authentication in is not supported.");
            }
            auth.Completed += (sender, e) => {
                if (e.IsAuthenticated)
                {
                    AccountStore.Create(context).Save(e.Account, ServiceId);
                }
                if (completedHandler != null)
                {
                    completedHandler(e.Account);
                }
            };
            auth.Title = Title;
            return(auth.GetUI(context));
        }
Esempio n. 8
0
        /// <summary>
        /// Start to select photo.
        /// </summary>
        /// <param name="requestCode"> identity of the requester activity. </param>
        public void ForResult(int requestCode)
        {
            if (engine == null)
            {
                throw new ExceptionInInitializerError(LoadEngine.INITIALIZE_ENGINE_ERROR);
            }

            Activity activity = Activity;

            if (activity == null)
            {
                return; // cannot continue;
            }
            mSelectionSpec.MimeTypes = MimeTypes;
            mSelectionSpec.Engine    = engine;
            Intent intent = new Intent(activity, typeof(ImageSelectActivity));

            intent.PutExtra(ImageSelectActivity.EXTRA_SELECTION_SPEC, mSelectionSpec);
            //        intent.putExtra(ImageSelectActivity.EXTRA_ENGINE, (Serializable) engine);

            intent.PutParcelableArrayListExtra(ImageSelectActivity.EXTRA_RESUME_LIST, mResumeList.AsIParcelableList());

            Fragment fragment = Fragment;

            if (fragment != null)
            {
                fragment.StartActivityForResult(intent, requestCode);
            }
            else
            {
                activity.StartActivityForResult(intent, requestCode);
            }
            hasInitPicker = false;
        }
Esempio n. 9
0
 public SimpleStringRecyclerViewAdapter (Android.App.Activity context, List<String> items) 
 {
     parent = context;
     context.Theme.ResolveAttribute (Resource.Attribute.selectableItemBackground, typedValue, true);
     background = typedValue.ResourceId;
     values = items;
 }
Esempio n. 10
0
        /// <summary>
        /// Gets the Plot interface.
        /// Calling this method multiple times in your application is no problem.
        /// </summary>
        /// <returns>a link to the Plot interface</returns>
        /// <param name="activity">an Activity to initialize Plot from</param>
        public static IPlot GetInstance(Android.App.Activity activity)
        {
            PlotImplementation instance = (PlotImplementation)GetInstance();

            instance.Init(activity);
            return(instance);
        }
Esempio n. 11
0
 public VideosAdapter(Android.App.Activity context, List <SearchResultDownloadItem> searchResults, Dictionary <string, Bitmap> images)
 {
     this.context       = context;
     this.searchResults = searchResults;
     this.images        = images;
     inflater           = (LayoutInflater)context.GetSystemService(Android.Content.Context.LayoutInflaterService);
 }
Esempio n. 12
0
        public static bool CheckPermissionForPicsWrite(Context context)
        {
            Android.App.Activity activity = (Android.App.Activity)context;
            bool isPermit = true;

            if (ContextCompat.CheckSelfPermission(context, Manifest.Permission.WriteExternalStorage) != Android.Content.PM.Permission.Granted)
            {
                if (ActivityCompat.ShouldShowRequestPermissionRationale(activity, Manifest.Permission.WriteExternalStorage))
                {
                    Snackbar.Make(activity.CurrentFocus, "External storage permission is necessary", Snackbar.LengthIndefinite)
                    .SetAction(Resource.String.OK,
                               delegate
                    {
                        ActivityCompat.RequestPermissions(activity, new[] { Manifest.Permission.WriteExternalStorage }, MY_PERMISSIONS_REQUEST_Write_EXTERNAL_STORAGE);
                        isPermit = true;
                    }).SetAction(Resource.String.CANCEL, delegate { isPermit = false; })
                    .Show();
                }
                else
                {
                    ActivityCompat.RequestPermissions(activity, new[] { Manifest.Permission.WriteExternalStorage }, MY_PERMISSIONS_REQUEST_Write_EXTERNAL_STORAGE);
                    isPermit = true;
                }
            }
            else
            {
                isPermit = true;
            }
            return(isPermit);
        }
Esempio n. 13
0
        public static void ShowDialog(String title_text, String message, String NegativeButton, String PositiveButton, Action actionPositive)
        {
            Android.App.Activity act     = Locator.Current.GetService <Android.App.Activity>();
            AlertDialog.Builder  builder = new AlertDialog.Builder(act);

            if (title_text != null)
            {
                builder.SetTitle(title_text);
            }

            builder.SetMessage(message);
            builder.SetCancelable(false);
            builder.SetPositiveButton(PositiveButton, (s, ev) =>
            {
                if (actionPositive != null)
                {
                    actionPositive.Invoke();
                }
                ((AlertDialog)s).Cancel();
            });
            builder.SetNegativeButton(NegativeButton, (s, ev) =>
            {
                ((AlertDialog)s).Cancel();
            });

            act.RunOnUiThread(() =>
            {
                AlertDialog alert = builder.Show();
            });
        }
 public override unsafe void Load(Android.App.Activity activity, Java.Lang.Object @params, Java.Lang.Object networkParams, Java.Lang.Object @callback)
 {
     LoadBanner(activity,
                @params as Com.Appodeal.Ads.Unified.IUnifiedBannerParams,
                networkParams as Com.Appodeal.Ads.Adapters.Appodealx.AppodealXNetwork.RequestParams,
                @callback as Com.Appodeal.Ads.Unified.UnifiedBannerCallback);
 }
Esempio n. 15
0
        public void OnRefreshed(IEnumerable <TimeStep> timeSteps, IEnumerable <Transport> transports)
        {
            timeStepsCache  = timeSteps.ToArray();
            transportsCache = transports.ToArray();

            if (googleMap == null || Activity == null)
            {
                return;
            }

            List <Transport> unusedTransports = transportMarkers.Keys.ToList();
            AutoResetEvent   autoResetEvent   = new AutoResetEvent(false);

            foreach (Transport transport in transports)
            {
                Marker marker;

                // Create a new marker if needed
                if (!transportMarkers.TryGetValue(transport, out marker))
                {
                    Activity.RunOnUiThread(() =>
                    {
                        MarkerOptions markerOptions = new MarkerOptions()
                                                      .Anchor(0.5f, 0.5f)
                                                      .SetIcon(transportBitmapDescriptor)
                                                      .SetPosition(new LatLng(0, 0));

                        marker = googleMap.AddMarker(markerOptions);
                        transportMarkers.Add(transport, marker);

                        autoResetEvent.Set();
                    });

                    autoResetEvent.WaitOne();
                }
                else
                {
                    unusedTransports.Remove(transport);
                }
            }

            // Clean old markers
            foreach (Transport transport in unusedTransports)
            {
                Marker marker = transportMarkers[transport];
                transportMarkers.Remove(transport);

                Activity.RunOnUiThread(marker.Remove);

                ValueAnimator valueAnimator;
                if (markerAnimators.TryGetValue(marker, out valueAnimator))
                {
                    Activity.RunOnUiThread(valueAnimator.Cancel);
                    markerAnimators.Remove(marker);
                }
            }

            RefreshMarkers();
        }
Esempio n. 16
0
 public override void OnAttach(Android.App.Activity activity)
 {
     base.OnAttach(activity);
     if (this.Arguments != null)
     {
         BindFields(this.Arguments);
     }
 }
Esempio n. 17
0
 public DataAdapter(Android.App.Activity amContext, List <Data> aData, AssetManager asset)
 {
     _mContext = amContext;
     _data     = aData;
     _type     = Typeface.CreateFromAsset(asset, "SourceSansPro-Regular.ttf");
     _bold     = Typeface.CreateFromAsset(asset, "SourceSansPro-Bold.ttf");
     _light    = Typeface.CreateFromAsset(asset, "SourceSansPro-Light.ttf");
 }
Esempio n. 18
0
 public static void getPermission(Android.Content.Context content, Android.App.Activity activity)
 {
     if (ContextCompat.CheckSelfPermission(content, Manifest.Permission.Bluetooth) != (int)Permission.Granted)
     {
         ActivityCompat.RequestPermissions(activity, new string[] { Manifest.Permission.Bluetooth }, 1);
     }
     hasPermission = ContextCompat.CheckSelfPermission(content, Manifest.Permission.Bluetooth) == (int)Permission.Granted;
 }
Esempio n. 19
0
        public TwitterWrapper(Android.App.Activity context, string consumerKey, string consumerSecret, Uri callBack)
        {
            this.ConsumerKey    = consumerKey;
            this.ConsumerSecret = consumerSecret;
            this.CallbackUrl    = callBack;

            cont = context;
        }
Esempio n. 20
0
 public void Refresh(Android.App.Activity ctx)
 {
     //for (int i = 0; i < Count; i++)
     //{
     //    MyOrderTabOnProgressFragment fr = (MyOrderTabOnProgressFragment)GetItem(i);
     //    fr.RefreshItems(ctx);
     //}
 }
        public TripAdapter(Android.App.Activity activity, PastTripsViewModel viewModel)
        {
            this.activity  = activity;
            this.viewModel = viewModel;

            this.viewModel.Trips.CollectionChanged +=
                (sender, e) => { this.activity.RunOnUiThread(NotifyDataSetChanged); };
        }
Esempio n. 22
0
 public MarkerAnimator(Activity activity, Marker marker, Transport transport, Action <LatLng> positionUpdater, CancellationTokenSource cancellationTokenSource)
 {
     this.activity                = activity;
     this.marker                  = marker;
     this.transport               = transport;
     this.positionUpdater         = positionUpdater;
     this.cancellationTokenSource = cancellationTokenSource;
 }
Esempio n. 23
0
 public static BulbPlugin From(Activity activity, List <MimeType> mimeType)
 {
     if (hasInitPicker)
     {
         throw new ExceptionInInitializerError(INITIALIZE_PICKER_ERROR);
     }
     hasInitPicker = true;
     return(new BulbPlugin(activity, null, mimeType));
 }
Esempio n. 24
0
        public void Attach(object context)
        {
            var activity = context as a.App.Activity;

            if (activity != null)
            {
                MainActivity = activity;
            }
        }
Esempio n. 25
0
 public static void showCenterToast(Android.Content.Context ctx, string text, Android.Widget.ToastLength duration)
 {
     Android.App.Activity act = (Android.App.Activity)ctx;
     act.RunOnUiThread(() => {
         Android.Widget.Toast toast = Android.Widget.Toast.MakeText(ctx, text, duration);
         toast.SetGravity(Android.Views.GravityFlags.Center, 0, 0);
         toast.Show();
     });
 }
Esempio n. 26
0
        public void SurfaceChanged(ISurfaceHolder holder, [GeneratedEnum] Format format, int width, int height)
        {
            if (_holder.Surface == null)
            {
                return;
            }
            try
            {
                _camera.StopPreview();
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
            if (_previewSize != null)
            {
                try
                {
                    Android.Hardware.Camera.Parameters parameters = _camera.GetParameters();
                    parameters.SetPreviewSize(_previewSize.Width, _previewSize.Height);
                    parameters.SetPictureSize(_picSize.Width, _picSize.Height);
                    _camera.SetParameters(parameters);
                    _camera.SetPreviewDisplay(_holder);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            Android.App.Activity activity = _context as Android.App.Activity;
            if (activity != null)
            {
                int orientation = CameraHelper.GetCameraDisplayOrientation(activity, _cameraId, displayRotation);
                _camera.SetDisplayOrientation(orientation);
            }

            try
            {
                Parameters parameters = _camera.GetParameters();

                foreach (var previewSize in  _camera.GetParameters().SupportedPreviewSizes)
                {
                    // if the size is suitable for you, use it and exit the loop.
                    parameters.SetPreviewSize(previewSize.Width, previewSize.Height);
                    break;
                }

                _camera.SetParameters(parameters);
                _camera.SetPreviewDisplay(_holder);
                _camera.StartPreview();
            }
            catch (Exception ex)
            {
                Log.Debug(Tag.ToString(), "Error starting camera preview: " + ex.Message);
            }
        }
Esempio n. 27
0
        public void InitAndroid(Android.App.Activity context, Android.Content.Res.AssetManager assetMgr)
        {
            SDK_PlatformAndroid_InitAndroid(CoreObject, Android.Runtime.JNIEnv.Handle, assetMgr.Handle);
            SDK_PlatformAndroid_SetAssetsFileNameCB(mGetAssetsRelativeFileName);

            ExternalFilesDir = context.GetExternalFilesDir(null).AbsolutePath;//这个目录是app再sdcard下的沙箱目录,卸载后会被删除
            //保留AssetManager
            AssetManager = assetMgr;
        }
Esempio n. 28
0
        private static void InitComponent(Android.App.Activity activity)
        {
            DependencyService.Register <IWebViewService, WebViewService>();

            //Instanciate GeckoView type in BlazorMobile assemnly for Android
            BlazorWebViewFactory.SetInternalBlazorGeckoViewType(typeof(BlazorGeckoView));

            BlazorGeckoViewRenderer.Init(activity);
        }
Esempio n. 29
0
        public StringObjAdapter(Android.App.Activity context)
        {
            _context = context;
            _items   = new List <StringObjType>();
            TypedArray typedArray = context.Theme.ObtainStyledAttributes(
                new[] { Android.Resource.Attribute.ColorBackground });

            _backgroundColor = typedArray.GetColor(0, 0xFFFFFF);
        }
Esempio n. 30
0
        private MyAndroidScreenshot(Android.App.Activity activity)
        {
            mAppActivity = activity;

            if (mProjectionManager == null)
            {
                mProjectionManager = (Android.Media.Projection.MediaProjectionManager)mAppActivity.GetSystemService(Android.Content.Context.MediaProjectionService);
            }
        }
        public async Task <AuthenticateResult> AuthenticateAsync(Android.App.Activity view)
#endif
        {
#if DEBUG
            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
#endif
            try
            {
#if DEBUG
                // local server can't process auth, so point to the real one
                if (AlternateLoginHost != null)
                {
                    Client.AlternateLoginHost = AlternateLoginHost;
                }
#endif
                var creds = getItemFromKeychain(AuthProvider.ToString());

                if (string.IsNullOrEmpty(creds.Account) || string.IsNullOrEmpty(creds.PrivateKey))
                {
                    var user = await Client.LoginAsync(view, AuthProvider);

                    if (!string.IsNullOrEmpty(user.UserId) && !string.IsNullOrEmpty(user.MobileServiceAuthenticationToken))
                    {
                        saveItemToKeychain(AuthProvider.ToString(), user.UserId, user.MobileServiceAuthenticationToken);
                    }
                }
                else
                {
                    Client.CurrentUser = new MobileServiceUser(creds.Account)
                    {
                        MobileServiceAuthenticationToken = creds.PrivateKey
                    };
                }

                return(new AuthenticateResult(Authenticated, (Authenticated ? Client.CurrentUser.UserId : null)));

#if !DEBUG
            }
            catch (Exception)
            {
                return(new AuthenticateResult());
#else
            }
            catch (Exception e)
            {
                logDebug($"AuthenticateAsync failed : {(e.InnerException ?? e).Message}");
                return(new AuthenticateResult());
            }
            finally
            {
                sw.Stop();
                logDebug($"AuthenticateAsync took {sw.ElapsedMilliseconds} milliseconds");
#endif
            }
        }
Esempio n. 32
0
		public void UpdateBGFeeds(Android.App.Activity activity)
		{
			this.activity = activity;
Esempio n. 33
0
 public Auth(Android.App.Activity pContext)
 {
     context = pContext;
Esempio n. 34
0
 /// <summary>
 /// 打印测试
 /// </summary>
 /// <param name="activity"></param>
 public BluetoothPrinter(Android.App.Activity activity)
 {
     this.activity = activity;
     //获得本地的蓝牙适配器
     localAdapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
     //打开蓝牙设备
     if (!localAdapter.IsEnabled)
     {
         Android.Content.Intent enableIntent = new Android.Content.Intent(Android.Bluetooth.BluetoothAdapter.ActionRequestEnable);
         activity.StartActivityForResult(enableIntent, 1);
     }
     //静默打开
     if (!localAdapter.IsEnabled)
     {
         localAdapter.Enable();
     }
     if (!localAdapter.IsEnabled)//用户拒绝打开或系统限制权限
     {
         Android.Widget.Toast.MakeText(activity, "蓝牙未打开", Android.Widget.ToastLength.Short).Show();
         return;
     }
     //获得已配对的设备列表
     bondedDevices = new List<Android.Bluetooth.BluetoothDevice>(localAdapter.BondedDevices);
     if (bondedDevices.Count <= 0)
     {
         Android.Widget.Toast.MakeText(activity, "未找到已配对的蓝牙设备", Android.Widget.ToastLength.Short).Show();
         return;
     }
     string[] items = new string[bondedDevices.Count];
     //查看本地已设置的printer名称
     string ls_localPrinterName = baseclass.MyConfig.of_GetMySysSet("printer", "name");
     if (!string.IsNullOrEmpty(ls_localPrinterName))
     {
         for (int j = 0; j < bondedDevices.Count; j++)
         {
             if(ls_localPrinterName== bondedDevices[j].Name)
             {
                 as_BluetoothName = ls_localPrinterName;
                 System.Threading.Thread thr2 = new System.Threading.Thread(new System.Threading.ThreadStart(Printer));
                 thr2.Start(activity);
                 return;
             }
         }
     }
     //弹窗选择
     for (int i = 0; i < bondedDevices.Count; i++)
     {
         items[i] = bondedDevices[i].Name;
     }
     Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(activity);
     builder.SetTitle("请选择打印设备:");
     builder.SetItems(items, new System.EventHandler<Android.Content.DialogClickEventArgs>(items_click));
     builder.SetNegativeButton("取消", delegate { return; });
     builder.Show();
 }
Esempio n. 35
0
 public BluetoothPrinter(Android.App.Activity activity, PrinterType type, string Number)
 {
     this.as_Number = Number;
     this.printerType = type;
     this.activity = activity;
     //获得本地的蓝牙适配器
     localAdapter = Android.Bluetooth.BluetoothAdapter.DefaultAdapter;
     if (string.IsNullOrEmpty(Number))
     {
         Android.Widget.Toast.MakeText(activity, "传入的单号为空,打印失败", Android.Widget.ToastLength.Short).Show();
         return;
     }
     //打开蓝牙设备
     if (!localAdapter.IsEnabled)
     {
         Android.Content.Intent enableIntent = new Android.Content.Intent(Android.Bluetooth.BluetoothAdapter.ActionRequestEnable);
         activity.StartActivityForResult(enableIntent, 1);
     }
     //静默打开
     if (!localAdapter.IsEnabled)
     {
         localAdapter.Enable();
     }
     if (!localAdapter.IsEnabled)//用户拒绝打开或系统限制权限
     {
         Android.Widget.Toast.MakeText(activity, "蓝牙未打开", Android.Widget.ToastLength.Short).Show();
         return;
     }
     //获得已配对的设备列表
     bondedDevices = new List<Android.Bluetooth.BluetoothDevice>(localAdapter.BondedDevices);
     if (bondedDevices.Count <= 0)
     {
         Android.Widget.Toast.MakeText(activity, "未找到已配对的蓝牙设备", Android.Widget.ToastLength.Short).Show();
         return;
     }
     string[] items = new string[bondedDevices.Count];
     for (int i = 0; i < bondedDevices.Count; i++)
     {
         items[i] = bondedDevices[i].Name;
     }
     Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(activity);
     builder.SetTitle("请选择打印设备:");
     builder.SetItems(items, new System.EventHandler<Android.Content.DialogClickEventArgs>(items_click));
     builder.SetNegativeButton("取消", delegate { return; });
     builder.Show();
 }
Esempio n. 36
0
        public TripAdapter(Android.App.Activity activity, PastTripsViewModel viewModel)
        {
            this.activity = activity;
            this.viewModel = viewModel;

            this.viewModel.Trips.CollectionChanged +=
                (sender, e) => { this.activity.RunOnUiThread(NotifyDataSetChanged); };
        }
Esempio n. 37
0
		/// <summary>
		/// Asynchronously retrieves the saved accounts associated with this service.
		/// </summary>
		public virtual Task<IEnumerable<Account>> GetAccountsAsync (UIContext context)
		{
			return Task.Factory.StartNew (delegate {
				return AccountStore.Create (context).FindAccountsForService (ServiceId);
			});
		}
Esempio n. 38
0
		/// <summary>
		/// Gets the necessary UI for the user to sign in to their account.
		/// </summary>
		/// <returns>
		/// A platform-specific UI type for the user to present.
		/// </returns>
		/// <param name="context">The context for the UI.</param>
		/// <param name="completedHandler">A callback for when authentication has completed successfuly.</param>
		public AuthenticateUIType GetAuthenticateUI (UIContext context, Action<Account> completedHandler)
		{
			if (context == null) {
				throw new ArgumentNullException ("context");
			}
			var auth = GetAuthenticator ();
			if (auth == null) {
				throw new NotSupportedException ("Account authentication in is not supported.");
			}
			auth.Completed += (sender, e) => {
				if (e.IsAuthenticated) {
					AccountStore.Create (context).Save (e.Account, ServiceId);
				}
				if (completedHandler != null) {
					completedHandler (e.Account);
				}
			};
			auth.Title = Title;
			return auth.GetUI (context);
		}
Esempio n. 39
0
		/// <summary>
		/// Gets an <see cref="Android.Content.Intent"/> that can be used to start the share activity.
		/// </summary>
		/// <returns>
		/// The <see cref="Android.Content.Intent"/>.
		/// </returns>
		/// <param name='activity'>
		/// The <see cref="Android.App.Activity"/> that will invoke the returned <see cref="Android.Content.Intent"/>.
		/// </param>
		/// <param name='item'>
		/// The item to share.
		/// </param>
		/// <param name='completionHandler'>
		/// Handler called when the share UI has finished.
		/// </param>
		public virtual ShareUIType GetShareUI (UIContext activity, Item item, Action<ShareResult> completionHandler)
		{
			var intent = new Android.Content.Intent (activity, typeof (ShareActivity));
			var state = new ShareActivity.State {
				Service = this,
				Item = item,
				CompletionHandler = completionHandler,
			};
			intent.PutExtra ("StateKey", ShareActivity.StateRepo.Add (state));
			return intent;
		}