-
Notifications
You must be signed in to change notification settings - Fork 291
Expand file tree
/
Copy pathStylingOptions.java
More file actions
69 lines (60 loc) · 2.14 KB
/
Copy pathStylingOptions.java
File metadata and controls
69 lines (60 loc) · 2.14 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.stfalcon.frescoimageviewersample.utils;
import android.content.Context;
import android.content.DialogInterface;
import androidx.appcompat.app.AlertDialog;
import com.stfalcon.frescoimageviewersample.R;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
/*
* Created by troy379 on 10.03.17.
*/
public class StylingOptions {
private Map<Property, Boolean> options = new TreeMap<Property, Boolean>() {{
put(Property.HIDE_STATUS_BAR, true);
put(Property.IMAGE_MARGIN, true);
put(Property.CONTAINER_PADDING, false);
put(Property.IMAGES_ROUNDING, false);
put(Property.SWIPE_TO_DISMISS, true);
put(Property.ZOOMING, true);
put(Property.SHOW_OVERLAY, true);
put(Property.RANDOM_BACKGROUND, false);
put(Property.POST_PROCESSING, false);
}};
public boolean get(Property property) {
return options.get(property);
}
public void showDialog(Context context) {
AlertDialog dialog = new AlertDialog.Builder(context)
.setMultiChoiceItems(
context.getResources().getStringArray(R.array.options),
toPrimitiveBooleanArray(options.values()),
new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {
options.put(Property.values()[indexSelected], isChecked);
}
}).create();
dialog.show();
}
public enum Property {
HIDE_STATUS_BAR,
IMAGE_MARGIN,
CONTAINER_PADDING,
IMAGES_ROUNDING,
SWIPE_TO_DISMISS,
ZOOMING,
SHOW_OVERLAY,
RANDOM_BACKGROUND,
POST_PROCESSING
}
private static boolean[] toPrimitiveBooleanArray(Collection<Boolean> collection) {
boolean[] array = new boolean[collection.size()];
int i = 0;
for (Boolean value : collection) {
array[i] = value;
i++;
}
return array;
}
}