导航菜单

页面标题

页面副标题

新暖心缘 v8.1.1 - VideoPagerActivity.java 源代码

正在查看: 新暖心缘 v8.1.1 应用的 VideoPagerActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.luanxingyuan.app.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.PopupWindow;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;
import butterknife.OnClick;
import cn.jpush.android.api.JThirdPlatFormInterface;
import com.luanxingyuan.app.base.BaseActivity;
import com.luanxingyuan.app.base.BaseResponse;
import com.luanxingyuan.app.bean.AlbumBean;
import com.luanxingyuan.app.util.DevicesUtil;
import com.luanxingyuan.app.util.ParamUtil;
import com.luanxingyuan.app.view.recycle.ViewPagerLayoutManager;
import com.pili.pldroid.player.PLOnPreparedListener;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import java.util.HashMap;
import java.util.List;
import k6.u0;
import r6.f;

public class VideoPagerActivity extends BaseActivity {
    private int currentIndex;
    private int defaultIndex;
    private Handler handler = new Handler(Looper.getMainLooper());
    private boolean noMoreData;

    @BindView
    SmartRefreshLayout refreshLayout;
    private r6.f<AlbumBean> requester;

    @BindView
    RecyclerView rv;
    private u0 videoPagerAdapter;
    private u0.a videoPagerHolder;

    class a extends r6.a<BaseResponse> {
        a() {
        }

        public void onResponse(BaseResponse baseResponse, int i8) {
        }
    }

    class b implements View.OnClickListener {

        final PopupWindow f7288a;

