// populate UserAlert object with data from screen controls & set Property with this UserAlert object private void BtnSetPersonalAlert_Click(object sender, EventArgs e) { // Perform Validation if (editTxtTitle.Text == string.Empty) { editTxtTitle.RequestFocus(); editTxtTitle.Hint = GetString(Resource.String.personalAlertsActivity_validation_message_enterTitle); } else if (editTxtDescription.Text == string.Empty || editTxtDescription.Text.Length >200) { editTxtDescription.RequestFocus(); editTxtDescription.Text = ""; editTxtDescription.Hint = GetString(Resource.String.personalAlertsActivity_validation_message_enterDescription); } else if (dateIsSet == false) { txtDate.Text = GetString(Resource.String.personalAlertsActivity_validation_message_setDate); btnSetDate.RequestFocus(); } else if (timeIsSet == false) { txtTime.Text = GetString(Resource.String.personalAlertsActivity_validation_message_setTime); btnSetTime.RequestFocus(); } else { // validation is successful UserAlert userAlert = new UserAlert { // don't add ID here - SQLite will do this automatically (auto-increment) Title = editTxtTitle.Text, DescriptionOfPersonalEvent = editTxtDescription.Text, CountryChar = GetString(Resource.String.personalAlertsActivity_personalAlertName), MarketImpact = GetString(Resource.String.personalAlertsActivity_personalAlertName_impact), IsPersonalAlert = true, // convert DateTime object to a ticks (long) DateInTicks = combinedDateTimeObject.Ticks }; Log.Debug("DEBUG", "\n\n\n" + userAlert.ToString() + "\n\n\n"); // reset appropriate validation dateIsSet = false; timeIsSet = false; // call Property in UserAlertActivity to pass data across (newsObject) UserAlertsActivity.SelectedUserAlert_PassedFrom_PersonalAlertsActivity = userAlert; // call intent to start next activity Intent intent = new Intent(this, typeof(UserAlertsActivity)); StartActivity(intent); } }
//public NewsObject_RecycleAdapter mAdapter; protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.UserAlert); //// Dummy Data //userAlertDisplayList = SetUpData.DummyDataForUserAlert(); // Get our RecyclerView layout: mRecyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView_UserAlert); //............................................................ // Layout Manager Setup: // Use the built-in linear layout manager: mLayoutManager = new LinearLayoutManager(this); // Or use the built-in grid layout manager (two horizontal rows): //mLayoutManager = new GridLayoutManager // (this, 2, GridLayoutManager.Horizontal, false); // Plug the layout manager into the RecyclerView: mRecyclerView.SetLayoutManager(mLayoutManager); //............................................................ // Adapter Setup: // Create an adapter for the RecyclerView, and pass it the // data set (List<userAlert>) to manage: mAdapter = new UserAlerts_RecycleAdapter(userAlertDisplayList); //Register the item click handler(below) with the adapter: mAdapter.ItemClick += MAdapter_ItemClick; // Plug the adapter into the RecyclerView: mRecyclerView.SetAdapter(mAdapter); //----------------------------------------------------------------------------------- // ToolBar - Top of Screen (method 1) var toolbar = FindViewById <Toolbar>(Resource.Id.userAlertsActivity_top_toolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.userAlertsActivity_top_toolbar_title); // Toolbar - Bottom of Screen (method 2) var toolbar_bottom = FindViewById <Toolbar>(Resource.Id.userAlertsActivity_bottom_toolbar); toolbar_bottom.Title = GetString(Resource.String.userAlertsActivity_bottom_toolbar_title); toolbar_bottom.InflateMenu(Resource.Menu.userAlertsActivity_bottomMenu); toolbar_bottom.MenuItemClick += (sender, e) => { switch (e.Item.ItemId) { case Resource.Id.userAlertsActivity_bottom_toolbar_option_personalAlerts: // call intent to start next activity Intent intent = new Intent(this, typeof(PersonalAlertsActivity)); StartActivity(intent); break; } }; // This code ONLY runs if - user selects to add an alert to a newsObject in Main Activity if (SelectedNewsObject_PassedFrom_MainActivity != null) { Log.Debug("DEBUG", "\n\n\n" + SelectedNewsObject_PassedFrom_MainActivity.ToString() + "\n\n\n"); // avoid null error if UserAlertTable doesn't exist - won't overwrite if it does DataAccessHelpers.CreateEmptyUserAlertTable(); UserAlert convertedUserAlert = DataAccessHelpers.ConvertNewsObjectToUserAlert(SelectedNewsObject_PassedFrom_MainActivity); Log.Debug("DEBUG", convertedUserAlert.ToString()); // store UserAlert in database & get its ID number - // need ID of UserAlert from DB at this mmoment for creating alarm code int userID_fromDB = DataAccessHelpers.AddNewUserAlertToDatabase(convertedUserAlert); Log.Debug("DEBUG", "UserAlertActivity says - new UserID from DB: " + userID_fromDB + "\n\n"); Log.Debug("DEBUG", "FINISHED\n\n\n"); // call SetAlarm() here ..... SetAlarm(convertedUserAlert); Log.Debug("DEBUG", "\n\n\npause for breakpoint\n\n\n"); } // This code ONLY runs if - user selects to add a Personal Alert in PersonalAlerts Activity if (SelectedUserAlert_PassedFrom_PersonalAlertsActivity != null) { Log.Debug("DEBUG", "\n\n\n" + SelectedUserAlert_PassedFrom_PersonalAlertsActivity.ToString() + "\n\n\n"); // avoid null error if UserAlertTable doesn't exist - won't overwrite if it does DataAccessHelpers.CreateEmptyUserAlertTable(); // before calling AddNewUserAlertToDatabase() make a copy of UserAlert as its corresponding // property will be set to null - use copy for SetAlarm() UserAlert tempUserAlertToSetAlarmWith = SelectedUserAlert_PassedFrom_PersonalAlertsActivity; // store UserAlert in database & get its ID number - // need ID of UserAlert from DB at this mmoment for creating alarm code int userID_fromDB = DataAccessHelpers.AddNewUserAlertToDatabase(SelectedUserAlert_PassedFrom_PersonalAlertsActivity); Log.Debug("DEBUG", "\n\n\nUserAlertActivity says - new UserID from DB: " + userID_fromDB + "\n\n\n"); // // call SetAlarm() here ..... SetAlarm(tempUserAlertToSetAlarmWith); Log.Debug("DEBUG", "\n\n\npause for breakpoint\n\n\n"); } PopulateUserAlertAdapter(); }// end OnCreate