refresh treatments confirm dialog

This commit is contained in:
Milos Kozak 2016-06-06 12:30:20 +02:00
parent bd47fb8624
commit 04f1b37c51

View file

@ -1,9 +1,11 @@
package info.nightscout.androidaps.plugins.Treatments;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
@ -185,10 +187,20 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
public void onClick(View view) {
switch (view.getId()) {
case R.id.treatments_reshreshfromnightscout:
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
builder.setTitle("Dialog");
builder.setMessage("Do you want to refresh treatments from Nightscout");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MainApp.getDbHelper().resetTreatments();
initializeData();
Intent restartNSClient = new Intent(Intents.ACTION_RESTART);
MainApp.instance().getApplicationContext().sendBroadcast(restartNSClient);
}
});
builder.setNegativeButton("Cancel", null);
builder.show();
break;
}
}
@ -243,7 +255,7 @@ public class TreatmentsFragment extends Fragment implements View.OnClickListener
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p/>
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.