예제 #1
0
 public void DeleteChannel(int setIndex, string channelName, DATA.Platforms channelPlatform)
 {
     SetsList.DeleteChannel(setIndex, channelName, channelPlatform);
     dbHandler.DeleteChannel(setIndex, channelName, channelPlatform);
     ((FragmentEditSets)fragmentPagerAdapter.tabs[1]).UpdateEditSetListView();
     UpdateActionBarSpinner();
 }
예제 #2
0
파일: DBHandler.cs 프로젝트: alidus/Goosent
        /// <summary>
        /// Удалить канал из локальной БД
        /// </summary>
        /// <param name="setIndex"></param>
        /// <param name="channelName"></param>
        /// <param name="channelPlatform"></param>
        public void DeleteChannel(int setIndex, string channelName, DATA.Platforms channelPlatform)
        {
            SQLiteDatabase db   = WritableDatabase;
            var            strs = new string[3] {
                channelName, ((int)channelPlatform).ToString(), (setIndex + 1).ToString()
            };

            db.Delete(CHANNELS_TABLE_NAME, KEY_CHANNEL_NAME + "=? and " + KEY_CHANNEL_PLATFORM + "=? and " + KEY_CHANNEL_SET_ID + "=?", strs);
        }
예제 #3
0
 public void DeleteChannel(int setIndex, string channelName, DATA.Platforms platform)
 {
     try
     {
         _setsList[setIndex].DeleteChannel(channelName, platform);
     }
     catch (Exception)
     {
         Console.WriteLine("Не удалось добавить канал из класса ChannelsSetsList");
     }
 }
예제 #4
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            // Попробовать добавить чат
            string channelName = channelNameEditText.Text;

            DATA.Platforms channelPlatform = (DATA.Platforms)spinner.SelectedItemId;
            if (IsChannelNotInSet(channelName) && IsChannelExist(channelName))
            {
                ((MainActivity)_context).AddChannel(_setIndex, new Channel(channelName, channelPlatform));
                Dismiss();
            }
        }
예제 #5
0
        public bool DeleteChannel(string channelName, DATA.Platforms channelPlatform)
        {
            try
            {
                foreach (Channel channel in _channels)
                {
                    if (channel.Name == channelName && channel.Platform == channelPlatform)
                    {
                        _channels.RemoveAt(_channels.IndexOf(channel));

                        return(true);
                    }
                }

                return(false);
            } catch (Exception)
            {
                throw new Exception("Не удалось удалить чат из набора");

                return(false);
            }
        }
예제 #6
0
파일: Channel.cs 프로젝트: alidus/Goosent
 public Channel(string name, DATA.Platforms platform)
 {
     _name     = name;
     _platform = platform;
 }
