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(); }
/// <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); }
public void DeleteChannel(int setIndex, string channelName, DATA.Platforms platform) { try { _setsList[setIndex].DeleteChannel(channelName, platform); } catch (Exception) { Console.WriteLine("Не удалось добавить канал из класса ChannelsSetsList"); } }
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(); } }
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); } }
public Channel(string name, DATA.Platforms platform) { _name = name; _platform = platform; }
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()); }; }