Skip to content

Commit

Permalink
Hotfix score coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
vladholubiev committed Jan 26, 2015
1 parent a6beffe commit bfc9de6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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) {
Expand All @@ -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);
}
}
}

0 comments on commit bfc9de6

Please sign in to comment.