导航菜单

页面标题

页面副标题

SpinDisplay v2.0.2.6 - MaterialEditActivity.java 源代码

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

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


package com.dmz.f20ad.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.RectF;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import b.b.k.l;
import b.u.y;
import butterknife.ButterKnife;
import com.appyvet.materialrangebar.RangeBar;
import com.dmz.f20ad.App;
import com.dmz.f20ad.activity.MaterialEditActivity;
import com.dmz.f20ad.libjpeg.Libjpeg;
import com.dmz.f20ad.lwplayer.OnLWProgressListener;
import com.dmz.f20ad.lwplayer.UriToPathUtil;
import com.dmz.f20ad.model.LocalResource;
import com.dmz.f20ad.model.Template;
import com.dmz.f20ad.view.ImageGestureView;
import com.dmz.f20ad.view.VideoGestureView;
import d.a.a.f;
import d.e.a.a;
import d.e.a.n.v2;
import d.e.a.n.w2;
import d.e.a.n.x2;
import d.e.a.p.p0;
import g.a.j;
import g.a.q.e.b.d;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.concurrent.Callable;
import l.a.a.m;
import me.zhanghai.android.materialprogressbar.BuildConfig;
import me.zhanghai.android.materialprogressbar.SingleCircularProgressDrawable;
import org.greenrobot.eventbus.ThreadMode;

public class MaterialEditActivity extends l implements a.InterfaceC0081a, OnLWProgressListener {
    public int A;
    public long B;
    public long C;
    public long D;
    public double G;
    public double H;
    public long I;
    public long J;
    public long K;
    public int L;
    public d.e.a.a M;
    public TextView endTextView;
    public ImageGestureView imagePlayView;
    public ImageGestureView imageView;
    public RangeBar mDurationEditor;
    public TextView materialTextView;
    public ProgressBar playProgress;
    public ConstraintLayout rangeBarView;
    public Template s;
    public Button saveButton;
    public TextView startTextView;
    public g.a.n.a t;
    public ImageView templatePlayView;
    public TextView templateTextView;
    public VideoGestureView videoView;
    public String w;
    public double z;
    public int u = -1;
    public int v = 0;
    public boolean x = false;
    public boolean y = false;
    public String E = BuildConfig.FLAVOR;
    public boolean F = false;

    public class a implements Runnable {

        public final int f2964b;

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

        @Override
        public void run() {
            MaterialEditActivity materialEditActivity = MaterialEditActivity.this;
            materialEditActivity.playProgress.setProgress((this.f2964b * 100) / ((int) materialEditActivity.I));
        }
    }

    public class b implements j<Integer> {

        public final String f2966b;

        public b(String str) {
            this.f2966b = str;
        }

        @Override
        public void a(g.a.n.b bVar) {
        }

        @Override
        public void a(Integer num) {
        }

        @Override
        public void a(Throwable th) {
            MaterialEditActivity.this.y();
            y.f(2131755354);
        }

        @Override
        public void c() {
            MaterialEditActivity.this.y();
            String str = this.f2966b;
            if (str == null) {
                Log.d("wyt MaterialEdit", "onActivityResult: null");
                return;
            }
            if (!str.equals("application/octet-stream")) {
                String str2 = this.f2966b;
                String substring = str2.substring(0, str2.indexOf(47));
                char c2 = 65535;
                int hashCode = substring.hashCode();
                if (hashCode != 100313435) {
                    if (hashCode == 112202875 && substring.equals("video")) {
                        c2 = 1;
                    }
                } else if (substring.equals("image")) {
                    c2 = 0;
                }
                if (c2 == 0) {
                    if (this.f2966b.contains("gif")) {
                        y.e(2131755197);
                        return;
                    } else {
                        MaterialEditActivity materialEditActivity = MaterialEditActivity.this;
                        materialEditActivity.d(materialEditActivity.w);
                        return;
                    }
                }
                if (c2 != 1) {
                    return;
                }
            }
            MaterialEditActivity materialEditActivity2 = MaterialEditActivity.this;
            materialEditActivity2.e(materialEditActivity2.w);
        }
    }

