Commit a66c5e3a authored by fengruiyu's avatar fengruiyu

1.首页的底部View的功能已完成

2.免费专区的页面和功能已完成
3.精选体验的页面和功能已完成
parent e1755026
......@@ -18,17 +18,17 @@
android:usesCleartextTraffic="true"
>
<activity android:name="com.mints.street.main.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.mints.street.login.LoginActivity">
</activity>
<activity android:name="com.mints.street.splash.SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
......
package com.mints.street.adapter
import android.content.Context
import android.view.View
import androidx.databinding.ObservableArrayList
import androidx.databinding.ObservableList
import androidx.databinding.ViewDataBinding
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.EnterDestinationAdapterBinding
import com.mints.street.main.vr.FreeZoneViewModel
import me.tatarka.bindingcollectionadapter2.BindingRecyclerViewAdapter
import me.tatarka.bindingcollectionadapter2.ItemBinding
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class EnterDestinationAdapter(val context: Context, val list :String):
AbstractVLayoutBaseAdapter<EnterDestinationAdapterBinding, String>(context,list,1) {
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
override fun onBindViewHolder(
holder: BindingViewHolder<EnterDestinationAdapterBinding>,
position: Int) {
vLayout = VirtualLayoutManager(context, VirtualLayoutManager.HORIZONTAL)
mAdapter = DelegateAdapter(vLayout,false)
holder.binding.listView.layoutManager = vLayout
holder.binding.listView.adapter = mAdapter
mAdapter?.addAdapter(ItemEnterDestinationAdapter(context,"",true))
}
override fun getItemCount() = 1
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.enter_destination_adapter
}
\ No newline at end of file
package com.mints.street.adapter
import android.content.Context
import com.alibaba.android.vlayout.LayoutHelper
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.fry.base.binding.setMargin
import com.mints.street.R
import com.mints.street.databinding.ItemGridMapAdapterBinding
import me.goldze.mvvmhabit.utils.AppUtils
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class GridMapAdapter(val context: Context,val list :List<String>):AbstractVLayoutBaseAdapter<ItemGridMapAdapterBinding,List<String>>(context,list,2) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemGridMapAdapterBinding>,
position: Int
) {
var a = holder.binding.bg.layoutParams
if(position%2 == 0){
holder.binding.bg.setMargin(AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),0,null,null,null)
}else{
holder.binding.bg.setMargin(0,AppUtils.dp2Px(context,10F),AppUtils.dp2Px(context,10F),0,null,null,null)
}
}
override fun getItemCount() = list.size
override fun onCreateLayoutHelper()=GridLayoutHelper(2)
override fun getLayoutId(viewType: Int) = R.layout.item_grid_map_adapter
}
\ No newline at end of file
package com.mints.street.adapter
import android.content.Context
import android.graphics.Point
import android.util.DisplayMetrics
import android.view.Display
import com.alibaba.android.vlayout.layout.LinearLayoutHelper
import com.fry.base.adapter.AbstractVLayoutBaseAdapter
import com.fry.base.adapter.BindingViewHolder
import com.mints.street.R
import com.mints.street.databinding.ItemEnterDestinationAdapterBinding
import me.goldze.mvvmhabit.base.AppManager
import me.goldze.mvvmhabit.utils.KLog
/**
* Created by 冯瑞雨 on 2021/7/9.
* @param isMultipleLayout 是否是多布局
*/
class ItemEnterDestinationAdapter(val context: Context,string:String,val isMultipleLayout:Boolean)
:AbstractVLayoutBaseAdapter<ItemEnterDestinationAdapterBinding,String>(context,string,1) {
override fun onBindViewHolder(
holder: BindingViewHolder<ItemEnterDestinationAdapterBinding>,
position: Int
) {
var a = context.resources.displayMetrics;
val bgLayoutParams = holder.binding.bg.layoutParams
if(isMultipleLayout){
bgLayoutParams.width = (a.widthPixels*0.9).toInt()
}else{
bgLayoutParams.width = a.widthPixels
}
}
override fun getItemCount() = 2
override fun onCreateLayoutHelper() = LinearLayoutHelper()
override fun getLayoutId(viewType: Int) = R.layout.item_enter_destination_adapter
}
package com.mints.street.main.home
import me.goldze.mvvmhabit.base.ItemViewModel
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class HomeButtonItemVM (viewModel: HomeViewModel): ItemViewModel<HomeViewModel?>(viewModel) {
}
\ No newline at end of file
......@@ -18,4 +18,9 @@ class HomeFragment:BaseFragment<FragmentHomeBinding,HomeViewModel>() {
savedInstanceState: Bundle?)= R.layout.fragment_home
override fun initVariableId()=BR.viewModel
override fun initData() {
super.initData()
viewModel.add()
}
}
\ No newline at end of file
package com.mints.street.main.home
import android.app.Application
import androidx.databinding.ObservableArrayList
import com.mints.street.BR
import com.mints.street.R
import me.goldze.mvvmhabit.base.BaseViewModel
import me.tatarka.bindingcollectionadapter2.ItemBinding
/**
* Created by 冯瑞雨 on 2021/7/2.
*/
class HomeViewModel(application: Application):BaseViewModel(application) {
var addressList = ObservableArrayList<HomeButtonItemVM?>()
var addressItemBinding = ItemBinding.of<HomeButtonItemVM>(BR.viewModel, R.layout.item_home_button)
fun add(){
for (index in 0..10){
addressList.add(HomeButtonItemVM(this))
}
}
}
\ No newline at end of file
package com.mints.street.main.vr
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.fry.base.base.BaseFragment
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.adapter.EnterDestinationAdapter
import com.mints.street.adapter.GridMapAdapter
import com.mints.street.adapter.ItemEnterDestinationAdapter
import com.mints.street.databinding.FragmentFeaturedExperienceBinding
/**
* Created by 冯瑞雨 on 2021/7/9.
* 精选体验
*/
class FeaturedExperienceFragment:BaseFragment<FragmentFeaturedExperienceBinding
,FeaturedExperienceViewModel>() {
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
override fun initContentView(
inflater: LayoutInflater?,
container: ViewGroup?,
savedInstanceState: Bundle?
)= R.layout.fragment_featured_experience
override fun initVariableId() = BR.viewModel
override fun initData() {
super.initData()
//初始化布局管理器
if (context ==null)return
vLayout = VirtualLayoutManager(context!!);
mAdapter = DelegateAdapter(vLayout,false)
binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter
mAdapter?.addAdapter(ItemEnterDestinationAdapter(context!!, "",false))
}
}
\ No newline at end of file
package com.mints.street.main.vr
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class FeaturedExperienceViewModel(application: Application):BaseViewModel(application) {
}
\ No newline at end of file
package com.mints.street.main.vr
import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.alibaba.android.vlayout.DelegateAdapter
import com.alibaba.android.vlayout.VirtualLayoutManager
import com.fry.base.base.BaseFragment
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.adapter.EnterDestinationAdapter
import com.mints.street.adapter.ItemEnterDestinationAdapter
import com.mints.street.adapter.GridMapAdapter
import com.mints.street.databinding.FragmentFreeZoneBinding
import me.goldze.mvvmhabit.utils.AppUtils
import me.goldze.mvvmhabit.utils.Utils
/**
* Created by 冯瑞雨 on 2021/7/9.
* 免费专区
*/
class FreeZoneFragment:BaseFragment<FragmentFreeZoneBinding,FreeZoneViewModel>() {
private var vLayout: VirtualLayoutManager? = null
private var mAdapter: DelegateAdapter? = null
override fun initContentView(
inflater: LayoutInflater?,
container: ViewGroup?,
savedInstanceState: Bundle?
)= R.layout.fragment_free_zone
override fun initVariableId() = BR.viewModel
override fun initData() {
super.initData()
//初始化布局管理器
if (context ==null)return
vLayout = VirtualLayoutManager(context!!);
mAdapter = DelegateAdapter(vLayout,false)
binding.listView.layoutManager = vLayout
binding.listView.adapter = mAdapter
mAdapter?.addAdapter(EnterDestinationAdapter(context!!, ""))
mAdapter?.addAdapter(GridMapAdapter(context!!, listOf("1","2","3","4","5","")))
}
}
\ No newline at end of file
package com.mints.street.main.vr
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class FreeZoneViewModel(application: Application):BaseViewModel(application) {
}
\ No newline at end of file
......@@ -46,12 +46,12 @@ class VRFragment : BaseFragment<FragmentVrBinding, VRViewModel>() {
private fun initTabFragment() {
val tabNames = mutableListOf<String>()
tabNames.add("热门")
tabNames.add("变老特效")
tabNames.add("免费专区")
tabNames.add("精选体验")
val fragments = mutableListOf<Fragment>()
fragments.add(MyFragment())
fragments.add(MyFragment())
fragments.add(FreeZoneFragment())
fragments.add(FeaturedExperienceFragment())
//初始化viewpager2
......
......@@ -5,6 +5,7 @@ import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivitySplashBinding
import com.mints.street.main.MainActivity
/**
* Created by 冯瑞雨 on 2021/7/5.
......@@ -23,8 +24,9 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
finish()
return
}
binding.bu.setOnClickListener {
startActivity(MainActivity::class.java)
}
checkAppSign()
}
/**
......
package com.mints.street.widget
import android.animation.ValueAnimator
import android.content.Context
import android.util.AttributeSet
import android.view.View
/**
* Created by 冯瑞雨 on 2021/7/9.
*/
class HomeBottomView(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : View(context, attrs,defStyleAttr) {
init {
}
val STATUS_DEFAULT = 0
val STATUS_EXTEND = 1
val STATUS_CLOSE = 2
val STATUS_ING = 3 //滑动中
private var touchSlop = 0
private var slideSlop = 0
private var offsetB = 0
private var animator: ValueAnimator? = null
private var width1 = 0
private val height1 = 0
private var offsetY = 0
private var offsetExtend = 0
private var offsetClose //是负数
= 0
private var offsetDefault = 0
private var child_default_height = 0
}
\ No newline at end of file
package com.mints.street.widget;
import android.animation.Animator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import me.goldze.mvvmhabit.utils.AppUtils;
import me.goldze.mvvmhabit.utils.KLog;
/**
* Created by yunzhao.liu on 2018/6/20
* <p>
* ScrollTo和ScrollBy滑动的是view的显示内容,并不改变view的坐标(即:ScrollLayout里的内容)
* ScrollBy:它是基于当前位置的相对滑动
* x和y不是坐标点,是偏移量,坐标系是左正上正
*/
public class ScrollLayout extends ViewGroup {
public ScrollLayout(Context context) {
this(context, null);
}
public ScrollLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public ScrollLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init(context);
}
public final static int STATUS_DEFAULT = 0;
public final static int STATUS_EXTEND = 1;
public final static int STATUS_CLOSE = 2;//关闭
public final static int STATUS_ING = 3;//滑动中
private int touchSlop;
private int slideSlop;
private int offsetB;
private ValueAnimator animator;
private int width;
private int height;
private int offsetY;
private int offsetExtend;
private int offsetClose;//是负数
private int offsetDefault;
private int child_default_height;
private float dX, dY;//TouchEvent_ACTION_DOWN坐标(dX,dY)
private float lastY;//TouchEvent最后一次坐标(lastX,lastY)
private boolean isEventValid = true;//本次touch事件是否有效
private boolean isMoveValid;//是移动有效
private int status;
private int curY, finalY;
private float factor;
private void init(Context context) {
touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
slideSlop = AppUtils.dp2Px(context, 45);
offsetB = AppUtils.dp2Px(context, 60);
animator = ValueAnimator.ofFloat(0f, 1f);
animator.setDuration(200);
animator.setInterpolator(new LinearInterpolator());
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
factor = (float) animation.getAnimatedValue();
//这里打印会先打印出:1,然后再从0-1打印,因为每次在start时,都会先调用stop
KLog.i("liuyzz--onAnimation--:", "" + factor);
//curY可为负数或正数
float scrollY = curY + (finalY - curY) * factor;
scrollTo(0, (int) scrollY);
postInvalidate();
if (listener != null) {
listener.onScrollChange(STATUS_ING);
//大于设置的展开距离后才设置颜色渐变
if (getScrollY() > offsetB) {
listener.onScrollProgress(255 * getScrollY() / offsetY);
} else {
listener.onScrollProgress(0);
}
}
}
});
animator.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
//动画全部更新完成后再走此方法:addUpdateListener->onAnimationEnd
@Override
public void onAnimationEnd(Animator animation) {
factor = 1;//容错处理,正常情况下addUpdateListener执行完成后factor是1
if (listener != null) {
listener.onScrollChange(status);
}
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
width = MeasureSpec.getSize(widthMeasureSpec);
height = MeasureSpec.getSize(heightMeasureSpec);
//界面下边显示出来的子View的高度
child_default_height = AppUtils.dp2Px(getContext(), 110);
offsetY = height - child_default_height;
offsetExtend = offsetY - offsetB;
offsetClose = offsetY + offsetB - height;//负数 向下移动到剩下40dp的高度
offsetDefault = 0;
int count = getChildCount();
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
measureChild(child, widthMeasureSpec, heightMeasureSpec);
}
setMeasuredDimension(width, height);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int count = getChildCount();
if (count > 0) {
int top = offsetY;//第一个View距顶高度
for (int i = 0; i < count; i++) {
View child = getChildAt(i);
int childHeight = child.getMeasuredHeight();
//必须有三个孩子,多了不显示
switch (i) {
case 0:
child.layout(0, top, width, top + childHeight);
top += childHeight;
break;
case 1:
//下:需要用屏幕高度-状态栏的高度(40dp)-第一个孩子的高度
child.layout(0, top, width, top + height - offsetB - getChildAt(0).getMeasuredHeight());
top += childHeight;
break;
case 2:
child.layout(0, offsetY, width, offsetY + childHeight);
break;
}
}
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
//手势坐标系:下正右正
float eX = ev.getX();
float eY = ev.getY();
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
dX = eX;
lastY = dY = eY;
isMoveValid = false;
isEventValid = true;
//首次进入getScrollY为0,当eY点击区域在offsetY距离下边,则进入
//当点击距离在offsetY上边则进入else
if (getScrollY() + eY > offsetY) {
//当动画正在执行时,事件不往View中传递
if (!(factor == 0 || factor == 1)) {
isEventValid = false;
} else {
//当子View为非滑动事件如TextView,LinearLayoutd等会调用它们的onTouchEvent的所有事件
//当子View为滑动事件如ListView,RecyclerView等不会调用onTouchEvent的Down事件,而是从Move事件开始嗲用
super.dispatchTouchEvent(ev);
}
return true;
}
return false;
case MotionEvent.ACTION_MOVE:
//当动画正在执行时,点击滑动不起作用
if (!isEventValid) return false;
//下滑offset就是负数,上滑就是正数
int offset = (int) (lastY - eY);
lastY = eY;
if ((status == STATUS_EXTEND
|| status == STATUS_CLOSE)
&& super.dispatchTouchEvent(ev)) {
return true;
}
//判断滑动的区间是否满足条件
if (!isMoveValid
&& Math.abs(eY - dY) > touchSlop
&& Math.abs(eY - dY) > Math.abs(eX - dX)) {
isMoveValid = true;
}
if (isMoveValid) {
if (getScrollY() + offset <= offsetClose) {
scrollTo(0, offsetClose);
status = STATUS_CLOSE;
if (listener != null) {
listener.onScrollChange(status);
}
} else if (getScrollY() + offset >= offsetExtend) {
scrollTo(0, offsetExtend);
status = STATUS_EXTEND;
setRecyclerViewLastY(true);
if (listener != null) {
listener.onScrollChange(status);
}
} else {
//偏移量坐标 左正上正
scrollBy(0, offset);
if (listener != null) {
if (getScrollY() > offsetB) {
listener.onScrollProgress(255 * getScrollY() / offsetY);
} else {
listener.onScrollProgress(0);
}
listener.onScrollChange(STATUS_ING);
}
}
}
return true;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
if (!isEventValid)return false;
if (isMoveValid
&& getScrollY() > offsetClose
&& getScrollY() < offsetExtend) {
dealUp(getScrollY());
isMoveValid = false;
return true;
}
setRecyclerViewLastY(status);
break;
}
return super.dispatchTouchEvent(ev);
}
private void dealUp(int scrollY) {
switch (status) {
case STATUS_DEFAULT:
if (scrollY > slideSlop) {//展开
toggle(STATUS_EXTEND);
} else if (scrollY < -slideSlop) {//关闭
toggle(STATUS_CLOSE);
} else {
toggle(STATUS_DEFAULT);
}
break;
case STATUS_EXTEND:
//scrollY<0,说明至少滑动了offsetExtend的距离
//偏移量scrollY是负数,所以关闭
if (scrollY < offsetDefault) {
toggle(STATUS_CLOSE);
} else if (scrollY < offsetExtend - slideSlop) {
toggle(STATUS_DEFAULT);
} else {
//滑动的距离大于0小于slideSlop距离时,恢复到原状态
toggle(STATUS_EXTEND);
}
break;
case STATUS_CLOSE:
//偏移量大于0则展开
if (scrollY > offsetDefault) {
toggle(STATUS_EXTEND);
//滑动距离大于slideSlop但小于0则滑动到初始状态
} else if (scrollY > offsetClose + slideSlop) {
toggle(STATUS_DEFAULT);
} else {
//滑动距离小于slideSlop距离则恢复到原状态
toggle(STATUS_CLOSE);
}
break;
}
}
public void toggle(int status) {
this.status = status;
curY = getScrollY();//y轴上的偏移量
switch (status) {
case STATUS_DEFAULT:
finalY = offsetDefault;
setRecyclerViewLastY(status);
break;
case STATUS_EXTEND:
finalY = offsetExtend;
setRecyclerViewLastY(status);
break;
case STATUS_CLOSE:
finalY = offsetClose;
setRecyclerViewLastY(status);
break;
}
start();
}
public void start() {
stop();
if (animator != null) {
animator.start();
}
}
public void stop() {
if (animator != null) {
animator.end();
}
}
/**
* 设置RecyclerView是否可滑动
* 目的:恢复当从顶部下滑后再滑动到顶部,可跟随滑动
*/
private void setRecyclerViewLastY(boolean isScroll) {
// ScrollRecyclerView.canScroll = isScroll;
}
private OnScrollChangedListener listener;
public interface OnScrollChangedListener {
void onScrollChange(int status);
void onScrollProgress(int progress);
}
public void setOnScrollChangedListener(OnScrollChangedListener l) {
this.listener = l;
}
/**
* 暂时不用
* @param status
*/
private void setRecyclerViewLastY(int status) {
// ScrollRecyclerView.lastY = (status == STATUS_EXTEND ? height : child_default_height);
}
}
package com.mints.street.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import com.fry.base.ui.widget.CustomRecycleView;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import me.goldze.mvvmhabit.utils.KLog;
/**
* Created by yunzhao.liu on 2018/6/20
*/
public class ScrollRecyclerView extends CustomRecycleView {
public static boolean canScroll = true;
public float lastY;
public ScrollRecyclerView(Context context) {
this(context, null);
}
public ScrollRecyclerView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public ScrollRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onTouchEvent(MotionEvent e) {
float eY = e.getY();
switch (e.getAction()) {
//因为是滚动列表,所以父View的dispatchTouchEvent不会调用Down事件,而是从Move事件开始调用
case MotionEvent.ACTION_DOWN:
KLog.i("liuyzz:recyclerview:", "---down");
lastY = eY;
canScroll = true;
super.onTouchEvent(e);
return true;
case MotionEvent.ACTION_MOVE:
if (!canScroll) {
return false;
}
//下滑负 上滑正
int offset = (int) (lastY - eY);
lastY = eY;
KLog.i("liuyzz:recyclerview:", ""+canScroll+"-isTop:"+isTop()+"-offset:"+offset);
canScroll = !isTop() || offset > 0;
super.onTouchEvent(e);//如果不写,则会不让滑动
return canScroll;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
canScroll = true;
super.onTouchEvent(e);
return true;
}
return super.onTouchEvent(e);
}
private boolean isTop() {
LayoutManager manager = getLayoutManager();
if (manager == null
|| !(manager instanceof LinearLayoutManager)) {
return false;
}
//显示区域最上面一条信息的position
int visibleItemPosition = ((LinearLayoutManager) manager).findFirstVisibleItemPosition();
View childView = getChildAt(0);//getChildAt(0)只能获得当前能看到的item的第一个
KLog.i("liuyzz:recyclerview:", "position:"+visibleItemPosition+"-top:"+childView.getTop());
//坐标系 下正右正
//D/liuyzz:recyclerview:: position:0-top:-3
//D/liuyzz:recyclerview:: position:0-top:-35
//D/liuyzz:recyclerview:: position:3-top:-10
//D/liuyzz:recyclerview:: position:3-top:-34
return childView != null && visibleItemPosition <= 0 && childView.getTop() >= 0;
}
}
......@@ -3,6 +3,6 @@
android:shape="rectangle">
<solid android:color="#ffffffff" />
<corners android:radius="10dp" />
<corners android:radius="4dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_7EE2FF" />
<corners android:radius="20dp" />
</shape>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="ViewModel"
name="viewModel"
type="com.mints.street.login.LoginViewModel" />
</data>
<androidx.appcompat.widget.LinearLayoutCompat
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<FrameLayout
android:id="@+id/fl_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<!--这里模拟一张oneshot单的焦点图展示-->
<ImageView
android:id="@+id/oneshot_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="400px" />
<RelativeLayout
android:id="@+id/splash_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white">
<!-- 广点通开屏广告支持“半屏/全屏”展示,开发者可以把Logo区域放在屏幕底部,然后在Logo上方提供一个容器来放置半开屏广告,请注意此容器高度不得小于400dp -->
<!-- 1.Logo区域:展示半开屏广告时使用,如果想展示全开屏广告,可以不需要这个Logo区域 -->
<!-- 注意:如需要这个Logo区域,建议开发者使用自己的Logo资源,而不是联盟的Logo资源@drawable/gdt_splash_logo,资源规格可参照@drawable/gdt_splash_logo -->
<FrameLayout
android:id="@+id/splash_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/app_logo" />
<!-- 2.预设开屏图片区域: -->
<!-- 开发者可以把自家App设计开屏图片摆放在这里,本示例中放置了一张静态图片。!-->
<!-- 注意1:直接将此图放在广告容器的下面即可,始终不要将广告容器splash_container的设为invisible,否则将不会展示广告无法计费,返回错误码600。-->
<!-- 注意2:建议开发者使用自己的开屏图片资源,而不是联盟的@drawable/splash_holder,资源规格可参照@drawable/splash_holder -->
<ImageView
android:id="@+id/splash_holder"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/app_logo"
android:scaleType="fitXY" />
<!-- 3.开屏广告容器区域:-->
<!-- 注意:该区域高度不得小于400dp。在本示例中没有写死splash_container的高度值,是因为第1部分的app_logo区域是一个高度很小的图片。 -->
<ImageView
android:id="@+id/app_logo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
/>
<!-- 4.自定义跳过按钮区域:开发者可以根据需要自己实现不同样式的跳过按钮 -->
<!-- 注意1:根据广告法规定,跳过按钮必须在屏幕当中出现。因此广告展示的时候,必须让将SkipView显示出来,即visible,否则将SDK将不展示广告,返回错误码608。。 -->
<!-- 注意2:SDK除了会检查跳过按钮的可见性,还将检测它的尺寸,其尺寸不得小于3dp*3dp,否则将SDK将不展示广告,返回错误码608。 -->
<TextView
android:id="@+id/skip_view"
android:layout_width="96dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="16dp"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:background="@drawable/shape_bg_circle"
android:gravity="center"
android:text="点击跳过"
android:textColor="@android:color/white"
android:textSize="14sp"
android:visibility="gone" />
<!-- 本示例省略了自定义的倒计时,和跳过按钮放在一起实现了。开发者也可以实现自己的倒计时View,方法是在onADTick回调中获得广告剩余的展示时间,并自由决定倒计时View的样式,SDK对倒计时的View没有要求。 -->
<!-- 自定义wifi预加载按钮,需设置状态为不显示,当素材为视频且视频开始播放时,SDK内部会处理为显示状态-->
<TextView
android:id="@+id/preload_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_margin="16dp"
android:background="@drawable/shape_bg_circle"
android:gravity="center"
android:text="已Wi-Fi预加载"
android:textColor="@android:color/white"
android:textSize="14sp"
android:visibility="gone" />
</RelativeLayout>
</FrameLayout>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="butt"
android:id="@+id/bu"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
<data>
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="140dp"
>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
</androidx.recyclerview.widget.RecyclerView>
</FrameLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.mints.street.main.vr.FeaturedExperienceViewModel" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_my"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlAccentColor="@color/gray"
app:srlPrimaryColor="@color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</FrameLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.mints.street.main.vr.FreeZoneViewModel" />
</data>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/srl_my"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srlAccentColor="@color/gray"
app:srlPrimaryColor="@color/white">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
</FrameLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="ViewModel"
name="viewModel"
type="com.mints.street.main.home.HomeViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
>
<ImageView
android:layout_marginTop="15dp"
android:id="@+id/image_map_change"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="广场"
android:textColor="@color/black"
android:textSize="39dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@mipmap/map_change_icon"
/>
<ImageView
android:layout_marginTop="15dp"
android:id="@+id/image_map_history"
app:layout_constraintTop_toBottomOf="@id/image_map_change"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@mipmap/map_history_icon"
/>
<ImageView
android:layout_marginTop="15dp"
android:id="@+id/image_location_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="120dp"
android:layout_width="35dp"
android:layout_height="35dp"
android:src="@mipmap/location_icon"
/>
<LinearLayout
android:id="@+id/map_a_d"
android:layout_width="31dp"
android:layout_height="63dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/image_location_icon"
android:orientation="vertical"
android:background="@drawable/shape_gold_card"
android:layout_marginEnd="2dp"
android:layout_marginBottom="10dp"
>
<ImageView
android:padding="10dp"
android:layout_width="31dp"
android:layout_height="31dp"
android:src="@mipmap/scale_add_icon"
/>
<View
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_width="wrap_content"
android:layout_height="0.5dp"
android:background="@color/color_333"
/>
<ImageView
android:padding="10dp"
android:layout_width="31dp"
android:layout_height="31dp"
android:src="@mipmap/scale_shrink_icon"
/>
</LinearLayout>
<com.mints.street.widget.ScrollLayout
android:id="@+id/scroll_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:fillViewport="true"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:gravity="center_horizontal"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:src="@mipmap/icon_content_back" />
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:text="占位置"
android:textColor="@color/color_2B3238" />
</LinearLayout>
<com.mints.street.widget.ScrollRecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemBinding="@{viewModel.addressItemBinding}"
app:items="@{viewModel.addressList}"
tools:listitem="@layout/item_home_button">
</com.mints.street.widget.ScrollRecyclerView>
</com.mints.street.widget.ScrollLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
......@@ -2,7 +2,7 @@
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="ViewModel"
name="viewModel"
type="com.mints.street.main.my.MyViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
......
......@@ -2,7 +2,7 @@
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="ViewModel"
name="viewModel"
type="com.mints.street.main.vr.VRViewModel" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.ItemEnterDestinationAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bg"
android:layout_width="match_parent"
android:layout_height="140dp"
android:background="@mipmap/vip_google_bg"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:padding="10dp"
>
<TextView
android:id="@+id/tv_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试"
android:textColor="@color/black"
android:textSize="16sp"
android:textStyle="bold"
/>
<TextView
android:gravity="center"
android:layout_marginTop="5dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tv_name"
android:id="@+id/tv_number_people"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="人数"
android:drawableStart="@mipmap/search_hot_icon"
android:textColor="@color/black"
android:textSize="12sp"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/street_go"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tv_name"
app:layout_constraintBottom_toBottomOf="@id/tv_number_people"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="0dp"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image2"
android:src="@mipmap/bg_fl"
/>
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/image2"
android:layout_width="0dp"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image1"
app:layout_constraintEnd_toStartOf="@id/image3"
android:src="@mipmap/bg_fl"
/>
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/image3"
android:layout_width="0dp"
android:layout_height="60dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image2"
app:layout_constraintEnd_toEndOf="parent"
android:src="@mipmap/bg_fl"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="viewModel"
type="com.mints.street.adapter.GridMapAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bg"
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@drawable/shape_gold_card_20"
>
<ImageView
android:id="@+id/image"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="match_parent"
android:layout_height="90dp"/>
<TextView
android:padding="10dp"
android:id="@+id/tv_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="测试"
android:textColor="@color/black"
android:textSize="12sp"
/>
<LinearLayout
app:layout_constraintTop_toBottomOf="@id/tv_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
>
<ImageView
android:padding="5dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/star_icon"
/><ImageView
android:padding="5dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/star_icon"
/><ImageView
android:padding="5dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/star_icon"
/><ImageView
android:padding="5dp"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@mipmap/star_icon"
/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
>
<data>
<variable
name="viewModel"
type="com.mints.street.main.home.HomeButtonItemVM" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@mipmap/abc_popup_background_mtrl_mult"
android:padding="15dp"
>
<TextView
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="sdfasd"
android:textSize="16sp"
android:singleLine="true"
android:textStyle="bold"
android:textColor="@color/color_2B3238"
/>
<ImageView
android:id="@+id/image1"
android:layout_width="0dp"
android:layout_height="65dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/image2"
tools:src="@mipmap/bg_fl"
/>
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/image2"
android:layout_width="0dp"
android:layout_height="65dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image1"
app:layout_constraintEnd_toStartOf="@id/image3"
tools:src="@mipmap/bg_fl"
/>
<ImageView
android:layout_marginStart="10dp"
android:id="@+id/image3"
android:layout_width="0dp"
android:layout_height="65dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/image2"
app:layout_constraintEnd_toEndOf="parent"
tools:src="@mipmap/bg_fl"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
......@@ -68,4 +68,7 @@ dependencies {
//底部bottomBar
api 'com.github.ittianyu:BottomNavigationViewEx:2.0.4'
//万能布局管理器VirtualLayout
api 'com.alibaba.android:vlayout:1.0.9'
}
package com.fry.base.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.alibaba.android.vlayout.DelegateAdapter;
import androidx.annotation.NonNull;
import androidx.databinding.ViewDataBinding;
/**
* @author jeme
* @date 2019/9/21
*/
public abstract class AbstractVLayoutBaseAdapter<T extends ViewDataBinding,D> extends DelegateAdapter.Adapter<BindingViewHolder<T>> {
protected Context mContext;
protected D mData;
protected int mViewType;
public AbstractVLayoutBaseAdapter(Context context, D datas, int viewType){
this.mContext = context;
this.mData = datas;
this.mViewType = viewType;
}
protected abstract int getLayoutId(int viewType);
public D getData(){
return mData;
}
@Override
public int getItemViewType(int position) {
return mViewType;
}
@Override
public long getItemId(int position) {
return position;
}
@NonNull
@Override
public BindingViewHolder<T> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new BindingViewHolder<>(LayoutInflater.from(mContext).inflate(getLayoutId(viewType), parent, false));
}
}
#Thu Jul 08 17:51:32 CST 2021
VERSION_BUILD=2593
#Fri Jul 09 19:35:56 CST 2021
VERSION_BUILD=2722
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