导航菜单

页面标题

页面副标题

95爱播免登录版 v3.1.9 - ImageDragActivity.java 源代码

正在查看: 95爱播免登录版 v3.1.9 应用的 ImageDragActivity.java JAVA 源代码文件

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


package com.showself.ui;

import android.app.Dialog;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageView;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.ImageLoader;
import com.mifeng.ui.R;
import com.showself.utils.Utils;
import com.showself.view.DragImageView;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

public class ImageDragActivity extends com.showself.ui.c implements View.OnClickListener {
    private DragImageView a;
    private int b;
    private int c;
    private int d;

    private String f2683e;

    private com.r.a.a f2684f;

    private Dialog f2685g;

    public ImageView f2686h;

    public Button f2687i;

    class a implements View.OnLongClickListener {
        a(ImageDragActivity imageDragActivity) {
        }

        @Override
        public boolean onLongClick(View view) {
            return false;
        }
    }

    class b implements Runnable {
        b() {
        }

        @Override
        public void run() {
            ImageDragActivity imageDragActivity = ImageDragActivity.this;
            imageDragActivity.H(imageDragActivity.f2683e);
        }
    }

    class c implements com.r.a.b {
        c() {
        }

        @Override
        public void a() {
            ImageDragActivity.this.G();
        }

        @Override
        public void b(String str) {
        }
    }

    public class d implements ImageLoader.ImageListener {
        public d() {
        }

        public void onErrorResponse(VolleyError volleyError) {
        }

        public void onResponse(ImageLoader.ImageContainer imageContainer, boolean z) {
            ImageDragActivity.this.a.setImageBitmap(imageContainer.getBitmap());
        }
    }

    private Bitmap E(String str) {
        Bitmap bitmap = null;
        try {
            InputStream openStream = new URL(str).openStream();
            bitmap = BitmapFactory.decodeStream(openStream);
            openStream.close();
            return bitmap;
        } catch (MalformedURLException e2) {
            e2.printStackTrace();
            return bitmap;
        } catch (IOException e3) {
            e3.printStackTrace();
            return bitmap;
        }
    }

    private void F() {
        if (this.f2684f == null) {
            this.f2684f = new com.r.a.a(this);
        }
        this.f2684f.c(new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"}, new c());
    }

    public void G() {
        new Thread(new b()).start();
        this.f2685g.dismiss();
        this.f2685g = null;
        Utils.Y0(this, R.string.save_guest_pic);
    }

    public void H(String str) {
        File file = new File(Utils.C(), "Boohee");
        if (!file.exists()) {
            file.mkdir();
        }
        Bitmap E = E(str);
        String str2 = System.currentTimeMillis() + ".jpg";
        File file2 = new File(file, str2);
        try {
            FileOutputStream fileOutputStream = new FileOutputStream(file2);
            E.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream);
            fileOutputStream.flush();
            fileOutputStream.close();
        } catch (FileNotFoundException e2) {
            e2.printStackTrace();
        } catch (IOException e3) {
            e3.printStackTrace();
        }
        try {
            MediaStore.Images.Media.insertImage(getContentResolver(), file2.getAbsolutePath(), str2, (String) null);
        } catch (FileNotFoundException e4) {
            e4.printStackTrace();
        }
        sendBroadcast(new Intent("android.intent.action.MEDIA_SCANNER_SCAN_FILE", Uri.fromFile(new File("/sdcard/Boohee/image.jpg"))));
    }

    public void D() {
        this.f2685g = new Dialog(this, 2131755755);
        View inflate = LayoutInflater.from(this).inflate(R.layout.change_guest_avatar, (ViewGroup) null);
        Button button = (Button) inflate.findViewById(R.id.btn_guest_avatar_select);
        this.f2687i = button;
        button.setOnClickListener(this);
        ImageView imageView = (ImageView) inflate.findViewById(R.id.iv_guest_close);
        this.f2686h = imageView;
        imageView.setOnClickListener(this);
        this.f2685g.setContentView(inflate);
        this.f2685g.getWindow().setLayout(-1, -1);
        this.f2685g.getWindow().setGravity(80);
        this.f2685g.getWindow().setWindowAnimations(2131755745);
        this.f2685g.setCanceledOnTouchOutside(true);
        this.f2685g.show();
    }

    @Override
    public void init() {
        this.a = (DragImageView) findViewById(R.id.iv_drag);
        WindowManager windowManager = getWindowManager();
        this.b = windowManager.getDefaultDisplay().getWidth();
        this.c = windowManager.getDefaultDisplay().getHeight();
        this.f2683e = getIntent().getStringExtra("url");
        this.d = Utils.Z(this);
        this.a.setmActivity(this);
        this.a.setScreen_H(this.c - this.d);
        this.a.setScreen_W(this.b);
        this.a.setOnLongClickListener(new a(this));
        if (TextUtils.isEmpty(this.f2683e)) {
            return;
        }
        ImageLoader.getInstance(this).displayShowImage(this.f2683e, this.a, new d());
    }

    @Override
    public void onClick(View view) {
        Utils.o0();
        int id = view.getId();
        if (id == 2131296478) {
            F();
        } else {
            if (id != 2131297183) {
                return;
            }
            this.f2685g.dismiss();
            this.f2685g = null;
        }
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.ac_drag_lay);
        init();
    }

    @Override
    public void onRequestPermissionsResult(int i2, String[] strArr, int[] iArr) {
        super.onRequestPermissionsResult(i2, strArr, iArr);
        if (this.f2684f.e(i2, strArr, iArr)) {
        }
    }

    @Override
    public void refresh(Object... objArr) {
    }
}