导航菜单

页面标题

页面副标题

SpinDisplay v2.0.2.6 - MediaLocalPreviewActivity.java 源代码

正在查看: SpinDisplay v2.0.2.6 应用的 MediaLocalPreviewActivity.java JAVA 源代码文件

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


package com.dmz.f20ad.activity;

import android.content.Intent;
import android.graphics.PorterDuff;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.VideoView;
import androidx.viewpager.widget.ViewPager;
import b.b.k.l;
import b.u.y;
import butterknife.ButterKnife;
import com.dmz.f20ad.App;
import com.dmz.f20ad.activity.MediaLocalPreviewActivity;
import com.dmz.f20ad.model.LocalResource;
import com.dmz.f20ad.model.LocalResourceDao;
import com.dmz.f20ad.model.MediaFile;
import com.dmz.f20ad.view.ImagePlayView;
import com.dmz.f20ad.view.TitleBarWithBack;
import d.a.a.f;
import g.a.e;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;
import me.zhanghai.android.materialprogressbar.BuildConfig;

public class MediaLocalPreviewActivity extends l {
    public TextView mDuration;
    public TextView mIndicator;
    public ImageButton mPlayAndPause;
    public TextView mType;
    public ViewPager mViewPager;
    public boolean s = false;
    public List<LocalResource> t;
    public TitleBarWithBack titleBar;
    public ImagePlayView u;
    public VideoView v;
    public b.x.a.a w;
    public g.a.n.b x;

    public class a extends ViewPager.m {

        public int f2991b;

        public final int f2992c;

        public a(int i2) {
            this.f2992c = i2;
            this.f2991b = this.f2992c;
        }

        @Override
        public void a(int i2, float f2, int i3) {
            int round = Math.round(i2 + f2);
            int i4 = this.f2991b;
            if (i4 != round) {
                LocalResource localResource = MediaLocalPreviewActivity.this.t.get(i4);
                if (localResource.getType() == 0 || localResource.getType() == 2) {
                    MediaLocalPreviewActivity.this.x();
                } else {
                    VideoView videoView = MediaLocalPreviewActivity.this.v;
                    if (videoView != null) {
                        videoView.pause();
                        MediaLocalPreviewActivity mediaLocalPreviewActivity = MediaLocalPreviewActivity.this;
                        mediaLocalPreviewActivity.s = false;
                        mediaLocalPreviewActivity.mPlayAndPause.setImageResource(2131230928);
                    }
                }
                this.f2991b = round;
                MediaLocalPreviewActivity.this.e(round);
            }
        }
    }

    public class b implements ImagePlayView.a {
        public b() {
        }

        public void a() {
        }

        public void a(long j2) {
        }
    }

    public void a(f fVar, d.a.a.b bVar) {
        this.x = e.a(new Callable() {
            @Override
            public final Object call() {
                return MediaLocalPreviewActivity.this.w();
            }
        }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).a(new g.a.p.b() {
            @Override
            public final void a(Object obj) {
                MediaLocalPreviewActivity.this.a((Integer) obj);
            }
        }, new g.a.p.b() {
            @Override
            public final void a(Object obj) {
                n.a.a.f7520c.a((Throwable) obj);
            }
        });
    }

    public void a(Integer num) {
        this.t.remove(num.intValue());
        this.w.d();
        y.e(2131755044);
        setResult(-1, new Intent().putExtra("com.xddzkj.rainbowifi.extra.INDEX_DELETED", num.intValue()));
        finish();
    }

    public final void e(int i2) {
        LocalResource localResource = this.t.get(i2);
        int fileTypeColor = MediaFile.getFileTypeColor(this, localResource.getType());
        this.titleBar.setTitleText(localResource.getName());
        this.mType.setText(localResource.getFileTypeString());
        this.mType.getBackground().setColorFilter(fileTypeColor, PorterDuff.Mode.MULTIPLY);
        this.mType.setTextColor(fileTypeColor);
        this.mDuration.setText(localResource.getDuration() + "s");
        this.mIndicator.setText(String.format(Locale.ENGLISH, "%d / %d", Integer.valueOf(i2 + 1), Integer.valueOf(this.t.size())));
        this.mPlayAndPause.setVisibility(localResource.getType() == 0 ? 8 : 0);
    }

    @Override
    public void finish() {
        super.finish();
        overridePendingTransition(0, 2130771998);
    }

    public void onClick(View view) {
        int id = view.getId();
        if (id != 2131296653) {
            if (id != 2131296838) {
                return;
            }
            f.b bVar = new f.b(this);
            bVar.a(2131755262);
            bVar.b(2131755041);
            bVar.c(2131755081);
            bVar.A = new f.k() {
                @Override
                public final void a(d.a.a.f fVar, d.a.a.b bVar2) {
                    MediaLocalPreviewActivity.this.a(fVar, bVar2);
                }
            };
            bVar.b();
            return;
        }
        int currentItem = this.mViewPager.getCurrentItem();
        LocalResource localResource = this.t.get(currentItem);
        if (this.s) {
            if (localResource.getType() == 0 || localResource.getType() == 2) {
                x();
                return;
            }
            this.v.pause();
            this.s = false;
            this.mPlayAndPause.setImageResource(2131230928);
            return;
        }
        this.s = true;
        this.mPlayAndPause.setImageResource(2131230933);
        if (localResource.getType() != 0 && localResource.getType() != 2) {
            this.v = (VideoView) this.mViewPager.findViewWithTag(Integer.valueOf(currentItem)).findViewById(2131296868);
            this.v.start();
        } else {
            this.u = (ImagePlayView) this.mViewPager.findViewWithTag(Integer.valueOf(currentItem)).findViewById(2131296535);
            this.u.setOnPlayStateChangedListener(new b());
            this.u.b(15);
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131492904);
        ButterKnife.a(this);
        App.f2838g.d().getAbsolutePath();
        int intExtra = getIntent().getIntExtra("com.xddzkj.rainbowifi.extra.INDEX_TO_SHOW", 0);
        this.t = getIntent().getParcelableArrayListExtra("com.xddzkj.rainbowifi.extra.MEDIA_LIST");
        this.mIndicator.setVisibility(this.t.size() <= 1 ? 8 : 0);
        this.w = new c();
        this.mViewPager.setAdapter(this.w);
        this.mViewPager.a(new a(intExtra));
        this.mViewPager.setCurrentItem(intExtra);
        e(intExtra);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mViewPager.a();
        g.a.n.b bVar = this.x;
        if (bVar != null) {
            bVar.a();
        }
        VideoView videoView = this.v;
        if (videoView == null || !videoView.isPlaying()) {
            return;
        }
        this.v.stopPlayback();
    }