    public class c implements RangeBar.d {

        public int f2968a;

        public int f2969b;

        public c() {
            this.f2968a = MaterialEditActivity.this.mDurationEditor.getLeftIndex();
            this.f2969b = MaterialEditActivity.this.mDurationEditor.getRightIndex();
        }

        @Override
        public void a(RangeBar rangeBar, int i2, int i3, String str, String str2) {
            RangeBar rangeBar2;
            float f2;
            float f3;
            if (i2 < 0) {
                MaterialEditActivity.this.mDurationEditor.a(SingleCircularProgressDrawable.START_ANGLE_MAX_NORMAL, r5.D);
                return;
            }
            long j2 = i3;
            MaterialEditActivity materialEditActivity = MaterialEditActivity.this;
            long j3 = materialEditActivity.B;
            if (j2 > j3) {
                materialEditActivity.mDurationEditor.a(materialEditActivity.C, j3);
                return;
            }
            if (i2 >= i3) {
                if (this.f2968a != i2) {
                    rangeBar2 = materialEditActivity.mDurationEditor;
                    long j4 = materialEditActivity.D;
                    f2 = j4 - 1;
                    f3 = j4;
                } else {
                    if (this.f2969b == i3) {
                        return;
                    }
                    rangeBar2 = materialEditActivity.mDurationEditor;
                    long j5 = materialEditActivity.C;
                    f2 = j5;
                    f3 = j5 + 1.0f;
                }
                rangeBar2.a(f2, f3);
                return;
            }
            if (this.f2968a != i2) {
                this.f2968a = i2;
                materialEditActivity.C = i2;
                long j6 = materialEditActivity.C;
                materialEditActivity.A = (int) (j6 * materialEditActivity.z);
                materialEditActivity.startTextView.setText(materialEditActivity.a(j6));
                return;
            }
            if (this.f2969b != i3) {
                materialEditActivity.A = (int) (materialEditActivity.C * materialEditActivity.z);
                this.f2969b = i3;
                materialEditActivity.D = j2;
                materialEditActivity.endTextView.setText(materialEditActivity.a(materialEditActivity.D));
            }
        }
    }

    public class d implements ViewTreeObserver.OnGlobalLayoutListener {

        public final Bitmap f2971b;

        public d(Bitmap bitmap) {
            this.f2971b = bitmap;
        }

        @Override
        public void onGlobalLayout() {
            MaterialEditActivity.this.imagePlayView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            if (b.h.e.a.a(MaterialEditActivity.this.getBaseContext(), "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
                MaterialEditActivity.this.imagePlayView.setBitmap(this.f2971b);
            }
        }
    }

    public class e implements RangeBar.d {

        public int f2973a;

        public int f2974b;

        public e() {
            this.f2973a = MaterialEditActivity.this.mDurationEditor.getLeftIndex();
            this.f2974b = MaterialEditActivity.this.mDurationEditor.getRightIndex();
        }

