From 8eb4ee994bd3671ba698c48d3d69df39f5513508 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Sat, 4 Apr 2015 23:10:29 +0800 Subject: [PATCH] fixed crashes when using browser sign in updated version code --- twidere/build.gradle | 2 +- .../activity/support/SignInActivity.java | 18 +++++++++++++++--- .../support/SupportProgressDialogFragment.java | 4 +++- twidere/src/main/res/xml/preferences_cards.xml | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/twidere/build.gradle b/twidere/build.gradle index 9ce7ec674..2cb33ee7f 100644 --- a/twidere/build.gradle +++ b/twidere/build.gradle @@ -10,7 +10,7 @@ android { applicationId "org.mariotaku.twidere" minSdkVersion 14 targetSdkVersion 22 - versionCode 105 + versionCode 106 versionName "0.3.0" multiDexEnabled true } diff --git a/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java b/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java index 66791ebfe..d4c581390 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java +++ b/twidere/src/main/java/org/mariotaku/twidere/activity/support/SignInActivity.java @@ -32,10 +32,12 @@ import android.graphics.Color; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; +import android.os.Handler; import android.support.annotation.NonNull; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; +import android.support.v4.app.FragmentTransaction; import android.support.v7.app.ActionBar; import android.text.Editable; import android.text.TextUtils; @@ -503,10 +505,20 @@ public class SignInActivity extends BaseActionBarActivity implements TwitterCons setSignInButton(); } + private final Handler mHandler = new Handler(); + void onSignInStart() { - if (isFinishing()) return; - final SupportProgressDialogFragment fragment = SupportProgressDialogFragment.show(this, FRAGMENT_TAG_SIGN_IN_PROGRESS); - fragment.setCancelable(false); + mHandler.post(new Runnable() { + @Override + public void run() { + if (isFinishing()) return; + final FragmentManager fm = getSupportFragmentManager(); + final FragmentTransaction ft = fm.beginTransaction(); + final SupportProgressDialogFragment fragment = new SupportProgressDialogFragment(); + fragment.setCancelable(false); + fragment.show(ft, FRAGMENT_TAG_SIGN_IN_PROGRESS); + } + }); } public static abstract class AbstractSignInTask extends AsyncTask { diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SupportProgressDialogFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SupportProgressDialogFragment.java index 78f199146..20646b198 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SupportProgressDialogFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/SupportProgressDialogFragment.java @@ -22,13 +22,15 @@ package org.mariotaku.twidere.fragment.support; import android.app.Dialog; import android.app.ProgressDialog; import android.os.Bundle; +import android.support.annotation.NonNull; import android.support.v4.app.FragmentActivity; import org.mariotaku.twidere.R; public class SupportProgressDialogFragment extends BaseSupportDialogFragment { - @Override + @NonNull + @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setMessage(getString(R.string.please_wait)); diff --git a/twidere/src/main/res/xml/preferences_cards.xml b/twidere/src/main/res/xml/preferences_cards.xml index cc01a89ef..22a459ea1 100644 --- a/twidere/src/main/res/xml/preferences_cards.xml +++ b/twidere/src/main/res/xml/preferences_cards.xml @@ -16,7 +16,7 @@ android:order="22" android:title="@string/name_first"/>