        b(PopupWindow popupWindow) {
            this.f7288a = popupWindow;
        }

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(VideoPagerActivity.this.getApplicationContext(), (Class<?>) ReportActivity.class);
            intent.putExtra("actor_id", VideoPagerActivity.this.videoPagerAdapter.c(VideoPagerActivity.this.currentIndex).t_id);
            VideoPagerActivity.this.startActivity(intent);
            this.f7288a.dismiss();
        }
    }

    class c implements View.OnClickListener {

        final PopupWindow f7290a;

        c(PopupWindow popupWindow) {
            this.f7290a = popupWindow;
        }

        @Override
        public void onClick(View view) {
            Intent intent = new Intent(VideoPagerActivity.this.getApplicationContext(), (Class<?>) ReportActivity.class);
            intent.putExtra("actor_id", VideoPagerActivity.this.videoPagerAdapter.c(VideoPagerActivity.this.currentIndex).t_id);
            VideoPagerActivity.this.startActivity(intent);
            this.f7290a.dismiss();
        }
    }

    class d implements com.luanxingyuan.app.view.recycle.d {
        d() {
        }

        @Override
        public void a(int i8, boolean z7) {
            AlbumBean c8 = VideoPagerActivity.this.videoPagerAdapter.c(i8);
            VideoPagerActivity.this.currentIndex = i8;
            VideoPagerActivity.this.playVideo(c8);
            if (!((VideoPagerActivity.this.videoPagerAdapter.getItemCount() - 1) - i8 <= 5) || VideoPagerActivity.this.noMoreData || VideoPagerActivity.this.requester.f()) {
                return;
            }
            VideoPagerActivity.this.requester.h();
        }

        @Override
        public void b() {
            VideoPagerActivity.this.playVideo(VideoPagerActivity.this.videoPagerAdapter.c(VideoPagerActivity.this.defaultIndex));
        }

        @Override
        public void c(View view) {
            u0.a aVar = (u0.a) VideoPagerActivity.this.rv.getChildViewHolder(view);
            if (aVar != null) {
                VideoPagerActivity.this.videoPagerAdapter.j(aVar);
            }
        }
    }

    class e extends u0 {
        e(Activity activity) {
            super(activity);
        }

        @Override
        public void i() {
            VideoPagerActivity videoPagerActivity = VideoPagerActivity.this;
            videoPagerActivity.playVideo(videoPagerActivity.videoPagerAdapter.c(VideoPagerActivity.this.currentIndex));
        }
    }

    class f extends w0.m<List<AlbumBean>> {
        f() {
        }
    }

    class g implements s7.d {
        g() {
        }

        @Override
        public void d(m7.i iVar) {
            iVar.b(0);
        }
    }

    class h implements s7.b {
        h() {
        }

        @Override
        public void c(m7.i iVar) {
            if (VideoPagerActivity.this.requester.f()) {
                return;
            }
            VideoPagerActivity.this.requester.h();
        }
    }

    class i extends r6.f<AlbumBean> {
        i() {
        }

        @Override
        public void j(List<AlbumBean> list, boolean z7) {
            if (VideoPagerActivity.this.isFinishing() || list == null) {
                return;
            }
            VideoPagerActivity.this.videoPagerAdapter.k(list, false);
        }
    }

    class j extends f.e {
        j() {
        }

        @Override
        public void b(boolean z7) {
            if (VideoPagerActivity.this.isFinishing()) {
                return;
            }
            VideoPagerActivity.this.refreshLayout.e(0, true, z7);
            VideoPagerActivity.this.noMoreData = z7;
        }
    }

    class k implements PLOnPreparedListener {

        class a implements Animation.AnimationListener {
            a() {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                VideoPagerActivity.this.videoPagerHolder.f14659j.setVisibility(8);
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationStart(Animation animation) {
            }
        }

        k() {
        }

        @Override
        public void onPrepared(int i8) {
            AlphaAnimation alphaAnimation = new AlphaAnimation(1.0f, 0.0f);
            alphaAnimation.setDuration(300L);
            alphaAnimation.setAnimationListener(new a());
            VideoPagerActivity.this.videoPagerHolder.f14659j.startAnimation(alphaAnimation);
        }
    }

    class l implements View.OnClickListener {

        final AlbumBean f7301a;

        l(AlbumBean albumBean) {
            this.f7301a = albumBean;
        }

        @Override
        public void onClick(View view) {
            if (VideoPagerActivity.this.videoPagerHolder.f14658i.getTag() == null) {
                VideoPagerActivity.this.playVideo(this.f7301a);
                return;
            }
            if (!VideoPagerActivity.this.videoPagerHolder.f14658i.isPlaying() || VideoPagerActivity.this.isPause()) {
                VideoPagerActivity.this.videoPagerHolder.f14658i.start();
                VideoPagerActivity.this.videoPagerHolder.f14662m.setVisibility(8);
                VideoPagerActivity.this.videoPagerHolder.f14658i.setTag(Boolean.FALSE);
            } else {
                VideoPagerActivity.this.videoPagerHolder.f14658i.pause();
                VideoPagerActivity.this.videoPagerHolder.f14662m.setVisibility(0);
                VideoPagerActivity.this.videoPagerHolder.f14658i.setTag(Boolean.TRUE);
            }
        }
    }

    private void addSeeTime(int i8) {
        HashMap hashMap = new HashMap();
        hashMap.put("userId", getUserId());
        hashMap.put("fileId", String.valueOf(i8));
        x7.a.h().c(m6.a.e()).e("param", ParamUtil.getParam(hashMap)).f().c(new a());
    }

    private void initRecycle() {
        ViewPagerLayoutManager viewPagerLayoutManager = new ViewPagerLayoutManager(this, 1);
        viewPagerLayoutManager.e(new d());
        this.videoPagerAdapter = new e(this);
        this.videoPagerAdapter.k((List) w0.a.o(getIntent().getStringExtra(JThirdPlatFormInterface.KEY_DATA), new f(), new z0.b[0]), false);
        this.rv.setLayoutManager(viewPagerLayoutManager);
        this.rv.setAdapter(this.videoPagerAdapter);
        this.rv.scrollToPosition(this.defaultIndex);
        viewPagerLayoutManager.f(this.defaultIndex);
        this.refreshLayout.P(false);
        this.refreshLayout.O(false);
        this.refreshLayout.M(false);
        this.refreshLayout.T(new g());
        this.refreshLayout.S(new h());
        i iVar = new i();
        this.requester = iVar;
        iVar.n(new j());
        this.requester.m(m6.a.G0());
        this.requester.p("queryType", getIntent().getStringExtra("queryType"));
        this.requester.o(getIntent().getIntExtra("page", 1));
        this.requester.h();
    }

    public boolean isPause() {
        return this.videoPagerHolder.f14658i.getTag() != null && ((Boolean) this.videoPagerHolder.f14658i.getTag()).booleanValue();
    }

    private void pauseVideoView() {
        if (this.videoPagerHolder == null || isFinishing()) {
            return;
        }
        this.videoPagerHolder.f14658i.pause();
        this.videoPagerHolder.f14658i.setTag(Boolean.TRUE);
        this.videoPagerHolder.f14662m.setVisibility(0);
    }

    public synchronized void playVideo(AlbumBean albumBean) {
        u0.a aVar = null;
        this.handler.removeCallbacksAndMessages(null);
        u0.a aVar2 = this.videoPagerHolder;
        if (aVar2 != null) {
            aVar2.f14661l.setOnClickListener(null);
            this.videoPagerHolder.f14658i.stopPlayback();
        }
        String str = albumBean.t_addres_url;
        if (albumBean.canSee()) {
            int i8 = 0;
            while (true) {
                if (i8 >= this.rv.getChildCount()) {
                    break;
                }
                RecyclerView recyclerView = this.rv;
                u0.a aVar3 = (u0.a) recyclerView.getChildViewHolder(recyclerView.getChildAt(i8));
                if (aVar3.f14663n == this.currentIndex) {
                    aVar = aVar3;
                    break;
                }
                i8++;
            }
            if (aVar == null) {
                RecyclerView recyclerView2 = this.rv;
                aVar = (u0.a) recyclerView2.getChildViewHolder(recyclerView2.getChildAt(0));
            }
            this.videoPagerHolder = aVar;
            aVar.f14658i.setVideoPath(str);
            aVar.f14658i.setLooping(true);
            aVar.f14658i.start();
            aVar.f14658i.setTag(Boolean.FALSE);
            aVar.f14658i.setOnPreparedListener(new k());
            aVar.f14661l.setOnClickListener(new l(albumBean));
            addSeeTime(albumBean.t_id);
        }
    }

    private void showComplainPopup(View view) {
        View inflate = LayoutInflater.from(this).inflate(2131493307, (ViewGroup) null, false);
        PopupWindow popupWindow = new PopupWindow(inflate, DevicesUtil.dp2px(getApplicationContext(), 81.0f), DevicesUtil.dp2px(getApplicationContext(), 81.0f), true);
        ((TextView) inflate.findViewById(2131296536)).setOnClickListener(new b(popupWindow));
        ((TextView) inflate.findViewById(2131297154)).setOnClickListener(new c(popupWindow));
        popupWindow.setBackgroundDrawable(new ColorDrawable(0));
        popupWindow.setOutsideTouchable(true);
        popupWindow.setTouchable(true);
        popupWindow.showAsDropDown(view, -123, 3);
    }

    public static void start(Context context, List<AlbumBean> list, int i8, int i9, int i10) {
        Intent intent = new Intent(context, (Class<?>) VideoPagerActivity.class);
        intent.putExtra(JThirdPlatFormInterface.KEY_DATA, w0.a.u(list));
        intent.putExtra("index", i8);
        intent.putExtra("queryType", i10 + "");
        intent.putExtra("page", i9);
        context.startActivity(intent);
    }

    @Override
    protected View getContentView() {
        return inflate(2131492978);
    }

    @Override
    protected boolean isImmersionBarEnabled() {
        return true;
    }

    @OnClick
    public void onClick(View view) {
        int id = view.getId();
        if (id == 2131296386) {
            finish();
        } else {
            if (id != 2131296535) {
                return;
            }
            showComplainPopup(view);
        }
    }

    @Override
    protected void onContentAdded() {
        needHeader(false);
        int intExtra = getIntent().getIntExtra("index", 0);
        this.defaultIndex = intExtra;
        this.currentIndex = intExtra;
        initRecycle();
    }

    @Override
    protected void onCreate(Bundle bundle) {
        setVolumeControlStream(3);
        super.onCreate(bundle);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        u0.a aVar = this.videoPagerHolder;
        if (aVar != null) {
            aVar.f14658i.stopPlayback();
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        pauseVideoView();
    }
}