Introduce cache and delete todo
This commit is contained in:
parent
86e40f24e5
commit
c7b98dd0e3
2 changed files with 7 additions and 14 deletions
|
@ -65,7 +65,7 @@ public class QuickActionRegistry {
|
||||||
|
|
||||||
private final OsmandSettings settings;
|
private final OsmandSettings settings;
|
||||||
|
|
||||||
private final List<QuickAction> quickActions;
|
private List<QuickAction> quickActions;
|
||||||
private final Map<String, Boolean> fabStateMap;
|
private final Map<String, Boolean> fabStateMap;
|
||||||
private final Gson gson;
|
private final Gson gson;
|
||||||
private List<QuickActionType> quickActionTypes = new ArrayList<>();
|
private List<QuickActionType> quickActionTypes = new ArrayList<>();
|
||||||
|
@ -75,13 +75,10 @@ public class QuickActionRegistry {
|
||||||
private QuickActionUpdatesListener updatesListener;
|
private QuickActionUpdatesListener updatesListener;
|
||||||
|
|
||||||
public QuickActionRegistry(OsmandSettings settings) {
|
public QuickActionRegistry(OsmandSettings settings) {
|
||||||
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
gson = new GsonBuilder().registerTypeAdapter(QuickAction.class, new QuickActionSerializer()).create();
|
gson = new GsonBuilder().registerTypeAdapter(QuickAction.class, new QuickActionSerializer()).create();
|
||||||
quickActions = parseActiveActionsList(settings.QUICK_ACTION_LIST.get());
|
|
||||||
fabStateMap = getQuickActionFabStateMapFromJson(settings.QUICK_ACTION.get());
|
fabStateMap = getQuickActionFabStateMapFromJson(settings.QUICK_ACTION.get());
|
||||||
updateActionTypes();
|
updateActionTypes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdatesListener(QuickActionUpdatesListener updatesListener) {
|
public void setUpdatesListener(QuickActionUpdatesListener updatesListener) {
|
||||||
|
@ -97,14 +94,7 @@ public class QuickActionRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<QuickAction> getFilteredQuickActions() {
|
public List<QuickAction> getFilteredQuickActions() {
|
||||||
List<QuickAction> actions = quickActions;
|
return getQuickActions();
|
||||||
List<QuickAction> filteredActions = new ArrayList<>();
|
|
||||||
for (QuickAction action : actions) {
|
|
||||||
if (quickActionTypesInt.containsKey(action.getActionType().getId())) {
|
|
||||||
filteredActions.add(action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return filteredActions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addQuickAction(QuickAction action){
|
public void addQuickAction(QuickAction action){
|
||||||
|
@ -188,7 +178,7 @@ public class QuickActionRegistry {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<QuickAction> parseActiveActionsList(String json) {
|
private List<QuickAction> parseActiveActionsList(String json) {
|
||||||
Type type = new TypeToken<List<QuickAction>>() {}.getType();
|
Type type = new TypeToken<List<QuickAction>>() {}.getType();
|
||||||
List<QuickAction> quickActions = gson.fromJson(json, type);
|
List<QuickAction> quickActions = gson.fromJson(json, type);
|
||||||
List<QuickAction> rquickActions = new ArrayList<>(quickActions.size());
|
List<QuickAction> rquickActions = new ArrayList<>(quickActions.size());
|
||||||
|
@ -199,6 +189,7 @@ public class QuickActionRegistry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.quickActions = rquickActions;
|
||||||
return rquickActions;
|
return rquickActions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +225,8 @@ public class QuickActionRegistry {
|
||||||
this.quickActionTypes = quickActionTypes;
|
this.quickActionTypes = quickActionTypes;
|
||||||
this.quickActionTypesInt = quickActionTypesInt;
|
this.quickActionTypesInt = quickActionTypesInt;
|
||||||
this.quickActionTypesStr = quickActionTypesStr;
|
this.quickActionTypesStr = quickActionTypesStr;
|
||||||
|
// reparse to get new quick actions
|
||||||
|
parseActiveActionsList(settings.QUICK_ACTION_LIST.get());
|
||||||
return quickActionTypes;
|
return quickActionTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class ExportProfileBottomSheet extends BasePreferenceBottomSheet {
|
||||||
|
|
||||||
|
|
||||||
QuickActionRegistry registry = app.getQuickActionRegistry();
|
QuickActionRegistry registry = app.getQuickActionRegistry();
|
||||||
List<QuickAction> actionsList = registry.parseActiveActionsList(app.getSettings().QUICK_ACTION_LIST.get());
|
List<QuickAction> actionsList = registry.getQuickActions();
|
||||||
if (!actionsList.isEmpty()) {
|
if (!actionsList.isEmpty()) {
|
||||||
dataList.put(Type.QUICK_ACTIONS, actionsList);
|
dataList.put(Type.QUICK_ACTIONS, actionsList);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue