From be5dbcbb2e5afef17d47b4cbbf9e0eb08de69da4 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 13 Aug 2015 20:11:58 +0200 Subject: [PATCH] fixed bug caused by rotating the device --- .../ui/preview/PreviewTextFragment.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/com/owncloud/android/ui/preview/PreviewTextFragment.java b/src/com/owncloud/android/ui/preview/PreviewTextFragment.java index e9479a3570..c1511aae07 100644 --- a/src/com/owncloud/android/ui/preview/PreviewTextFragment.java +++ b/src/com/owncloud/android/ui/preview/PreviewTextFragment.java @@ -202,11 +202,20 @@ public class PreviewTextFragment extends FileFragment { * Show loading dialog */ public void showLoadingDialog() { - // Construct dialog - LoadingDialog loading = new LoadingDialog(getResources().getString(R.string.wait_a_moment)); - FragmentManager fm = getActivity().getSupportFragmentManager(); - FragmentTransaction ft = fm.beginTransaction(); - loading.show(ft, DIALOG_WAIT_TAG); + // only once + Fragment frag = getActivity().getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG); + LoadingDialog loading = null; + if (frag == null) { + // Construct dialog + loading = new LoadingDialog(getResources().getString(R.string.wait_a_moment)); + FragmentManager fm = getActivity().getSupportFragmentManager(); + FragmentTransaction ft = fm.beginTransaction(); + loading.show(ft, DIALOG_WAIT_TAG); + } else { + loading = (LoadingDialog) frag; + loading.setShowsDialog(true); + } + } /**