Commit 2207581e authored by 张释方's avatar 张释方

提交会员界面

parent 47bb2b23
......@@ -87,7 +87,7 @@
<activity android:name=".main.my.MoresettingsActivity"/>
<activity android:name=".main.my.AboutusActivity"/>
<activity android:name=".main.my.PermissionsActivity"/>
<activity android:name=".main.my.OpenvipActivity"/>
<!-- ShareSDK start -->
<activity
android:name="com.mob.tools.MobUIShell"
......
package com.mints.street.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;
import com.fry.base.utils.DensityUtils;
import com.mints.street.adapter.listener.OnPageSelectListener;
import com.mints.street.widget.CoverFlowViewPager;
import java.util.List;
public class CoverFlowAdapter extends PagerAdapter implements ViewPager.OnPageChangeListener {
/**
* 默认缩小的padding值
*/
public static int sWidthPadding;
public static int sHeightPadding;
/**
* 子元素的集合
*/
private List<View> mViewList;
/**
* 滑动监听的回调接口
*/
private OnPageSelectListener listener;
/**
* 上下文对象
*/
private Context mContext;
public CoverFlowAdapter(List<View> mImageViewList, Context context) {
this.mViewList = mImageViewList;
mContext = context;
// 设置padding值
sWidthPadding = DensityUtils.dip2px(16);
sHeightPadding = DensityUtils.dip2px(28);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView(mViewList.get(position));
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View view = mViewList.get(position);
container.addView(view);
return view;
}
@Override
public int getCount() {
return mViewList == null ? 0 : mViewList.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
// 该方法回调ViewPager 的滑动偏移量
if (mViewList.size() > 0 && position < mViewList.size()) {
//当前手指触摸滑动的页面,从0页滑动到1页 offset越来越大,padding越来越大
int outHeightPadding = (int) (positionOffset * sHeightPadding);
int outWidthPadding = (int) (positionOffset * sWidthPadding);
// 从0滑动到一时,此时position = 0,其应该是缩小的,符合
mViewList.get(position).setPadding(outWidthPadding, outHeightPadding, outWidthPadding, outHeightPadding);
// position+1 为即将显示的页面,越来越大
if (position < mViewList.size() - 1) {
int inWidthPadding = (int) ((1 - positionOffset) * sWidthPadding);
int inHeightPadding = (int) ((1 - positionOffset) * sHeightPadding);
mViewList.get(position + 1).setPadding(inWidthPadding, inHeightPadding, inWidthPadding, inHeightPadding);
}
}
}
@Override
public void onPageSelected(int position) {
// 回调选择的接口
if (listener != null) {
listener.select(position);
}
}
@Override
public void onPageScrollStateChanged(int state) {
}
/**
* 当将某一个作为最中央时的回调
*
* @param listener
*/
public void setOnPageSelectListener(CoverFlowViewPager listener) {
this.listener = listener;
}
}
package com.mints.street.adapter.listener;
public interface OnPageSelectListener {
void select(int position);
}
......@@ -62,7 +62,8 @@ class MyFragment : BaseFragment<FragmentMyBinding, MyViewModel>(), View.OnClickL
//设置立即领取点击事件
binding.btTry.setOnClickListener {
startActivity(PermissionsActivity::class.java)
// startActivity(PermissionsActivity::class.java)
startActivity(OpenvipActivity::class.java)
}
ly_aboutus.setOnClickListener(this)
......
package com.mints.street.main.my
import android.graphics.Color
import android.os.Bundle
import android.view.View
import com.fry.base.base.BaseActivity
import com.mints.street.BR
import com.mints.street.R
import com.mints.street.databinding.ActivityOpenvipBinding
import kotlinx.android.synthetic.main.activity_openvip.*
import kotlinx.android.synthetic.main.include_header.*
class OpenvipActivity: BaseActivity<ActivityOpenvipBinding, OpenvipViewModel>() {
override fun initVariableId() = BR.viewModel
override fun initContentView(savedInstanceState: Bundle?)= R.layout.activity_openvip
override fun initData() {
super.initData()
initView()
}
private fun initView() {
val layoutInflater = layoutInflater
// 初始化数据
// 初始化数据
val list: MutableList<View> = ArrayList()
val page1 = layoutInflater.inflate(R.layout.view_data_page1, null)
val page2 = layoutInflater.inflate(R.layout.view_data_page2, null)
val page3 = layoutInflater.inflate(R.layout.view_data_page3, null)
list.add(page1)
list.add(page2)
list.add(page3)
//设置显示的数据
cfp_data_viewpager.setViewList(list)
tv_title.text="成为会员"
tv_title.setTextColor(Color.WHITE)
iv_left_icon.setImageResource(R.mipmap.iv_return_white)
iv_left_icon.visibility= View.VISIBLE
}
}
package com.mints.street.main.my
import android.app.Application
import me.goldze.mvvmhabit.base.BaseViewModel
class OpenvipViewModel (application: Application): BaseViewModel(application) {
}
......@@ -45,6 +45,7 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
}
//校验App签名
checkAppSign()
}
......@@ -53,7 +54,7 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
if (mForceGoMain) {
goToMainActivity()
}
if (onPaused ) {
if (onPaused) {
// 这种情况下,百度开屏广告不能在onAdDismiss中跳转,需要自己在onResume中跳转主页。
goToMainActivity()
}
......@@ -68,7 +69,6 @@ class SplashActivity:BaseActivity<ActivitySplashBinding,SplashViewModel>() {
override fun onStop() {
super.onStop()
mForceGoMain = true
}
......
package com.mints.street.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.viewpager.widget.ViewPager;
import com.fry.base.utils.DensityUtils;
import com.mints.street.R;
import com.mints.street.adapter.CoverFlowAdapter;
import com.mints.street.adapter.listener.OnPageSelectListener;
import java.util.ArrayList;
import java.util.List;
public class CoverFlowViewPager extends RelativeLayout implements OnPageSelectListener {
/**
* 适配器
*/
private CoverFlowAdapter mAdapter;
/**
* 用于左右滚动
*/
private ViewPager mViewPager;
/**
* 需要显示的视图集合
*/
private List<View> mViewList = new ArrayList<>();
private OnPageSelectListener listener;
public CoverFlowViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(context, R.layout.widget_cover_flow, this);
mViewPager = findViewById(R.id.vp_conver_flow);
// 365dp 380
int marginWidth = DensityUtils.dip2px(50);
int displayWidth = DensityUtils.getDisplayWidth(getContext());
int height = DensityUtils.dip2px( 150);
LayoutParams layoutParams = new LayoutParams(displayWidth - marginWidth, height);
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
mViewPager.setLayoutParams(layoutParams);
init();
}
/**
* 初始化方法
*/
private void init() {
// 构造适配器,传入数据源
mAdapter = new CoverFlowAdapter(mViewList, getContext());
// 设置选中的回调
mAdapter.setOnPageSelectListener(this);
// 设置适配器
mViewPager.setAdapter(mAdapter);
// 设置滑动的监听,因为adpter实现了滑动回调的接口,所以这里直接设置adpter
mViewPager.addOnPageChangeListener(mAdapter);
// 预加载个数
mViewPager.setOffscreenPageLimit(5);
// 设置触摸事件的分发
setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// 传递给ViewPager 进行滑动处理
return mViewPager.dispatchTouchEvent(event);
}
});
}
/**
* 设置显示的数据,进行一层封装
*
* @param lists
*/
public void setViewList(List<View> lists) {
if (lists == null) {
return;
}
mViewList.clear();
for (View view : lists) {
FrameLayout layout = new FrameLayout(getContext());
// 设置padding 值,默认缩小
layout.setPadding(CoverFlowAdapter.sWidthPadding, CoverFlowAdapter.sHeightPadding, CoverFlowAdapter.sWidthPadding, CoverFlowAdapter.sHeightPadding);
layout.addView(view);
mViewList.add(layout);
}
// 刷新数据
mAdapter.notifyDataSetChanged();
}
/**
* 当将某一个作为最中央时的回调
*
* @param listener
*/
public void setOnPageSelectListener(OnPageSelectListener listener) {
this.listener = listener;
}
// 显示的回调
@Override
public void select(int position) {
if (listener != null) {
listener.select(position);
}
}
}
......@@ -2,7 +2,6 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="ViewModel"
type="com.mints.street.main.my.MoresettingsViewModel" />
......
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:background="@drawable/shape_bt_disagree"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_bt_disagree"
android:gravity="center_horizontal"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_bt_disagree"
android:gravity="center_horizontal"
android:orientation="vertical">
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_conver_flow"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:overScrollMode="never" />
</RelativeLayout>
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.fry.base.utils;
import android.content.Context;
import android.graphics.Point;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
......@@ -10,6 +11,7 @@ import me.goldze.mvvmhabit.utils.Utils;
/**
* 2019-09-29 created
* dip、px转化.
*
* @author KOM
*/
public class DensityUtils {
......@@ -17,7 +19,7 @@ public class DensityUtils {
private static Point screenPoint;
public static Point getWindowWidthHeight() {
if(screenPoint == null){
if (screenPoint == null) {
screenPoint = new Point();
WindowManager wm = (WindowManager) Utils.getContext()
.getSystemService(Context.WINDOW_SERVICE);
......@@ -41,6 +43,22 @@ public class DensityUtils {
return new int[]{point.x, point.y};
}
private static DisplayMetrics sDisplayMetrics;
public static int getDisplayWidth(Context context) {
initDisplayMetrics(context);
return sDisplayMetrics.widthPixels;
}
public static int getDisplayHeight(Context context) {
initDisplayMetrics(context);
return sDisplayMetrics.heightPixels;
}
private static synchronized void initDisplayMetrics(Context context) {
sDisplayMetrics = context.getResources().getDisplayMetrics();
}
public static int dip2px(float dpValue) {
final float scale = Utils.getContext().getResources().getDisplayMetrics().density;
return (int) (dpValue * scale + 0.5f);
......
#Sat Jul 10 16:33:56 CST 2021
VERSION_BUILD=2754
#Mon Jul 12 16:02:26 CST 2021
VERSION_BUILD=2813
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