Fix history
This commit is contained in:
parent
61cd6c6ec6
commit
f733ad4f8a
2 changed files with 25 additions and 3 deletions
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="confirmation_to_clear_history">Do you want to clear the whole history?</string>
|
||||
<string name="delay_to_start_navigation_descr">Automatically start navigation after specified interval</string>
|
||||
<string name="delay_to_start_navigation">Skip route planning</string>
|
||||
<string name="shared_string_go">Go</string>
|
||||
|
|
|
@ -18,7 +18,10 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
|||
import net.osmand.util.MapUtils;
|
||||
import android.R.anim;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -64,9 +67,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
|
|||
clearButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
helper.removeAll();
|
||||
historyAdapter.clear();
|
||||
clearButton.setVisibility(View.GONE);
|
||||
clearWithConfirmation();
|
||||
}
|
||||
});
|
||||
((ListView)view.findViewById(android.R.id.list)).setOnItemClickListener(new OnItemClickListener() {
|
||||
|
@ -79,6 +80,26 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
|
|||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void clearWithConfirmation() {
|
||||
Builder bld = new AlertDialog.Builder(getActivity());
|
||||
bld.setMessage(R.string.confirmation_to_clear_history);
|
||||
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
clearWithoutConfirmation();
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_no, null);
|
||||
bld.show();
|
||||
}
|
||||
|
||||
private void clearWithoutConfirmation() {
|
||||
helper.removeAll();
|
||||
historyAdapter.clear();
|
||||
clearButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
|
Loading…
Reference in a new issue