performance improvements for task list

This commit is contained in:
Phillip Thelen 2016-05-12 13:44:29 +02:00
parent b01890427b
commit ff70591cc5
15 changed files with 274 additions and 281 deletions

View file

@ -1,115 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
<FrameLayout
android:id="@+id/checkBoxHolder"
android:layout_width="@dimen/button_width"
android:layout_height="match_parent">
<CheckBox
<CheckBox
android:id="@+id/checkBox"
android:layout_width="@dimen/checkbox_size"
android:layout_height="@dimen/checkbox_size"
android:layout_centerInParent="true"
android:gravity="center"
android:button="@drawable/daily_checkbox"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="@dimen/task_top_bottom_padding"
android:paddingTop="@dimen/task_top_bottom_padding"
android:id="@+id/linearLayout"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="@+id/checklistIndicatorWrapper"
android:layout_toStartOf="@+id/checklistIndicatorWrapper">
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/notesTextView"
style="@style/CardText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<RelativeLayout android:orientation="vertical"
android:id="@+id/checklistIndicatorWrapper"
android:layout_width="@dimen/checklist_wrapper_width"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<TextView
android:id="@+id/checkListCompletedTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"
android:layout_above="@+id/checklistDivider"/>
<View
android:id="@+id/checklistDivider"
android:layout_width="@dimen/checklist_divider_width"
android:layout_height="@dimen/hairline_height"
android:background="@color/white"
android:layout_centerInParent="true"/>
<TextView
android:id="@+id/checkListAllTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"
android:layout_below="@+id/checklistDivider"/>
</RelativeLayout>
<View
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
android:layout_gravity="center" />
</FrameLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="@dimen/task_top_bottom_padding"
android:paddingTop="@dimen/task_top_bottom_padding"
android:id="@+id/linearLayout"
android:layout_weight="1">
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/notesTextView"
style="@style/CardText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3" />
<TextView
android:id="@+id/streakTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:id="@+id/checklistIndicatorWrapper"
android:layout_width="@dimen/checklist_wrapper_width"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/checkListCompletedTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"/>
<View
android:id="@+id/checklistDivider"
android:layout_width="@dimen/checklist_divider_width"
android:layout_height="@dimen/hairline_height"
android:background="@color/white"/>
<TextView
android:id="@+id/checkListAllTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"/>
</LinearLayout>
<View
android:id="@+id/checklistSeparator"
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<View
android:id="@+id/checklistSeparator"
android:layout_width="match_parent"
android:layout_height="@dimen/hairline_height"
android:background="@color/cell_separator" />
<LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/checklistView"
android:orientation="vertical" />
<View
android:id="@+id/checklistBottomSpace"
<View
android:id="@+id/checklistBottomSpace"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="@color/checklist_separator" />
</LinearLayout>
</LinearLayout>

View file

@ -1,14 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white">
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal">
<LinearLayout
android:layout_width="80dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/btnLayout">
android:layout_width="80dp"
android:layout_height="match_parent"
android:orientation="horizontal"
android:id="@+id/btnLayout"
android:baselineAligned="false">
<FrameLayout
android:layout_width="0dp"
android:layout_height="match_parent"
@ -44,14 +46,11 @@
style="@style/HabitButton"/>
</FrameLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
@ -74,9 +73,5 @@
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
android:gravity="center" />
</LinearLayout>

View file

