Skip to content

Commit e9044f8

Browse files
committed
Bugfixes; Downgrade gradle plugin as it causes problems
1 parent 2f8cb99 commit e9044f8

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

app/src/main/java/com/proxerme/app/activity/DashboardActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ protected void onCreate(Bundle savedInstanceState) {
143143
userManager.addOnLoginStateListener(new UserManager.OnLoginStateListener() {
144144
@Override
145145
public void onLogin(@NonNull LoginUser user) {
146-
if (!isFinishing()) {
146+
if (!isDestroyedCompat()) {
147147
drawerHelper.refreshHeader();
148148
}
149149
}
150150

151151
@Override
152152
public void onLogout() {
153-
if (!isFinishing()) {
153+
if (!isDestroyedCompat()) {
154154
drawerHelper.refreshHeader();
155155
}
156156
}

app/src/main/java/com/proxerme/app/activity/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.annotation.SuppressLint;
44
import android.net.Uri;
5+
import android.os.Build;
56
import android.os.Bundle;
67
import android.support.annotation.NonNull;
78
import android.support.customtabs.CustomTabsIntent;
@@ -59,4 +60,8 @@ public void showPage(@NonNull String url) {
5960
CustomTabActivityHelper.openCustomTab(
6061
this, customTabsIntent, Uri.parse(url), new WebviewFallback());
6162
}
63+
64+
public boolean isDestroyedCompat() {
65+
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed();
66+
}
6267
}

app/src/main/java/com/proxerme/app/dialog/LoginDialog.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
*/
3939
public class LoginDialog extends DialogFragment {
4040

41+
private static final String STATE_LOADING = "login_loading";
42+
4143
ViewGroup root;
4244

4345
@Bind(R.id.dialog_login_username_container)
@@ -69,6 +71,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
6971
initViews();
7072

7173
if (savedInstanceState != null) {
74+
loading = savedInstanceState.getBoolean(STATE_LOADING);
75+
7276
handleVisibility();
7377
}
7478

@@ -107,6 +111,12 @@ public void onDismiss(DialogInterface dialog) {
107111
ProxerConnection.cancelSync(ProxerTag.LOGIN, false);
108112
}
109113

114+
@Override
115+
public void onSaveInstanceState(Bundle outState) {
116+
super.onSaveInstanceState(outState);
117+
outState.putBoolean(STATE_LOADING, loading);
118+
}
119+
110120
private void findViews() {
111121
root = (ViewGroup) View.inflate(getContext(), R.layout.dialog_login, null);
112122
ButterKnife.bind(this, root);
@@ -118,6 +128,7 @@ private void initViews() {
118128
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
119129
if (actionId == EditorInfo.IME_ACTION_GO) {
120130
login();
131+
121132
return true;
122133
}
123134
return false;
@@ -156,9 +167,11 @@ public void onLogin(@NonNull LoginUser user) {
156167

157168
@Override
158169
public void onLoginFailed(@NonNull ProxerException exception) {
159-
Toast.makeText(getContext(),
160-
ErrorHandler.getMessageForErrorCode(getContext(),
161-
exception.getErrorCode()), Toast.LENGTH_LONG).show();
170+
if (getContext() != null) {
171+
Toast.makeText(getContext(),
172+
ErrorHandler.getMessageForErrorCode(getContext(),
173+
exception.getErrorCode()), Toast.LENGTH_LONG).show();
174+
}
162175

163176
loading = false;
164177
handleVisibility();

build.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2-
31
buildscript {
42
repositories {
53
jcenter()
64
}
75
dependencies {
8-
classpath 'com.android.tools.build:gradle:1.4.0-beta3'
9-
10-
// NOTE: Do not place your application dependencies here; they belong
11-
// in the individual module build.gradle files
6+
classpath 'com.android.tools.build:gradle:1.3.1'
127
}
138
}
149

0 commit comments

Comments
 (0)