        @Override
        public void a(RangeBar rangeBar, int i2, int i3, String str, String str2) {
            RangeBar rangeBar2;
            float f2;
            float f3;
            if (i2 < 0) {
                MaterialEditActivity.this.mDurationEditor.a(SingleCircularProgressDrawable.START_ANGLE_MAX_NORMAL, r5.K);
                return;
            }
            long j2 = i3;
            MaterialEditActivity materialEditActivity = MaterialEditActivity.this;
            long j3 = materialEditActivity.I;
            if (j2 > j3) {
                materialEditActivity.mDurationEditor.a(materialEditActivity.J, j3);
                return;
            }
            if (i2 >= i3) {
                if (this.f2973a != i2) {
                    rangeBar2 = materialEditActivity.mDurationEditor;
                    long j4 = materialEditActivity.K;
                    f2 = j4 - 1;
                    f3 = j4;
                } else {
                    if (this.f2974b == i3) {
                        return;
                    }
                    rangeBar2 = materialEditActivity.mDurationEditor;
                    long j5 = materialEditActivity.J;
                    f2 = j5;
                    f3 = j5 + 1.0f;
                }
                rangeBar2.a(f2, f3);
                return;
            }
            materialEditActivity.videoView.i();
            if (this.f2973a != i2) {
                long j6 = i2;
                MaterialEditActivity.this.videoView.a(j6);
                this.f2973a = i2;
                MaterialEditActivity materialEditActivity2 = MaterialEditActivity.this;
                materialEditActivity2.J = j6;
                long j7 = materialEditActivity2.J;
                materialEditActivity2.H = j7 * materialEditActivity2.G;
                materialEditActivity2.startTextView.setText(materialEditActivity2.a(j7));
            } else if (this.f2974b != i3) {
                MaterialEditActivity.this.videoView.a((int) r5.J);
                MaterialEditActivity materialEditActivity3 = MaterialEditActivity.this;
                materialEditActivity3.H = materialEditActivity3.J * materialEditActivity3.G;
                this.f2974b = i3;
                materialEditActivity3.K = j2;
                materialEditActivity3.endTextView.setText(materialEditActivity3.a(materialEditActivity3.K));
            }
            if (MaterialEditActivity.this.videoView.c()) {
                MaterialEditActivity.this.videoView.e();
            }
        }
    }

    public class f implements ViewTreeObserver.OnGlobalLayoutListener {

        public final Bitmap f2976b;

        public f(Bitmap bitmap) {
            this.f2976b = bitmap;
        }

        @Override
        public void onGlobalLayout() {
            MaterialEditActivity.this.imageView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
            if (b.h.e.a.a(MaterialEditActivity.this.getBaseContext(), "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
                MaterialEditActivity.this.imageView.setBitmap(this.f2976b);
            }
        }
    }

    public class g implements Runnable {
        public g() {
        }

        @Override
        public void run() {
            VideoGestureView videoGestureView;
            MaterialEditActivity materialEditActivity;
            try {
                MaterialEditActivity.this.playProgress.setProgress(((MaterialEditActivity.this.L + 1) * 100) / ((int) MaterialEditActivity.this.I));
                if (MaterialEditActivity.this.videoView.b()) {
                    videoGestureView = MaterialEditActivity.this.videoView;
                    materialEditActivity = MaterialEditActivity.this;
                } else {
                    MaterialEditActivity.this.videoView.h();
                    videoGestureView = MaterialEditActivity.this.videoView;
                    materialEditActivity = MaterialEditActivity.this;
                }
                videoGestureView.a(materialEditActivity.J);
                MaterialEditActivity.this.H = MaterialEditActivity.this.J * MaterialEditActivity.this.G;
            } catch (Exception e2) {
                d.b.a.a.a.a(e2, d.b.a.a.a.a("onProgress: "), "wyt MaterialEdit");
            }
        }
    }

    public static void c(d.a.a.f fVar, d.a.a.b bVar) {
    }

    public void A() {
        final String format = String.format("%s/%s", App.f2838g.d(), "tempimage");
        this.t.c(g.a.e.a(new Callable() {
            @Override
            public final Object call() {
                return MaterialEditActivity.this.b(format);
            }
        }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).e());
    }

    public void B() {
        z();
        String format = String.format("%s/%s", App.f2838g.d(), "tempimage");
        int i2 = this.v;
        if (i2 == 1) {
            this.templatePlayView.setImageBitmap(BitmapFactory.decodeFile(String.format("%s/%s", format, "1.bin")));
        } else if (i2 > 1) {
            A();
        }
    }

    public void C() {
        if (this.M == null) {
            this.M = new d.e.a.a(this, 2131492936, new int[0]);
            this.M.setCancelable(false);
        }
        this.M.show();
    }

    public final Bitmap a(int i2, int i3, Rect rect, Bitmap bitmap, Bitmap bitmap2) {
        Bitmap createBitmap = Bitmap.createBitmap(i2, i3, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(createBitmap);
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(-16777216);
        canvas.drawARGB(0, 0, 0, 0);
        canvas.drawBitmap(bitmap, (Rect) null, rect, paint);
        Paint paint2 = new Paint();
        paint2.setAlpha(255);
        canvas.drawBitmap(bitmap2, (Rect) null, new Rect(0, 0, i2, i3), paint2);
        return createBitmap;
    }

    public Integer a(int i2, String str, long j2) {
        while (true) {
            int i3 = this.A;
            if (i3 >= i2 || !this.F) {
                break;
            }
            this.A = i3 + 1;
            StringBuilder a2 = d.b.a.a.a.a(str, "/");
            a2.append(this.A);
            a2.append(".jpg");
            runOnUiThread(new x2(this, BitmapFactory.decodeFile(a2.toString()), i2));
            if (this.A >= i2) {
                this.A = (int) (this.C * this.z);
            }
            Thread.sleep(j2);
        }
        return 0;
    }

    public final String a(float f2) {
        return String.format("%ds", Integer.valueOf((int) f2));
    }

    public void a(Uri uri, g.a.f fVar) {
        if (Build.VERSION.SDK_INT >= 29) {
            runOnUiThread(new v2(this));
            this.w = y.a(uri);
        }
        ((d.a) fVar).c();
    }

    public void a(LocalResource localResource) {
        this.u = 2;
        this.videoView.setVisibility(8);
        this.imagePlayView.setVisibility(0);
        this.imageView.setVisibility(8);
        this.playProgress.setVisibility(0);
        this.rangeBarView.setVisibility(0);
        this.F = false;
        while (this.videoView.b()) {
            this.videoView.a();
        }
        this.A = 0;
        this.z = localResource.getPts();
        this.B = localResource.getDuration();
        this.C = 0L;
        this.D = this.B;
        this.startTextView.setText(a(SingleCircularProgressDrawable.START_ANGLE_MAX_NORMAL));
        this.endTextView.setText(a(this.B));
        this.mDurationEditor.setTickEnd(this.B);
        this.mDurationEditor.a(this.C, this.D);
        this.mDurationEditor.setOnRangeBarChangeListener(new c());
        a(localResource.getLocation_url(), localResource.getFrames());
    }

    public void a(d.a.a.f fVar, d.a.a.b bVar) {
        this.t.c(new d.k.a.d(this).a("android.permission.WRITE_EXTERNAL_STORAGE").b(new g.a.p.b() {
            @Override
            public final void a(Object obj) {
                MaterialEditActivity.this.b((Boolean) obj);
            }
        }));
    }

    public void a(d.a.a.f fVar, CharSequence charSequence) {
        String charSequence2 = charSequence.toString();
        if (charSequence2.getBytes(Charset.forName("UTF-8")).length < 1) {
            y.e(2131755166);
        } else if (charSequence2.getBytes(Charset.forName("UTF-8")).length > 20) {
            y.e(2131755168);
        } else {
            fVar.dismiss();
            c(charSequence2);
        }
    }

    @Override
    public void a(d.e.a.a r12, android.view.View r13) {
        throw new UnsupportedOperationException("Method not decompiled: com.dmz.f20ad.activity.MaterialEditActivity.a(d.e.a.a, android.view.View):void");
    }

    public void a(Integer num) {
    }

    public void a(final String str, final int i2) {
        if (!new File(str).exists() || i2 < 1) {
            return;
        }
        this.E = str;
        Bitmap decodeFile = BitmapFactory.decodeFile(str + "/1.jpg");
        this.imagePlayView.getViewTreeObserver().addOnGlobalLayoutListener(new d(decodeFile));
        this.imagePlayView.setBitmap(decodeFile);
        this.F = true;
        final long j2 = (long) (1000.0d / this.z);
        this.t.c(g.a.e.a(new Callable() {
            @Override
            public final Object call() {
                return MaterialEditActivity.this.a(i2, str, j2);
            }
        }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).b(new g.a.p.b() {
            @Override
            public final void a(Object obj) {
                MaterialEditActivity.this.a((Integer) obj);
            }
        }));
    }

    public Integer b(String str) {
        while (this.y) {
            Thread.sleep(10L);
        }
        this.y = true;
        this.x = false;
        int i2 = 1;
        while (i2 <= this.v && !this.x) {
            runOnUiThread(new w2(this, BitmapFactory.decodeFile(String.format("%s/%s", str, i2 + ".bin"))));
            i2++;
            if (i2 > this.v) {
                i2 = 1;
            }
            Thread.sleep(30L);
        }
        this.y = false;
        return 0;
    }

    public void b(Boolean bool) {
        if (!bool.booleanValue()) {
            finish();
            return;
        }
        d.e.a.a aVar = new d.e.a.a(this, 2131492937, new int[]{2131296401, 2131296403, 2131296407});
        aVar.setOwnerActivity(this);
        aVar.f4765d = this;
        aVar.show();
    }

    public void c(final String str) {
        if (this.v < 1) {
            return;
        }
        C();
        SharedPreferences sharedPreferences = getSharedPreferences("com.dmz.f20ad", 0);
        final int i2 = sharedPreferences.getInt("local_num", 0);
        final String format = String.format("%s/%s/%s", App.f2838g.d(), "localresource", d.b.a.a.a.a("local_", i2));
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putInt("local_num", i2 + 1);
        edit.commit();
        File file = new File(format);
        if (!file.exists()) {
            file.mkdirs();
        }
        int i3 = this.u;
        if (i3 == 0) {
            final int width = this.imageView.getWidth();
            final int height = this.imageView.getHeight();
            final Bitmap a2 = this.imageView.a();
            this.t.c(g.a.e.a(new Callable() {
                @Override
                public final Object call() {
                    return MaterialEditActivity.this.a(width, height, a2, format);
                }
            }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).b(new g.a.p.b() {
                @Override
                public final void a(Object obj) {
                    MaterialEditActivity.this.b(i2, str, format, (Integer) obj);
                }
            }));
            return;
        }
        if (i3 == 1) {
            this.videoView.a((int) this.J, (int) this.K, 20, this.v, format);
            String a3 = d.b.a.a.a.a("local_", i2);
            String b2 = d.b.a.a.a.b(format, "/1.bin");
            long j2 = this.K;
            long j3 = this.J;
            App.f2838g.c().getLocalResourceDao().insert(new LocalResource(a3, str, b2, 2, (int) (j2 - j3), format, 20, ((int) (j2 - j3)) * 20, 0));
            return;
        }
        if (i3 != 2) {
            this.t.c(g.a.e.a(new Callable() {
                @Override
                public final Object call() {
                    return MaterialEditActivity.this.a(format);
                }
            }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).b(new g.a.p.b() {
                @Override
                public final void a(Object obj) {
                    MaterialEditActivity.this.a(i2, str, format, (Integer) obj);
                }
            }));
            return;
        }
        RectF bitmapMatrixRectF = this.imagePlayView.getBitmapMatrixRectF();
        final Rect rect = new Rect((int) bitmapMatrixRectF.left, (int) bitmapMatrixRectF.top, (int) bitmapMatrixRectF.right, (int) bitmapMatrixRectF.bottom);
        final int width2 = this.imagePlayView.getWidth();
        final int height2 = this.imagePlayView.getHeight();
        final int i4 = (int) ((this.D - this.C) * this.z);
        this.t.c(g.a.e.a(new Callable() {
            @Override
            public final Object call() {
                return MaterialEditActivity.this.a(i4, width2, height2, rect, format);
            }
        }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).b(new g.a.p.b() {
            @Override
            public final void a(Object obj) {
                MaterialEditActivity.this.a(i2, str, format, i4, (Integer) obj);
            }
        }));
    }

    public void d(String str) {
        this.u = 0;
        this.videoView.setVisibility(8);
        this.imagePlayView.setVisibility(8);
        this.imageView.setVisibility(0);
        this.playProgress.setVisibility(8);
        this.rangeBarView.setVisibility(8);
        this.F = false;
        while (this.videoView.b()) {
            this.videoView.a();
        }
        Bitmap decodeFile = BitmapFactory.decodeFile(str);
        this.imageView.getViewTreeObserver().addOnGlobalLayoutListener(new f(decodeFile));
        this.imageView.setBitmap(decodeFile);
    }

    public void doClick(View view) {
        int id = view.getId();
        if (id != 2131296583) {
            if (id == 2131296799) {
                w();
                return;
            } else {
                if (id != 2131296838) {
                    return;
                }
                if (this.v < 1) {
                    y.e(2131755249);
                    return;
                } else {
                    this.t.c(new d.k.a.d(this).a("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE").b(new g.a.p.b() {
                        @Override
                        public final void a(Object obj) {
                            MaterialEditActivity.this.a((Boolean) obj);
                        }
                    }));
                    return;
                }
            }
        }
        if (b.h.e.a.a(this, "android.permission.WRITE_EXTERNAL_STORAGE") == 0) {
            d.e.a.a aVar = new d.e.a.a(this, 2131492937, new int[]{2131296401, 2131296403, 2131296408});
            aVar.setOwnerActivity(this);
            aVar.f4765d = this;
            aVar.show();
            return;
        }
        f.b bVar = new f.b(this);
        bVar.d(2131755232);
        bVar.a(2131755233);
        bVar.b(2131755075);
        bVar.c(2131755081);
        bVar.L = false;
        bVar.M = false;
        bVar.A = new f.k() {
            @Override
            public final void a(d.a.a.f fVar, d.a.a.b bVar2) {
                MaterialEditActivity.this.a(fVar, bVar2);
            }
        };
        bVar.B = new f.k() {
            @Override
            public final void a(d.a.a.f fVar, d.a.a.b bVar2) {
                MaterialEditActivity.c(fVar, bVar2);
            }
        };
        bVar.b();
    }

    public void e(String str) {
        this.u = 1;
        this.videoView.setVisibility(0);
        this.imagePlayView.setVisibility(8);
        this.imageView.setVisibility(8);
        this.playProgress.setVisibility(0);
        this.rangeBarView.setVisibility(0);
        this.F = false;
        while (this.videoView.b()) {
            this.videoView.a();
        }
        this.videoView.a(str);
        this.videoView.setOnProgressListener(this);
        this.I = this.videoView.getVideoInfo().getDuration();
        this.J = 0L;
        this.K = this.I;
        this.G = this.videoView.getVideoInfo().getFps();
        this.startTextView.setText(a(SingleCircularProgressDrawable.START_ANGLE_MAX_NORMAL));
        this.endTextView.setText(a(this.I));
        this.mDurationEditor.setTickEnd(this.I);
        this.mDurationEditor.a(this.J, this.K);
        this.mDurationEditor.setOnRangeBarChangeListener(new e());
        this.videoView.h();
    }

    @Override
    public void onActivityResult(int i2, int i3, Intent intent) {
        super.onActivityResult(i2, i3, intent);
        if (i3 == -1) {
            if (i2 == 0) {
                final Uri uri = (Uri) intent.getParcelableArrayListExtra("extra_result_selection").get(0);
                String type = getContentResolver().getType(uri);
                this.w = UriToPathUtil.getRealPathFromUri(this, uri);
                StringBuilder a2 = d.b.a.a.a.a("onActivityResult: ");
                a2.append(this.w);
                Log.d("wyt MaterialEdit", a2.toString());
                g.a.e.a(new g.a.g() {
                    @Override
                    public final void a(g.a.f fVar) {
                        MaterialEditActivity.this.a(uri, fVar);
                    }
                }).b(g.a.s.b.b()).a(g.a.m.b.a.a()).a(new b(type));
                return;
            }
            if (i2 != 1) {
                if (i2 != 2) {
                    return;
                }
                this.v = intent.getIntExtra("frames", 0);
                B();
                return;
            }
            LocalResource localResource = (LocalResource) intent.getParcelableExtra("com.dmz.3ddisplay.extra.MEDIA_FILE");
            if (localResource.getType() == 0) {
                d(localResource.getThumbnail());
            } else if (localResource.getType() == 1) {
                e(localResource.getLocation_url());
            } else if (localResource.getType() == 2) {
                a(localResource);
            }
        }
    }

    @m(threadMode = ThreadMode.MAIN)
    public void onBusEvent(p0 p0Var) {
        String str = p0Var.f5197a;
        String str2 = p0Var.f5198b;
        if (str == "mergevideo" && str2 == "VideoGestureView") {
            y();
            y.e(2131755084);
        }
    }

    @Override
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(2131492901);
        ButterKnife.a(this);
        this.t = new g.a.n.a();
        this.s = (Template) getIntent().getParcelableExtra("com.dmz.f20ad.extra.TEMPLATE");
        l.a.a.c.c().b(this);
        Display defaultDisplay = getWindowManager().getDefaultDisplay();
        Point point = new Point();
        defaultDisplay.getSize(point);
        int i2 = point.x;
        x();
        File file = new File(String.format("%s/%s", App.f2838g.d(), "localresource"));
        if (!file.exists()) {
            file.mkdir();
        }
        w();
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.F = false;
        z();
        this.videoView.f();
        this.t.a();
        x();
        y.a();
    }

    @Override
    public void onProgress(long j2, int i2) {
        this.H += 1.0d;
        int i3 = (int) (this.H / this.G);
        if (i2 < 0 || i3 >= this.K) {
            runOnUiThread(new g());
        } else if (i3 != this.L) {
            this.L = i3;
            runOnUiThread(new a(i3));
        }
    }

    @Override
    public void onResume() {
        super.onResume();
    }

    public void w() {
        Intent putExtra;
        Template template = this.s;
        if (template == null) {
            return;
        }
        if (template.getType() != 0) {
            putExtra = new Intent(this, (Class<?>) WebViewActivity.class).putExtra("com.dmz.f20ad.extra.TEMPLATE", this.s);
        } else if (!this.s.getUrl().equals("PaintsActivity")) {
            return;
        } else {
            putExtra = new Intent(this, (Class<?>) PaintsActivity.class);
        }
        startActivityForResult(putExtra, 2);
    }

    public void x() {
        String format = String.format("%s/%s", App.f2838g.d(), "clipimage");
        String format2 = String.format("%s/%s", App.f2838g.d(), "tempimage");
        File file = new File(format);
        File file2 = new File(format2);
        try {
            y.b(file);
            y.b(file2);
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }

    public void y() {
        d.e.a.a aVar = this.M;
        if (aVar != null) {
            aVar.dismiss();
            this.M = null;
        }
    }

    public void z() {
        this.x = true;
    }

    public void b(int i2, String str, String str2, Integer num) {
        int i3;
        int i4;
        int i5;
        int i6 = this.v;
        if (i6 > 1) {
            i4 = i6 / 20;
            i3 = 2;
            i5 = 20;
        } else {
            i3 = 0;
            i4 = 0;
            i5 = 0;
        }
        Log.d("wyt MaterialEdit", "mergeSource: insert id:" + App.f2838g.c().getLocalResourceDao().insert(new LocalResource(d.b.a.a.a.a("local_", i2), str, d.b.a.a.a.b(str2, "/1.bin"), i3, i4, str2, i5, this.v, 0)));
        y.e(2131755084);
        y();
    }

    public void a(Boolean bool) {
        if (bool.booleanValue()) {
            f.b bVar = new f.b(this);
            bVar.d(2131755160);
            bVar.a(2131755150);
            String string = getString(2131755151);
            f.e eVar = new f.e() {
                @Override
                public final void a(d.a.a.f fVar, CharSequence charSequence) {
                    MaterialEditActivity.this.a(fVar, charSequence);
                }
            };
            if (bVar.s == null) {
                bVar.o0 = eVar;
                bVar.n0 = string;
                bVar.m0 = BuildConfig.FLAVOR;
                bVar.p0 = false;
                bVar.R = false;
                bVar.b(2131755041);
                bVar.B = new f.k() {
                    @Override
                    public final void a(d.a.a.f fVar, d.a.a.b bVar2) {
                        fVar.dismiss();
                    }
                };
                bVar.c(2131755081);
                bVar.b();
                return;
            }
            throw new IllegalStateException("You cannot set content() when you're using a custom view.");
        }
        y.e(2131755091);
    }

    public void a(int i2, String str, String str2, int i3, Integer num) {
        Log.d("wyt MaterialEdit", "mergeSource: insert id:" + App.f2838g.c().getLocalResourceDao().insert(new LocalResource(d.b.a.a.a.a("local_", i2), str, d.b.a.a.a.b(str2, "/1.bin"), 2, (int) (this.D - this.C), str2, (int) this.z, i3, 0)));
        y.e(2131755084);
        y();
    }

    public Integer a(String str) {
        for (int i2 = 1; i2 < this.v + 1; i2++) {
            Bitmap decodeFile = BitmapFactory.decodeFile(String.format("%s/%s/%s.bin", App.f2838g.d(), "tempimage", Integer.valueOf(i2)));
            String str2 = str + "/" + i2 + ".bin";
            File file = new File(str2);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e2) {
                    e2.printStackTrace();
                }
            }
            new Libjpeg().nativeCompressBitmap2(decodeFile, 100, str2);
        }
        return 0;
    }

