diff --git a/app/src/main/java/com/kiminonawa/mydiary/entries/diary/SaveDiaryTask.java b/app/src/main/java/com/kiminonawa/mydiary/entries/diary/SaveDiaryTask.java index 43294ac..e1255a7 100644 --- a/app/src/main/java/com/kiminonawa/mydiary/entries/diary/SaveDiaryTask.java +++ b/app/src/main/java/com/kiminonawa/mydiary/entries/diary/SaveDiaryTask.java @@ -114,13 +114,13 @@ protected Integer doInBackground(Long... params) { @Override protected void onPostExecute(Integer result) { super.onPostExecute(result); + progressDialog.dismiss(); if (result == SaveDiaryTask.RESULT_INSERT_SUCCESSFUL) { Toast.makeText(mContext, mContext.getString(R.string.toast_diary_insert_successful), Toast.LENGTH_LONG).show(); + callBack.onDiarySaved(); } else { Toast.makeText(mContext, mContext.getString(R.string.toast_diary_insert_fail), Toast.LENGTH_LONG).show(); } - progressDialog.dismiss(); - callBack.onDiarySaved(); } private void savePhoto(String filename) throws Exception { diff --git a/app/src/main/java/com/kiminonawa/mydiary/entries/entries/DiaryViewerDialogFragment.java b/app/src/main/java/com/kiminonawa/mydiary/entries/entries/DiaryViewerDialogFragment.java index 3676109..aaf319e 100644 --- a/app/src/main/java/com/kiminonawa/mydiary/entries/entries/DiaryViewerDialogFragment.java +++ b/app/src/main/java/com/kiminonawa/mydiary/entries/entries/DiaryViewerDialogFragment.java @@ -775,7 +775,7 @@ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth setDiaryTime(); TimePickerFragment timePickerFragment = TimePickerFragment.newInstance(calendar.getTimeInMillis()); timePickerFragment.setOnTimeSetListener(this); - timePickerFragment.show(getFragmentManager(), "timePickerFragment"); + timePickerFragment.show(getActivity().getSupportFragmentManager(), "timePickerFragment"); } } diff --git a/app/src/main/java/com/kiminonawa/mydiary/shared/ScreenHelper.java b/app/src/main/java/com/kiminonawa/mydiary/shared/ScreenHelper.java index f0bf95e..0c43744 100644 --- a/app/src/main/java/com/kiminonawa/mydiary/shared/ScreenHelper.java +++ b/app/src/main/java/com/kiminonawa/mydiary/shared/ScreenHelper.java @@ -6,11 +6,10 @@ import android.content.res.Resources; import android.os.Build; import android.util.DisplayMetrics; +import android.util.Log; import android.util.TypedValue; import android.view.View; -import java.text.DecimalFormat; - /** * Created by daxia on 2016/9/23. */ @@ -21,8 +20,8 @@ public class ScreenHelper { public static float getScreenRatio(Activity activity) { DisplayMetrics metrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(metrics); - DecimalFormat mDecimalFormat = new DecimalFormat("#.##"); - float ScreenRatio = Float.valueOf(mDecimalFormat.format(metrics.heightPixels / metrics.widthPixels)); + float ScreenRatio = (float) metrics.heightPixels / (float) metrics.widthPixels; + Log.e("Test", "screenRation = " + ScreenRatio); return ScreenRatio; }