diff --git a/gradle.properties b/gradle.properties index 8c8ea2d1f..55b4ba5d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -23,6 +23,6 @@ android.enableJetifier=true systemProp.http.proxyHost=127.0.0.1 systemProp.https.proxyHost=127.0.0.1 -systemProp.https.proxyPort=10809 -systemProp.http.proxyPort=10809 +systemProp.https.proxyPort=7980 +systemProp.http.proxyPort=7890 #android.enableR8.fullMode=true \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveBuyGuardTopListAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveBuyGuardTopListAdapter.java new file mode 100644 index 000000000..6a367104d --- /dev/null +++ b/live/src/main/java/com/yunbao/live/adapter/LiveBuyGuardTopListAdapter.java @@ -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{ + 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); + } + }); + } + } +} diff --git a/live/src/main/java/com/yunbao/live/custom/LiveBuyGuardLinearLayoutManager.java b/live/src/main/java/com/yunbao/live/custom/LiveBuyGuardLinearLayoutManager.java new file mode 100644 index 000000000..89720e133 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/custom/LiveBuyGuardLinearLayoutManager.java @@ -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); + } +} diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveBuyGuardDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveBuyGuardDialog.java new file mode 100644 index 000000000..8dfdbbf47 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/LiveBuyGuardDialog.java @@ -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 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)); + } +} diff --git a/live/src/main/java/com/yunbao/live/fragments/LiveBuyGuardVPFragment.java b/live/src/main/java/com/yunbao/live/fragments/LiveBuyGuardVPFragment.java new file mode 100644 index 000000000..ead17a048 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/fragments/LiveBuyGuardVPFragment.java @@ -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); + } +} diff --git a/live/src/main/res/layout/dialog_live_buy_guard.xml b/live/src/main/res/layout/dialog_live_buy_guard.xml new file mode 100644 index 000000000..9da5d76a1 --- /dev/null +++ b/live/src/main/res/layout/dialog_live_buy_guard.xml @@ -0,0 +1,30 @@ + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_vp_live_buy_guard.xml b/live/src/main/res/layout/view_vp_live_buy_guard.xml new file mode 100644 index 000000000..356233a55 --- /dev/null +++ b/live/src/main/res/layout/view_vp_live_buy_guard.xml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/mipmap-xhdpi/bg_star_guard.png b/live/src/main/res/mipmap-xhdpi/bg_star_guard.png new file mode 100644 index 000000000..bb3105a3f Binary files /dev/null and b/live/src/main/res/mipmap-xhdpi/bg_star_guard.png differ diff --git a/live/src/main/res/mipmap-xxxhdpi/dialog_live_buy_guard_bg.png b/live/src/main/res/mipmap-xxxhdpi/dialog_live_buy_guard_bg.png new file mode 100644 index 000000000..b520ed632 Binary files /dev/null and b/live/src/main/res/mipmap-xxxhdpi/dialog_live_buy_guard_bg.png differ diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 2b280ad62..776f08d8f 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -699,6 +699,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Override public void onKickedOffline() { super.onKickedOffline(); + Log.i("tx", "腾讯云服务器踢出登录"); CommonAppConfig.getInstance().clearLoginInfo(); LoginActivity.forward(); diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java index aa91acf13..bd6cb2dae 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java @@ -1,6 +1,7 @@ package com.yunbao.main.views; import android.content.Context; +import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; @@ -9,6 +10,7 @@ import com.umeng.analytics.MobclickAgent; import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.event.FloatWarOrderEvent; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.live.dialog.LiveBuyGuardDialog; import com.yunbao.main.R; 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); - /* img_trophy.setOnLongClickListener(new View.OnLongClickListener() { + img_trophy.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View view) { + new LiveBuyGuardDialog(mContext).showDialog(); return true; } - });*/ + }); }