mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 01:28:52 -06:00
Show message when no habits are found
This commit is contained in:
@@ -95,6 +95,17 @@ public class ListHabitsFragment extends Fragment
|
||||
listView.setOnTouchListener(controller);
|
||||
listView.setDragEnabled(true);
|
||||
|
||||
if (Habit.getCount() == 0)
|
||||
{
|
||||
Log.d("x", "Removing listView");
|
||||
Typeface fontawesome =
|
||||
Typeface.createFromAsset(getActivity().getAssets(), "fontawesome-webfont.ttf");
|
||||
|
||||
((TextView) view.findViewById(R.id.tvStarEmpty)).setTypeface(fontawesome);
|
||||
|
||||
((ViewGroup) listView.getParent()).removeView(listView);
|
||||
}
|
||||
|
||||
GregorianCalendar day = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
|
||||
day.setTimeInMillis(DateHelper.getStartOfDay(DateHelper.getLocalTime()));
|
||||
|
||||
@@ -245,9 +256,6 @@ public class ListHabitsFragment extends Fragment
|
||||
|
||||
class ListHabitsAdapter extends BaseAdapter
|
||||
{
|
||||
|
||||
String habits[] = {"wake up early", "work out", "meditate", "take vitamins", "go to school",
|
||||
"cook dinner & lunch"};
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private Typeface fontawesome;
|
||||
@@ -344,11 +352,13 @@ public class ListHabitsFragment extends Fragment
|
||||
{
|
||||
tvStar.setText(context.getString(R.string.fa_star_o));
|
||||
tvStar.setTextColor(inactiveColor);
|
||||
} else if (score < Habit.FULL_STAR_CUTOFF)
|
||||
}
|
||||
else if (score < Habit.FULL_STAR_CUTOFF)
|
||||
{
|
||||
tvStar.setText(context.getString(R.string.fa_star_half_o));
|
||||
tvStar.setTextColor(inactiveColor);
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
tvStar.setText(context.getString(R.string.fa_star));
|
||||
tvStar.setTextColor(activeColor);
|
||||
|
||||
@@ -17,6 +17,27 @@
|
||||
dslv:use_default_controller="true"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/tvEmpty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvStarEmpty"
|
||||
style="@style/habitsListEmptyStyle"
|
||||
android:text="@string/fa_star_half_o"
|
||||
android:textSize="80sp"/>
|
||||
|
||||
<TextView
|
||||
android:text="@string/no_habits_found"
|
||||
style="@style/habitsListEmptyStyle"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
<LinearLayout style="@style/habitsListHeaderStyle">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<declare-styleable name="DragSortListView">
|
||||
<attr name="collapsed_height" format="dimension"/>
|
||||
<attr name="drag_scroll_start" format="float"/>
|
||||
<attr name="max_drag_scroll_speed" format="float"/>
|
||||
<attr name="float_background_color" format="color"/>
|
||||
<attr name="remove_mode">
|
||||
<enum name="clickRemove" value="0"/>
|
||||
<enum name="flingRemove" value="1"/>
|
||||
</attr>
|
||||
<attr name="track_drag_sort" format="boolean"/>
|
||||
<attr name="float_alpha" format="float"/>
|
||||
<attr name="slide_shuffle_speed" format="float"/>
|
||||
<attr name="remove_animation_duration" format="integer"/>
|
||||
<attr name="drop_animation_duration" format="integer"/>
|
||||
<attr name="drag_enabled" format="boolean"/>
|
||||
<attr name="sort_enabled" format="boolean"/>
|
||||
<attr name="remove_enabled" format="boolean"/>
|
||||
<attr name="drag_start_mode">
|
||||
<enum name="onDown" value="0"/>
|
||||
<enum name="onMove" value="1"/>
|
||||
<enum name="onLongPress" value="2"/>
|
||||
</attr>
|
||||
<attr name="drag_handle_id" format="integer"/>
|
||||
<attr name="fling_handle_id" format="integer"/>
|
||||
<attr name="click_remove_id" format="integer"/>
|
||||
<attr name="use_default_controller" format="boolean"/>
|
||||
</declare-styleable>
|
||||
<!--<declare-styleable name="DragSortListView">-->
|
||||
<!--<attr name="collapsed_height" format="dimension"/>-->
|
||||
<!--<attr name="drag_scroll_start" format="float"/>-->
|
||||
<!--<attr name="max_drag_scroll_speed" format="float"/>-->
|
||||
<!--<attr name="float_background_color" format="color"/>-->
|
||||
<!--<attr name="remove_mode">-->
|
||||
<!--<enum name="clickRemove" value="0"/>-->
|
||||
<!--<enum name="flingRemove" value="1"/>-->
|
||||
<!--</attr>-->
|
||||
<!--<attr name="track_drag_sort" format="boolean"/>-->
|
||||
<!--<attr name="float_alpha" format="float"/>-->
|
||||
<!--<attr name="slide_shuffle_speed" format="float"/>-->
|
||||
<!--<attr name="remove_animation_duration" format="integer"/>-->
|
||||
<!--<attr name="drop_animation_duration" format="integer"/>-->
|
||||
<!--<attr name="drag_enabled" format="boolean"/>-->
|
||||
<!--<attr name="sort_enabled" format="boolean"/>-->
|
||||
<!--<attr name="remove_enabled" format="boolean"/>-->
|
||||
<!--<attr name="drag_start_mode">-->
|
||||
<!--<enum name="onDown" value="0"/>-->
|
||||
<!--<enum name="onMove" value="1"/>-->
|
||||
<!--<enum name="onLongPress" value="2"/>-->
|
||||
<!--</attr>-->
|
||||
<!--<attr name="drag_handle_id" format="integer"/>-->
|
||||
<!--<attr name="fling_handle_id" format="integer"/>-->
|
||||
<!--<attr name="click_remove_id" format="integer"/>-->
|
||||
<!--<attr name="use_default_controller" format="boolean"/>-->
|
||||
<!--</declare-styleable>-->
|
||||
</resources>
|
||||
|
||||
@@ -56,5 +56,6 @@
|
||||
<string name="discard">Discard</string>
|
||||
<string name="save">Save</string>
|
||||
<string name="streaks">Streaks</string>
|
||||
<string name="no_habits_found">You have no active habits</string>
|
||||
|
||||
</resources>
|
||||
@@ -80,4 +80,14 @@
|
||||
<item name="android:textSize">10sp</item>
|
||||
<item name="android:textColor">#606060</item>
|
||||
</style>
|
||||
|
||||
|
||||
<style name="habitsListEmptyStyle">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:gravity">center</item>
|
||||
<item name="android:layout_marginTop">20dp</item>
|
||||
<item name="android:textColor">#c0c0c0</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user