mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-13 17:51:57 +00:00
performance improvements for task list
This commit is contained in:
parent
b01890427b
commit
ff70591cc5
15 changed files with 274 additions and 281 deletions
|
|
@ -1,115 +1,96 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/white"
|
android:background="@color/white"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<RelativeLayout
|
<FrameLayout
|
||||||
android:id="@+id/checkBoxHolder"
|
android:id="@+id/checkBoxHolder"
|
||||||
android:layout_width="@dimen/button_width"
|
android:layout_width="@dimen/button_width"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<CheckBox
|
<CheckBox
|
||||||
android:id="@+id/checkBox"
|
android:id="@+id/checkBox"
|
||||||
android:layout_width="@dimen/checkbox_size"
|
android:layout_width="@dimen/checkbox_size"
|
||||||
android:layout_height="@dimen/checkbox_size"
|
android:layout_height="@dimen/checkbox_size"
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:button="@drawable/daily_checkbox"
|
android:button="@drawable/daily_checkbox"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center" />
|
||||||
</RelativeLayout>
|
</FrameLayout>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:orientation="vertical"
|
||||||
android:layout_height="match_parent">
|
android:layout_width="0dp"
|
||||||
<LinearLayout
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:paddingLeft="16dp"
|
||||||
android:layout_width="wrap_content"
|
android:paddingRight="16dp"
|
||||||
android:layout_height="match_parent"
|
android:paddingEnd="16dp"
|
||||||
android:paddingLeft="16dp"
|
android:paddingBottom="@dimen/task_top_bottom_padding"
|
||||||
android:paddingRight="16dp"
|
android:paddingTop="@dimen/task_top_bottom_padding"
|
||||||
android:paddingEnd="16dp"
|
android:id="@+id/linearLayout"
|
||||||
android:paddingBottom="@dimen/task_top_bottom_padding"
|
android:layout_weight="1">
|
||||||
android:paddingTop="@dimen/task_top_bottom_padding"
|
<com.github.data5tream.emojilib.EmojiTextView
|
||||||
android:id="@+id/linearLayout"
|
android:id="@+id/checkedTextView"
|
||||||
android:layout_alignParentTop="true"
|
style="@style/CardTitle"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_width="match_parent"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_height="wrap_content" />
|
||||||
android:layout_toLeftOf="@+id/checklistIndicatorWrapper"
|
<com.github.data5tream.emojilib.EmojiTextView
|
||||||
android:layout_toStartOf="@+id/checklistIndicatorWrapper">
|
android:id="@+id/notesTextView"
|
||||||
<com.github.data5tream.emojilib.EmojiTextView
|
style="@style/CardText"
|
||||||
android:id="@+id/checkedTextView"
|
android:layout_width="match_parent"
|
||||||
style="@style/CardTitle"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent"
|
android:maxLines="3" />
|
||||||
android:layout_height="wrap_content" />
|
<TextView
|
||||||
<com.github.data5tream.emojilib.EmojiTextView
|
android:id="@+id/streakTextView"
|
||||||
android:id="@+id/notesTextView"
|
android:layout_width="match_parent"
|
||||||
style="@style/CardText"
|
android:layout_height="wrap_content"/>
|
||||||
android:layout_width="match_parent"
|
</LinearLayout>
|
||||||
android:layout_height="wrap_content"
|
<LinearLayout android:orientation="vertical"
|
||||||
android:maxLines="3" />
|
android:id="@+id/checklistIndicatorWrapper"
|
||||||
<TextView
|
android:layout_width="@dimen/checklist_wrapper_width"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:gravity="center">
|
||||||
</LinearLayout>
|
<TextView
|
||||||
<RelativeLayout android:orientation="vertical"
|
android:id="@+id/checkListCompletedTextView"
|
||||||
android:id="@+id/checklistIndicatorWrapper"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="@dimen/checklist_wrapper_width"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:textColor="@color/white"
|
||||||
android:gravity="center"
|
android:gravity="center"/>
|
||||||
android:layout_alignParentTop="true"
|
<View
|
||||||
android:layout_alignParentBottom="true"
|
android:id="@+id/checklistDivider"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_width="@dimen/checklist_divider_width"
|
||||||
android:layout_alignParentEnd="true">
|
android:layout_height="@dimen/hairline_height"
|
||||||
<TextView
|
android:background="@color/white"/>
|
||||||
android:id="@+id/checkListCompletedTextView"
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/checkListAllTextView"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:textColor="@color/white"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center"
|
android:textColor="@color/white"
|
||||||
android:layout_above="@+id/checklistDivider"/>
|
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"
|
|
||||||
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>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<View
|
<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_width="match_parent"
|
||||||
android:layout_height="@dimen/hairline_height"
|
android:layout_height="@dimen/hairline_height"
|
||||||
android:background="@color/cell_separator" />
|
android:background="@color/cell_separator" />
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/checklistView"
|
android:id="@+id/checklistView"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
<View
|
<View
|
||||||
android:id="@+id/checklistBottomSpace"
|
android:id="@+id/checklistBottomSpace"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="10dp"
|
android:layout_height="10dp"
|
||||||
android:background="@color/checklist_separator" />
|
android:background="@color/checklist_separator" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/white">
|
android:background="@color/white"
|
||||||
|
android:orientation="horizontal">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="80dp"
|
android:layout_width="80dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:id="@+id/btnLayout">
|
android:id="@+id/btnLayout"
|
||||||
|
android:baselineAligned="false">
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
@ -44,14 +46,11 @@
|
||||||
style="@style/HabitButton"/>
|
style="@style/HabitButton"/>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
android:paddingEnd="16dp"
|
android:paddingEnd="16dp"
|
||||||
|
|
@ -74,9 +73,5 @@
|
||||||
android:id="@+id/rightBorderView"
|
android:id="@+id/rightBorderView"
|
||||||
android:layout_width="5dp"
|
android:layout_width="5dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center"
|
android:gravity="center" />
|
||||||
android:layout_alignParentTop="true"
|
</LinearLayout>
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_alignParentEnd="true" />
|
|
||||||
</RelativeLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
<RelativeLayout
|
<FrameLayout
|
||||||
android:id="@+id/checkBoxHolder"
|
android:id="@+id/checkBoxHolder"
|
||||||
android:layout_width="@dimen/button_width"
|
android:layout_width="@dimen/button_width"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
@ -18,81 +18,65 @@
|
||||||
android:id="@+id/checkBox"
|
android:id="@+id/checkBox"
|
||||||
android:layout_width="@dimen/checkbox_size"
|
android:layout_width="@dimen/checkbox_size"
|
||||||
android:layout_height="@dimen/checkbox_size"
|
android:layout_height="@dimen/checkbox_size"
|
||||||
android:layout_centerInParent="true"
|
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:button="@drawable/todo_checkbox"
|
android:button="@drawable/todo_checkbox"
|
||||||
android:layout_gravity="center_horizontal" />
|
android:layout_gravity="center" />
|
||||||
</RelativeLayout>
|
</FrameLayout>
|
||||||
<RelativeLayout
|
<LinearLayout
|
||||||
android:orientation="horizontal"
|
android:layout_width="0dp"
|
||||||
android:layout_width="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="match_parent">
|
android:orientation="vertical"
|
||||||
<LinearLayout
|
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_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:textColor="@color/white"
|
||||||
android:layout_centerVertical="true"
|
android:gravity="center"/>
|
||||||
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>
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/rightBorderView"
|
android:id="@+id/checklistDivider"
|
||||||
android:layout_width="5dp"
|
android:layout_width="@dimen/checklist_divider_width"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="@dimen/hairline_height"
|
||||||
android:gravity="center"
|
android:background="@color/white"/>
|
||||||
android:layout_alignParentTop="true"
|
<TextView
|
||||||
android:layout_alignParentRight="true"
|
android:id="@+id/checkListAllTextView"
|
||||||
android:layout_alignParentEnd="true" />
|
android:layout_width="match_parent"
|
||||||
</RelativeLayout>
|
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>
|
</LinearLayout>
|
||||||
<View
|
<View
|
||||||
android:id="@id/checklistSeparator"
|
android:id="@id/checklistSeparator"
|
||||||
|
|
|
||||||
|
|
@ -110,11 +110,11 @@ public class APIHelper implements Action1<Throwable> {
|
||||||
private final Retrofit retrofitAdapter;
|
private final Retrofit retrofitAdapter;
|
||||||
private HostConfig cfg;
|
private HostConfig cfg;
|
||||||
|
|
||||||
|
|
||||||
final Observable.Transformer apiCallTransformer =
|
final Observable.Transformer apiCallTransformer =
|
||||||
observable -> ((Observable)observable).subscribeOn(Schedulers.io())
|
observable -> ((Observable)observable).subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnError(this);
|
.doOnError(this);
|
||||||
|
|
||||||
private AlertDialog displayedAlert;
|
private AlertDialog displayedAlert;
|
||||||
|
|
||||||
//private OnHabitsAPIResult mResultListener;
|
//private OnHabitsAPIResult mResultListener;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,11 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import rx.Observable;
|
||||||
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
|
import rx.functions.Func1;
|
||||||
|
import rx.schedulers.Schedulers;
|
||||||
|
|
||||||
|
|
||||||
public class ContentCache {
|
public class ContentCache {
|
||||||
public interface GotContentEntryCallback<T extends Object> {
|
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) {
|
private <T> void getContentAndSearchFor(final String typeOfSearch, final String searchKey, final GotContentEntryCallback<T> gotEntry) {
|
||||||
apiService.getContent().subscribe(contentResult -> {
|
apiService.getContent()
|
||||||
switch (typeOfSearch) {
|
.subscribeOn(Schedulers.io())
|
||||||
case "quest": {
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
Collection<QuestContent> questList = contentResult.quests;
|
.subscribe(contentResult -> {
|
||||||
|
switch (typeOfSearch) {
|
||||||
|
case "quest": {
|
||||||
|
Collection<QuestContent> questList = contentResult.quests;
|
||||||
|
|
||||||
for (QuestContent quest : questList) {
|
for (QuestContent quest : questList) {
|
||||||
if (quest.getKey() == searchKey) {
|
if (quest.getKey().equals(searchKey)) {
|
||||||
gotEntry.GotObject((T) quest);
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, throwable -> {});
|
||||||
gotEntry.GotObject((T) searchedItem);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
saveContentResultToDb(contentResult);
|
|
||||||
}, throwable -> {});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Object> void getContentAndSearchForList(final String typeOfSearch, final List<String> searchKeys, final GotContentEntryCallback<List<T>> gotEntry) {
|
private void getContentAndSearchForList(final String typeOfSearch, final List<String> searchKeys, final GotContentEntryCallback<List<ItemData>> gotEntry) {
|
||||||
apiService.getContent().subscribe(contentResult -> {
|
List<ItemData> resultList = new ArrayList<>();
|
||||||
switch (typeOfSearch) {
|
apiService.getContent()
|
||||||
case "item": {
|
.flatMap(contentResult -> {
|
||||||
List<T> resultList = new ArrayList<T>();
|
|
||||||
|
|
||||||
List<ItemData> itemList = new ArrayList<ItemData>(contentResult.gear.flat);
|
List<ItemData> itemList = new ArrayList<ItemData>(contentResult.gear.flat);
|
||||||
itemList.add(contentResult.potion);
|
itemList.add(contentResult.potion);
|
||||||
itemList.add(contentResult.armoire);
|
itemList.add(contentResult.armoire);
|
||||||
|
return Observable.from(itemList);
|
||||||
for (ItemData item : itemList) {
|
})
|
||||||
if (searchKeys.contains(item.key)) {
|
.filter(item -> searchKeys.contains(item.key))
|
||||||
resultList.add((T) item);
|
.subscribeOn(Schedulers.io())
|
||||||
}
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
}
|
.subscribe(resultList::add, throwable -> {}, () -> gotEntry.GotObject(resultList));
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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.FilterTasksByTagsCommand;
|
||||||
import com.habitrpg.android.habitica.events.commands.TaskCheckedCommand;
|
import com.habitrpg.android.habitica.events.commands.TaskCheckedCommand;
|
||||||
import com.habitrpg.android.habitica.helpers.TagsHelper;
|
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.habitrpg.android.habitica.ui.viewHolders.tasks.BaseTaskViewHolder;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||||
import com.raizlabs.android.dbflow.runtime.transaction.BaseTransaction;
|
import com.raizlabs.android.dbflow.runtime.transaction.BaseTransaction;
|
||||||
|
|
@ -31,6 +32,7 @@ import java.util.List;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
import rx.functions.Func0;
|
import rx.functions.Func0;
|
||||||
|
import rx.functions.Func1;
|
||||||
import rx.schedulers.Schedulers;
|
import rx.schedulers.Schedulers;
|
||||||
|
|
||||||
public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder>
|
public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder>
|
||||||
|
|
@ -173,6 +175,7 @@ public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder
|
||||||
|
|
||||||
public void loadContent(boolean forced) {
|
public void loadContent(boolean forced) {
|
||||||
if (this.content == null || forced) {
|
if (this.content == null || forced) {
|
||||||
|
List<Task> tasks = new ArrayList<>();
|
||||||
Observable.defer(() -> Observable.just(new Select().from(Task.class)
|
Observable.defer(() -> Observable.just(new Select().from(Task.class)
|
||||||
.where(Condition.column("type").eq(this.taskType))
|
.where(Condition.column("type").eq(this.taskType))
|
||||||
.and(Condition.CombinedCondition
|
.and(Condition.CombinedCondition
|
||||||
|
|
@ -181,9 +184,15 @@ public abstract class BaseTasksRecyclerViewAdapter<VH extends BaseTaskViewHolder
|
||||||
)
|
)
|
||||||
.orderBy(OrderBy.columns("position", "dateCreated").descending())
|
.orderBy(OrderBy.columns("position", "dateCreated").descending())
|
||||||
.queryList()))
|
.queryList()))
|
||||||
|
.flatMap(Observable::from)
|
||||||
|
.map(task -> {
|
||||||
|
task.parsedText = MarkdownParser.parseMarkdown(task.getText());
|
||||||
|
task.parsedNotes = MarkdownParser.parseMarkdown(task.getNotes());
|
||||||
|
return task;
|
||||||
|
})
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(this::setTasks, throwable -> {});
|
.subscribe(tasks::add, throwable -> {}, () -> setTasks(tasks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -177,17 +177,19 @@ public class PreferencesFragment extends BasePreferencesFragment implements
|
||||||
|
|
||||||
public void setUser(HabitRPGUser user) {
|
public void setUser(HabitRPGUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
if (user.getFlags().getClassSelected()) {
|
if (user != null && user.getFlags() != null) {
|
||||||
if (user.getPreferences().getDisableClasses()) {
|
if (user.getFlags().getClassSelected()) {
|
||||||
classSelectionPreference.setTitle(getString(R.string.enable_class));
|
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 {
|
} else {
|
||||||
classSelectionPreference.setTitle(getString(R.string.change_class));
|
classSelectionPreference.setTitle(getString(R.string.enable_class));
|
||||||
classSelectionPreference.setSummary(getString(R.string.change_class_description));
|
classSelectionPreference.setVisible(true);
|
||||||
}
|
}
|
||||||
classSelectionPreference.setVisible(true);
|
|
||||||
} else {
|
|
||||||
classSelectionPreference.setTitle(getString(R.string.enable_class));
|
|
||||||
classSelectionPreference.setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
@ -17,6 +16,10 @@ import android.widget.TextView;
|
||||||
import butterknife.BindColor;
|
import butterknife.BindColor;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
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 {
|
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) {
|
public void bindHolder(Task newTask, int position) {
|
||||||
this.task = newTask;
|
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) {
|
if (this.task.getNotes().length() > 0) {
|
||||||
this.notesTextView.setText(MarkdownParser.parseMarkdown(this.task.getNotes()));
|
|
||||||
this.notesTextView.setVisibility(View.VISIBLE);
|
this.notesTextView.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
this.notesTextView.setVisibility(View.GONE);
|
this.notesTextView.setVisibility(View.GONE);
|
||||||
|
|
@ -78,4 +86,8 @@ public class BaseTaskViewHolder extends RecyclerView.ViewHolder implements View.
|
||||||
|
|
||||||
EventBus.getDefault().post(event);
|
EventBus.getDefault().post(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canContainMarkdown() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import butterknife.OnClick;
|
||||||
public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implements CompoundButton.OnCheckedChangeListener {
|
public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implements CompoundButton.OnCheckedChangeListener {
|
||||||
|
|
||||||
@BindView(R.id.checkBoxHolder)
|
@BindView(R.id.checkBoxHolder)
|
||||||
RelativeLayout checkboxHolder;
|
ViewGroup checkboxHolder;
|
||||||
|
|
||||||
@BindView(R.id.checkBox)
|
@BindView(R.id.checkBox)
|
||||||
CheckBox checkbox;
|
CheckBox checkbox;
|
||||||
|
|
@ -42,7 +42,7 @@ public abstract class ChecklistedViewHolder extends BaseTaskViewHolder implement
|
||||||
View checklistBottomSpace;
|
View checklistBottomSpace;
|
||||||
|
|
||||||
@BindView(R.id.checklistIndicatorWrapper)
|
@BindView(R.id.checklistIndicatorWrapper)
|
||||||
RelativeLayout checklistIndicatorWrapper;
|
ViewGroup checklistIndicatorWrapper;
|
||||||
|
|
||||||
@BindView(R.id.checkListCompletedTextView)
|
@BindView(R.id.checkListCompletedTextView)
|
||||||
TextView checklistCompletedTextView;
|
TextView checklistCompletedTextView;
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,15 @@ import com.habitrpg.android.habitica.R;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
|
||||||
public class DailyViewHolder extends ChecklistedViewHolder {
|
public class DailyViewHolder extends ChecklistedViewHolder {
|
||||||
|
|
||||||
|
@BindView(R.id.streakTextView)
|
||||||
|
TextView streakTextView;
|
||||||
|
|
||||||
public final int dailyResetOffset;
|
public final int dailyResetOffset;
|
||||||
|
|
||||||
public DailyViewHolder(View itemView, int dailyResetOffset) {
|
public DailyViewHolder(View itemView, int dailyResetOffset) {
|
||||||
|
|
@ -22,6 +28,12 @@ public class DailyViewHolder extends ChecklistedViewHolder {
|
||||||
} else {
|
} else {
|
||||||
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
|
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
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import android.os.Trace;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
|
@ -44,7 +45,7 @@ public class RewardViewHolder extends BaseTaskViewHolder {
|
||||||
|
|
||||||
this.rewardButton.setText(this.priceFormat.format(this.task.value));
|
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);
|
this.rewardImageView.setVisibility(View.VISIBLE);
|
||||||
DataBindingUtils.loadImage(this.rewardImageView, "shop_" + this.task.getId());
|
DataBindingUtils.loadImage(this.rewardImageView, "shop_" + this.task.getId());
|
||||||
} else {
|
} 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)
|
@OnClick(R.id.btnReward)
|
||||||
public void buyReward() {
|
public void buyReward() {
|
||||||
BuyRewardCommand event = new BuyRewardCommand();
|
BuyRewardCommand event = new BuyRewardCommand();
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,15 @@ import com.habitrpg.android.habitica.R;
|
||||||
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
import com.magicmicky.habitrpgwrapper.lib.models.tasks.Task;
|
||||||
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import butterknife.BindView;
|
||||||
|
|
||||||
public class TodoViewHolder extends ChecklistedViewHolder {
|
public class TodoViewHolder extends ChecklistedViewHolder {
|
||||||
|
|
||||||
|
@BindView(R.id.duedateTextView)
|
||||||
|
TextView duedateTextView;
|
||||||
|
|
||||||
public TodoViewHolder(View itemView) {
|
public TodoViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
}
|
}
|
||||||
|
|
@ -15,14 +21,20 @@ public class TodoViewHolder extends ChecklistedViewHolder {
|
||||||
public void bindHolder(Task newTask, int position) {
|
public void bindHolder(Task newTask, int position) {
|
||||||
super.bindHolder(newTask, position);
|
super.bindHolder(newTask, position);
|
||||||
if (this.task.getCompleted()) {
|
if (this.task.getCompleted()) {
|
||||||
this.checklistIndicatorWrapper.setBackgroundResource(this.task.getLightTaskColor());
|
|
||||||
} else {
|
|
||||||
this.checklistIndicatorWrapper.setBackgroundColor(this.taskGray);
|
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
|
@Override
|
||||||
public Boolean shouldDisplayAsActive() {
|
public Boolean shouldDisplayAsActive() {
|
||||||
return this.task.getCompleted();
|
return !this.task.getCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,6 @@ import retrofit2.http.Query;
|
||||||
* Created by Negue on 27.11.2015.
|
* Created by Negue on 27.11.2015.
|
||||||
*/
|
*/
|
||||||
public interface InAppPurchasesApiService {
|
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);
|
Call<PurchaseValidationResult> validatePurchase(@Query("_id") String id, @Query("apiToken") String apiToken, @Body PurchaseValidationRequest request);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,10 @@ import rx.Observable;
|
||||||
|
|
||||||
public interface MaintenanceApiService {
|
public interface MaintenanceApiService {
|
||||||
|
|
||||||
@GET("/maintenance-android.json")
|
@GET("maintenance-android.json")
|
||||||
Observable<MaintenanceResponse> getMaintenanceStatus();
|
Observable<MaintenanceResponse> getMaintenanceStatus();
|
||||||
|
|
||||||
@GET("/deprecation-android.json")
|
@GET("deprecation-android.json")
|
||||||
Observable<MaintenanceResponse> getDepricationStatus();
|
Observable<MaintenanceResponse> getDepricationStatus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,9 @@ public class Task extends BaseModel {
|
||||||
// used for buyable items
|
// used for buyable items
|
||||||
public String specialTag;
|
public String specialTag;
|
||||||
|
|
||||||
|
public CharSequence parsedText;
|
||||||
|
public CharSequence parsedNotes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue