Commit e8aae74e authored by 419948809@qq.com's avatar 419948809@qq.com

首页改版的2020-2-24提交代码

parent f3ad1d43
...@@ -19,7 +19,9 @@ import android.support.v7.widget.LinearLayoutManager; ...@@ -19,7 +19,9 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager; import android.support.v7.widget.StaggeredGridLayoutManager;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
...@@ -174,20 +176,20 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa ...@@ -174,20 +176,20 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
mHotTravelAdapter = new HotCarTypeAdapter(); mHotTravelAdapter = new HotCarTypeAdapter();
ryHomeHotTravel.setLayoutManager(new GridLayoutManager(getContext(), 2)); ryHomeHotTravel.setLayoutManager(new GridLayoutManager(getContext(), 2));
ryHomeHotTravel.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5)));// 分割线。 ryHomeHotTravel.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5), DisplayUtil.dip2px(_mActivity, 8)));// 分割线。
ryHomeHotTravel.setNestedScrollingEnabled(false); ryHomeHotTravel.setNestedScrollingEnabled(false);
ryHomeHotTravel.setAdapter(mHotTravelAdapter); ryHomeHotTravel.setAdapter(mHotTravelAdapter);
mCampAdapter = new HotCarTypeAdapter(); mCampAdapter = new HotCarTypeAdapter();
ryHomeCamp.setLayoutManager(new GridLayoutManager(getContext(), 2)); ryHomeCamp.setLayoutManager(new GridLayoutManager(getContext(), 2));
ryHomeCamp.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5)));// 分割线。 ryHomeCamp.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5), DisplayUtil.dip2px(_mActivity, 8)));// 分割线。
ryHomeCamp.setNestedScrollingEnabled(false); ryHomeCamp.setNestedScrollingEnabled(false);
ryHomeCamp.setAdapter(mCampAdapter); ryHomeCamp.setAdapter(mCampAdapter);
//精选活动 //精选活动
mActivityAdapter = new SelectedEventsAdapter(); mActivityAdapter = new SelectedEventsAdapter();
recyclerViewActivity.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); recyclerViewActivity.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
recyclerViewActivity.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5)));// 分割线。 recyclerViewActivity.addItemDecoration(new AbSpacesItemDecoration1(DisplayUtil.dip2px(_mActivity, 10)));// 分割线。
recyclerViewActivity.setNestedScrollingEnabled(false); recyclerViewActivity.setNestedScrollingEnabled(false);
recyclerViewActivity.setAdapter(mActivityAdapter); recyclerViewActivity.setAdapter(mActivityAdapter);
mActivityAdapter.setOnItemClickListener((adapter, view, position) -> { mActivityAdapter.setOnItemClickListener((adapter, view, position) -> {
...@@ -241,14 +243,14 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa ...@@ -241,14 +243,14 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
//房车游榜单 //房车游榜单
mRvTourAdapter = new RVTourListAdapter(); mRvTourAdapter = new RVTourListAdapter();
recyclerViewRvtourlist.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); recyclerViewRvtourlist.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
recyclerViewRvtourlist.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5))); recyclerViewRvtourlist.addItemDecoration(new AbSpacesItemDecoration1(DisplayUtil.dip2px(_mActivity, 10)));
recyclerViewRvtourlist.setNestedScrollingEnabled(false); recyclerViewRvtourlist.setNestedScrollingEnabled(false);
recyclerViewRvtourlist.setAdapter(mRvTourAdapter); recyclerViewRvtourlist.setAdapter(mRvTourAdapter);
// //房车游榜单 标注 // //房车游榜单 标注
mRvTourLabelAdapter = new RVTourListLabelAdapter(); mRvTourLabelAdapter = new RVTourListLabelAdapter();
recyclerViewRvtourlistTitle.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); recyclerViewRvtourlistTitle.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
recyclerViewRvtourlistTitle.addItemDecoration(new AbSpacesItemDecoration(DisplayUtil.dip2px(_mActivity, 5))); recyclerViewRvtourlistTitle.addItemDecoration(new AbSpacesItemDecoration1(DisplayUtil.dip2px(_mActivity, 10)));
recyclerViewRvtourlistTitle.setNestedScrollingEnabled(false); recyclerViewRvtourlistTitle.setNestedScrollingEnabled(false);
height = _mActivity.getWindowManager().getDefaultDisplay().getHeight(); height = _mActivity.getWindowManager().getDefaultDisplay().getHeight();
...@@ -329,20 +331,50 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa ...@@ -329,20 +331,50 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
} }
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration { public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int space; private int sh;
private int sv;
public AbSpacesItemDecoration(int space) { public AbSpacesItemDecoration(int sh, int sv) {
this.space = space; this.sh = sh;
this.sv = sv;
} }
@Override @Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.left = space; int position = parent.getChildAdapterPosition(view);
outRect.right = space;
outRect.bottom = space; if (sh != 0) {
//注释这两行是为了上下间距相同 if (position % 2 == 0) {
// if(parent.getChildAdapterPosition(view)==0){ outRect.right = sh;
outRect.top = space; } else {
outRect.left = sh;
}
}
if (sv != 0) {
if (position <= 1) {
outRect.bottom = sv;
} else {
outRect.top = sv;
}
}
}
}
public class AbSpacesItemDecoration1 extends RecyclerView.ItemDecoration {
private int sh;
public AbSpacesItemDecoration1(int sh) {
this.sh = sh;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (sh != 0) {
int position = parent.getChildAdapterPosition(view);
if (position != 0)
outRect.left = sh;
}
} }
} }
...@@ -662,19 +694,19 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa ...@@ -662,19 +694,19 @@ public class HomeFragment extends BaseFragment<HomePresenter> implements Observa
} }
private void indicatorChange(int position) { private void indicatorChange(int position) {
if(llIndicator == null) return; if (llIndicator == null) return;
llIndicator.removeAllViews(); llIndicator.removeAllViews();
for (int i = 0; i < images.size(); i++) { for (int i = 0; i < images.size(); i++) {
ImageView imageView = new ImageView(getContext()); ImageView imageView = new ImageView(getContext());
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
LinearLayout.LayoutParams params = null; LinearLayout.LayoutParams params = null;
if (position == i) { if (position == i) {
params = new LinearLayout.LayoutParams(DisplayUtil.dip2px(getContext(),15), DisplayUtil.dip2px(getContext(),7)); params = new LinearLayout.LayoutParams(DisplayUtil.dip2px(getContext(), 15), DisplayUtil.dip2px(getContext(), 7));
} else { } else {
params = new LinearLayout.LayoutParams(DisplayUtil.dip2px(getContext(),7), DisplayUtil.dip2px(getContext(),7)); params = new LinearLayout.LayoutParams(DisplayUtil.dip2px(getContext(), 7), DisplayUtil.dip2px(getContext(), 7));
} }
params.leftMargin = DisplayUtil.dip2px(getContext(),3); params.leftMargin = DisplayUtil.dip2px(getContext(), 3);
params.rightMargin = DisplayUtil.dip2px(getContext(),3); params.rightMargin = DisplayUtil.dip2px(getContext(), 3);
if (i == position) { if (i == position) {
imageView.setImageResource(R.drawable.icon_show); imageView.setImageResource(R.drawable.icon_show);
} else { } else {
......
...@@ -266,84 +266,94 @@ ...@@ -266,84 +266,94 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout
<RelativeLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:background="@color/colorWrite"
android:layout_marginTop="27dp" android:orientation="vertical">
android:layout_marginRight="@dimen/dp_10">
<TextView <RelativeLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/rv_home_title_hot_travle" android:layout_marginLeft="@dimen/dp_10"
android:textColor="@color/colorMain" android:layout_marginTop="27dp"
android:textSize="@dimen/text_16" android:layout_marginRight="@dimen/dp_10">
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_hot_travel_more" android:layout_width="wrap_content"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:text="@string/rv_home_title_hot_travle"
android:layout_alignParentRight="true" android:textColor="@color/colorMain"
android:layout_marginRight="@dimen/size_5" android:textSize="@dimen/text_16"
android:drawableRight="@drawable/common_icon_rig_gray" android:textStyle="bold" />
android:drawablePadding="@dimen/dp_4"
android:paddingRight="5dp"
android:text="@string/rv_order_all_order"
android:textColor="@color/text_Gray"
android:textSize="@dimen/size_12" />
</RelativeLayout> <TextView
android:id="@+id/tv_hot_travel_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/size_5"
android:drawableRight="@drawable/common_icon_rig_gray"
android:drawablePadding="@dimen/dp_4"
android:text="@string/rv_order_all_order"
android:textColor="@color/text_Gray"
android:textSize="@dimen/size_12" />
<android.support.v7.widget.RecyclerView </RelativeLayout>
android:id="@+id/ry_home_hot_travel"
android:layout_width="match_parent"
android:layout_height="450dp"
android:layout_marginTop="17dp"
android:paddingLeft="@dimen/size_10"
android:paddingRight="@dimen/size_10" />
<RelativeLayout <android.support.v7.widget.RecyclerView
android:layout_marginLeft="@dimen/size_10"
android:layout_marginRight="@dimen/size_10"
android:id="@+id/ry_home_hot_travel"
android:layout_width="match_parent"
android:layout_height="430dp"
android:layout_marginTop="17dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10" android:background="@color/colorWrite"
android:layout_marginTop="@dimen/dp_10" android:orientation="vertical">
android:layout_marginRight="@dimen/dp_10">
<TextView <RelativeLayout
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginTop="27dp"
android:layout_marginRight="@dimen/dp_10">
android:text="@string/rv_home_title_camp" <TextView
android:textColor="@color/colorMain" android:layout_width="wrap_content"
android:textSize="@dimen/text_16" android:layout_height="wrap_content"
android:textStyle="bold" /> android:text="@string/rv_home_title_camp"
android:textColor="@color/colorMain"
android:textSize="@dimen/text_16"
android:textStyle="bold" />
<TextView <TextView
android:id="@+id/tv_camp_more" android:id="@+id/tv_camp_more"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_alignParentRight="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginRight="@dimen/size_5" android:layout_marginRight="@dimen/size_5"
android:drawableRight="@drawable/common_icon_rig_gray" android:drawableRight="@drawable/common_icon_rig_gray"
android:drawablePadding="@dimen/dp_4" android:drawablePadding="@dimen/dp_4"
android:paddingRight="5dp" android:text="@string/rv_order_all_order"
android:text="@string/rv_order_all_order" android:textColor="@color/text_Gray"
android:textColor="@color/text_Gray" android:textSize="@dimen/size_12" />
android:textSize="@dimen/size_12" />
</RelativeLayout> </RelativeLayout>
<android.support.v7.widget.RecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/ry_home_camp" android:id="@+id/ry_home_camp"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="370dp" android:layout_height="wrap_content"
android:layout_marginTop="17dp" android:layout_marginTop="17dp"
android:paddingLeft="@dimen/size_10" android:paddingLeft="@dimen/size_10"
android:paddingRight="@dimen/size_10" /> android:paddingRight="@dimen/size_10" />
</LinearLayout>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -378,7 +388,7 @@ ...@@ -378,7 +388,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:drawableRight="@drawable/common_icon_rig_black_gray" android:drawableRight="@drawable/common_icon_rig_black_gray"
android:drawablePadding="@dimen/size_5" android:drawablePadding="@dimen/dp_4"
android:text="全部" android:text="全部"
android:textColor="@color/text_Gray" android:textColor="@color/text_Gray"
android:textSize="@dimen/size_12" /> android:textSize="@dimen/size_12" />
...@@ -388,8 +398,9 @@ ...@@ -388,8 +398,9 @@
android:id="@+id/recyclerView_home_activity" android:id="@+id/recyclerView_home_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="@dimen/dp_10" android:layout_marginLeft="@dimen/dp_10"
android:paddingRight="@dimen/dp_10" /> android:layout_marginRight="@dimen/dp_10" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -467,8 +478,8 @@ ...@@ -467,8 +478,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:layout_alignParentBottom="true"
android:paddingLeft="@dimen/size_10" android:paddingLeft="@dimen/size_5"
android:paddingRight="@dimen/size_10" /> android:paddingRight="@dimen/size_5" />
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:layout_marginBottom="@dimen/size_16"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment