forked from organicmaps/organicmaps-tmp
[android] Made UI for cian category in search
This commit is contained in:
parent
43982be440
commit
1fe9895986
4 changed files with 54 additions and 5 deletions
27
android/res/layout/item_search_category_cian.xml
Normal file
27
android/res/layout/item_search_category_cian.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?clickableBackground">
|
||||
<TextView
|
||||
style="@style/MwmWidget.TextView.Search"
|
||||
android:background="@null"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/tv__category"
|
||||
android:drawablePadding="@dimen/margin_base"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
tools:drawableLeft="@drawable/ic_food_light"
|
||||
tools:text="Sample category"/>
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/margin_base"
|
||||
android:layout_marginRight="@dimen/margin_base"
|
||||
android:src="?cianLogo"/>
|
||||
</LinearLayout>
|
|
@ -86,6 +86,8 @@
|
|||
<attr name="tagBackground" format="reference"/>
|
||||
|
||||
<attr name="sponsoredGalleryMore" format="reference"/>
|
||||
|
||||
<attr name="cianLogo" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="ThemeAttrs.NavButtons">
|
||||
|
|
|
@ -103,6 +103,8 @@
|
|||
<item name="tagBackground">@drawable/bg_tag</item>
|
||||
|
||||
<item name="sponsoredGalleryMore">@drawable/ic_sponsored_gallery_more</item>
|
||||
|
||||
<item name="cianLogo">@drawable/logo_cain_light</item>
|
||||
</style>
|
||||
|
||||
<!-- Night theme -->
|
||||
|
@ -208,5 +210,7 @@
|
|||
<item name="tagBackground">@drawable/bg_tag_night</item>
|
||||
|
||||
<item name="sponsoredGalleryMore">@drawable/ic_sponsored_gallery_more_night</item>
|
||||
|
||||
<item name="cianLogo">@drawable/logo_cain_dark</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.mapswithme.maps.search;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
@ -69,11 +69,26 @@ class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolde
|
|||
mInflater = LayoutInflater.from(fragment.getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position)
|
||||
{
|
||||
if (mCategoryResIds[position] == R.string.real_estate)
|
||||
return R.layout.item_search_category_cian;
|
||||
return R.layout.item_search_category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
|
||||
{
|
||||
final View view = mInflater.inflate(R.layout.item_search_category, parent, false);
|
||||
return new ViewHolder(view);
|
||||
final View view;
|
||||
if (viewType == R.layout.item_search_category_cian)
|
||||
{
|
||||
view = mInflater.inflate(R.layout.item_search_category_cian, parent, false);
|
||||
return new ViewHolder(view, (TextView) view.findViewById(R.id.tv__category));
|
||||
}
|
||||
|
||||
view = mInflater.inflate(R.layout.item_search_category, parent, false);
|
||||
return new ViewHolder(view, (TextView)view);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -95,13 +110,14 @@ class CategoriesAdapter extends RecyclerView.Adapter<CategoriesAdapter.ViewHolde
|
|||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
|
||||
{
|
||||
@NonNull
|
||||
private final TextView mTitle;
|
||||
|
||||
ViewHolder(View v)
|
||||
ViewHolder(@NonNull View v, @NonNull TextView tv)
|
||||
{
|
||||
super(v);
|
||||
v.setOnClickListener(this);
|
||||
mTitle = (TextView) v;
|
||||
mTitle = tv;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Reference in a new issue