Prevent crash

This commit is contained in:
M66B
2020-10-30 10:36:16 +01:00
parent aea6a79019
commit 3c8c9da858
27 changed files with 133697 additions and 229 deletions

View File

@@ -20,7 +20,6 @@ package eu.faircode.email;
*/
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
@@ -58,9 +57,7 @@ public class FragmentDialogDuration extends FragmentDialogBase {
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
String title = getArguments().getString("title");
final Context context = getContext();
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_duration, null);
final View dview = LayoutInflater.from(getContext()).inflate(R.layout.dialog_duration, null);
final TextView tvDuration = dview.findViewById(R.id.tvDuration);
final Button btn1hour = dview.findViewById(R.id.btn1hour);
final Button btn1day = dview.findViewById(R.id.btn1day);
@@ -74,10 +71,10 @@ public class FragmentDialogDuration extends FragmentDialogBase {
cal.setTimeInMillis(savedInstanceState.getLong("fair:time"));
Log.i("Set init=" + new Date(cal.getTimeInMillis()));
final DateFormat DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.FULL, SimpleDateFormat.SHORT);
final DateFormat DTF = Helper.getDateTimeInstance(getContext(), SimpleDateFormat.FULL, SimpleDateFormat.SHORT);
tvDuration.setText(DTF.format(cal.getTime()));
timePicker.setIs24HourView(android.text.format.DateFormat.is24HourFormat(context));
timePicker.setIs24HourView(android.text.format.DateFormat.is24HourFormat(getContext()));
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
@@ -86,7 +83,7 @@ public class FragmentDialogDuration extends FragmentDialogBase {
timePicker.setMinute(cal.get(Calendar.MINUTE));
}
Dialog dialog = new AlertDialog.Builder(context)
Dialog dialog = new AlertDialog.Builder(getContext())
.setTitle(title)
.setView(dview)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@@ -177,9 +174,8 @@ public class FragmentDialogDuration extends FragmentDialogBase {
@Override
protected void sendResult(int result) {
if (result == RESULT_OK) {
final Context context = getContext();
if (!ActivityBilling.isPro(context)) {
startActivity(new Intent(context, ActivityBilling.class));
if (!ActivityBilling.isPro(getContext())) {
startActivity(new Intent(getContext(), ActivityBilling.class));
result = RESULT_CANCELED;
}
}