Improve reward list handling. Fixes #103

This commit is contained in:
Phillip Thelen 2015-12-05 16:12:01 +01:00
parent f3ecc21661
commit dd99bbe3ba
3 changed files with 26 additions and 15 deletions

View file

@ -20,7 +20,7 @@
android:clickable="false"
>
<LinearLayout
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
@ -33,30 +33,35 @@
android:layout_height="60dp"
android:layout_gravity="center_vertical"
android:visibility='@{reward.specialTag == "item" ? View.VISIBLE : View.GONE}'
bind:imageName='@{"shop_"+reward.id}'/>
bind:imageName='@{"shop_"+reward.id}'
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<LinearLayout
android:id="@+id/textReward"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="@dimen/task_top_bottom_padding"
android:paddingTop="@dimen/task_top_bottom_padding"
android:paddingLeft='16dp'
android:paddingRight="@dimen/reward_spacing">
android:paddingRight="@dimen/reward_spacing"
android:layout_toLeftOf="@+id/btnReward"
android:layout_toRightOf="@+id/imageView3"
android:layout_toEndOf="@+id/imageView3">
<TextView
android:id="@+id/checkedTextView"
style="@style/CardTitle"
android:layout_width="300dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{reward.text}"/>
<TextView
android:id="@+id/notesTextView"
style="@style/CardText"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{reward.notes}"
android:visibility="@{reward.notes != null ? View.VISIBLE : View.GONE}"/>
@ -65,20 +70,22 @@
<Button
android:id="@+id/btnReward"
android:layout_width="60dp"
android:layout_height="30dp"
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_marginRight="8dp"
android:textColor="@color/white"
android:layout_gravity="center_vertical"
android:textSize="15sp"
android:drawableLeft="@drawable/ic_header_gold"
android:text='@{String.format("%.0f", reward.value)}'
android:background="@drawable/rounded_purple_square"
android:layout_weight="2"
android:layout_marginRight="10dp"
android:paddingLeft="6dp" />
android:paddingLeft="6dp"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</LinearLayout>
</RelativeLayout>
<View
android:id="@+id/bottomBorderView"
android:layout_width="match_parent"

View file

@ -511,11 +511,15 @@ public class HabitItemRecyclerViewAdapter<THabitItem extends Task>
@Override
public void onClick(View v) {
if (v == btnReward) {
BuyRewardCommand event = new BuyRewardCommand();
event.Reward = Item;
EventBus.getDefault().post(event);
} else {
LinearLayout contentViewForDialog = createContentViewForDialog();
MaterialDialog dialog = createGearDialog(contentViewForDialog);
dialog.show();
} else super.onClick(v);
};
}
private MaterialDialog createGearDialog(LinearLayout contentViewForDialog) {

View file

@ -74,7 +74,7 @@ public class PreferencesFragment extends PreferenceFragment implements SharedPre
private void scheduleNotifications() {
String timeval = getPreferenceManager().getSharedPreferences().getString("reminder_time", null);
String timeval = getPreferenceManager().getSharedPreferences().getString("reminder_time", "19:00");
if (timeval != null) {
String[] pieces = timeval.split(":");