fix potential NPE

This commit is contained in:
Mohamed Zenadi
2015-08-03 00:01:24 +02:00
parent d57246adb1
commit feb8eefcc4
2 changed files with 7 additions and 3 deletions

View File

@@ -449,9 +449,13 @@ public class PasswordStore extends AppCompatActivity {
case CLONE_REPO_BUTTON:
// duplicate code
if (settings.getBoolean("git_external", false) && settings.getString("git_external_repo", null) != null) {
File dir = new File(settings.getString("git_external_repo", null));
String externalRepoPath = settings.getString("git_external_repo", null);
File dir = externalRepoPath != null ? new File(externalRepoPath) : null;
if (dir.exists() && dir.isDirectory() && !FileUtils.listFiles(dir, null, true).isEmpty() &&
if (dir != null &&
dir.exists() &&
dir.isDirectory() &&
!FileUtils.listFiles(dir, null, true).isEmpty() &&
!PasswordRepository.getPasswords(dir).isEmpty()) {
PasswordRepository.closeRepository();
checkLocalRepository();

View File

@@ -9,6 +9,6 @@
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>
android:orientation="vertical"/>
</RelativeLayout>