|
29 | 29 | import android.os.Build;
|
30 | 30 | import android.os.Bundle;
|
31 | 31 | import android.os.Environment;
|
| 32 | +import android.support.annotation.NonNull; |
32 | 33 | import android.support.design.widget.Snackbar;
|
33 | 34 | import android.support.v4.app.ActivityCompat;
|
34 | 35 | import android.support.v4.content.ContextCompat;
|
|
44 | 45 | import android.widget.RelativeLayout;
|
45 | 46 | import android.widget.TextView;
|
46 | 47 |
|
| 48 | +import com.afollestad.materialdialogs.DialogAction; |
47 | 49 | import com.afollestad.materialdialogs.MaterialDialog;
|
48 | 50 | import com.devpaul.materiallibrary.views.MaterialFloatingActionButton;
|
49 | 51 | import com.github.developerpaul123.filepickerlibrary.adapter.FileListAdapter;
|
@@ -338,17 +340,18 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun
|
338 | 340 | .content(R.string.file_picker_permission_rationale_dialog_content)
|
339 | 341 | .positiveText(R.string.file_picker_ok)
|
340 | 342 | .negativeText(R.string.file_picker_cancel)
|
341 |
| - .callback(new MaterialDialog.ButtonCallback() { |
| 343 | + .onPositive(new MaterialDialog.SingleButtonCallback() { |
342 | 344 | @Override
|
343 |
| - public void onPositive(MaterialDialog dialog) { |
| 345 | + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { |
344 | 346 | ActivityCompat.requestPermissions(FilePickerActivity.this,
|
345 | 347 | new String[]{Manifest.permission.READ_EXTERNAL_STORAGE,
|
346 | 348 | Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
347 | 349 | REQUEST_FOR_READ_EXTERNAL_STORAGE);
|
348 | 350 | }
|
349 |
| - |
| 351 | + }) |
| 352 | + .onNegative(new MaterialDialog.SingleButtonCallback() { |
350 | 353 | @Override
|
351 |
| - public void onNegative(MaterialDialog dialog) { |
| 354 | + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { |
352 | 355 | setResult(RESULT_CANCELED);
|
353 | 356 | finish();
|
354 | 357 | }
|
@@ -393,8 +396,8 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
|
393 | 396 |
|
394 | 397 | switch (requestCode) {
|
395 | 398 | case REQUEST_FOR_READ_EXTERNAL_STORAGE:
|
396 |
| - if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED && |
397 |
| - grantResults[1] == PackageManager.PERMISSION_GRANTED) { |
| 399 | + if ((grantResults.length > 0) && (grantResults[0] == PackageManager.PERMISSION_GRANTED) && |
| 400 | + (grantResults[1] == PackageManager.PERMISSION_GRANTED)) { |
398 | 401 | //permission granted.
|
399 | 402 | init();
|
400 | 403 | } else {
|
@@ -473,7 +476,7 @@ public void onClick(View view) {
|
473 | 476 | setResult(RESULT_OK, data);
|
474 | 477 | finish();
|
475 | 478 | } else {
|
476 |
| - Snackbar.make(getWindow().getDecorView(), String.format(getString(R.string.file_picker_snackbar_select_file_ext_message),requiredExtension), Snackbar.LENGTH_SHORT).show(); |
| 479 | + Snackbar.make(getWindow().getDecorView(), String.format(getString(R.string.file_picker_snackbar_select_file_ext_message), requiredExtension), Snackbar.LENGTH_SHORT).show(); |
477 | 480 | }
|
478 | 481 | } else {
|
479 | 482 | data = new Intent();
|
|
0 commit comments