Example #1
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                if (viewHolder is LastChatAdapterViewHolder holder)
                {
                    var item = UserList[position];
                    if (item != null)
                    {
                        Initialize(holder, item);

                        holder.LytParent.Activated = SelectedItems.Get(position, false);

                        if (!holder.LytParent.HasOnClickListeners)
                        {
                            holder.LytParent.Click += delegate
                            {
                                try
                                {
                                    if (ClickListener == null)
                                    {
                                        return;
                                    }

                                    ClickListener.ItemClick(holder.MainView, item, position);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            };

                            holder.LytParent.LongClick += delegate
                            {
                                try
                                {
                                    if (ClickListener == null)
                                    {
                                        return;
                                    }

                                    ClickListener.ItemLongClick(holder.MainView, item, position);
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            };
                        }


                        ToggleCheckedIcon(holder, position);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #2
0
        private static int[] AsIntArray(SparseBooleanArray checkedItems)
        {
            int num = 0;

            // compute number of items
            for (int i = 0; i < checkedItems.Size(); i++)
            {
                int key = checkedItems.KeyAt(i);
                if (checkedItems.Get(key))
                {
                    ++num;
                }
            }

            int[] array = new int[num];
            //add indexes that are checked
            for (int i = 0, j = 0; i < checkedItems.Size(); i++)
            {
                int key = checkedItems.KeyAt(i);
                if (checkedItems.Get(key))
                {
                    array[j++] = key;
                }
            }
            Java.Util.Arrays.Sort(array);
            return(array);
        }
Example #3
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder viewHolder, int position)
        {
            try
            {
                int type = GetItemViewType(position);
                var item = MessageList[type];
                if (item != null)
                {
                    if (viewHolder is TextViewHolder holder)
                    {
                        Initialize(holder, item);

                        holder.LytParent.Activated = SelectedItems.Get(position, false);

                        holder.LytParent.Click += delegate
                        {
                            try
                            {
                                if (OnClickListener == null)
                                {
                                    return;
                                }

                                OnClickListener.OnItemClick(holder.LytParent, item, position);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        };

                        holder.LytParent.LongClick += delegate
                        {
                            try
                            {
                                if (OnClickListener == null)
                                {
                                    return;
                                }

                                OnClickListener.OnItemLongClick(holder.LytParent, item, position);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        };

                        ToggleCheckedBackground(holder, position);
                    }
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #4
0
        public void OnComplete(Task task)
        {
            if (task.IsSuccessful)
            {
                // add the profile stuff here
                new AddProfile(title, email, staffid, college, department, name, this).Execute(Common.getAddresApiProfile());

                String             selected           = "";
                int                cntChoice          = courseListView.Count;
                SparseBooleanArray sparseBooleanArray = courseListView.CheckedItemPositions;
                for (int i = 0; i < cntChoice; i++)
                {
                    if (sparseBooleanArray.Get(i))
                    {
                        // upload to mongo db one after the oder
                        new AddCourse(courseListView.GetItemAtPosition(i).ToString(), this).Execute(Common.getAddresApiCourses());

                        selected += courseListView.GetItemAtPosition(i).ToString() + "\n";
                    }
                }
                Android.Widget.Toast.MakeText(this, "Your registration is now complete", Android.Widget.ToastLength.Short).Show();
                signupCoursespgb.Visibility    = ViewStates.Gone;
                signupCoursesHolder.Visibility = ViewStates.Visible;
                StartActivity(typeof(MainActivity));
                Finish();
            }
            else
            {
                NetworkInfo networkInfo = connectivityManager.ActiveNetworkInfo;
                try
                {
                    bool isOnline = networkInfo.IsConnected;

                    if (isOnline == true)
                    {
                        Toast.MakeText(this, "Sorry Could not signup try again", Android.Widget.ToastLength.Short).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Connect to the internet and try again!", Android.Widget.ToastLength.Long).Show();
                    }
                }
                catch (Exception e)
                {
                    Toast.MakeText(this, "Connect to the internet and try again!", Android.Widget.ToastLength.Long).Show();
                }
            }
        }
        private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            SparseBooleanArray checkeds = listView.CheckedItemPositions;
            int num_selected            = 0;

            for (int i = 0; i < checkeds.Size(); i++)
            {
                if (checkeds.ValueAt(i))
                {
                    num_selected++;
                    int  key   = checkeds.KeyAt(i);
                    bool value = checkeds.Get(key);
                    if (value)
                    {
                        //
                    }
                }
            }
        }
        public void OnClick(View v)
        {
            if (v.Id == Resource.Id.addanddropdone)
            {
                String             selected           = "";
                int                cntChoice          = courseListView.Count;
                SparseBooleanArray sparseBooleanArray = courseListView.CheckedItemPositions;
                for (int i = 0; i < cntChoice; i++)
                {
                    if (sparseBooleanArray.Get(i))
                    {
                        // upload to mongo db one after the oder
                        new AddCourse(courseListView.GetItemAtPosition(i).ToString(), this).Execute(Common.getAddresApiCourses());

                        selected += courseListView.GetItemAtPosition(i).ToString() + "\n";
                    }
                }
                Android.Widget.Toast.MakeText(this, "Your registration is now complete", Android.Widget.ToastLength.Short).Show();
            }
        }
        private void saveEntries()
        {
            if (etNumbOfLesson.Text.Equals("") || etRoom.Text.Equals(""))
            {
                Toast.MakeText(context, "Fill in all the fields", ToastLength.Long).Show();
                return;
            }

            if (DataBaseHelper.ContainsEntry(userGroupID, Int32.Parse(etNumbOfLesson.Text), date))
            {
                Toast.MakeText(context, "Entry with this lesson number already exists", ToastLength.Long).Show();
                return;
            }

            SparseBooleanArray sbArray = lvEntry.CheckedItemPositions;
            int         i        = 0;
            CultureInfo provider = CultureInfo.InvariantCulture;

            foreach (Entry entry in entries)
            {
                entry.EntryDate      = DateTime.Parse(tvDate.Text);
                entry.NumberOfLesson = Int32.Parse(etNumbOfLesson.Text);
                entry.Room           = Int32.Parse(etRoom.Text);
                entry.Professor      = professors.ElementAt(spProfessor.SelectedItemPosition);
                entry.Subject        = subjects.ElementAt(spSubject.SelectedItemPosition);
                if (sbArray.Get(i))
                {
                    entry.Mark = 1;
                }
                DataBaseHelper.AddNewEntry(entry);
                i++;
                //System.Diagnostics.Debug.WriteLine(entry.Student.Name + " " + entry.Mark);
            }

            Toast.MakeText(context, "New entry saved successfully", ToastLength.Long).Show();
            FragmentManager.BeginTransaction()
            .Replace(Resource.Id.content_frame, new LeaderDayFragment())
            .Commit();
        }
        public void OnItemCheckedStateChanged(ActionMode mode, int position, long id, bool @checked)
        {
            if (this.activeMode != null)
            {
                if (this.behavior == SINGLE_SELECT && this.ListView.CheckedItemCount > 1)
                {
                    SparseBooleanArray checkarr = this.ListView.CheckedItemPositions;
                    for (var i = 0; i < this.ListView.Adapter.Count; i++)
                    {
                        /*
                         * check item is checked
                         * and not the last item
                         */
                        if (checkarr.Get(i) && position != i)
                        {
                            this.ListView.SetItemChecked(i, false);
                            break;
                        }
                    }
                }

                UpdateSubtitle(mode);
            }
        }
        private void LoadTextOfChatItem(TextViewHolder holder, int position, GetChatConversationsObject.Messages item)
        {
            try
            {
                try
                {
                    if (holder.Time.Text != item.CreatedAt)
                    {
                        DateTime time = Methods.Time.UnixTimeStampToDateTime(int.Parse(item.CreatedAt));
                        holder.Time.Text = time.ToShortTimeString();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

                holder.TextSanitizerAutoLink.Load(Methods.FunString.DecodeString(item.Text), item.Type);

                holder.LytParent.Activated = SelectedItems.Get(position, false);

                if (!holder.LytParent.HasOnClickListeners)
                {
                    holder.LytParent.Click += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemClick(holder.LytParent, item, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };

                    holder.LytParent.LongClick += delegate
                    {
                        try
                        {
                            if (ClickListener == null)
                            {
                                return;
                            }

                            ClickListener.ItemLongClick(holder.LytParent, item, position);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    };
                }


                ToggleCheckedBackground(holder, position);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }