public void OnResume() { base.OnResume(); // Always call the superclass first. mics = new List <SavedMic>(); mics = MicsManager.GetMicsFromPreferences(); //refresh listview? }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); //string micId = savedInstanceState.GetString("mic_id"); //string micId = base.GetString("mic_id"); string micId = Intent.GetStringExtra("mic_id"); string micName = MicsManager.GetMicsFromPreferences().FirstOrDefault(e => e.WavioId == micId).Name; SetContentView(Resource.Layout.page_settings); var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); toolbar.Title = micName; MicSettingsFragment fragment = new MicSettingsFragment(micId, this); SupportFragmentManager.BeginTransaction() .Replace(Resource.Id.content_frame, fragment) .Commit(); }
private void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e) { //Toast.MakeText(this, "Item " + e.Position, ToastLength.Short).Show(); //throw new NotImplementedException(); var intent = new Intent(this, typeof(MicSettingsActivity)); intent.PutExtra("mic_id", MicsManager.GetMicsFromPreferences()[(int)e.Id].WavioId); StartActivity(intent); }
void SetupTabs() { var micNames = MicsManager.GetMicsFromPreferences().Select(e => e.Name).ToList(); micNames.Insert(0, "All"); var micIds = MicsManager.GetMicsFromPreferences().Select(e => e.WavioId).ToList(); micIds.Insert(0, "All"); adapter = new TabbedNotifsAdapter(home, ChildFragmentManager, micNames.ToArray(), micIds.ToArray()); viewPager.Adapter = adapter; tabs.SetupWithViewPager(viewPager); }
private void UpdateMics() { var micNames = MicsManager.GetMicsFromPreferences().Select(e => e.Name).ToList(); micNames.Insert(0, "All"); var micIds = MicsManager.GetMicsFromPreferences().Select(e => e.WavioId).ToList(); micIds.Insert(0, "All"); var same = micIds.SequenceEqual(mics); if (!same) { mics = micIds; adapter.SetTabs(micNames.ToArray(), micIds.ToArray()); adapter.NotifyDataSetChanged(); } }
protected override void OnCreate(Android.OS.Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.page_mics); imageLoader = ImageLoader.Instance; var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); mics = MicsManager.GetMicsFromPreferences(); mRegistrationBroadcastReceiver = new Shared.BroadcastReceiver(); mRegistrationBroadcastReceiver.Receive += (sender, e) => { //progressDialog.Dismiss(); var result = e.Intent.GetBooleanExtra("gcm_success", false); if (result) { if (waitingForGCM) { waitingForGCM = false; RequestAddMic(); } } }; LocalBroadcastManager.GetInstance(this).RegisterReceiver(mRegistrationBroadcastReceiver, new IntentFilter("registrationComplete")); listView = FindViewById <ListView>(Resource.Id.micsListView); listView.ItemClick += OnListItemClick; listView.Adapter = new MicAdapter(this, mics); //var grid = FindViewById<GridView>(Resource.Id.grid); //grid.Adapter = new MonkeyAdapter(this, friends); //grid.ItemClick += GridOnItemClick; }
public void RequestDeleteMic() { var progress = Acr.UserDialogs.UserDialogs.Instance.Progress("Deleting 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", ""); try { if (string.IsNullOrEmpty(micId)) { Acr.UserDialogs.UserDialogs.Instance.ErrorToast("Error: No ID given!"); return; } if (string.IsNullOrEmpty(gcmID)) { 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.UNREGISTER_MIC.ToString()); parameters.Add(Shared.ParamType.WAVIO_ID, micId); 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) { Acr.UserDialogs.UserDialogs.Instance.ShowError("Network error!"); return; } progress.Hide(); if (serverResponse.error == Shared.ServerResponsecode.OK) { var saveSuccess = MicsManager.RemoveMicFromPreferences(micId); if (saveSuccess) { } editor.PutBoolean("settings_changed", true); editor.PutBoolean("mic_added", true); editor.Apply(); parent.NavigateUp(); } else if (serverResponse.error == Shared.ServerResponsecode.DATABASE_ERROR) { Acr.UserDialogs.UserDialogs.Instance.ShowError("Server error!"); } else { if (serverResponse.request != Shared.RequestCode.UNREGISTER_MIC) { Acr.UserDialogs.UserDialogs.Instance.ShowError("Request type mismatch!"); return; } Acr.UserDialogs.UserDialogs.Instance.ShowError("Unknown error!"); } return; }); } catch (WebException ex) { string _exception = ex.ToString(); Acr.UserDialogs.UserDialogs.Instance.ShowError("Network error!"); Console.WriteLine("--->" + _exception); } }