Bläddra i källkod

NullCheck for drawer

Andy Scherzinger 9 år sedan
förälder
incheckning
8db8b07be0
1 ändrade filer med 16 tillägg och 2 borttagningar
  1. 16 2
      src/com/owncloud/android/ui/activity/FileActivity.java

+ 16 - 2
src/com/owncloud/android/ui/activity/FileActivity.java

@@ -315,12 +315,26 @@ public class FileActivity extends AppCompatActivity
         super.onBackPressed();
     }
 
+    /**
+     * checks if the drawer exists and is opened.
+     *
+     * @return <code>true</code> if the drawer is open, else <code>false</code>
+     */
     public boolean isDrawerOpen() {
-        return mDrawerLayout.isDrawerOpen(GravityCompat.START);
+        if(mDrawerLayout != null) {
+            return mDrawerLayout.isDrawerOpen(GravityCompat.START);
+        } else {
+            return false;
+        }
     }
 
+    /**
+     * closes the navigation drawer.
+     */
     public void closeNavDrawer() {
-        mDrawerLayout.closeDrawer(GravityCompat.START);
+        if(mDrawerLayout != null) {
+            mDrawerLayout.closeDrawer(GravityCompat.START);
+        }
     }
 
     protected void initDrawer(){