Skip to content

Commit

Permalink
fixed FileChooser when choosing a directory
Browse files Browse the repository at this point in the history
  • Loading branch information
pepperonas committed Apr 18, 2017
1 parent ae95ddc commit fbbd490
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Add JitPack to your repositories:

and add the library to your dependencies:
```
compile 'com.github.pepperonas:materialdialog:0.3.2'
compile 'com.github.pepperonas:materialdialog:0.3.3'
```


Expand Down
2 changes: 1 addition & 1 deletion library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
minSdkVersion 12
targetSdkVersion 25
versionCode 1
versionName "0.3.2"
versionName "0.3.3"
}
lintOptions {
abortOnError false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ private void invoke(@NonNull final Builder builder) {
builder.viewSpacingRight, builder.viewSpacingBottom);
}


setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
if (builder.fullscreen) {
getWindow().setLayout(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
}
}
});

// list
if ((builder.items != null && builder.items.length > 0) || builder.shareAppDialog
|| builder.adapter != null) {
Expand Down Expand Up @@ -629,17 +640,6 @@ public void onDismiss(DialogInterface dialog) {
}
});


setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
if (builder.fullscreen) {
getWindow().setLayout(LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT);
}
}
});

}


Expand Down
37 changes: 36 additions & 1 deletion showcase/src/main/java/com/pepperonas/showcase/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public void onShow(AlertDialog d) {
@Override
public void onDismiss() {
super.onDismiss();
showToast("onDismiss");
}
})
.buttonCallback(new MaterialDialog.ButtonCallback() {
Expand Down Expand Up @@ -296,6 +295,35 @@ public void onPositive(MaterialDialog dialog) {
}


private void showDirectoryChooserDialog() {
new Builder(this)
.negativeText("CANCEL")
.fileChooserDialog(this, false, null, new FileChooserListener() {
@Override
public void onFileSelected(MaterialDialog dialog, View view, int position, long id,
File file) {
super.onFileSelected(dialog, view, position, id, file);
showToast("onFileSelected (" + file.getPath() + ")");
dialog.dismiss();
}

@Override
public void onFileSet(MaterialDialog dialog, File file) {
super.onFileSet(dialog, file);
showToast("onFileSet (" + file.getPath() + ")");
}
})
.buttonCallback(new ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
super.onPositive(dialog);
}
})
.positiveText("OK")
.show();
}


private void showMaterialDialogListNoTitle() {
new MaterialDialog.Builder(this)
.title(null)
Expand Down Expand Up @@ -603,6 +631,13 @@ public void onDialogFileChooser(View view) {
showFileChooserDialog();
}

public void onDialogDirectoryChooser(View view) {
if (!checkPermission()) {
return;
}
showDirectoryChooserDialog();
}


public void onDialogListNoTitle(View view) {
showMaterialDialogListNoTitle();
Expand Down
8 changes: 8 additions & 0 deletions showcase/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
android:onClick="onDialogFileChooser"
android:text="File Chooser Dialog" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/button_margin_bottom"
android:layout_marginTop="@dimen/button_margin_top"
android:onClick="onDialogDirectoryChooser"
android:text="Directory Chooser Dialog" />

<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down

0 comments on commit fbbd490

Please sign in to comment.