@ -10,7 +10,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
<FrameLayout
android:id="@+id/checkBoxHolder"
android:layout_width="@dimen/button_width"
android:layout_height="match_parent">
@ -18,81 +18,65 @@
android:id="@+id/checkBox"
android:layout_width="@dimen/checkbox_size"
android:layout_height="@dimen/checkbox_size"
android:layout_centerInParent="true"
android:gravity="center"
android:button="@drawable/todo_checkbox"
android:layout_gravity="center_horizontal" />
</RelativeLayout>
<RelativeLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_gravity="center" />
</FrameLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="@dimen/task_top_bottom_padding"
android:paddingTop="@dimen/task_top_bottom_padding"
android:layout_weight="1">
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/notesTextView"
style="@style/CardText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="3" />
<TextView
android:id="@+id/duedateTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:orientation="vertical"
android:id="@+id/checklistIndicatorWrapper"
android:layout_width="@dimen/checklist_wrapper_width"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:id="@+id/checkListCompletedTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_centerVertical="true"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingEnd="16dp"
android:paddingBottom="@dimen/task_top_bottom_padding"
android:paddingTop="@dimen/task_top_bottom_padding">
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.github.data5tream.emojilib.EmojiTextView
android:id="@+id/notesTextView"
style="@style/CardText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:maxLines="3" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<RelativeLayout android:orientation="vertical"
android:id="@+id/checklistIndicatorWrapper"
android:layout_width="@dimen/checklist_wrapper_width"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
<TextView
android:id="@+id/checkListCompletedTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"
android:layout_above="@+id/checklistDivider"/>
<View
android:id="@+id/checklistDivider"
android:layout_width="@dimen/checklist_divider_width"
android:layout_height="@dimen/hairline_height"
android:background="@color/white"
android:layout_centerInParent="true"/>
<TextView
android:id="@+id/checkListAllTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"
android:layout_below="@+id/checklistDivider"/>
</RelativeLayout>
android:textColor="@color/white"
android:gravity="center"/>
<View
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
android:gravity="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
android:id="@+id/checklistDivider"
android:layout_width="@dimen/checklist_divider_width"
android:layout_height="@dimen/hairline_height"
android:background="@color/white"/>
<TextView
android:id="@+id/checkListAllTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:gravity="center"/>
</LinearLayout>
<View
android:id="@+id/rightBorderView"
android:layout_width="5dp"
android:layout_height="match_parent"
android:gravity="center" />
</LinearLayout>
<View
android:id="@id/checklistSeparator"

View file

