confirm dialog on removing temptarget
This commit is contained in:
parent
b6714ae254
commit
7c90dfe03c
|
@ -77,7 +77,6 @@ public class MainApp extends Application {
|
||||||
// Register all tabs in app here
|
// Register all tabs in app here
|
||||||
pluginsList.add(OverviewFragment.getPlugin());
|
pluginsList.add(OverviewFragment.getPlugin());
|
||||||
pluginsList.add(ActionsFragment.getPlugin());
|
pluginsList.add(ActionsFragment.getPlugin());
|
||||||
pluginsList.add(TempTargetRangeFragment.getPlugin());
|
|
||||||
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
if (Config.DANAR) pluginsList.add(DanaRFragment.getPlugin());
|
||||||
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
if (Config.DANARKOREAN) pluginsList.add(DanaRKoreanFragment.getPlugin());
|
||||||
if (Config.CAREPORTALENABLED) pluginsList.add(CareportalFragment.getPlugin());
|
if (Config.CAREPORTALENABLED) pluginsList.add(CareportalFragment.getPlugin());
|
||||||
|
@ -89,6 +88,7 @@ public class MainApp extends Application {
|
||||||
pluginsList.add(SimpleProfileFragment.getPlugin());
|
pluginsList.add(SimpleProfileFragment.getPlugin());
|
||||||
pluginsList.add(LocalProfileFragment.getPlugin());
|
pluginsList.add(LocalProfileFragment.getPlugin());
|
||||||
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
pluginsList.add(CircadianPercentageProfileFragment.getPlugin());
|
||||||
|
pluginsList.add(TempTargetRangeFragment.getPlugin());
|
||||||
pluginsList.add(TreatmentsFragment.getPlugin());
|
pluginsList.add(TreatmentsFragment.getPlugin());
|
||||||
pluginsList.add(TempBasalsFragment.getPlugin());
|
pluginsList.add(TempBasalsFragment.getPlugin());
|
||||||
pluginsList.add(SafetyFragment.getPlugin());
|
pluginsList.add(SafetyFragment.getPlugin());
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.plugins.TempTargetRange;
|
package info.nightscout.androidaps.plugins.TempTargetRange;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
@ -53,7 +54,9 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
LinearLayoutManager llm;
|
LinearLayoutManager llm;
|
||||||
Button refreshFromNS;
|
Button refreshFromNS;
|
||||||
|
|
||||||
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempTargetsViewHolder> {
|
Context context;
|
||||||
|
|
||||||
|
public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.TempTargetsViewHolder> {
|
||||||
|
|
||||||
List<TempTarget> tempTargetList;
|
List<TempTarget> tempTargetList;
|
||||||
|
|
||||||
|
@ -95,7 +98,7 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
super.onAttachedToRecyclerView(recyclerView);
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TempTargetsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
public class TempTargetsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||||
CardView cv;
|
CardView cv;
|
||||||
TextView date;
|
TextView date;
|
||||||
TextView duration;
|
TextView duration;
|
||||||
|
@ -121,20 +124,29 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
TempTarget tempTarget = (TempTarget) v.getTag();
|
final TempTarget tempTarget = (TempTarget) v.getTag();
|
||||||
|
final Context finalContext = context;
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.temptargetrange_remove:
|
case R.id.temptargetrange_remove:
|
||||||
String _id = tempTarget._id;
|
final String _id = tempTarget._id;
|
||||||
if (_id != null && !_id.equals("")) {
|
if (_id != null && !_id.equals("")) {
|
||||||
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
try {
|
builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
|
||||||
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + _id);
|
||||||
daoTempTargets.delete(tempTarget);
|
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
MainApp.bus().post(new EventTempTargetRangeChange());
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
} catch (SQLException e) {
|
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
|
||||||
e.printStackTrace();
|
try {
|
||||||
}
|
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
|
||||||
|
daoTempTargets.delete(tempTarget);
|
||||||
|
MainApp.bus().post(new EventTempTargetRangeChange());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
|
||||||
|
builder.show();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -158,6 +170,8 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
|
||||||
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
|
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
|
||||||
refreshFromNS.setOnClickListener(this);
|
refreshFromNS.setOnClickListener(this);
|
||||||
|
|
||||||
|
context = getContext();
|
||||||
|
|
||||||
updateGUI();
|
updateGUI();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
|
@ -404,4 +404,5 @@
|
||||||
<string name="careportal_temptarget">Temporary Target</string>
|
<string name="careportal_temptarget">Temporary Target</string>
|
||||||
<string name="eatingsoon">Eating Soon</string>
|
<string name="eatingsoon">Eating Soon</string>
|
||||||
<string name="activity">Activity</string>
|
<string name="activity">Activity</string>
|
||||||
|
<string name="removerecord">Remove record:</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue