Change wikivoyage search list item layout
This commit is contained in:
parent
cfe53d4d7f
commit
56cf31eb0e
6 changed files with 78 additions and 70 deletions
|
@ -29,6 +29,7 @@
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/recycler_view"
|
android:id="@+id/recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"
|
||||||
|
android:scrollbars="vertical"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -1,70 +1,64 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/wikivoyage_card_bg_color"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical">
|
||||||
android:padding="8dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:minHeight="@dimen/bottom_sheet_selected_item_title_height"
|
||||||
|
android:paddingLeft="@dimen/content_padding"
|
||||||
|
android:paddingRight="@dimen/content_padding">
|
||||||
|
|
||||||
<TextView
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="search_term: "/>
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginEnd="@dimen/content_padding"
|
||||||
|
android:layout_marginRight="@dimen/content_padding"
|
||||||
|
tools:src="@drawable/ic_action_placeholder_city"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textAppearance="@style/TextAppearance.ListItemTitle"
|
||||||
|
tools:text="Amsterdam"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textAppearance="@style/TextAppearance.ContextMenuSubtitle"
|
||||||
|
tools:text="Amstellend North Holland"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/search_term"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<View
|
||||||
|
android:id="@+id/divider"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginLeft="@dimen/bottom_sheet_selected_item_title_height"
|
||||||
<TextView
|
android:layout_marginStart="@dimen/bottom_sheet_selected_item_title_height"
|
||||||
android:layout_width="wrap_content"
|
android:background="?attr/wikivoyage_card_divider_color"
|
||||||
android:layout_height="wrap_content"
|
android:focusable="false"/>
|
||||||
android:text="city_id: "/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/city_id"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="article_title: "/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/article_title"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="lang: "/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/lang"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
|
|
||||||
<attr name="wikivoyage_bg_color" format="reference"/>
|
<attr name="wikivoyage_bg_color" format="reference"/>
|
||||||
<attr name="wikivoyage_card_bg_color" format="reference"/>
|
<attr name="wikivoyage_card_bg_color" format="reference"/>
|
||||||
|
<attr name="wikivoyage_card_divider_color" format="reference"/>
|
||||||
<attr name="wikivoyage_app_bar_color" format="reference"/>
|
<attr name="wikivoyage_app_bar_color" format="reference"/>
|
||||||
<attr name="wikivoyage_app_bar_text_color" format="reference"/>
|
<attr name="wikivoyage_app_bar_text_color" format="reference"/>
|
||||||
<attr name="wikivoyage_active_color" format="reference"/>
|
<attr name="wikivoyage_active_color" format="reference"/>
|
||||||
|
|
|
@ -199,6 +199,7 @@
|
||||||
|
|
||||||
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_light</item>
|
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_light</item>
|
||||||
<item name="wikivoyage_card_bg_color">@color/wikivoyage_card_bg_light</item>
|
<item name="wikivoyage_card_bg_color">@color/wikivoyage_card_bg_light</item>
|
||||||
|
<item name="wikivoyage_card_divider_color">@color/wikivoyage_card_divider_light</item>
|
||||||
<item name="wikivoyage_app_bar_color">@color/wikivoyage_app_bar_light</item>
|
<item name="wikivoyage_app_bar_color">@color/wikivoyage_app_bar_light</item>
|
||||||
<item name="wikivoyage_app_bar_text_color">@color/wikivoyage_app_bar_text_light</item>
|
<item name="wikivoyage_app_bar_text_color">@color/wikivoyage_app_bar_text_light</item>
|
||||||
<item name="wikivoyage_active_color">@color/wikivoyage_active_light</item>
|
<item name="wikivoyage_active_color">@color/wikivoyage_active_light</item>
|
||||||
|
@ -389,6 +390,7 @@
|
||||||
|
|
||||||
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_dark</item>
|
<item name="wikivoyage_bg_color">@color/wikivoyage_bg_dark</item>
|
||||||
<item name="wikivoyage_card_bg_color">@color/wikivoyage_card_bg_dark</item>
|
<item name="wikivoyage_card_bg_color">@color/wikivoyage_card_bg_dark</item>
|
||||||
|
<item name="wikivoyage_card_divider_color">@color/wikivoyage_card_divider_dark</item>
|
||||||
<item name="wikivoyage_app_bar_color">@color/wikivoyage_app_bar_dark</item>
|
<item name="wikivoyage_app_bar_color">@color/wikivoyage_app_bar_dark</item>
|
||||||
<item name="wikivoyage_app_bar_text_color">@color/wikivoyage_app_bar_text_dark</item>
|
<item name="wikivoyage_app_bar_text_color">@color/wikivoyage_app_bar_text_dark</item>
|
||||||
<item name="wikivoyage_active_color">@color/wikivoyage_active_dark</item>
|
<item name="wikivoyage_active_color">@color/wikivoyage_active_dark</item>
|
||||||
|
|
|
@ -6,8 +6,11 @@ import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.plus.IconsCache;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult;
|
||||||
|
|
||||||
|
@ -16,6 +19,8 @@ import java.util.List;
|
||||||
|
|
||||||
public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<SearchRecyclerViewAdapter.ViewHolder> {
|
public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<SearchRecyclerViewAdapter.ViewHolder> {
|
||||||
|
|
||||||
|
private IconsCache iconsCache;
|
||||||
|
|
||||||
private List<WikivoyageSearchResult> items = new ArrayList<>();
|
private List<WikivoyageSearchResult> items = new ArrayList<>();
|
||||||
|
|
||||||
private View.OnClickListener onItemClickListener;
|
private View.OnClickListener onItemClickListener;
|
||||||
|
@ -24,6 +29,10 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<SearchRecycl
|
||||||
this.onItemClickListener = onItemClickListener;
|
this.onItemClickListener = onItemClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SearchRecyclerViewAdapter(OsmandApplication app) {
|
||||||
|
this.iconsCache = app.getIconsCache();
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
|
||||||
|
@ -34,13 +43,14 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<SearchRecycl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
|
public void onBindViewHolder(@NonNull ViewHolder holder, int pos) {
|
||||||
WikivoyageSearchResult item = items.get(i);
|
boolean lastItem = pos == getItemCount() - 1;
|
||||||
// FIXME
|
|
||||||
viewHolder.searchTerm.setText(item.getSearchTerm().toString());
|
WikivoyageSearchResult item = items.get(pos);
|
||||||
viewHolder.cityId.setText(String.valueOf(item.getCityId()));
|
holder.icon.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_placeholder_city, R.color.icon_color));
|
||||||
viewHolder.articleTitle.setText(item.getArticleTitle().toString());
|
holder.title.setText(item.getArticleTitle().toString());
|
||||||
viewHolder.lang.setText(item.getLang().toString());
|
holder.description.setText(item.getLang().toString());
|
||||||
|
holder.divider.setVisibility(lastItem ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -63,17 +73,17 @@ public class SearchRecyclerViewAdapter extends RecyclerView.Adapter<SearchRecycl
|
||||||
|
|
||||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
final TextView searchTerm;
|
final ImageView icon;
|
||||||
final TextView cityId;
|
final TextView title;
|
||||||
final TextView articleTitle;
|
final TextView description;
|
||||||
final TextView lang;
|
final View divider;
|
||||||
|
|
||||||
public ViewHolder(View itemView) {
|
public ViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
searchTerm = (TextView) itemView.findViewById(R.id.search_term);
|
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||||
cityId = (TextView) itemView.findViewById(R.id.city_id);
|
title = (TextView) itemView.findViewById(R.id.title);
|
||||||
articleTitle = (TextView) itemView.findViewById(R.id.article_title);
|
description = (TextView) itemView.findViewById(R.id.description);
|
||||||
lang = (TextView) itemView.findViewById(R.id.lang);
|
divider = itemView.findViewById(R.id.divider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class WikivoyageSearchDialogFragment extends WikivoyageBaseDialogFragment
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
adapter = new SearchRecyclerViewAdapter();
|
adapter = new SearchRecyclerViewAdapter(getMyApplication());
|
||||||
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
|
final RecyclerView rv = (RecyclerView) mainView.findViewById(R.id.recycler_view);
|
||||||
rv.setLayoutManager(new LinearLayoutManager(getContext()));
|
rv.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
rv.setAdapter(adapter);
|
rv.setAdapter(adapter);
|
||||||
|
|
Loading…
Reference in a new issue