@ -110,11 +110,11 @@ public class APIHelper implements Action1<Throwable> {
private final Retrofit retrofitAdapter;
private HostConfig cfg;
final Observable.Transformer apiCallTransformer =
observable -> ((Observable)observable).subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnError(this);
private AlertDialog displayedAlert;
//private OnHabitsAPIResult mResultListener;

View file

@ -13,6 +13,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
public class ContentCache {
public interface GotContentEntryCallback<T extends Object> {
@ -78,92 +83,60 @@ public class ContentCache {
}
}
private <T extends Object> void getContentAndSearchFor(final String typeOfSearch, final String searchKey, final GotContentEntryCallback<T> gotEntry) {
apiService.getContent().subscribe(contentResult -> {
switch (typeOfSearch) {
case "quest": {
Collection<QuestContent> questList = contentResult.quests;
private <T> void getContentAndSearchFor(final String typeOfSearch, final String searchKey, final GotContentEntryCallback<T> gotEntry) {
apiService.getContent()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(contentResult -> {
switch (typeOfSearch) {
case "quest": {
Collection<QuestContent> questList = contentResult.quests;
for (QuestContent quest : questList) {
if (quest.getKey() == searchKey) {
gotEntry.GotObject((T) quest);
}
}
break;
}
case "item": {
T searchedItem = null;
if (searchKey == "potion") {
searchedItem = (T) contentResult.potion;
} else if (searchKey == "armoire") {
searchedItem = (T) contentResult.armoire;
} else {
Collection<ItemData> itemList = contentResult.gear.flat;
for (ItemData item : itemList) {
if (item.key.equals(searchKey)) {
searchedItem = (T) item;
for (QuestContent quest : questList) {
if (quest.getKey().equals(searchKey)) {
gotEntry.GotObject((T) quest);
}
}
break;
}
case "item": {
T searchedItem = null;
if (searchKey.equals("potion")) {
searchedItem = (T) contentResult.potion;
} else if (searchKey == "armoire") {
searchedItem = (T) contentResult.armoire;
} else {
Collection<ItemData> itemList = contentResult.gear.flat;
for (ItemData item : itemList) {
if (item.key.equals(searchKey)) {
searchedItem = (T) item;
}
}
}
gotEntry.GotObject(searchedItem);
break;
}
}
gotEntry.GotObject((T) searchedItem);
break;
}
}
saveContentResultToDb(contentResult);
}, throwable -> {});
}, throwable -> {});
}
private <T extends Object> void getContentAndSearchForList(final String typeOfSearch, final List<String> searchKeys, final GotContentEntryCallback<List<T>> gotEntry) {
apiService.getContent().subscribe(contentResult -> {
switch (typeOfSearch) {
case "item": {
List<T> resultList = new ArrayList<T>();
private void getContentAndSearchForList(final String typeOfSearch, final List<String> searchKeys, final GotContentEntryCallback<List<ItemData>> gotEntry) {
List<ItemData> resultList = new ArrayList<>();
apiService.getContent()
.flatMap(contentResult -> {
List<ItemData> itemList = new ArrayList<ItemData>(contentResult.gear.flat);
itemList.add(contentResult.potion);
itemList.add(contentResult.armoire);
for (ItemData item : itemList) {
if (searchKeys.contains(item.key)) {
resultList.add((T) item);
}
}
gotEntry.GotObject(resultList);
break;
}
}
saveContentResultToDb(contentResult);
}, throwable -> {});
}
private void saveContentResultToDb(ContentResult contentResult) {
Collection<QuestContent> questList = contentResult.quests;
for (QuestContent quest : questList) {
quest.save();
if (quest.boss != null) {
quest.boss.key = quest.getKey();
quest.boss.async().save();
}
}
Collection<ItemData> itemList = new ArrayList<>(contentResult.gear.flat);
itemList.add(contentResult.armoire);
itemList.add(contentResult.potion);
for (ItemData item : itemList) {
item.async().save();
}
return Observable.from(itemList);
})
.filter(item -> searchKeys.contains(item.key))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(resultList::add, throwable -> {}, () -> gotEntry.GotObject(resultList));
}
}

View file

@ -6,6 +6,7 @@ import com.habitrpg.android.habitica.events.TaskUpdatedEvent;
import com.habitrpg.android.habitica.events.commands.FilterTasksByTagsCommand;
import com.habitrpg.android.habitica.events.commands.TaskCheckedCommand;
import com.habitrpg.android.habitica.helpers.TagsHelper;
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser;
import com.habitrpg.android.habitica.ui.viewHolders.tasks.BaseTaskViewHolder;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import com.raizlabs.android.dbflow.runtime.transaction.BaseTransaction;
@ -31,6 +32,7 @@ import java.util.List;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func0;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder>
@ -173,6 +175,7 @@ public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder
public void loadContent(boolean forced) {
if (this.content == null || forced) {
List<Task> tasks = new ArrayList<>();
Observable.defer(() -> Observable.just(new Select().from(Task.class)
.where(Condition.column("type").eq(this.taskType))
.and(Condition.CombinedCondition
@ -181,9 +184,15 @@ public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder
)
.orderBy(OrderBy.columns("position", "dateCreated").descending())
.queryList()))
.flatMap(Observable::from)
.map(task -> {
task.parsedText = MarkdownParser.parseMarkdown(task.getText());
task.parsedNotes = MarkdownParser.parseMarkdown(task.getNotes());
return task;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::setTasks, throwable -> {});
.subscribe(tasks::add, throwable -> {}, () -> setTasks(tasks));
}
}

View file

@ -177,17 +177,19 @@ public class PreferencesFragment extends BasePreferencesFragment implements
public void setUser(HabitRPGUser user) {
this.user = user;
if (user.getFlags().getClassSelected()) {
if (user.getPreferences().getDisableClasses()) {
classSelectionPreference.setTitle(getString(R.string.enable_class));
if (user != null && user.getFlags() != null) {
if (user.getFlags().getClassSelected()) {
if (user.getPreferences().getDisableClasses()) {
classSelectionPreference.setTitle(getString(R.string.enable_class));
} else {
classSelectionPreference.setTitle(getString(R.string.change_class));
classSelectionPreference.setSummary(getString(R.string.change_class_description));
}
classSelectionPreference.setVisible(true);
} else {
classSelectionPreference.setTitle(getString(R.string.change_class));
classSelectionPreference.setSummary(getString(R.string.change_class_description));
classSelectionPreference.setTitle(getString(R.string.enable_class));
classSelectionPreference.setVisible(true);
}
classSelectionPreference.setVisible(true);
} else {
classSelectionPreference.setTitle(getString(R.string.enable_class));
classSelectionPreference.setVisible(true);
}
}
}

View file

@ -8,7 +8,6 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import org.greenrobot.eventbus.EventBus;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.view.View;
@ -17,6 +16,10 @@ import android.widget.TextView;
import butterknife.BindColor;
import butterknife.BindView;
import butterknife.ButterKnife;
import hugo.weaving.DebugLog;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;
public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
@ -54,9 +57,14 @@ public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.
public void bindHolder(Task newTask, int position) {
this.task = newTask;
this.titleTextView.setText(MarkdownParser.parseMarkdown(this.task.getText()));
if (this.canContainMarkdown()) {
this.titleTextView.setText(this.task.parsedText);
this.notesTextView.setText(this.task.parsedNotes);
} else {
this.titleTextView.setText(this.task.getText());
this.notesTextView.setText(this.task.getNotes());
}
if (this.task.getNotes().length() > 0) {
this.notesTextView.setText(MarkdownParser.parseMarkdown(this.task.getNotes()));
this.notesTextView.setVisibility(View.VISIBLE);
} else {
this.notesTextView.setVisibility(View.GONE);
@ -78,4 +86,8 @@ public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.
EventBus.getDefault().post(event);
}
public boolean canContainMarkdown() {
return true;
}
}

View file

@ -29,7 +29,7 @@ import butterknife.OnClick;
public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implements CompoundButton.OnCheckedChangeListener {
@BindView(R.id.checkBoxHolder)
RelativeLayout checkboxHolder;
ViewGroup checkboxHolder;
@BindView(R.id.checkBox)
CheckBox checkbox;
@ -42,7 +42,7 @@ public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implement
View checklistBottomSpace;
@BindView(R.id.checklistIndicatorWrapper)
RelativeLayout checklistIndicatorWrapper;
ViewGroup checklistIndicatorWrapper;
@BindView(R.id.checkListCompletedTextView)
TextView checklistCompletedTextView;

View file

@ -4,9 +4,15 @@ import com.habitrpg.android.habitica.R;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
public class DailyViewHolder extends ChecklistedViewHolder {
@BindView(R.id.streakTextView)
TextView streakTextView;
public final int dailyResetOffset;
public DailyViewHolder(View itemView, int dailyResetOffset) {
@ -22,6 +28,12 @@ public class DailyViewHolder extends ChecklistedViewHolder {
} else {
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
}
if (task.streak != null && task.streak > 0) {
this.streakTextView.setText(itemView.getContext().getString(R.string.daily_streak, task.streak));
this.streakTextView.setVisibility(View.VISIBLE);
} else {
this.streakTextView.setVisibility(View.GONE);
}
}
@Override

View file

@ -8,6 +8,7 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import org.greenrobot.eventbus.EventBus;
import android.os.Trace;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
@ -44,7 +45,7 @@ public class RewardViewHolder extends BaseTaskViewHolder {
this.rewardButton.setText(this.priceFormat.format(this.task.value));
if (this.task.specialTag != null && this.task.specialTag.equals("item")) {
if (this.isItem()) {
this.rewardImageView.setVisibility(View.VISIBLE);
DataBindingUtils.loadImage(this.rewardImageView, "shop_" + this.task.getId());
} else {
@ -52,6 +53,15 @@ public class RewardViewHolder extends BaseTaskViewHolder {
}
}
private boolean isItem() {
return this.task.specialTag != null && this.task.specialTag.equals("item");
}
@Override
public boolean canContainMarkdown() {
return !isItem();
}
@OnClick(R.id.btnReward)
public void buyReward() {
BuyRewardCommand event = new BuyRewardCommand();

View file

@ -4,9 +4,15 @@ import com.habitrpg.android.habitica.R;
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
public class TodoViewHolder extends ChecklistedViewHolder {
@BindView(R.id.duedateTextView)
TextView duedateTextView;
public TodoViewHolder(View itemView) {
super(itemView);
}
@ -15,14 +21,20 @@ public class TodoViewHolder extends ChecklistedViewHolder {
public void bindHolder(Task newTask, int position) {
super.bindHolder(newTask, position);
if (this.task.getCompleted()) {
this.checklistIndicatorWrapper.setBackgroundResource(this.task.getLightTaskColor());
} else {
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
} else {
this.checklistIndicatorWrapper.setBackgroundResource(this.task.getLightTaskColor());
}
if (task.duedate != null) {
this.duedateTextView.setText(itemView.getContext().getString(R.string.todo_due, task.streak));
this.duedateTextView.setVisibility(View.VISIBLE);
} else {
this.duedateTextView.setVisibility(View.GONE);
}
}
@Override
public Boolean shouldDisplayAsActive() {
return this.task.getCompleted();
return !this.task.getCompleted();
}
}

View file

@ -13,6 +13,6 @@ import retrofit2.http.Query;
* Created by Negue on 27.11.2015.
*/
public interface InAppPurchasesApiService {
@POST("/iap/android/verify")
@POST("iap/android/verify")
Call<PurchaseValidationResult> validatePurchase(@Query("_id") String id, @Query("apiToken") String apiToken, @Body PurchaseValidationRequest request);
}

View file

@ -7,10 +7,10 @@ import rx.Observable;
public interface MaintenanceApiService {
@GET("/maintenance-android.json")
@GET("maintenance-android.json")
Observable<MaintenanceResponse> getMaintenanceStatus();
@GET("/deprecation-android.json")
@GET("deprecation-android.json")
Observable<MaintenanceResponse> getDepricationStatus();
}

View file

@ -106,6 +106,9 @@ public class Task extends BaseModel {
// used for buyable items
public String specialTag;
public CharSequence parsedText;
public CharSequence parsedNotes;
/**
* @return the id
*/