新增守护测试页面

This commit is contained in:
zlzw 2024-02-26 14:41:01 +08:00
parent df735af252
commit ae9ef1f8a1
11 changed files with 301 additions and 4 deletions

View File

@ -23,6 +23,6 @@ android.enableJetifier=true
systemProp.http.proxyHost=127.0.0.1 systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1 systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=10809 systemProp.https.proxyPort=7980
systemProp.http.proxyPort=10809 systemProp.http.proxyPort=7890
#android.enableR8.fullMode=true #android.enableR8.fullMode=true

View File

@ -0,0 +1,90 @@
package com.yunbao.live.adapter;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
public class LiveBuyGuardTopListAdapter extends RecyclerView.Adapter<LiveBuyGuardTopListAdapter.ViewHolder>{
private Context mContext;
public LiveBuyGuardTopListAdapter(Context mContext) {
this.mContext = mContext;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.view_vp_live_buy_guard,parent,false));
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
holder.bind(position);
}
@Override
public int getItemCount() {
return 3;
}
public class ViewHolder extends RecyclerView.ViewHolder{
ImageView imageView;
public ViewHolder(android.view.View itemView) {
super(itemView);
imageView=itemView.findViewById(R.id.bg);
Log.i("测试","");
itemView.setFocusable(true);
itemView.setFocusableInTouchMode(true);
itemView.getViewTreeObserver().addOnGlobalFocusChangeListener(new ViewTreeObserver.OnGlobalFocusChangeListener(){
@Override
public void onGlobalFocusChanged(View view, View view1) {
Log.i("测试","焦点变换:"+view+"|"+getAbsoluteAdapterPosition());
}
});
/* itemView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
Log.i("测试","焦点变换:"+b+"|"+getAbsoluteAdapterPosition());
}
});*/
}
public void bind(int position) {
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) itemView.getLayoutParams();
int def=15;
int margin=15;
int marginDef=5;
if(position==0){
params.leftMargin=DpUtil.dp2px(margin);
params.rightMargin=DpUtil.dp2px(marginDef);
}else if(position==getItemCount()-1){
params.rightMargin=DpUtil.dp2px(margin);
params.leftMargin=DpUtil.dp2px(marginDef);
}else{
params.leftMargin=DpUtil.dp2px(def);
params.rightMargin=DpUtil.dp2px(def);
}
itemView.setLayoutParams(params);
itemView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
System.out.println("~~~~~~~焦点 "+b);
}
});
}
}
}

View File

@ -0,0 +1,56 @@
package com.yunbao.live.custom;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.ScaleAnimation;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
public class LiveBuyGuardLinearLayoutManager extends LinearLayoutManager {
String TAG = "测试";
public LiveBuyGuardLinearLayoutManager(Context context) {
super(context);
}
public LiveBuyGuardLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
super(context, orientation, reverseLayout);
}
@Override
public int scrollHorizontallyBy(int dx, RecyclerView.Recycler recycler, RecyclerView.State state) {
int scroll = super.scrollHorizontallyBy(dx, recycler, state);
Log.i(TAG, "scrollHorizontallyBy: dx "+dx+"|"+state.hasTargetScrollPosition()+"|"+state.isPreLayout()+"|"+scroll);
View now = findViewByPosition(findFirstCompletelyVisibleItemPosition());
View old = findViewByPosition(findFirstCompletelyVisibleItemPosition() - 1);
View next = findViewByPosition(findFirstCompletelyVisibleItemPosition() + 1);
if (now != null) {
toView(now, 1);
}
if (old != null) {
toView(old, 0.6f);
}
if (next != null) {
toView(next, 0.6f);
}
//toView(now,1);
Log.i(TAG, "scrollHorizontallyBy: " + scroll);
return scroll;
}
//https://www.jianshu.com/p/b6c42e0f6422
private void toView(View view, float scale) {
if (view == null) return;
if(view.getAnimation()!=null&&view.getAnimation().hasStarted()) return;
ScaleAnimation scaleAnimation = new ScaleAnimation(view.getScaleX(),scale,view.getScaleY(), scale);
//scaleAnimation.setDuration(100);
//view.startAnimation(scaleAnimation);
view.setScaleX(scale);
view.setScaleY(scale);
}
}

View File

@ -0,0 +1,67 @@
package com.yunbao.live.dialog;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.PagerSnapHelper;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.custom.ItemDecoration;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.live.R;
import com.yunbao.live.adapter.LiveBuyGuardTopListAdapter;
import com.yunbao.live.custom.LiveBuyGuardLinearLayoutManager;
import com.yunbao.live.fragments.LiveBuyGuardVPFragment;
import java.util.ArrayList;
import java.util.List;
public class LiveBuyGuardDialog extends AbsDialogPopupWindow {
FragmentActivity activity;
RecyclerView recyclerView;
List<Fragment> fragments=new ArrayList<>();
public LiveBuyGuardDialog(@NonNull Context context) {
super(context);
activity=(FragmentActivity) context;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_live_buy_guard;
}
@Override
protected void onCreate() {
super.onCreate();
recyclerView=findViewById(R.id.recycler_view);
recyclerView.setAdapter(new LiveBuyGuardTopListAdapter(mContext));
LiveBuyGuardLinearLayoutManager layoutManager=new LiveBuyGuardLinearLayoutManager(mContext,RecyclerView.HORIZONTAL,false);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener(){
@Override
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
}
});
ItemDecoration decoration = new ItemDecoration(mContext, 0x00000000, 25, 0);
decoration.setOnlySetItemOffsetsButNoDraw(true);
//recyclerView.addItemDecoration(decoration);
recyclerView.setLayoutManager(layoutManager);
PagerSnapHelper snapHelper=new PagerSnapHelper();
snapHelper.attachToRecyclerView(recyclerView);
}
private void initViewPage(){
fragments.add(LiveBuyGuardVPFragment.newInstance(0));
fragments.add(LiveBuyGuardVPFragment.newInstance(1));
}
}

View File

@ -0,0 +1,35 @@
package com.yunbao.live.fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
public class LiveBuyGuardVPFragment extends Fragment {
private int type;
public static LiveBuyGuardVPFragment newInstance(int type) {
return new LiveBuyGuardVPFragment(type);
}
public LiveBuyGuardVPFragment(int type) {
this.type = type;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.view_vp_live_buy_guard,container,false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
android:layout_width="match_parent"
android:layout_height="509dp">
<ImageView
android:id="@+id/bg"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitCenter"
android:src="@mipmap/dialog_live_buy_guard_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="170dp"
android:layout_marginTop="70dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="3"
tools:listitem="@layout/view_vp_live_buy_guard" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="330dp"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/bg"
android:layout_width="0dp"
android:layout_height="160dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@mipmap/bg_star_guard" />
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 396 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -699,6 +699,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override @Override
public void onKickedOffline() { public void onKickedOffline() {
super.onKickedOffline(); super.onKickedOffline();
Log.i("tx", "腾讯云服务器踢出登录");
CommonAppConfig.getInstance().clearLoginInfo(); CommonAppConfig.getInstance().clearLoginInfo();
LoginActivity.forward(); LoginActivity.forward();

View File

@ -1,6 +1,7 @@
package com.yunbao.main.views; package com.yunbao.main.views;
import android.content.Context; import android.content.Context;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
@ -9,6 +10,7 @@ import com.umeng.analytics.MobclickAgent;
import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.event.FloatWarOrderEvent; import com.yunbao.common.event.FloatWarOrderEvent;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.live.dialog.LiveBuyGuardDialog;
import com.yunbao.main.R; import com.yunbao.main.R;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -48,12 +50,13 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy); ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy);
/* img_trophy.setOnLongClickListener(new View.OnLongClickListener() { img_trophy.setOnLongClickListener(new View.OnLongClickListener() {
@Override @Override
public boolean onLongClick(View view) { public boolean onLongClick(View view) {
new LiveBuyGuardDialog(mContext).showDialog();
return true; return true;
} }
});*/ });
} }