forked from organicmaps/organicmaps
[android] Fixed top offset for first flexline
This commit is contained in:
parent
c186156ea2
commit
3876594c71
6 changed files with 41 additions and 8 deletions
|
@ -1,11 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body4"
|
||||
android:gravity="center"
|
||||
android:textAllCaps="true"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:overScrollMode="never"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -117,7 +117,7 @@ public class MultilanguageAdapter extends RecyclerView.Adapter<MultilanguageAdap
|
|||
public void onClick(View v)
|
||||
{
|
||||
// TODO(mgsergio): Implement item deletion.
|
||||
// int position = getRelativePosition();
|
||||
// int position = getAdapterPosition();
|
||||
// mHostFragment.removeLocalizedName(position + 1);
|
||||
// mNames.remove(position);
|
||||
// notifyItemRemoved(position);
|
||||
|
|
|
@ -165,7 +165,6 @@ class TagsCompositeAdapter extends RecyclerView.Adapter<TagsCompositeAdapter.Tag
|
|||
@Override
|
||||
public void onItemClick(@NonNull View v, @NonNull TagsAdapter.TagViewHolder item)
|
||||
{
|
||||
item.getAdapterPosition();
|
||||
ComponentHolder components = mComponentHolders.get(mIndex);
|
||||
Pair<TagsAdapter, TagsAdapter.TagViewHolder> pair = new Pair<>(components.mAdapter, item);
|
||||
mListener.onItemClick(v, pair);
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.Intent;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.DividerItemDecoration;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Pair;
|
||||
|
@ -24,6 +25,7 @@ import com.mapswithme.maps.bookmarks.OnItemClickListener;
|
|||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.maps.bookmarks.data.CatalogTag;
|
||||
import com.mapswithme.maps.bookmarks.data.CatalogTagsGroup;
|
||||
import com.mapswithme.maps.widget.recycler.ItemDecoratorFactory;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -70,7 +72,7 @@ public class UgcRoutesFragment extends BaseMwmFragment implements BookmarkManage
|
|||
mProgress = root.findViewById(R.id.progress_container);
|
||||
mTagsContainer = root.findViewById(R.id.tags_container);
|
||||
mRetryBtnContainer = root.findViewById(R.id.retry_btn_container);
|
||||
mRecycler = root.findViewById(R.id.recycler);
|
||||
initRecycler(root);
|
||||
View retryBtn = mRetryBtnContainer.findViewById(R.id.retry_btn);
|
||||
retryBtn.setOnClickListener(v -> onRetryClicked());
|
||||
UiUtils.hide(mTagsContainer, mRetryBtnContainer);
|
||||
|
@ -80,6 +82,16 @@ public class UgcRoutesFragment extends BaseMwmFragment implements BookmarkManage
|
|||
return root;
|
||||
}
|
||||
|
||||
private void initRecycler(@NonNull ViewGroup root)
|
||||
{
|
||||
mRecycler = root.findViewById(R.id.recycler);
|
||||
mRecycler.setItemAnimator(null);
|
||||
RecyclerView.ItemDecoration decor = ItemDecoratorFactory.createRatingRecordDecorator(
|
||||
getContext().getApplicationContext(),
|
||||
DividerItemDecoration.VERTICAL);
|
||||
mRecycler.addItemDecoration(decor);
|
||||
}
|
||||
|
||||
private void onRetryClicked()
|
||||
{
|
||||
UiUtils.hide(mTagsContainer, mRetryBtnContainer);
|
||||
|
|
|
@ -6,6 +6,11 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.android.flexbox.FlexLine;
|
||||
import com.google.android.flexbox.FlexboxLayoutManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UgcRouteTagItemDecorator extends TagItemDecoration
|
||||
{
|
||||
private int mCurrentOffset;
|
||||
|
@ -26,6 +31,19 @@ public class UgcRouteTagItemDecorator extends TagItemDecoration
|
|||
|
||||
outRect.left = mCurrentOffset == 0 ? 0 : getDivider().getIntrinsicWidth() / 2;
|
||||
outRect.right = getDivider().getIntrinsicWidth() / 2;
|
||||
FlexboxLayoutManager flexboxLayoutManager = (FlexboxLayoutManager) parent.getLayoutManager();
|
||||
List<FlexLine> flexLines = flexboxLayoutManager.getFlexLines();
|
||||
if (flexLines == null || flexLines.isEmpty())
|
||||
{
|
||||
outRect.top = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
FlexLine flexLine = flexLines.get(0);
|
||||
int position = parent.getLayoutManager().getPosition(view);
|
||||
int itemCount = flexLine.getItemCount();
|
||||
if (position < itemCount)
|
||||
outRect.top = 0;
|
||||
}
|
||||
|
||||
private boolean hasSpaceFromRight(Rect outRect, View view, RecyclerView parent)
|
||||
|
|
Loading…
Add table
Reference in a new issue