diff --git a/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemAdapter.java b/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemAdapter.java index e246219..adbddcc 100644 --- a/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemAdapter.java +++ b/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemAdapter.java @@ -3,6 +3,7 @@ import android.content.Context; import android.graphics.Typeface; import android.support.v7.widget.RecyclerView; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -44,10 +45,15 @@ public void onBindViewHolder(SubjectItemViewHolder holder, int position) { holder.subjectWeight.setVisibility(View.GONE); holder.subjectScore.setText(String.valueOf(current.getTotalScore())); holder.subjectScore.setTypeface(holder.subjectScore.getTypeface(), Typeface.BOLD); + if (isTotalScoreView(holder)) { + holder.subjectScore.setBackgroundResource(DrawableUtils.getScoreCircleDrawable(current.getTotalScore())); + } else { + holder.subjectScore.setBackgroundResource(DrawableUtils.getScoreCircleDrawable(current.getLastModule().getScore())); + } } else { holder.subjectScore.setText(String.valueOf(current.getLastModule().getScore())); + holder.subjectScore.setBackgroundResource(DrawableUtils.getScoreCircleDrawable(current.getLastModule().getScore())); } - holder.subjectScore.setBackgroundResource(DrawableUtils.getScoreCircleDrawable(current.getLastModule().getScore())); } private boolean areAllModulesPassed(int subjectIndex) { @@ -61,6 +67,11 @@ private boolean areAllModulesPassed(int subjectIndex) { return allModulesPassed; } + private boolean isTotalScoreView(SubjectItemViewHolder holder) { + String totalScoreName = App.getContext().getString(R.string.total_score_name); + return holder.subjectDate.getText().equals(totalScoreName); + } + @Override public int getItemCount() { return data.size(); diff --git a/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemOnClickListener.java b/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemOnClickListener.java index 4b7f8a4..dec9c11 100644 --- a/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemOnClickListener.java +++ b/app/src/main/java/ua/samosfator/moduleok/fragment/last_total_fragment/SubjectItemOnClickListener.java @@ -1,6 +1,8 @@ package ua.samosfator.moduleok.fragment.last_total_fragment; import android.graphics.Typeface; +import android.os.Handler; +import android.os.Looper; import android.view.View; import android.widget.TextView; import android.widget.ViewFlipper; @@ -11,7 +13,6 @@ import ua.samosfator.moduleok.DrawableUtils; import ua.samosfator.moduleok.R; import ua.samosfator.moduleok.animation.AnimationFactory; -import ua.samosfator.moduleok.parser.Module; import ua.samosfator.moduleok.parser.Subject; import ua.samosfator.moduleok.recyclerview.RecyclerItemClickListener; @@ -49,7 +50,12 @@ private void setSubjectScore() { if (isTotalScoreView()) { subjectTotalScoreTextView.setText(String.valueOf(lastScore)); } else { - subjectTotalScoreTextView.setText(String.valueOf(totalScore)); + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + subjectTotalScoreTextView.setText(String.valueOf(totalScore)); + } + }, 200); } } @@ -59,8 +65,18 @@ private boolean isTotalScoreView() { } private void setSubjectTotalScoreBackground() { - int drawableDependsOnTotalScore = DrawableUtils.getScoreCircleDrawable(totalScore); - subjectTotalScoreTextView.setBackgroundResource(drawableDependsOnTotalScore); + if (isTotalScoreView()) { + int drawableDependsOnTotalScore = DrawableUtils.getScoreCircleDrawable(lastScore); + subjectTotalScoreTextView.setBackgroundResource(drawableDependsOnTotalScore); + } else { + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + int drawableDependsOnTotalScore = DrawableUtils.getScoreCircleDrawable(totalScore); + subjectTotalScoreTextView.setBackgroundResource(drawableDependsOnTotalScore); + } + }, 200); + } } private void animateSubjectTotalScoreChange(View view) { @@ -79,7 +95,12 @@ private void toggleTotalScoreTypeface() { if (isTotalScoreView()) { subjectTotalScoreTextView.setTypeface(null, Typeface.NORMAL); } else { - subjectTotalScoreTextView.setTypeface(null, Typeface.BOLD); + new Handler(Looper.getMainLooper()).postDelayed(new Runnable() { + @Override + public void run() { + subjectTotalScoreTextView.setTypeface(null, Typeface.BOLD); + } + }, 200); } } }