Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-04-25 12:05:21 +02:00
commit aa5460a965

View file

@ -22,33 +22,42 @@ import java.util.List;
public class ExploreTabFragment extends BaseOsmAndFragment {
private ExploreRvAdapter adapter = new ExploreRvAdapter();
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final View mainView = inflater.inflate(R.layout.fragment_explore_tab, container, false);
ExploreRvAdapter adapter = new ExploreRvAdapter();
adapter.setItems(generateItems());
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
rv.setLayoutManager(new LinearLayoutManager(getContext()));
adapter.setItems(getItems());
rv.setAdapter(adapter);
return mainView;
}
private List<Object> getItems() {
private List<Object> generateItems() {
final List<Object> items = new ArrayList<>();
final OsmandApplication app = getMyApplication();
boolean nightMode = !getSettings().isLightContent();
List<Object> items = new ArrayList<>();
List<TravelArticle> savedArticles = app.getTravelDbHelper().searchPopular();
final boolean nightMode = !getSettings().isLightContent();
items.add(new OpenBetaTravelCard(app, nightMode, getFragmentManager()));
items.add(new StartEditingTravelCard(app, nightMode));
addPopularDestinations(items, nightMode);
return items;
}
private void addPopularDestinations(@NonNull List<Object> items, boolean nightMode) {
OsmandApplication app = getMyApplication();
List<TravelArticle> savedArticles = app.getTravelDbHelper().searchPopular();
if (!savedArticles.isEmpty()) {
items.add(getString(R.string.popular_destinations));
for (TravelArticle article : savedArticles) {
items.add(new ArticleTravelCard(app, nightMode, article, getFragmentManager()));
}
}
return items;
}
}