mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 05:09:00 +00:00
show habit streak
This commit is contained in:
parent
25a3208054
commit
f9b867964b
3 changed files with 42 additions and 0 deletions
|
|
@ -93,6 +93,19 @@
|
|||
android:textColor="@color/task_secondary_text"
|
||||
tools:text="special" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/streakTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/task_icon_size"
|
||||
android:layout_marginStart="@dimen/task_icon_space"
|
||||
android:layout_marginLeft="@dimen/task_icon_space"
|
||||
android:drawableStart="@drawable/task_icon_streak"
|
||||
android:drawableLeft="@drawable/task_icon_streak"
|
||||
android:textColor="@color/task_secondary_text"
|
||||
tools:text="10"
|
||||
android:gravity="center_vertical"
|
||||
style="@style/Caption3" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iconviewChallenge"
|
||||
android:layout_width="@dimen/task_icon_size"
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ public class Task extends RealmObject implements Parcelable {
|
|||
public TaskGroupPlan group;
|
||||
//Habits
|
||||
public Boolean up, down;
|
||||
public int counterUp, counterDown;
|
||||
//todos/dailies
|
||||
public boolean completed;
|
||||
public RealmList<ChecklistItem> checklist;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.view.View;
|
|||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.habitrpg.android.habitica.R;
|
||||
import com.habitrpg.android.habitica.events.HabitScoreEvent;
|
||||
|
|
@ -30,6 +31,9 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
@BindView(R.id.btnMinus)
|
||||
Button btnMinus;
|
||||
|
||||
@BindView(R.id.streakTextView)
|
||||
TextView streakTextView;
|
||||
|
||||
public HabitViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
|
@ -69,6 +73,21 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
this.btnMinus.setVisibility(View.GONE);
|
||||
this.btnMinus.setClickable(false);
|
||||
}
|
||||
|
||||
String streakString = "";
|
||||
if (task.counterUp > 0 && task.counterDown > 0) {
|
||||
streakString = streakString + "+" + String.valueOf(task.counterUp) + " | -" + String.valueOf(task.counterDown);
|
||||
} else if (task.counterUp > 0) {
|
||||
streakString = streakString + "+" + String.valueOf(task.counterUp);
|
||||
} else if (task.counterUp > 0) {
|
||||
streakString = streakString + "-" + String.valueOf(task.counterDown);
|
||||
}
|
||||
if (streakString.length() > 0) {
|
||||
streakTextView.setText(streakString);
|
||||
streakTextView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
streakTextView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.btnPlus)
|
||||
|
|
@ -94,4 +113,13 @@ public class HabitViewHolder extends BaseTaskViewHolder {
|
|||
this.btnPlus.setEnabled(!taskActionsDisabled);
|
||||
this.btnMinus.setEnabled(!taskActionsDisabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean getTaskIconWrapperIsVisible() {
|
||||
Boolean isVisible = super.getTaskIconWrapperIsVisible();
|
||||
if (this.streakTextView.getVisibility() == View.VISIBLE) {
|
||||
isVisible = true;
|
||||
}
|
||||
return isVisible;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue