Пример #1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                //Wrong:
                //var intent = new Intent(this, typeof(HomeView));
                //intent.AddFlags(ActivityFlags.ClearTop);
                //StartActivity(intent);
                NavUtils.NavigateUpFromSameTask(this);

                //if this could be launched externally:

                /*
                 * var upIntent = NavUtils.GetParentActivityIntent(this);
                 * if (NavUtils.ShouldUpRecreateTask(this, upIntent))
                 * {
                 *  Android.Support.V4.App.TaskStackBuilder.Create(this).
                 *      AddNextIntentWithParentStack(upIntent).
                 *      StartActivities();
                 * }
                 * else
                 * {
                 *  NavUtils.NavigateUpTo(this, upIntent);
                 * }
                 */
                break;
            }

            return(base.OnOptionsItemSelected(item));
        }
Пример #2
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item == null)
            {
                return(false);
            }

            switch (item.ItemId)
            {
            case global::Android.Resource.Id.Home:
                NavUtils.NavigateUpFromSameTask(this);

                return(true);

            case Resource.Id.action_refresh_log:
                RefreshLog();

                return(true);

            case Resource.Id.action_clear_log:
                UserLog.Clear();
                RefreshLog();

                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     switch (item.ItemId)
     {
     case Android.Resource.Id.Home:
         NavUtils.NavigateUpFromSameTask(this);
         break;
     }
     return(base.OnOptionsItemSelected(item));
 }
Пример #4
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId == Resource.Id.home)
            {
                NavUtils.NavigateUpFromSameTask(this);
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
        /*
         * public override void OnListItemClick(ListView l, global::Android.Views.View v, int position, long id)
         * {
         *  int pos = _adapter.SectionedPositionToPosition(position);
         *  HenspeRowModel henspeRowModel = _itemsAdapter[pos];
         * }
         */

        /*
         * public override void OnCreateOptionsMenu(IMenu menu, MenuInflater inflater)
         * {
         * inflater.Inflate(Resource.Menu.MenuHome, menu);
         * }
         */

        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.homeMenuItem:
                NavUtils.NavigateUpFromSameTask(this.Activity);
                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
Пример #6
0
        public override bool OnOptionsItemSelected(ActionbarSherlock.View.IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                if (this is HomeActivity)
                {
                    return(false);
                }

                NavUtils.NavigateUpFromSameTask(this);
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
Пример #7
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                NavUtils.NavigateUpFromSameTask(this);
                break;

            case Resource.Id.new_mic:
                //AddSound();
                CheckMicOnline(PostMicCheck.AddSound);
                break;
            }

            return(base.OnOptionsItemSelected(item));
        }
Пример #8
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item == null)
            {
                return(false);
            }

            switch (item.ItemId)
            {
            case global::Android.Resource.Id.Home:
                NavUtils.NavigateUpFromSameTask(this);

                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
Пример #9
0
 public override bool OnSupportNavigateUp()
 {
     Android.Content.Intent upIntent = NavUtils.GetParentActivityIntent(this);
     if (upIntent == null)
     {
         NavUtils.NavigateUpFromSameTask(this);
         return(true);
     }
     if (NavUtils.ShouldUpRecreateTask(this, upIntent))
     {
         // this activity is not part of this app's task
         global::Android.Support.V4.App.TaskStackBuilder.Create(this).AddNextIntentWithParentStack(upIntent).StartActivities();
     }
     else
     {
         // this activity is part of this app's task
         NavUtils.NavigateUpTo(this, upIntent);
     }
     return(true);
 }
Пример #10
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:

                NavUtils.NavigateUpFromSameTask(this);

                //Wrong:
                //var intent = new Intent(this, typeof(HomeView));
                //intent.AddFlags(ActivityFlags.ClearTop);
                //StartActivity(intent);


                //if this could be launched externally:

                /*var upIntent = NavUtils.GetParentActivityIntent(this);
                 * if (NavUtils.ShouldUpRecreateTask(this, upIntent))
                 * {
                 *      // This activity is NOT part of this app's task, so create a new task
                 *      // when navigating up, with a synthesized back stack.
                 *      Android.Support.V4.App.TaskStackBuilder.Create(this).
                 *              AddNextIntentWithParentStack(upIntent).StartActivities();
                 * }
                 * else
                 * {
                 *      // This activity is part of this app's task, so simply
                 *      // navigate up to the logical parent activity.
                 *      NavUtils.NavigateUpTo(this, upIntent);
                 * }*/

                break;
            }

            return(base.OnOptionsItemSelected(item));
        }
 public void NavigateUp()
 {
     NavUtils.NavigateUpFromSameTask(this);
 }
