Skip to content

Commit

Permalink
Bugfixes; Downgrade gradle plugin as it causes problems
Browse files Browse the repository at this point in the history
  • Loading branch information
rubengees committed Oct 16, 2015
1 parent 2f8cb99 commit e9044f8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,14 @@ protected void onCreate(Bundle savedInstanceState) {
userManager.addOnLoginStateListener(new UserManager.OnLoginStateListener() {
@Override
public void onLogin(@NonNull LoginUser user) {
if (!isFinishing()) {
if (!isDestroyedCompat()) {
drawerHelper.refreshHeader();
}
}

@Override
public void onLogout() {
if (!isFinishing()) {
if (!isDestroyedCompat()) {
drawerHelper.refreshHeader();
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/com/proxerme/app/activity/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.annotation.SuppressLint;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.customtabs.CustomTabsIntent;
Expand Down Expand Up @@ -59,4 +60,8 @@ public void showPage(@NonNull String url) {
CustomTabActivityHelper.openCustomTab(
this, customTabsIntent, Uri.parse(url), new WebviewFallback());
}

public boolean isDestroyedCompat() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && isDestroyed();
}
}
19 changes: 16 additions & 3 deletions app/src/main/java/com/proxerme/app/dialog/LoginDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
*/
public class LoginDialog extends DialogFragment {

private static final String STATE_LOADING = "login_loading";

ViewGroup root;

@Bind(R.id.dialog_login_username_container)
Expand Down Expand Up @@ -69,6 +71,8 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
initViews();

if (savedInstanceState != null) {
loading = savedInstanceState.getBoolean(STATE_LOADING);

handleVisibility();
}

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

@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(STATE_LOADING, loading);
}

private void findViews() {
root = (ViewGroup) View.inflate(getContext(), R.layout.dialog_login, null);
ButterKnife.bind(this, root);
Expand All @@ -118,6 +128,7 @@ private void initViews() {
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_GO) {
login();

return true;
}
return false;
Expand Down Expand Up @@ -156,9 +167,11 @@ public void onLogin(@NonNull LoginUser user) {

@Override
public void onLoginFailed(@NonNull ProxerException exception) {
Toast.makeText(getContext(),
ErrorHandler.getMessageForErrorCode(getContext(),
exception.getErrorCode()), Toast.LENGTH_LONG).show();
if (getContext() != null) {
Toast.makeText(getContext(),
ErrorHandler.getMessageForErrorCode(getContext(),
exception.getErrorCode()), Toast.LENGTH_LONG).show();
}

loading = false;
handleVisibility();
Expand Down
7 changes: 1 addition & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.4.0-beta3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:1.3.1'
}
}

Expand Down

0 comments on commit e9044f8

Please sign in to comment.