У меня есть Recyclerview с countDownTimers, который показывает время, оставшееся до игры, в днях, часах, минутах и секундах. Теперь у меня проблема: когда я выхожу из активности, счетчики countDownTimers все еще работают.
Вот мой адаптер:
Public class RvAdapterShowVsTeamChallenges extends RecyclerView.Adapter {
private Boolean boFirstTime = true;
private int [] ayColors = {R.drawable.circle_red,R.drawable.circle_purple,R.drawable.circle_orange,R.drawable.circle_blue,R.drawable.circle_tile};
private Context context;
private CountDownTimer countDownTimerTest;
private DatabaseWrite databaseWrite;
private SharedPrefs sharedPrefs;
public RvAdapterShowVsTeamChallenges(final Context context)
{
this.context = context;
}
public class ViewHolderClass extends RecyclerView.ViewHolder{
private TextView txtChallenger;
private TextView txtOponnent;
private TextView txtChallengerScore;
private TextView txtOponnentScore;
private TextView txtTime;
private TextView txtChallengerLetters;
private TextView txtOponnentLetters;
private ProgressBar prgChallenger;
private ProgressBar prgOponnent;
public ViewHolderClass(View itemView) {
super(itemView);
sharedPrefs = new SharedPrefs(context);
txtChallenger = (TextView) itemView.findViewById(R.id.txtChallenger);
txtOponnent = (TextView) itemView.findViewById(R.id.txtOponnent);
txtChallengerScore = (TextView) itemView.findViewById(R.id.txtChallengerScore);
txtOponnentScore = (TextView) itemView.findViewById(R.id.txtOponnentScore);
txtChallengerLetters = (TextView)itemView.findViewById(R.id.txtChallengerLetter);
txtOponnentLetters = (TextView)itemView.findViewById(R.id.imgOponnent);
txtTime = (TextView) itemView.findViewById(R.id.txtTime);
prgChallenger = (ProgressBar) itemView.findViewById(R.id.prgTimeLeft);
prgOponnent = (ProgressBar) itemView.findViewById(R.id.prgOponnent);
}
}
@Override
public ViewHolderClass onCreateViewHolder(final ViewGroup parent, final int viewType) {
View itemview1 = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_show_vs_team_challenges,null);
if(boFirstTime)
{
for(int i=0; i
Подробнее здесь: https://stackoverflow.com/questions/409 ... cyclerview