Пример #12
0
        public void RequestAddMic()
        {
            var progress = Acr.UserDialogs.UserDialogs.Instance.Progress("Registering mic...");

            string hwid = Android.OS.Build.Serial;

            var SharedSettings = new Dictionary <String, String>();
            var prefs          = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();
            String gcmID     = prefs.GetString("GCMID", "");
            var    wavioId   = prefs.GetString("NewWavoID", "");
            var    wavioName = prefs.GetString("NewWavioName", "");

            try
            {
                if (string.IsNullOrEmpty(wavioId))
                {
                    if (progressDialog != null)
                    {
                        progressDialog.Dismiss();
                    }
                    Acr.UserDialogs.UserDialogs.Instance.ErrorToast("Error: No ID given!");
                    return;
                }
                if (string.IsNullOrEmpty(gcmID))
                {
                    if (progressDialog != null)
                    {
                        progressDialog.Dismiss();
                    }
                    Acr.UserDialogs.UserDialogs.Instance.ErrorToast("Error: No GCM ID!");
                    return;
                }

                var client     = new RestClient(Shared.SERVERURL);
                var request    = new RestRequest("resource/{id}", Method.POST);
                var parameters = new Dictionary <string, string>();

                parameters.Add(Shared.ParamType.REQUEST_CODE, Shared.RequestCode.REGISTER_MIC.ToString());
                parameters.Add(Shared.ParamType.WAVIO_ID, wavioId);
                parameters.Add(Shared.ParamType.GCM_ID, gcmID);
                parameters.Add(Shared.ParamType.HWID, hwid);
                string requestJson = JsonConvert.SerializeObject(parameters);
                request.AddParameter(Shared.ParamType.REQUEST, requestJson);

                Console.WriteLine("Waiting for response");


                client.ExecuteAsync(request, response => {
                    ServerResponse serverResponse = JsonConvert.DeserializeObject <ServerResponse>(response.Content);

                    if (serverResponse == null)
                    {
                        if (progressDialog != null)
                        {
                            progressDialog.Dismiss();
                        }
                        Acr.UserDialogs.UserDialogs.Instance.ShowError("Network error!");
                        return;
                    }

                    progress.Hide();

                    if (serverResponse.error == Shared.ServerResponsecode.OK)
                    {
                        if (progressDialog != null)
                        {
                            progressDialog.Dismiss();
                        }
                        var saveSuccess = MicsManager.AddMicToPreferences(wavioId, wavioName);
                        if (saveSuccess)
                        {
                        }
                        editor.PutBoolean("settings_changed", true);

                        editor.PutBoolean("mic_added", true);
                        editor.Apply();

                        NavUtils.NavigateUpFromSameTask(this);
                    }
                    else if (serverResponse.error == Shared.ServerResponsecode.DATABASE_ERROR)
                    {
                        if (progressDialog != null)
                        {
                            progressDialog.Dismiss();
                        }
                        Acr.UserDialogs.UserDialogs.Instance.ShowError("Server error!");
                    }
                    else
                    {
                        if (serverResponse.request != Shared.RequestCode.REGISTER_MIC)
                        {
                            if (progressDialog != null)
                            {
                                progressDialog.Dismiss();
                            }
                            Acr.UserDialogs.UserDialogs.Instance.ShowError("Request type mismatch!");
                            return;
                        }
                        if (progressDialog != null)
                        {
                            progressDialog.Dismiss();
                        }
                        Acr.UserDialogs.UserDialogs.Instance.ShowError("Unknown error!");
                    }
                    return;
                });
            }
            catch (WebException ex)
            {
                string _exception = ex.ToString();
                if (progressDialog != null)
                {
                    progressDialog.Dismiss();
                }
                Acr.UserDialogs.UserDialogs.Instance.ShowError("Network error!");
                Console.WriteLine("--->" + _exception);
            }
        }