Fix compilation
This commit is contained in:
parent
908544e560
commit
865f4c00a7
3 changed files with 28 additions and 13 deletions
|
@ -25,6 +25,7 @@ import net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo;
|
|||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
import net.osmand.plus.quickaction.QuickActionType;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
@ -940,16 +941,21 @@ public class SettingsHelper {
|
|||
for (int i = 0; i < itemsJson.length(); i++) {
|
||||
JSONObject object = itemsJson.getJSONObject(i);
|
||||
String name = object.getString("name");
|
||||
// FIXME QA: make type string
|
||||
int actionType = object.getInt("type");
|
||||
// TODO
|
||||
String paramsString = object.getString("params");
|
||||
HashMap<String, String> params = gson.fromJson(paramsString, type);
|
||||
QuickAction quickAction = new QuickAction(actionType);
|
||||
if (!name.isEmpty()) {
|
||||
quickAction.setName(name);
|
||||
QuickActionType tp = QuickActionRegistry.getActionTypeById(actionType);
|
||||
if(tp != null) {
|
||||
|
||||
String paramsString = object.getString("params");
|
||||
HashMap<String, String> params = gson.fromJson(paramsString, type);
|
||||
|
||||
QuickAction quickAction = new QuickAction(actionType);
|
||||
if (!name.isEmpty()) {
|
||||
quickAction.setName(name);
|
||||
}
|
||||
quickAction.setParams(params);
|
||||
items.add(quickAction);
|
||||
}
|
||||
quickAction.setParams(params);
|
||||
items.add(quickAction);
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new IllegalArgumentException("Json parse error", e);
|
||||
|
|
|
@ -36,7 +36,7 @@ public class QuickAction {
|
|||
}
|
||||
|
||||
public QuickAction(QuickActionType type) {
|
||||
// FIXME id
|
||||
// FIXME QA: id
|
||||
this.id = System.currentTimeMillis();
|
||||
this.actionType = type;
|
||||
}
|
||||
|
|
|
@ -188,12 +188,12 @@ public class QuickActionRegistry {
|
|||
|
||||
|
||||
private String quickActionListToString(List<QuickAction> quickActions) {
|
||||
// FIXME backward compatibiltiy
|
||||
// FIXME QA: backward compatibiltiy
|
||||
return new Gson().toJson(quickActions);
|
||||
}
|
||||
|
||||
public List<QuickAction> parseActiveActionsList(String json) {
|
||||
// FIXME backward compatibiltiy
|
||||
// FIXME QA: backward compatibiltiy
|
||||
Type type = new TypeToken<List<QuickAction>>() {
|
||||
}.getType();
|
||||
ArrayList<QuickAction> quickActions = new Gson().fromJson(json, type);
|
||||
|
@ -258,9 +258,18 @@ public class QuickActionRegistry {
|
|||
}
|
||||
}
|
||||
|
||||
public static QuickActionType getActionTypeById(int type) {
|
||||
for (QuickActionType t : getActionTypes()) {
|
||||
if (t.getId() == type) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static QuickAction newActionByType(int type) {
|
||||
for(QuickActionType t : getActionTypes()) {
|
||||
if(t.getId() == type) {
|
||||
for (QuickActionType t : getActionTypes()) {
|
||||
if (t.getId() == type) {
|
||||
return t.createNew();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue