Display toast when user does not long press

pull/30/head
Alinson S. Xavier 10 years ago
parent 0e10a0d14d
commit d42343cab3

@ -260,22 +260,23 @@ public class ListHabitsFragment extends Fragment
@Override @Override
public boolean onLongClick(View v) public boolean onLongClick(View v)
{ {
int id = v.getId(); switch(v.getId())
if (id == R.id.tvCheck)
{ {
lastLongClick = new Date().getTime(); case R.id.tvCheck:
Habit habit = Habit.get((Long) v.getTag(R.string.habit_key)); {
int offset = (Integer) v.getTag(R.string.offset_key); lastLongClick = new Date().getTime();
long timestamp = DateHelper.getStartOfDay( Habit habit = Habit.get((Long) v.getTag(R.string.habit_key));
DateHelper.getLocalTime() - offset * DateHelper.millisecondsInOneDay); int offset = (Integer) v.getTag(R.string.offset_key);
long timestamp = DateHelper.getStartOfDay(
DateHelper.getLocalTime() - offset * DateHelper.millisecondsInOneDay);
executeCommand(habit.new ToggleRepetitionCommand(timestamp)); executeCommand(habit.new ToggleRepetitionCommand(timestamp));
Vibrator vb = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE); Vibrator vb = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);
vb.vibrate(100); vb.vibrate(100);
return true; return true;
}
} }
return false; return false;
@ -296,6 +297,12 @@ public class ListHabitsFragment extends Fragment
@Override @Override
public void onClick(View v) public void onClick(View v)
{ {
switch(v.getId())
{
case R.id.tvCheck:
activity.showToast(R.string.long_press_to_toggle);
return;
}
} }
class ListHabitsAdapter extends BaseAdapter class ListHabitsAdapter extends BaseAdapter
@ -356,6 +363,7 @@ public class ListHabitsFragment extends Fragment
TextView btCheck = (TextView) check.findViewById(R.id.tvCheck); TextView btCheck = (TextView) check.findViewById(R.id.tvCheck);
btCheck.setTypeface(fontawesome); btCheck.setTypeface(fontawesome);
btCheck.setOnLongClickListener(ListHabitsFragment.this); btCheck.setOnLongClickListener(ListHabitsFragment.this);
btCheck.setOnClickListener(ListHabitsFragment.this);
((LinearLayout) view.findViewById(R.id.llButtons)).addView(check); ((LinearLayout) view.findViewById(R.id.llButtons)).addView(check);
} }

@ -62,5 +62,6 @@
<string name="save">Save</string> <string name="save">Save</string>
<string name="streaks">Streaks</string> <string name="streaks">Streaks</string>
<string name="no_habits_found">You have no active habits</string> <string name="no_habits_found">You have no active habits</string>
<string name="long_press_to_toggle">Long press to check or uncheck</string>
</resources> </resources>
Loading…
Cancel
Save