Hide empty message

pull/30/head
Alinson S. Xavier 10 years ago
parent 3d79f5d928
commit 48cfec7605

@ -7,7 +7,6 @@ import android.graphics.Color;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
@ -61,8 +60,8 @@ public class ListHabitsFragment extends Fragment
TextView tvNameHeader; TextView tvNameHeader;
long lastLongClick = 0; long lastLongClick = 0;
private int tvNameWidth; private int tvNameWidth;
private int button_count; private int button_count;
private View llEmpty;
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -95,16 +94,11 @@ public class ListHabitsFragment extends Fragment
listView.setOnTouchListener(controller); listView.setOnTouchListener(controller);
listView.setDragEnabled(true); listView.setDragEnabled(true);
if (Habit.getCount() == 0)
{
Log.d("x", "Removing listView");
Typeface fontawesome = Typeface fontawesome =
Typeface.createFromAsset(getActivity().getAssets(), "fontawesome-webfont.ttf"); Typeface.createFromAsset(getActivity().getAssets(), "fontawesome-webfont.ttf");
((TextView) view.findViewById(R.id.tvStarEmpty)).setTypeface(fontawesome); ((TextView) view.findViewById(R.id.tvStarEmpty)).setTypeface(fontawesome);
llEmpty = view.findViewById(R.id.llEmpty);
((ViewGroup) listView.getParent()).removeView(listView); updateEmptyMessage();
}
GregorianCalendar day = new GregorianCalendar(TimeZone.getTimeZone("GMT")); GregorianCalendar day = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
day.setTimeInMillis(DateHelper.getStartOfDay(DateHelper.getLocalTime())); day.setTimeInMillis(DateHelper.getStartOfDay(DateHelper.getLocalTime()));
@ -198,9 +192,16 @@ public class ListHabitsFragment extends Fragment
public void notifyDataSetChanged() public void notifyDataSetChanged()
{ {
updateEmptyMessage();
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
private void updateEmptyMessage()
{
Log.d("x", "updating empty message");
llEmpty.setVisibility(Habit.getCount() > 0 ? View.GONE : View.VISIBLE);
}
@Override @Override
public boolean onLongClick(View v) public boolean onLongClick(View v)
{ {

@ -29,7 +29,7 @@
<EditText <EditText
android:id="@+id/input_description" android:id="@+id/input_description"
android:hint="@string/description" android:hint="@string/description_hint"
style="@style/dialogFormInputMultiline" /> style="@style/dialogFormInputMultiline" />
<LinearLayout <LinearLayout

@ -18,7 +18,7 @@
/> />
<LinearLayout <LinearLayout
android:id="@+id/tvEmpty" android:id="@+id/llEmpty"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
@ -31,13 +31,11 @@
android:textSize="80sp"/> android:textSize="80sp"/>
<TextView <TextView
android:text="@string/no_habits_found" style="@style/habitsListEmptyStyle"
style="@style/habitsListEmptyStyle"/> android:text="@string/no_habits_found"/>
</LinearLayout> </LinearLayout>
<LinearLayout style="@style/habitsListHeaderStyle"> <LinearLayout style="@style/habitsListHeaderStyle">
<TextView <TextView

@ -47,6 +47,7 @@
<string name="history">History</string> <string name="history">History</string>
<string name="clear">Clear</string> <string name="clear">Clear</string>
<string name="description">Description</string> <string name="description">Description</string>
<string name="description_hint">Description</string>
<string name="repeat">Repeat</string> <string name="repeat">Repeat</string>
<string name="default_freq_num">3</string> <string name="default_freq_num">3</string>
<string name="times_every">times every</string> <string name="times_every">times every</string>

Loading…
Cancel
Save