示例#1
0
 void ChangeNotifyContent()
 {
     cursor = Db.RawQuery(("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + NoteNumber.ToString()), null);
     notifyFragment.Content = Multitools.GetNameNote(EditText.Text.Split("\n")[0], cursor);
     notifyFragment.ChangeIntent(this);
 }
示例#2
0
        //изменить цвет фона
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            base.GetView(position, convertView, parent);
            string title;

            string[] nameNote;
            if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
            {
                nameNote = Html.FromHtml(Cursor.GetString(Cursor.GetColumnIndex("ColumnText")), FromHtmlOptions.ModeCompact).ToString().Split("\n");
            }
            else
            {
                nameNote = Html.FromHtml(Cursor.GetString(Cursor.GetColumnIndex("ColumnText"))).ToString().Split("\n");
            }
            int IsNotify = Cursor.GetInt(Cursor.GetColumnIndex(Databasehelper.COLUMN_NOTIFY));

            SqlHelper = new Databasehelper(context);
            Db        = SqlHelper.ReadableDatabase;
            if (convertView == null)
            {
                convertView = View.Inflate(context, Resource.Layout.activity_rows, null);
                Cursor.MoveToPosition(position);

                viewHolder = new ViewHolder(convertView);


                convertView.Tag = viewHolder;
            }
            else
            {
                viewHolder = (ViewHolder)convertView.Tag;
            }
            try
            {
                cursor1 = Db.RawQuery("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + GetItemId(position).ToString(), null);
                title   = Multitools.GetNameNote(nameNote[0], cursor1);
            }
            catch { title = nameNote[0]; }
            viewHolder.namenotes.Text = title; //Set Title In List
            if (IsNotify == 1)
            {
                viewHolder.image.Visibility = ViewStates.Visible;
            }
            else
            {
                viewHolder.image.Visibility = ViewStates.Invisible;
            }
            viewHolder.editingTime.Text = Cursor.GetString(Cursor.GetColumnIndex(Databasehelper.COLUMN_EDITINGTIME));
            Color c = new Color(Cursor.GetInt(Cursor.GetColumnIndex(Databasehelper.COLUMN_COLOR)));

            viewHolder.layout.SetBackgroundColor(c);

            if (IsShow)
            {
                viewHolder.checkBox.Visibility = ViewStates.Visible;
            }
            else
            {
                viewHolder.checkBox.Visibility = ViewStates.Invisible;
            }

            if (IsShow)
            {
                viewHolder.checkBox.Checked = IsChecked[position];
            }
            if (!viewHolder.checkBox.HasOnClickListeners)
            {
                viewHolder.checkBox.Click += (sender, e) =>
                {
                    IsChecked[position] = !IsChecked[position];
                }
            }
            ;
            return(convertView);
        }
示例#3
0
        void OnClickAccept(object sender, EventArgs e)
        {
            if ((DateTime.Now.Date == Date && (DateTime.Now.Hour > Hour || DateTime.Now.Hour == Hour && DateTime.Now.Minute >= Minute)) || DateTime.Now.Date > Date) //If current date, check hour is not less current hour, and if current date and hour, check minute
            {
                Toast toast = Toast.MakeText(Context, "Нельзя установить прошедшее время или дату.", ToastLength.Short);
                toast.Show();
            }
            else
            {
                Id = SqlHelper.SaveText(Editable, Args);

                if (Args == null)
                {
                    Args = new Bundle();
                    Args.PutString("_id", Id.ToString());
                }
                cursor  = Db.RawQuery(("select " + Databasehelper.COLUMN_IMGPATH + " from " + Databasehelper.CONTENTTABLE + " where _id == " + Id.ToString()), null);
                Content = Multitools.GetNameNote(Editable.ToString().Split("\n")[0], cursor);
                Calendar calendar = Calendar.Instance;

                calendar.Set(CalendarField.Year, Date.Year);
                calendar.Set(CalendarField.Month, Date.Month - 1);
                calendar.Set(CalendarField.DayOfMonth, Date.Day);
                calendar.Set(CalendarField.HourOfDay, Hour);
                calendar.Set(CalendarField.Minute, Minute);
                calendar.Set(CalendarField.Second, 0);
                NotifyManager notify = new NotifyManager();
                alarm  = (Android.App.AlarmManager)Context.GetSystemService(Context.AlarmService);
                intent = new Intent(Context, typeof(NotifyManager));

                intent.PutExtra("_id", Id);
                intent.PutExtra("message", Content);
                //ChangeIntent(Context);
                pendingIntent = Android.App.PendingIntent.GetBroadcast(Context, Convert.ToInt32(Id), intent, Android.App.PendingIntentFlags.UpdateCurrent);



                if (Convert.ToInt32(Build.VERSION.Sdk) >= 19)
                {
                    alarm.SetExact(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }
                else
                {
                    alarm.Set(Android.App.AlarmType.RtcWakeup, calendar.TimeInMillis, pendingIntent);
                }

                ContentValues cv = new ContentValues();
                cv.Put(Databasehelper.COLUMN_NOTIFY, 1);
                cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.COLUMN_TIME, calendar.TimeInMillis);
                //cv.Put(Databasehelper.START_ID, uniqueId);
                //cv.Put(Databasehelper.NEW_ID, Id); //While id is identific

                Db.Update(Databasehelper.TEXTTABLE, cv, "_id=?", new string[] { Id.ToString() });
                //PrefsEditor.PutBoolean(Id.ToString(), true);
                //PrefsEditor.Apply();


                Dialog.Cancel();
            }
        }