forked from organicmaps/organicmaps
[android] Review fixes
This commit is contained in:
parent
6305d4705b
commit
f090ccf3e9
6 changed files with 31 additions and 40 deletions
|
@ -87,11 +87,11 @@ public:
|
|||
auto const oneOfClass = env->FindClass("com/mapswithme/maps/search/HotelsFilter$OneOf");
|
||||
auto const hotelTypeClass =
|
||||
env->FindClass("com/mapswithme/maps/search/HotelsFilter$HotelType");
|
||||
m_hotelType = env->GetFieldID(oneOfClass, "mType",
|
||||
m_oneOfType = env->GetFieldID(oneOfClass, "mType",
|
||||
"Lcom/mapswithme/maps/search/HotelsFilter$HotelType;");
|
||||
m_typeRhs =
|
||||
env->GetFieldID(oneOfClass, "mRhs", "Lcom/mapswithme/maps/search/HotelsFilter$OneOf;");
|
||||
m_hotelId = env->GetFieldID(hotelTypeClass, "mType", "I");
|
||||
m_oneOfTile =
|
||||
env->GetFieldID(oneOfClass, "mTile", "Lcom/mapswithme/maps/search/HotelsFilter$OneOf;");
|
||||
m_hotelType = env->GetFieldID(hotelTypeClass, "mType", "I");
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -163,11 +163,11 @@ private:
|
|||
|
||||
Rule BuildOneOf(JNIEnv * env, jobject filter)
|
||||
{
|
||||
auto const hotelType = env->GetObjectField(filter, m_hotelType);
|
||||
auto type = static_cast<unsigned>(env->GetIntField(hotelType, m_hotelId));
|
||||
auto const rhs = env->GetObjectField(filter, m_typeRhs);
|
||||
unsigned value = 1U << type;
|
||||
return BuildOneOf(env, rhs, value);
|
||||
auto const oneOfType = env->GetObjectField(filter, m_oneOfType);
|
||||
auto hotelType = static_cast<unsigned>(env->GetIntField(oneOfType, m_hotelType));
|
||||
auto const tile = env->GetObjectField(filter, m_oneOfTile);
|
||||
unsigned value = 1U << hotelType;
|
||||
return BuildOneOf(env, tile, value);
|
||||
}
|
||||
|
||||
Rule BuildOneOf(JNIEnv * env, jobject filter, unsigned value)
|
||||
|
@ -175,12 +175,12 @@ private:
|
|||
if (filter == nullptr)
|
||||
return search::hotels_filter::OneOf(value);
|
||||
|
||||
auto const hotelType = env->GetObjectField(filter, m_hotelType);
|
||||
auto type = static_cast<unsigned>(env->GetIntField(hotelType, m_hotelId));
|
||||
auto const rhs = env->GetObjectField(filter, m_typeRhs);
|
||||
value = value | (1U << type);
|
||||
auto const oneOfType = env->GetObjectField(filter, m_oneOfType);
|
||||
auto hotelType = static_cast<unsigned>(env->GetIntField(oneOfType, m_hotelType));
|
||||
auto const tile = env->GetObjectField(filter, m_oneOfTile);
|
||||
value = value | (1U << hotelType);
|
||||
|
||||
return BuildOneOf(env, rhs, value);
|
||||
return BuildOneOf(env, tile, value);
|
||||
}
|
||||
|
||||
Rule BuildRatingOp(JNIEnv * env, int op, jobject filter)
|
||||
|
@ -232,9 +232,9 @@ private:
|
|||
jfieldID m_field;
|
||||
jfieldID m_op;
|
||||
|
||||
jfieldID m_oneOfType;
|
||||
jfieldID m_oneOfTile;
|
||||
jfieldID m_hotelType;
|
||||
jfieldID m_hotelId;
|
||||
jfieldID m_typeRhs;
|
||||
|
||||
jfieldID m_rating;
|
||||
jfieldID m_priceRate;
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/header"/>
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/scroll"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -83,14 +82,12 @@
|
|||
android:fontFamily="@string/robotoMedium"
|
||||
android:text="@string/booking_filters_rating"
|
||||
tools:targetApi="jelly_bean"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
<com.mapswithme.maps.search.RatingFilterView
|
||||
android:id="@+id/rating"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -103,14 +100,12 @@
|
|||
android:fontFamily="@string/robotoMedium"
|
||||
android:text="@string/booking_filters_price_category"
|
||||
tools:targetApi="jelly_bean"/>
|
||||
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
<com.mapswithme.maps.search.PriceFilterView
|
||||
android:id="@+id/price"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
<include layout="@layout/divider_horizontal"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -119,20 +119,20 @@ public class HotelsFilter implements Parcelable
|
|||
@NonNull
|
||||
public final HotelType mType;
|
||||
@Nullable
|
||||
public final OneOf mRhs;
|
||||
public final OneOf mTile;
|
||||
|
||||
public OneOf(@NonNull HotelType type, @Nullable OneOf rhs)
|
||||
public OneOf(@NonNull HotelType type, @Nullable OneOf tile)
|
||||
{
|
||||
super(TYPE_ONE_OF);
|
||||
mType = type;
|
||||
mRhs = rhs;
|
||||
mTile = tile;
|
||||
}
|
||||
|
||||
public OneOf(Parcel source)
|
||||
{
|
||||
super(TYPE_ONE_OF);
|
||||
mType = source.readParcelable(HotelType.class.getClassLoader());
|
||||
mRhs = source.readParcelable(HotelsFilter.class.getClassLoader());
|
||||
mTile = source.readParcelable(HotelsFilter.class.getClassLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -140,7 +140,7 @@ public class HotelsFilter implements Parcelable
|
|||
{
|
||||
super.writeToParcel(dest, flags);
|
||||
dest.writeParcelable(mType, flags);
|
||||
dest.writeParcelable(mRhs, flags);
|
||||
dest.writeParcelable(mTile, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,7 +202,7 @@ public class HotelsFilterView extends FrameLayout
|
|||
private HotelsFilter combineFilters(@NonNull HotelsFilter... filters)
|
||||
{
|
||||
HotelsFilter result = null;
|
||||
for (HotelsFilter filter: filters)
|
||||
for (HotelsFilter filter : filters)
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
|
@ -362,8 +362,8 @@ public class HotelsFilterView extends FrameLayout
|
|||
@NonNull HotelsFilter.OneOf types)
|
||||
{
|
||||
hotelTypes.add(types.mType);
|
||||
if (types.mRhs != null)
|
||||
populateHotelTypes(hotelTypes, types.mRhs);
|
||||
if (types.mTile != null)
|
||||
populateHotelTypes(hotelTypes, types.mTile);
|
||||
}
|
||||
|
||||
public void setListener(@Nullable HotelsFilterListener listener)
|
||||
|
|
|
@ -36,19 +36,14 @@ public class TagItemDecoration extends RecyclerView.ItemDecoration
|
|||
|
||||
int parentRight = parent.getWidth() - parent.getPaddingRight();
|
||||
int parentLeft = parent.getPaddingLeft();
|
||||
int lastHeight = 0;
|
||||
int lastHeight = Integer.MIN_VALUE;
|
||||
|
||||
int childCount = parent.getChildCount();
|
||||
for (int i = 0; i < childCount; i++)
|
||||
{
|
||||
View child = parent.getChildAt(i);
|
||||
if (lastHeight == 0)
|
||||
lastHeight = child.getTop();
|
||||
boolean isLineChanged = child.getTop() > lastHeight;
|
||||
boolean isNewLine = isLineChanged || i == 0;
|
||||
lastHeight = child.getTop();
|
||||
|
||||
if (!isNewLine)
|
||||
if (child.getTop() <= lastHeight)
|
||||
{
|
||||
mDivider.setBounds(child.getLeft() - mDivider.getIntrinsicWidth(),
|
||||
child.getTop(),
|
||||
|
@ -63,6 +58,7 @@ public class TagItemDecoration extends RecyclerView.ItemDecoration
|
|||
child.getTop());
|
||||
}
|
||||
mDivider.draw(canvas);
|
||||
lastHeight = child.getTop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TagLayoutManager extends RecyclerView.LayoutManager
|
|||
|
||||
int widthUsed = 0;
|
||||
int heightUsed = 0;
|
||||
int maxHeight = 0;
|
||||
int lineHeight = 0;
|
||||
int itemsCountOneLine = 0;
|
||||
for (int i = 0; i < getItemCount(); i++)
|
||||
{
|
||||
|
@ -37,20 +37,20 @@ public class TagLayoutManager extends RecyclerView.LayoutManager
|
|||
measureChildWithMargins(child, widthUsed, heightUsed);
|
||||
int width = getDecoratedMeasuredWidth(child);
|
||||
int height = getDecoratedMeasuredHeight(child);
|
||||
maxHeight = Math.max(maxHeight, height);
|
||||
lineHeight = Math.max(lineHeight, height);
|
||||
if (widthUsed + width >= getWidth())
|
||||
{
|
||||
widthUsed = 0;
|
||||
if (itemsCountOneLine > 0)
|
||||
{
|
||||
itemsCountOneLine = -1;
|
||||
heightUsed += maxHeight;
|
||||
heightUsed += lineHeight;
|
||||
child.forceLayout();
|
||||
measureChildWithMargins(child, widthUsed, heightUsed);
|
||||
width = getDecoratedMeasuredWidth(child);
|
||||
height = getDecoratedMeasuredHeight(child);
|
||||
}
|
||||
maxHeight = 0;
|
||||
lineHeight = 0;
|
||||
}
|
||||
layoutDecorated(child, widthUsed, heightUsed, widthUsed + width, heightUsed + height);
|
||||
widthUsed += width;
|
||||
|
|
Loading…
Add table
Reference in a new issue