public override bool OnOptionsItemSelected(IMenuItem item) {
                Android_Content.ContentResolver cr = GetActivity().GetContentResolver();

                switch (item.GetItemId()) {
                    case POPULATE_ID:
                        if (mPopulatingTask != null) {
                            mPopulatingTask.Cancel(false);
                        }
                        mPopulatingTask = new PopulateAsyncTask(cr);

                        mPopulatingTask.Execute((object[]) null);
                        return true;

                    case CLEAR_ID:
                        if (mPopulatingTask != null) {
                            mPopulatingTask.Cancel(false);
                            mPopulatingTask = null;
                        }
                        AsyncTask<object, object, object> task = new ClearAsyncTask(cr);
                        task.Execute((object[])null);
                        return true;

                    default:
                        return base.OnOptionsItemSelected(item);
                }
            }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            initBundle = bundle;
            Instance   = this;

            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;


            var name     = typeof(Model.Message).Name;                                        // "Message"
            var messages = this.Intent.GetStringExtra(name);                                  // "messages"

            System.Collections.Generic.List <Model.Message> messageList = null;

            if (messages != null)
            {
                messageList = Api.MessageReceiver.Deserialize(messages);
                // Api.LowLevelApi.Instance.ShowNotification(messageList.Count.ToString(), messageList.First().Address);
            }

            InstanceResolver = this.ContentResolver;

            base.OnCreate(bundle);

            Xamarin.Essentials.Platform.Init(
                XxmsApp.Droid.MainActivity.Instance,
                XxmsApp.Droid.MainActivity.Instance.initBundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);

            var application = new App(messageList);

            LoadApplication(application);

            try
            {
                // LoadApplication(application);
            }
            catch (Exception ex)
            {
                var exc = ex;
            }


            // CreateMessageStateListener();

            // set in App.xaml:
            // Xamarin.Forms.Application.Current.On<Xamarin.Forms.PlatformConfiguration.Android>()
            // .UseWindowSoftInputModeAdjust(WindowSoftInputModeAdjust.Resize);
        }
                public ClearAsyncTask(Android_Content.ContentResolver cr)
	            {
                    this.cr = cr;
	            }
                public PopulateAsyncTask(Android_Content.ContentResolver cr)
	            {
                    this.cr = cr;
	            }