blob: 2c375f5cde197c5121cb954b1f3e05eea24a13ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package de.danoeh.antennapod.dialog;
import android.content.Context;
import android.view.View;
import androidx.appcompat.app.AlertDialog;
import androidx.core.util.Consumer;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.DataFolderAdapter;
public class ChooseDataFolderDialog {
public static void showDialog(final Context context, Consumer<String> handlerFunc) {
View content = View.inflate(context, R.layout.choose_data_folder_dialog, null);
AlertDialog dialog = new AlertDialog.Builder(context)
.setView(content)
.setTitle(R.string.choose_data_directory)
.setMessage(R.string.choose_data_directory_message)
.setNegativeButton(R.string.cancel_label, null)
.create();
((RecyclerView) content.findViewById(R.id.recyclerView)).setLayoutManager(new LinearLayoutManager(context));
DataFolderAdapter adapter = new DataFolderAdapter(context, path -> {
dialog.dismiss();
handlerFunc.accept(path);
});
((RecyclerView) content.findViewById(R.id.recyclerView)).setAdapter(adapter);
if (adapter.getItemCount() > 0) {
dialog.show();
} else {
new AlertDialog.Builder(context)
.setTitle(R.string.error_label)
.setMessage(R.string.external_storage_error_msg)
.setPositiveButton(android.R.string.ok, null)
.show();
}
}
}
|