    public void a(int i2, String str, String str2, Integer num) {
        int i3;
        int i4;
        int i5 = this.v;
        if (i5 > 1) {
            i4 = i5 / 20;
            i3 = 2;
        } else {
            i3 = 0;
            i4 = 0;
        }
        Log.d("wyt MaterialEdit", "mergeSource: insert id:" + App.f2838g.c().getLocalResourceDao().insert(new LocalResource(d.b.a.a.a.a("local_", i2), str, d.b.a.a.a.b(str2, "/1.bin"), i3, i4, str2, 20, this.v, 0)));
        y.e(2131755084);
        y();
    }

    public Integer a(int i2, int i3, Bitmap bitmap, String str) {
        for (int i4 = 1; i4 < this.v + 1; i4++) {
            Bitmap a2 = a(i2, i3, new Rect(0, 0, i2, i3), bitmap, BitmapFactory.decodeFile(String.format("%s/%s/%s.bin", App.f2838g.d(), "tempimage", Integer.valueOf(i4))));
            String str2 = str + "/" + i4 + ".bin";
            File file = new File(str2);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e2) {
                    e2.printStackTrace();
                }
            }
            new Libjpeg().nativeCompressBitmap2(a2, 100, str2);
        }
        return 0;
    }

    public Integer a(int i2, int i3, int i4, Rect rect, String str) {
        for (int i5 = 1; i5 < i2 + 1; i5++) {
            int i6 = this.v;
            int i7 = i5 % i6;
            if (i7 != 0) {
                i6 = i7;
            }
            Bitmap a2 = a(i3, i4, rect, BitmapFactory.decodeFile(String.format("%s/%s.bin", this.E, Integer.valueOf(i5))), BitmapFactory.decodeFile(String.format("%s/%s/%s.bin", App.f2838g.d(), "tempimage", Integer.valueOf(i6))));
            String str2 = str + "/" + i5 + ".bin";
            File file = new File(str2);
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (IOException e2) {
                    e2.printStackTrace();
                }
            }
            new Libjpeg().nativeCompressBitmap2(a2, 100, str2);
        }
        return 0;
    }
}