private async Task PrepareRecyclerViewAsync() { try { _userId = Helpers.Utilities.GetUserId(); recyclerView = FindViewById <RecyclerView>(Resource.Id.tasks_RecyclerView); recyclerView.SetLayoutManager(_layoutManager); recyclerView.HasFixedSize = true; _tasks = await _taskDataHelper.GetAsync(_userId); _adapter = new TaskViewAdapter(_tasks); _adapter.ItemDeleteClick += Adapter_ItemDeleteClick; _adapter.ItemClick += Adapter_ItemClick; recyclerView.SetAdapter(_adapter); ToggleEmptyView(); } catch (Exception ex) { Log.WriteLine(LogPriority.Error, "Planner Error", ex.Message); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); Cheeseknife.Inject(this); recyclerView.SetLayoutManager(new LinearLayoutManager(this)); adapter = new TaskViewAdapter(new List <Task>(), this); recyclerView.SetAdapter(adapter); }
private async Task PrepareRecyclerViewAsync() { try { recyclerView = FindViewById <RecyclerView>(Resource.Id.tasksView_RecyclerView); recyclerView.SetLayoutManager(_layoutManager); recyclerView.HasFixedSize = true; var tasks = await _taskDataService.GetAsync(); _adapter = new TaskViewAdapter(tasks); recyclerView.SetAdapter(_adapter); } catch (System.Exception ex) { throw ex; } }
async public Task<bool> BtnSaveClickAsync() { // Test if the controls are filled if (GetControlReferences () == false) return false ; if (Validate () == false) return false; _task.Typ = BusinessLayer.UtilityClasses.taskTyps [_spinnerTyp.SelectedItemPosition].ID; _task.Art = BusinessLayer.UtilityClasses.taskArts [_spinnerArt.SelectedItemPosition].ID; // First test if the task is going to be closed if (_task.Status == "0" && _taskStatus[ _spinnerStatus.SelectedItemPosition].StartsWith("1") == true) { // Because the task is been closed, we have to enter the following values _task.User_Close =MainActivity.User.Name; _task.Datum_Close = DateTime.Now.ToString ("dd.MM.yyyy"); _task.Time_Close = DateTime.Now.Hour.ToString ("00") + ":" + DateTime.Now.Minute.ToString ("00"); } else if(_task.ID == null && _taskStatus[_spinnerStatus.SelectedItemPosition].StartsWith("1") == true) { // Because the task is been closed, we have to enter the following values _task.User_Close =MainActivity.User.Name; _task.Datum_Close = DateTime.Now.ToString ("dd.MM.yyyy"); _task.Time_Close = DateTime.Now.Hour.ToString ("00") + ":" + DateTime.Now.Minute.ToString ("00"); } else { _task.User_Close = ""; _task.Datum_Close = ""; _task.Time_Close = "00:00:00,00"; } _task.Status = _taskStatus[ _spinnerStatus.SelectedItemPosition].Substring(0,1); if (_ansprechpartner != null) _task.AnsprechpartnerID = _ansprechpartner.ID; else _task.AnsprechpartnerID = "0"; _task.Adr_Id = _stateClass._person.ID; _task.Datum = _edDatum.Text; _task.Zeit = _edZeit.Text; _task.Mitarbeiter = BusinessLayer.UtilityClasses.mitarbeitern[ _spinnerMitarbeiter.SelectedItemPosition].Name; _task.Abteilung = BusinessLayer.UtilityClasses.abteilungen[ _spinnerAbteilung.SelectedItemPosition].Name; _task.Ansprechpartner = _edAnsprechpartner.Text;//_ansprechpartnern[ _spinnerAnsprechpartner.SelectedItemPosition].Name; _task.Memo = _edText.Text; _task.Datum_Save = _edDatumEdit.Text; _task.User_Save =MainActivity.User.Name; _task.Time_TelStart = _edStartTelefon.Text; _task.Time_TelDauer = _edDauerTelefon.Text; if (string.IsNullOrEmpty ( _task.ID) ) _task.Datum_Edit = DateTime.Now.ToString ("dd.MM.yyyy"); if (_task.ID == null) { // INSERT statement // if we are working with the Offline Database, we have to create a custom ID if (MainActivity.User.NetworkStatus == DataAccessLayer.NetworkState.Disconnected) // "OF" for Offline + Date + Time _task.ID = "OF" + DateTime.Now.ToString("dd.MM.yyyy") + DateTime.Now.ToString("hh:mm:ss"); var result = await _task.SaveAsync(MainActivity.User); if ( result == DataAccessLayer.SOAResult.FALSE || result == DataAccessLayer.SOAResult.Disconnected) return false; _tasks.Insert (0, _task); _edNummer.Text = _task.ID; // Redraw the spinner _spinnerTask = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerTasks); _spinnerTask.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (SpinnerTaskItemSelected ); TaskViewAdapter _adapterTask = new TaskViewAdapter (_mainActivity,_tasks); _spinnerTask.Adapter = _adapterTask; } else { // UPDATE statement var result = await _task.SaveAsync(MainActivity.User); if ( result == DataAccessLayer.SOAResult.FALSE || result == DataAccessLayer.SOAResult.Disconnected) return false; // Redraw the spinner _spinnerTask = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerTasks); _spinnerTask.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (SpinnerTaskItemSelected ); TaskViewAdapter _adapterTask = new TaskViewAdapter (_mainActivity,_tasks); _spinnerTask.Adapter = _adapterTask; _spinnerTask.SetSelection (_selectedIndex); } // Disable the controls DisableControls (); // Configure the buttons if (MainActivity.User.NetworkStatus == DataAccessLayer.NetworkState.Disconnected) ConfigureButtons(permission.Create, permission.Update, false, false, false); else ConfigureButtons(permission.Create , permission.Update, false, false, permission.UpDownload); DataAccessLayer.PerformanceWatch stopWatch = new DataAccessLayer.PerformanceWatch(); return true; }
async public Task ListViewClickAsync() { // Test if the controls are filled if (GetControlReferences () == false) return ; // Disable the controls DisableControls (); // Specific Controls // Test if the controls are filled if (GetControlReferences () == false) return ; _ansprechpartnern = await BusinessLayer.Ansprechpartner.GetAnsprechpartnernAsync ( _stateClass._person.ID, Utilities.GetCurrentLanguage(_mainActivity),MainActivity.User); _tasks = await BusinessLayer.Task.GetTasksAsync ( _stateClass._person.ID,MainActivity.User); _taskStatus = CreateTaskStatusList (UI.Utilities.GetCurrentLanguage(_mainActivity)); // Fill the spinners // Tasks _spinnerTask = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerTasks); TaskViewAdapter _adapterTask = new TaskViewAdapter (_mainActivity, _tasks); _spinnerTask.Adapter = _adapterTask; // Ansprechpartner _spinnerAnsprechpartner = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerAnsprechpartner); _spinnerAnsprechpartner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (SpinnerAnsprechpartnerItemSelected ); AnsprechpartnerViewAdapter _adapterAnsprechpartner = new AnsprechpartnerViewAdapter (_mainActivity,_ansprechpartnern); _spinnerAnsprechpartner.Adapter = _adapterAnsprechpartner; // Art Spinner _spinnerArt = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerArt); ArtViewAdapter _adapterArt = new ArtViewAdapter (_mainActivity, BusinessLayer.UtilityClasses.taskArts); _spinnerArt.Adapter = _adapterArt; // Typ Spinner _spinnerTyp = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerTyp); TypViewAdapter _adapterTyp = new TypViewAdapter (_mainActivity, BusinessLayer.UtilityClasses.taskTyps); _spinnerTyp.Adapter = _adapterTyp; // Status Spinner _spinnerStatus = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerStatus); StringViewAdapter _adapterString = new StringViewAdapter (_mainActivity, _taskStatus); _spinnerStatus.Adapter = _adapterString; // Mitarbeiter Spinner _spinnerMitarbeiter = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerMitarbeiter); _spinnerMitarbeiter.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (SpinnerMitarbeiterItemSelected ); MitarbeiterViewAdapter _adapterMitarbeiter = new MitarbeiterViewAdapter (_mainActivity,BusinessLayer.UtilityClasses.mitarbeitern); _spinnerMitarbeiter.Adapter = _adapterMitarbeiter; // Abteilung Spinner _spinnerAbteilung = _mainActivity.FindViewById<Spinner> (Resource.Id.spinnerAbteilung); AbteilungViewAdapter _adapterAbteilung = new AbteilungViewAdapter (_mainActivity, BusinessLayer.UtilityClasses.abteilungen); _spinnerAbteilung.Adapter = _adapterAbteilung; // Specific Controls if (_tasks.Count > 0) { // Show by default the first item, if there is an item!!! _edDatum.Text = _tasks [_selectedIndex].Datum; _edZeit.Text = _tasks [_selectedIndex].Zeit; _edAnsprechpartner.Text = _tasks [_selectedIndex].Ansprechpartner; _edStartTelefon.Text = _tasks [_selectedIndex].Time_TelStart; _edDauerTelefon.Text = _tasks [_selectedIndex].Time_TelDauer; _edDatumEdit.Text = _tasks [_selectedIndex].Datum_Edit; _edDatumClose.Text = _tasks [_selectedIndex].Datum_Close; _edText.Text = _tasks [_selectedIndex].Memo; _edNummer.Text = _tasks [_selectedIndex].ID; } else { // If not, just clear all controls _task = BusinessLayer.Task.Create (); ResetControls (); } // Configure the buttons if (MainActivity.User.NetworkStatus == DataAccessLayer.NetworkState.Disconnected) ConfigureButtons(permission.Create, false, false, false, false); else ConfigureButtons(permission.Create, false, false, false, permission.UpDownload); return ; }
public override void OnStart () { base.OnStart (); _spinnerTyp = _activity.FindViewById<Spinner>(Resource.Id.spinnerTyp); _spinnerArt = _activity.FindViewById<Spinner>(Resource.Id.spinnerArt); _spinnerStatus = _activity.FindViewById<Spinner> (Resource.Id.spinnerStatus); _spinnerMitarbeiter = _activity.FindViewById<Spinner>(Resource.Id.spinnerMitarbeiter); _spinnerAbteilung = _activity.FindViewById<Spinner>(Resource.Id.spinnerAbteilung); _edNummer = _activity.FindViewById<EditText> (Resource.Id.edNummer); _edDatum = _activity.FindViewById<EditText> (Resource.Id.edDatum); _edZeit = _activity.FindViewById<EditText> (Resource.Id.edZeit); _edAnsprechpartner = _activity.FindViewById<EditText> (Resource.Id.edAnsprechpartner); _edStartTelefon = _activity.FindViewById<EditText> (Resource.Id.edStartTelefon); _edDauerTelefon = _activity.FindViewById<EditText> (Resource.Id.edDauerTelefon); _edDatumEdit = _activity.FindViewById<EditText> (Resource.Id.edDatumEdit); _edDatumClose = _activity.FindViewById<EditText> (Resource.Id.edDatumClose); _edText = _activity.FindViewById<EditText> (Resource.Id.edText); // Fill the spinners // Tasks _spinnerTask = _activity.FindViewById<Spinner> (Resource.Id.spinnerTasks); _spinnerTask.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (_stateFragment.SpinnerTaskItemSelected ); TaskViewAdapter _adapterTask = new TaskViewAdapter (_activity, _stateFragment._tasks); _spinnerTask.Adapter = _adapterTask; _spinnerTask.Touch += SpinnerTask_Touch; // Ansprechpartner _spinnerAnsprechpartner = _activity.FindViewById<Spinner> (Resource.Id.spinnerAnsprechpartner); _spinnerAnsprechpartner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (_stateFragment.SpinnerAnsprechpartnerItemSelected ); AnsprechpartnerViewAdapter _adapterAnsprechpartner = new AnsprechpartnerViewAdapter (_activity, _stateFragment._ansprechpartnern); _spinnerAnsprechpartner.Adapter = _adapterAnsprechpartner; _spinnerAnsprechpartner.Touch += SpinnerAnsprechpartner_Touch; // Art Spinner _spinnerArt = _activity.FindViewById<Spinner> (Resource.Id.spinnerArt); ArtViewAdapter _adapterArt = new ArtViewAdapter (_activity, BusinessLayer.UtilityClasses.taskArts); _spinnerArt.Adapter = _adapterArt; _spinnerArt.Touch += SpinnerArt_Touch; // Typ Spinner _spinnerTyp = _activity.FindViewById<Spinner> (Resource.Id.spinnerTyp); TypViewAdapter _adapterTyp = new TypViewAdapter (_activity, BusinessLayer.UtilityClasses.taskTyps); _spinnerTyp.Adapter = _adapterTyp; _spinnerTyp.Touch += SpinnerTyp_Touch; // Status Spinner _spinnerStatus = _activity.FindViewById<Spinner> (Resource.Id.spinnerStatus); StringViewAdapter _adapterString = new StringViewAdapter (_activity, _stateFragment._taskStatus); _spinnerStatus.Adapter = _adapterString; _spinnerStatus.Touch += SpinnerStatus_Touch; // Mitarbeiter Spinner _spinnerMitarbeiter = _activity.FindViewById<Spinner> (Resource.Id.spinnerMitarbeiter); _spinnerMitarbeiter.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (_stateFragment.SpinnerMitarbeiterItemSelected ); MitarbeiterViewAdapter _adapterMitarbeiter = new MitarbeiterViewAdapter (_activity, BusinessLayer.UtilityClasses.mitarbeitern); _spinnerMitarbeiter.Adapter = _adapterMitarbeiter; _spinnerMitarbeiter.Touch += SpinnerMitarbeiter_Touch; // Abteilung Spinner _spinnerAbteilung = _activity.FindViewById<Spinner> (Resource.Id.spinnerAbteilung); AbteilungViewAdapter _adapterAbteilung = new AbteilungViewAdapter (_activity, BusinessLayer.UtilityClasses.abteilungen); _spinnerAbteilung.Adapter = _adapterAbteilung; _spinnerAbteilung.Touch += SpinnerAbteilung_Touch; // Disable the controls if necessary _stateFragment.GetControlReferences(); if (_edNummer.Enabled == false) _stateFragment.DisableControls(); }
private void FillListView() { if (_positionen != null) { PositionViewAdapter _adapter = new PositionViewAdapter(_activity, _positionen); _listview.Adapter = _adapter; _listview.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { }; } else if (_tasks != null) { TaskViewAdapter adapter = new TaskViewAdapter(_activity, _tasks, Android.Graphics.Color.Black); _listview.Adapter = adapter; _listview.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { _selectedIndex = e.Position; this.Dismiss(); }; } else if (_logs != null) { LogViewAdapter adapter = new LogViewAdapter(_activity, _logs); _listview.Adapter = adapter; _listview.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { _selectedIndex = e.Position; this.Dismiss(); }; } else if (_anschriften != null) { AnschriftViewAdapter adapter = new AnschriftViewAdapter(_activity, _anschriften); _listview.Adapter = adapter; _listview.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) => { _selectedIndex = e.Position; this.Dismiss(); }; } }