Я пишу проект для Android, который даст пользователю зелье для выбора дня и времени дня, чтобы получить комнату для занятий в городе, если она доступна. Я использую RecyclelerView, чтобы дать пользователю панель, похожую на календарь, чтобы проверить дату и выбрать время. есть кнопка, по которой пользователь может щелкнуть и добавить панель в окно просмотра, чтобы установить параметры для следующей недели. однако, когда я нажимаю эту кнопку, просмотрщик повторяет данные, заданные в предыдущих пунктах, в новом. каждые два шага это повторяется само собой. Пожалуйста, помогите мне.
вот мой код для адаптера:
@Override
public void onBindViewHolder(@NonNull final ViewHolder holder, final int position)
{
//Log.d("AdapterData", "Generated");
Log.d("Fuck",holder.getLayoutPosition()+"");
//DateNumberSetter
holder.date1.setText(models.get(position).getDate1());
holder.date2.setText(models.get(position).getDate2());
holder.date3.setText(models.get(position).getDate3());
holder.date4.setText(models.get(position).getDate4());
holder.date5.setText(models.get(position).getDate5());
holder.date6.setText(models.get(position).getDate6());
holder.date7.setText(models.get(position).getDate7());
//YearMonthSetter
holder.textviewMonth.setText(models.get(position).getMonth());
holder.textviewYear.setText(models.get(position).getYear());
//Switchers
holder.firstLinAddTime1.setAlpha(0.3f);
holder.firstLinAddTime2.setAlpha(0.3f);
holder.firstLinAddTime3.setAlpha(0.3f);
holder.firstLinAddTime4.setAlpha(0.3f);
holder.firstLinAddTime5.setAlpha(0.3f);
holder.firstLinAddTime6.setAlpha(0.3f);
holder.firstLinAddTime7.setAlpha(0.3f);
holder.switcher1.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime1.setAlpha(1.0f);
holder.firstLinAddTime1.setEnabled(true);
holder.timeAdder1.setEnabled(true);
holder.scrollView1.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime1.setAlpha(0.3f);
holder.secondLinAddTime1.setAlpha(0.3f);
holder.firstLinAddTime1.setEnabled(false);
holder.timeAdder1.setEnabled(false);
holder.scrollView1.setNestedScrollingEnabled(false);
holder.scrollView1.smoothScrollTo(0, 0);
holder.startTime1.setText("");
holder.finishTime1.setText("");
holder.startTime11.setText("");
holder.finishTime11.setText("");
holder.secondLinAddTime1.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate1();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
holder.switcher2.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime2.setAlpha(1.0f);
holder.firstLinAddTime2.setEnabled(true);
holder.timeAdder2.setEnabled(true);
holder.scrollView2.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime2.setAlpha(0.3f);
holder.secondLinAddTime2.setAlpha(0.3f);
holder.firstLinAddTime2.setEnabled(false);
holder.timeAdder2.setEnabled(false);
holder.scrollView2.setNestedScrollingEnabled(false);
holder.scrollView2.smoothScrollTo(0, 0);
holder.startTime2.setText("");
holder.finishTime2.setText("");
holder.startTime22.setText("");
holder.finishTime22.setText("");
holder.secondLinAddTime2.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate2();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
holder.switcher3.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime3.setAlpha(1.0f);
holder.firstLinAddTime3.setEnabled(true);
holder.timeAdder3.setEnabled(true);
holder.scrollView3.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime3.setAlpha(0.3f);
holder.secondLinAddTime3.setAlpha(0.3f);
holder.firstLinAddTime3.setEnabled(false);
holder.timeAdder3.setEnabled(false);
holder.scrollView3.setNestedScrollingEnabled(false);
holder.scrollView3.smoothScrollTo(0, 0);
holder.startTime3.setText("");
holder.finishTime3.setText("");
holder.startTime33.setText("");
holder.finishTime33.setText("");
holder.secondLinAddTime3.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate3();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
holder.switcher4.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime4.setAlpha(1.0f);
holder.firstLinAddTime4.setEnabled(true);
holder.timeAdder4.setEnabled(true);
holder.scrollView4.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime4.setAlpha(0.3f);
holder.secondLinAddTime4.setAlpha(0.3f);
holder.firstLinAddTime4.setEnabled(false);
holder.timeAdder4.setEnabled(false);
holder.scrollView4.setNestedScrollingEnabled(false);
holder.scrollView4.smoothScrollTo(0, 0);
holder.startTime4.setText("");
holder.finishTime4.setText("");
holder.startTime44.setText("");
holder.finishTime44.setText("");
holder.secondLinAddTime4.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate4();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
holder.switcher5.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime5.setAlpha(1.0f);
holder.firstLinAddTime5.setEnabled(true);
holder.timeAdder5.setEnabled(true);
holder.scrollView5.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime5.setAlpha(0.3f);
holder.secondLinAddTime5.setAlpha(0.3f);
holder.firstLinAddTime5.setEnabled(false);
holder.timeAdder5.setEnabled(false);
holder.scrollView5.setNestedScrollingEnabled(false);
holder.scrollView5.smoothScrollTo(0, 0);
holder.startTime5.setText("");
holder.finishTime5.setText("");
holder.startTime55.setText("");
holder.finishTime55.setText("");
holder.secondLinAddTime5.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate5();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
holder.switcher6.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime6.setAlpha(1.0f);
holder.firstLinAddTime6.setEnabled(true);
holder.timeAdder6.setEnabled(true);
holder.scrollView6.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime6.setAlpha(0.3f);
holder.secondLinAddTime6.setAlpha(0.3f);
holder.firstLinAddTime6.setEnabled(false);
holder.timeAdder6.setEnabled(false);
holder.scrollView6.setNestedScrollingEnabled(false);
holder.scrollView6.smoothScrollTo(0, 0);
holder.startTime6.setText("");
holder.finishTime6.setText("");
holder.startTime66.setText("");
holder.finishTime66.setText("");
holder.secondLinAddTime6.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate6();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
holder.switcher7.setOnCheckedChangeListener(new SmoothCheckBox.OnCheckedChangeListener()
{
@Override
public void onCheckedChanged(SmoothCheckBox checkBox, boolean isChecked)
{
if (isChecked)
{
holder.firstLinAddTime7.setAlpha(1.0f);
holder.firstLinAddTime7.setEnabled(true);
holder.timeAdder7.setEnabled(true);
holder.scrollView7.setNestedScrollingEnabled(true);
}
else
{
holder.firstLinAddTime7.setAlpha(0.3f);
holder.secondLinAddTime7.setAlpha(0.3f);
holder.firstLinAddTime7.setEnabled(false);
holder.timeAdder7.setEnabled(false);
holder.scrollView7.setNestedScrollingEnabled(false);
holder.scrollView7.smoothScrollTo(0, 0);
holder.startTime7.setText("");
holder.finishTime7.setText("");
holder.startTime77.setText("");
holder.finishTime77.setText("");
holder.secondLinAddTime7.setVisibility(View.INVISIBLE);
String Date = models.get(position).getDate7();
String Month = models.get(position).getMonth();
String Year = models.get(position).getYear();
Database.execSQL("UPDATE SearchPanel SET firsttimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET firsttimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimestart = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
Database.execSQL("UPDATE SearchPanel SET secondtimefinish = '0' WHERE date = '" + Date + "' AND month = '" + Month + "' AND year = '" + Year + "'");
}
}
});
//SecondTimeAdder
holder.timeAdder1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime1.setVisibility(View.VISIBLE);
holder.scrollView1.smoothScrollTo(0, 310);
}
});
holder.timeAdder2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime2.setVisibility(View.VISIBLE);
holder.scrollView2.smoothScrollTo(0, 310);
}
});
holder.timeAdder3.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime3.setVisibility(View.VISIBLE);
holder.scrollView3.smoothScrollTo(0, 310);
}
});
holder.timeAdder4.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime4.setVisibility(View.VISIBLE);
holder.scrollView4.smoothScrollTo(0, 310);
}
});
holder.timeAdder5.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime5.setVisibility(View.VISIBLE);
holder.scrollView5.smoothScrollTo(0, 310);
}
});
holder.timeAdder6.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime6.setVisibility(View.VISIBLE);
holder.scrollView6.smoothScrollTo(0, 310);
}
});
holder.timeAdder7.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
holder.secondLinAddTime7.setVisibility(View.VISIBLE);
holder.scrollView7.smoothScrollTo(0, 310);
}
});
//TimeSetter
holder.firstLinAddTime1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 1;
}
});
holder.firstLinAddTime2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 2;
}
});
holder.firstLinAddTime3.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 3;
}
});
holder.firstLinAddTime4.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 4;
}
});
holder.firstLinAddTime5.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 5;
}
});
holder.firstLinAddTime6.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 6;
}
});
holder.firstLinAddTime7.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 7;
}
});
holder.secondLinAddTime1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 11;
}
});
holder.secondLinAddTime2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 22;
}
});
holder.secondLinAddTime3.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 33;
}
});
holder.secondLinAddTime4.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 44;
}
});
holder.secondLinAddTime5.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 55;
}
});
holder.secondLinAddTime6.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 66;
}
});
holder.secondLinAddTime7.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
viewHolder = holder;
viewPosition = position;
showTimePicker();
timePosition = 77;
}
});
}