    @Override
    public void onPause() {
        super.onPause();
        x();
    }

    public Integer w() {
        int currentItem = this.mViewPager.getCurrentItem();
        LocalResource localResource = this.t.get(currentItem);
        LocalResourceDao localResourceDao = App.f2838g.c().getLocalResourceDao();
        if (localResource.getType() == 0 || localResource.getType() == 2) {
            y.b(new File(localResource.getLocation_url()));
            localResourceDao.delete(localResource);
        } else {
            localResourceDao.delete(localResource);
            App.f2838g.c().getCloudFileDao().deleteByKey(Long.valueOf(Long.parseLong(localResource.getFileId().replace("yun_", BuildConfig.FLAVOR))));
        }
        return Integer.valueOf(currentItem);
    }

    public final void x() {
        ImagePlayView imagePlayView = this.u;
        if (imagePlayView != null) {
            imagePlayView.a();
        }
    }

    public class c extends b.x.a.a {

        public class a implements MediaPlayer.OnCompletionListener {
            public a() {
            }

            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                MediaLocalPreviewActivity.this.mPlayAndPause.setImageResource(2131230928);
                MediaLocalPreviewActivity.this.s = false;
            }
        }

        public c() {
        }

        public static boolean a(VideoView videoView, MediaPlayer mediaPlayer, int i2, int i3) {
            videoView.stopPlayback();
            y.e(2131755260);
            return true;
        }

        @Override
        public int a() {
            return MediaLocalPreviewActivity.this.t.size();
        }

        @Override
        public void a(ViewGroup viewGroup, int i2, Object obj) {
            viewGroup.removeView((View) obj);
        }

        public void a(final ImageView imageView, MediaPlayer mediaPlayer) {
            mediaPlayer.setOnInfoListener(new MediaPlayer.OnInfoListener() {
                @Override
                public final boolean onInfo(MediaPlayer mediaPlayer2, int i2, int i3) {
                    return MediaLocalPreviewActivity.c.this.a(imageView, mediaPlayer2, i2, i3);
                }
            });
        }

        @Override
        public boolean a(View view, Object obj) {
            return view == obj;
        }

        @Override
        public Object a(ViewGroup viewGroup, int i2) {
            LocalResource localResource = MediaLocalPreviewActivity.this.t.get(i2);
            if (localResource.getType() == 0 || localResource.getType() == 2) {
                View inflate = LayoutInflater.from(MediaLocalPreviewActivity.this).inflate(2131492967, (ViewGroup) null);
                ImagePlayView imagePlayView = (ImagePlayView) inflate.findViewById(2131296535);
                try {
                    imagePlayView.a(localResource.getLocation_url(), localResource.getFrames());
                } catch (FileNotFoundException e2) {
                    e2.printStackTrace();
                }
                imagePlayView.getHolder().setFormat(-2);
                inflate.setTag(Integer.valueOf(i2));
                viewGroup.addView(inflate);
                imagePlayView.c(1);
                return inflate;
            }
            File file = new File(localResource.getLocation_url());
            View inflate2 = LayoutInflater.from(MediaLocalPreviewActivity.this).inflate(2131492968, (ViewGroup) null);
            final ImageView imageView = (ImageView) inflate2.findViewById(2131296818);
            ((d.e.a.f) d.d.a.c.a(inflate2)).a(localResource.getThumbnail()).a(imageView);
            final VideoView videoView = (VideoView) inflate2.findViewById(2131296868);
            videoView.setVideoURI(Uri.fromFile(file));
            videoView.setOnCompletionListener(new a());
            videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                @Override
                public final void onPrepared(MediaPlayer mediaPlayer) {
                    MediaLocalPreviewActivity.c.this.a(imageView, mediaPlayer);
                }
            });
            videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
                @Override
                public final boolean onError(MediaPlayer mediaPlayer, int i3, int i4) {
                    MediaLocalPreviewActivity.c.a(videoView, mediaPlayer, i3, i4);
                    return true;
                }
            });
            videoView.getHolder().setFormat(-2);
            inflate2.setTag(Integer.valueOf(i2));
            viewGroup.addView(inflate2);
            return inflate2;
        }

        public boolean a(ImageView imageView, MediaPlayer mediaPlayer, int i2, int i3) {
            if (i2 != 3) {
                return false;
            }
            imageView.setVisibility(8);
            MediaLocalPreviewActivity.this.mPlayAndPause.setImageResource(2131230933);
            MediaLocalPreviewActivity.this.s = true;
            return true;
        }
    }
}