예제 #7
0
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            EditSetViewHolder viewHolder = (EditSetViewHolder)holder;

            viewHolder.setNameTextView.Text = _setsList[position].Name;
            // Если карта не была выбрана до этого, но стала выбранной сейчас
            if (!viewHolder.isSelected && ((MainActivity)mContext).SelectedSetIndex == position)
            {
                // Анимация "высоты" карточки
                var cardElevationValueAnimator = ValueAnimator.OfFloat(mContext.Resources.GetDimension(Resource.Dimension.setCardElevation), mContext.Resources.GetDimension(Resource.Dimension.setCardSelectedElevation));
                cardElevationValueAnimator.SetDuration(100);
                cardElevationValueAnimator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) =>
                {
                    viewHolder.setCardView.CardElevation = (float)e.Animation.AnimatedValue;
                };
                cardElevationValueAnimator.Start();

                // Изменение цвета сепаратора
                viewHolder.separatorLine.SetBackgroundColor(mContext.Resources.GetColor(Resource.Color.primary));

                viewHolder.isSelected = true;
            }
            // Карта была выбранной, но сейчас стала обычной
            else if (viewHolder.isSelected && ((MainActivity)mContext).SelectedSetIndex != position)
            {
                // Анимация "высоты" карточки
                var cardElevationValueAnimator = ValueAnimator.OfFloat(mContext.Resources.GetDimension(Resource.Dimension.setCardSelectedElevation), mContext.Resources.GetDimension(Resource.Dimension.setCardElevation));
                cardElevationValueAnimator.SetDuration(100);
                cardElevationValueAnimator.Update += (object sender, ValueAnimator.AnimatorUpdateEventArgs e) =>
                {
                    viewHolder.setCardView.CardElevation = (float)e.Animation.AnimatedValue;
                };
                cardElevationValueAnimator.Start();

                // Изменение цвета сепаратора
                viewHolder.separatorLine.SetBackgroundColor(Android.Graphics.Color.Gray);

                viewHolder.isSelected = false;
            }

            viewHolder.channelsBaseLinearLayout.RemoveAllViews();

            int          currentRowWidth = 0;
            bool         startNewLine    = true;
            int          rowTotalWidth   = 0;
            View         viewInStack     = null;
            LinearLayout rowLinearLayout = null;

            foreach (Channel channel in _setsList[position])
            {
                if (startNewLine)
                {
                    rowLinearLayout = GetNewRowLinearLayout();
                    viewHolder.channelsBaseLinearLayout.AddView(rowLinearLayout);
                    rowTotalWidth = GetWidthOfView(viewHolder.channelsBaseLinearLayout);

                    if (viewInStack != null) // Перенос вьюшки с предыдущей строки
                    {
                        rowLinearLayout.AddView(viewInStack);
                        currentRowWidth += GetWidthOfView(viewInStack);
                        viewInStack      = null;
                    }
                    startNewLine = false;
                }
                View channelView = LayoutInflater.From(mContext).Inflate(Resource.Layout.SetCardView_ChannelView, null);
                channelView.SetTag(Resource.String.channelViewNameStoringTag, channel.Name);    // Добавить информацию о имени канала и платформе в теги вьюшки
                channelView.SetTag(Resource.String.channelViewPlatformStoringTag, (int)channel.Platform);
                channelView.SetTag(Resource.String.channelViewSetIndexStoringTag, position);

                TextView channelTextView = (TextView)channelView.FindViewById(Resource.Id.setCardView_channelViewName_TextView);
                channelTextView.Text = channel.Name;

                currentRowWidth += GetWidthOfView(channelView);

                if (currentRowWidth >= display.Width * 0.9)
                {
                    startNewLine    = true;
                    viewInStack     = channelView;
                    currentRowWidth = 0;
                }
                else
                {
                    rowLinearLayout.AddView(channelView);
                }



                // Добавить синюю рамку каналам, если сет выделен
                if (((MainActivity)mContext).SelectedSetIndex == position)
                {
                    channelTextView.SetBackgroundDrawable(mContext.Resources.GetDrawable(Resource.Drawable.setCardView_channelSelectedViewBackground));
                }
                else
                {
                    channelTextView.SetBackgroundDrawable(mContext.Resources.GetDrawable(Resource.Drawable.setCardView_channelViewBackground));
                }

                channelView.LongClick += (object sender, View.LongClickEventArgs e) =>
                {
                    int            setIndex    = (int)channelView.GetTag(Resource.String.channelViewSetIndexStoringTag);
                    string         channelName = (string)channelView.GetTag(Resource.String.channelViewNameStoringTag);
                    DATA.Platforms platform    = (DATA.Platforms)(int) channelView.GetTag(Resource.String.channelViewPlatformStoringTag);

                    ((MainActivity)mContext).DeleteChannel(setIndex, channelName, platform);
                };
            }

            // Добавить кнопку добавления канала
            View     addChannelView     = LayoutInflater.From(mContext).Inflate(Resource.Layout.SetCardView_ChannelView, null);
            TextView addChannelTextView = (TextView)addChannelView.FindViewById(Resource.Id.setCardView_channelViewName_TextView);

            addChannelTextView.Text = mContext.Resources.GetString(Resource.String.add_channel_view_text);
            addChannelTextView.SetBackgroundColor(mContext.Resources.GetColor(Resource.Color.accentColor));
            addChannelTextView.SetTextColor(Android.Graphics.Color.White);
            currentRowWidth += GetWidthOfView(addChannelView);

            if (currentRowWidth >= display.Width * 0.9 || viewHolder.channelsBaseLinearLayout.ChildCount == 0)
            {
                rowLinearLayout = GetNewRowLinearLayout();
                viewHolder.channelsBaseLinearLayout.AddView(rowLinearLayout);
                rowLinearLayout.AddView(addChannelView);
            }
            else
            {
                rowLinearLayout.AddView(addChannelView);
            }

            addChannelView.Click += (object sender, EventArgs e) =>
            {
                Fragments.AddChatDialogFragment addChatDialogFragment = Fragments.AddChatDialogFragment.GetInstance(position);
                addChatDialogFragment.Show(((Activity)mContext).FragmentManager, "Adding chat to set " + position.ToString());
            };
        }