use of com.pratilipi.data.client.NavigationData in project pratilipi by Pratilipi.
the class NavigationDataUtil method getNavigationDataList.
public static List<NavigationData> getNavigationDataList(Language language) throws UnexpectedServerException {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
List<Navigation> navigationList = dataAccessor.getNavigationList(language);
List<NavigationData> navigationDataList = new ArrayList<>(navigationList.size());
for (Navigation navigation : navigationList) navigationDataList.add(new NavigationData(navigation.getTitle(), navigation.getLinkList()));
return navigationDataList;
}
use of com.pratilipi.data.client.NavigationData in project pratilipi by Pratilipi.
the class NavigationListApi method get.
@Get
public Response get(GetRequest request) throws UnexpectedServerException {
Gson gson = new Gson();
List<NavigationData> navigationList = NavigationDataUtil.getNavigationDataList(request.language);
if (UxModeFilter.isAndroidApp()) {
for (NavigationData navigationData : navigationList) {
for (Navigation.Link link : navigationData.getLinkList()) {
if (link.getApiRequest() == null)
continue;
JsonObject apiRequest = gson.fromJson((String) link.getApiRequest(), JsonElement.class).getAsJsonObject();
link.setApiRequest(apiRequest);
}
}
if (navigationList.size() > 2) {
for (Navigation.Link link : navigationList.get(2).getLinkList()) navigationList.get(0).addLink(link);
navigationList = navigationList.subList(0, 2);
}
NavigationData navigationData = navigationList.remove(0);
navigationList.add(navigationData);
} else {
for (NavigationData navigationData : navigationList) {
for (Navigation.Link link : navigationData.getLinkList()) {
link.setApiName(null);
link.setApiRequest(null);
}
}
}
return new Response(navigationList);
}
Aggregations