导航菜单

页面标题

页面副标题

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

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

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


package com.showself.ui.takepicture;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.hardware.Camera;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.TextUtils;
import android.view.Display;
import android.view.KeyEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;
import com.mifeng.ui.R;
import com.showself.ui.ShowSelfApp;
import com.showself.utils.Utils;
import com.showself.utils.e0;
import com.showself.utils.l;
import com.showself.utils.p;
import com.showself.utils.v;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.open.SocialConstants;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TakePictureActivity extends com.showself.ui.c implements View.OnClickListener, Camera.AutoFocusCallback {
    private SurfaceView a;
    private ImageView b;
    private ImageView c;
    private ImageView d;

    private ImageView f3307e;

    private ImageView f3308f;

    private Camera f3309g;

    private Camera.Parameters f3310h;

    private SurfaceHolder f3311i;
    private int l;
    private long n;
    private long o;
    private long p;
    private long q;
    private File r;
    private Bitmap s;
    private Intent t;
    private SharedPreferences v;
    private SharedPreferences.Editor w;
    private int x;
    private int y;

    private boolean f3312j = false;

    private boolean f3313k = false;
    private boolean m = true;
    private int u = 0;
    private boolean z = true;

    class a implements Camera.AutoFocusCallback {
        a() {
        }

        @Override
        public void onAutoFocus(boolean z, Camera camera) {
            if (!z || camera == null) {
                return;
            }
            camera.takePicture(null, null, new e(TakePictureActivity.this, null));
        }
    }

    class b implements l {
        b() {
        }

        @Override
        public void a(boolean z) {
            if (z) {
                TakePictureActivity.this.finish();
            }
        }
    }

    class c implements Runnable {
        final byte[] a;

        class a implements Runnable {
            a() {
            }

            @Override
            public void run() {
                Uri fromFile;
                Utils.n(TakePictureActivity.this);
                ?? r0 = TakePictureActivity.this;
                MediaScannerConnection.scanFile(r0, new String[]{((TakePictureActivity) r0).r.toString()}, null, null);
                if (TakePictureActivity.this.u == 1) {
                    if (Build.VERSION.SDK_INT >= 24) {
                        fromFile = androidx.core.a.b.e(TakePictureActivity.this, ShowSelfApp.h().getPackageName() + ".fileprovider", TakePictureActivity.this.r);
                    } else {
                        fromFile = Uri.fromFile(TakePictureActivity.this.r);
                    }
                    ?? r1 = TakePictureActivity.this;
                    Utils.c1(r1, fromFile, 1, 1, ((TakePictureActivity) r1).x / 4, TakePictureActivity.this.x / 4);
                    return;
                }
                if (TakePictureActivity.this.u == 2 || TakePictureActivity.this.u == 3) {
                    Intent intent = new Intent(TakePictureActivity.this.getApplicationContext(), (Class<?>) PictureAcitivityPreview.class);
                    intent.putExtra("isPutvideo", TakePictureActivity.this.u);
                    intent.putExtra("picPath", TakePictureActivity.this.r.getAbsolutePath());
                    TakePictureActivity.this.startActivityForResult(intent, 2);
                    TakePictureActivity.this.finish();
                    return;
                }
                if (TakePictureActivity.this.r != null) {
                    Intent intent2 = new Intent(TakePictureActivity.this.getApplicationContext(), (Class<?>) PictureAcitivityPreview.class);
                    intent2.putExtra("isPutvideo", TakePictureActivity.this.u);
                    intent2.putExtra("picPath", TakePictureActivity.this.r.getAbsolutePath());
                    TakePictureActivity.this.startActivity(intent2);
                    TakePictureActivity.this.finish();
                }
            }
        }

        c(byte[] bArr) {
            this.a = bArr;
        }

        @Override
        public void run() {
            FileInputStream fileInputStream;
            BufferedOutputStream bufferedOutputStream;
            ?? e2;
            File file;
            Date date = new Date();
            String str = new SimpleDateFormat("yyyyMMddHHmmss").format(date) + ".jpg";
            File file2 = new File(Utils.C(), Environment.DIRECTORY_PICTURES);
            if (!file2.exists()) {
                file2.mkdirs();
            }
            byte[] bArr = new byte[WXMediaMessage.DESCRIPTION_LENGTH_LIMIT];
            BufferedOutputStream bufferedOutputStream2 = null;
            try {
                try {
                    file = new File(Utils.C() + "/temp2");
                    bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file));
                } catch (IOException e3) {
                    e2 = e3;
                    e2.printStackTrace();
                }
                try {
                    bufferedOutputStream.write(this.a);
                    String str2 = Build.MODEL;
                    File a2 = v.a(TakePictureActivity.this, file.getPath(), (!TakePictureActivity.this.f3312j || str2.contains("HTC") || str2.contains("htc") || str2.contains("M040") || str2.contains("M032")) ? 90 : 270);
                    TakePictureActivity.this.r = new File(file2, str);
                    e2 = new FileInputStream(a2);
                    try {
                        BufferedOutputStream bufferedOutputStream3 = new BufferedOutputStream(new FileOutputStream(TakePictureActivity.this.r));
                        while (true) {
                            try {
                                int read = e2.read(bArr);
                                if (read == -1) {
                                    break;
                                } else {
                                    bufferedOutputStream3.write(bArr, 0, read);
                                }
                            } catch (Exception unused) {
                                bufferedOutputStream2 = bufferedOutputStream3;
                                if (bufferedOutputStream2 != null) {
                                    try {
                                        try {
                                            bufferedOutputStream2.close();
                                        } catch (IOException e4) {
                                            e4.printStackTrace();
                                            if (e2 != 0) {
                                                try {
                                                    try {
                                                        e2.close();
                                                        if (bufferedOutputStream != null) {
                                                            bufferedOutputStream.close();
                                                            return;
                                                        }
                                                        return;
                                                    } catch (IOException e5) {
                                                        e5.printStackTrace();
                                                        if (bufferedOutputStream != null) {
                                                            bufferedOutputStream.close();
                                                            return;
                                                        }
                                                        return;
                                                    }
                                                } finally {
                                                }
                                            }
                                            return;
                                        }
                                    } catch (Throwable th) {
                                        try {
                                        } catch (IOException e6) {
                                            e6.printStackTrace();
                                        }
                                        if (e2 != 0) {
                                            try {
                                                try {
                                                    e2.close();
                                                    if (bufferedOutputStream != null) {
                                                        bufferedOutputStream.close();
                                                    }
                                                } catch (IOException e7) {
                                                    e7.printStackTrace();
                                                    if (bufferedOutputStream != null) {
                                                        bufferedOutputStream.close();
                                                    }
                                                    throw th;
                                                }
                                            } finally {
                                            }
                                        }
                                        throw th;
                                    }
                                }
                                if (bufferedOutputStream != null) {
                                    bufferedOutputStream.close();
                                }
                                try {
                                    if (e2 != 0) {
                                        try {
                                            e2.close();
                                            if (bufferedOutputStream != null) {
                                                bufferedOutputStream.close();
                                            }
                                        } catch (IOException e8) {
                                            e8.printStackTrace();
                                            if (bufferedOutputStream != null) {
                                                bufferedOutputStream.close();
                                            }
                                        }
                                        return;
                                    }
                                    return;
                                } finally {
                                    if (bufferedOutputStream != null) {
                                        try {
                                            bufferedOutputStream.close();
                                        } catch (IOException e9) {
                                            e9.printStackTrace();
                                        }
                                    }
                                }
                            } catch (Throwable th2) {
                                th = th2;
                                bufferedOutputStream2 = bufferedOutputStream3;
                                Throwable th3 = th;
                                fileInputStream = e2;
                                th = th3;
                                try {
                                    if (bufferedOutputStream2 != null) {
                                        try {
                                            try {
                                                bufferedOutputStream2.close();
                                            } catch (IOException e10) {
                                                e10.printStackTrace();
                                                if (fileInputStream != null) {
                                                    try {
                                                        try {
                                                            fileInputStream.close();
                                                            if (bufferedOutputStream != null) {
                                                                bufferedOutputStream.close();
                                                            }
                                                        } catch (IOException e11) {
                                                            e11.printStackTrace();
                                                            if (bufferedOutputStream != null) {
                                                                bufferedOutputStream.close();
                                                            }
                                                            throw th;
                                                        }
                                                    } finally {
                                                        if (bufferedOutputStream != null) {
                                                            try {
                                                                bufferedOutputStream.close();
                                                            } catch (IOException e12) {
                                                                e12.printStackTrace();
                                                            }
                                                        }
                                                    }
                                                }
                                                throw th;
                                            }
                                        } catch (Throwable th4) {
                                            try {
                                                try {
                                                } catch (IOException e13) {
                                                    e13.printStackTrace();
                                                }
                                                if (fileInputStream != null) {
                                                    try {
                                                        fileInputStream.close();
                                                        if (bufferedOutputStream != null) {
                                                            bufferedOutputStream.close();
                                                        }
                                                    } catch (IOException e14) {
                                                        e14.printStackTrace();
                                                        if (bufferedOutputStream != null) {
                                                            bufferedOutputStream.close();
                                                        }
                                                        throw th4;
                                                    }
                                                }
                                                throw th4;
                                            } finally {
                                                if (bufferedOutputStream != null) {
                                                    try {
                                                        bufferedOutputStream.close();
                                                    } catch (IOException e15) {
                                                        e15.printStackTrace();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    if (bufferedOutputStream != null) {
                                        bufferedOutputStream.close();
                                    }
                                } catch (IOException e16) {
                                    e16.printStackTrace();
                                }
                                if (fileInputStream != null) {
                                    try {
                                        try {
                                            fileInputStream.close();
                                            if (bufferedOutputStream != null) {
                                                bufferedOutputStream.close();
                                            }
                                        } catch (IOException e17) {
                                            e17.printStackTrace();
                                            if (bufferedOutputStream != null) {
                                                bufferedOutputStream.close();
                                            }
                                            throw th;
                                        }
                                    } finally {
                                        if (bufferedOutputStream != null) {
                                            try {
                                                bufferedOutputStream.close();
                                            } catch (IOException e18) {
                                                e18.printStackTrace();
                                            }
                                        }
                                    }
                                }
                                throw th;
                            }
                        }
                        p.d("TakePictureActivity", "jpgFile = " + TakePictureActivity.this.r.getAbsolutePath());
                        TakePictureActivity.this.runOnUiThread(new a());
                        try {
                            try {
                                bufferedOutputStream3.close();
                                bufferedOutputStream.close();
                                try {
                                    try {
                                        e2.close();
                                        bufferedOutputStream.close();
                                    } catch (IOException e19) {
                                        e2 = e19;
                                        e2.printStackTrace();
                                        bufferedOutputStream.close();
                                    }
                                } catch (Throwable th5) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e20) {
                                        e20.printStackTrace();
                                    }
                                    throw th5;
                                }
                            } catch (Throwable th6) {
                                try {
                                    try {
                                        try {
                                            e2.close();
                                            bufferedOutputStream.close();
                                        } catch (IOException e21) {
                                            e21.printStackTrace();
                                            bufferedOutputStream.close();
                                        }
                                    } catch (IOException e22) {
                                        e22.printStackTrace();
                                    }
                                    throw th6;
                                } catch (Throwable th7) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e23) {
                                        e23.printStackTrace();
                                    }
                                    throw th7;
                                }
                            }
                        } catch (IOException e24) {
                            e24.printStackTrace();
                            try {
                                try {
                                    e2.close();
                                    bufferedOutputStream.close();
                                    e2 = e2;
                                } catch (Throwable th8) {
                                    try {
                                        bufferedOutputStream.close();
                                    } catch (IOException e25) {
                                        e25.printStackTrace();
                                    }
                                    throw th8;
                                }
                            } catch (IOException e26) {
                                e26.printStackTrace();
                                bufferedOutputStream.close();
                                e2 = e26;
                            }
                        }
                    } catch (Exception unused2) {
                    } catch (Throwable th9) {
                        th = th9;
                    }
                } catch (Exception unused3) {
                    e2 = 0;
                } catch (Throwable th10) {
                    th = th10;
                    fileInputStream = null;
                }
            } catch (Exception unused4) {
                e2 = 0;
                bufferedOutputStream = null;
            } catch (Throwable th11) {
                th = th11;
                fileInputStream = null;
                bufferedOutputStream = null;
            }
        }
    }

    class d implements Camera.AutoFocusCallback {
        d() {
        }

        @Override
        public void onAutoFocus(boolean z, Camera camera) {
            TakePictureActivity.this.c.setClickable(true);
            if (!z || camera == null) {
                return;
            }
            camera.takePicture(null, null, new e(TakePictureActivity.this, null));
        }
    }

    private final class e implements Camera.PictureCallback {
        private e() {
        }

        @Override
        public void onPictureTaken(byte[] bArr, Camera camera) {
            try {
                TakePictureActivity.this.O(bArr);
                p.d("TakePictureActivity", "拍照成功");
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }

        e(TakePictureActivity takePictureActivity, a aVar) {
            this();
        }
    }

    class f implements SurfaceHolder.Callback {
        f() {
        }

        @Override
        public void surfaceChanged(SurfaceHolder surfaceHolder, int i2, int i3, int i4) {
            TakePictureActivity.this.L(surfaceHolder);
        }

        @Override
        public void surfaceCreated(SurfaceHolder surfaceHolder) {
            TakePictureActivity.this.f3311i = surfaceHolder;
            TakePictureActivity.this.M(surfaceHolder);
        }

        @Override
        public void surfaceDestroyed(SurfaceHolder surfaceHolder) {
            TakePictureActivity.this.z = true;
            if (TakePictureActivity.this.f3309g != null) {
                TakePictureActivity.this.f3309g.release();
                TakePictureActivity.this.f3309g = null;
            }
        }
    }

    public void L(SurfaceHolder surfaceHolder) {
        Camera camera = this.f3309g;
        if (camera != null) {
            Camera.Parameters parameters = camera.getParameters();
            this.f3310h = parameters;
            parameters.setPictureFormat(256);
            this.f3310h.setJpegQuality(100);
            Display defaultDisplay = getWindowManager().getDefaultDisplay();
            int width = defaultDisplay.getWidth();
            int height = defaultDisplay.getHeight();
            if (Build.VERSION.SDK_INT <= 19) {
                this.f3310h.setPictureSize(height, width);
            }
            int i2 = this.l;
            if (i2 == 0) {
                this.f3310h.setFlashMode("off");
            } else if (i2 == 1) {
                this.f3310h.setFlashMode("on");
            } else if (i2 == 2) {
                this.f3310h.setFlashMode("auto");
            }
            try {
                this.f3309g.setParameters(this.f3310h);
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
    }

    public void M(SurfaceHolder surfaceHolder) {
        try {
            if (this.f3309g == null) {
                Camera open = Camera.open(this.y);
                this.f3309g = open;
                open.setDisplayOrientation(90);
                this.f3309g.setPreviewDisplay(surfaceHolder);
                this.f3309g.startPreview();
            }
        } catch (Exception e2) {
            Camera camera = this.f3309g;
            if (camera != null) {
                camera.release();
                this.f3309g = null;
            }
            e2.printStackTrace();
        }
    }

    private void N() {
        Utils.Q0(this, getString(R.string.prompt), getString(R.string.save_photo_alert), getString(R.string.negative), getResources().getColor(2131099757), getString(R.string.positive), getResources().getColor(2131099758), new b(), true);
    }

    private void Q(boolean z) {
        int numberOfCameras = Camera.getNumberOfCameras();
        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
        for (int i2 = 0; i2 < numberOfCameras; i2++) {
            Camera.getCameraInfo(i2, cameraInfo);
            int i3 = cameraInfo.facing;
            if (i3 == 1 && z) {
                this.y = i2;
                return;
            } else {
                if (i3 == 0 && !z) {
                    this.y = i2;
                    return;
                }
            }
        }
    }

    public void O(byte[] bArr) throws IOException {
        Utils.U0(this);
        new Thread(new c(bArr)).start();
    }

    public void P(boolean z) {
        Camera camera = this.f3309g;
        if (camera != null) {
            camera.stopPreview();
            this.f3309g.release();
            this.f3309g = null;
        }
        Q(z);
        Camera open = Camera.open(this.y);
        this.f3309g = open;
        open.setDisplayOrientation(90);
        try {
            this.f3309g.setPreviewDisplay(this.f3311i);
        } catch (IOException e2) {
            e2.printStackTrace();
        }
        this.f3309g.startPreview();
    }

    public void R(int i2) {
        Camera camera = this.f3309g;
        if (camera == null) {
            return;
        }
        if (this.f3310h == null) {
            this.f3310h = camera.getParameters();
        }
        if (i2 == 1) {
            this.f3310h.setFlashMode("on");
        } else if (i2 == 2) {
            this.f3310h.setFlashMode("auto");
        } else {
            this.f3310h.setFlashMode("off");
        }
        this.f3309g.setParameters(this.f3310h);
    }

    @Override
    public void init() {
        this.a = (SurfaceView) findViewById(R.id.picture_surfaceview);
        this.b = (ImageView) findViewById(R.id.iv_close_take_pictrue);
        this.c = (ImageView) findViewById(R.id.iv_take_pictrue);
        this.d = (ImageView) findViewById(R.id.iv_take_location_pictrue);
        this.f3307e = (ImageView) findViewById(R.id.iv_camara_swith);
        ImageView imageView = (ImageView) findViewById(R.id.iv_flash_light);
        this.f3308f = imageView;
        int i2 = this.l;
        if (i2 == 0) {
            imageView.setBackgroundResource(R.drawable.flash_ligth_off);
        } else if (i2 == 1) {
            imageView.setBackgroundResource(R.drawable.flash_light_open);
        } else if (i2 == 2) {
            imageView.setBackgroundResource(R.drawable.flash_light_auto);
        }
        this.b.setOnClickListener(this);
        this.c.setOnClickListener(this);
        this.d.setOnClickListener(this);
        this.f3307e.setOnClickListener(this);
        this.f3308f.setOnClickListener(this);
    }

    @Override
    protected void onActivityResult(int i2, int i3, Intent intent) {
        if (i3 == -1 && i2 == 2) {
            setResult(-1, intent);
            finish();
        }
        if (i3 == -1 && i2 == 11) {
            Uri data = intent.getData();
            if (data == null) {
                Utils.Y0(getApplicationContext(), R.string.network_get_photo_fail);
                return;
            }
            File a2 = v.a(this, v.g(data, this), -1);
            if (this.u == 1) {
                int i4 = this.x;
                Utils.c1(this, data, 1, 1, i4 / 4, i4 / 4);
            } else {
                try {
                    Intent intent2 = new Intent(getApplicationContext(), (Class<?>) PictureAcitivityPreview.class);
                    intent2.putExtra("isPutvideo", this.u);
                    intent2.putExtra("picPath", a2.getAbsolutePath());
                    startActivity(intent2);
                    finish();
                } catch (Exception unused) {
                }
            }
        }
        if (i3 == -1 && i2 == 111) {
            try {
                File a3 = v.a(this, Utils.C() + "/myPhoto/croptemp", -1);
                Intent intent3 = new Intent();
                intent3.putExtra("picPath", a3.getAbsolutePath());
                setResult(111, intent3);
                finish();
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        if (i2 == 111) {
            setResult(i3, intent);
            finish();
        }
        super.onActivityResult(i2, i3, intent);
    }

    @Override
    public void onAutoFocus(boolean z, Camera camera) {
    }

    @Override
    public void onClick(View view) {
        if (Utils.o0()) {
        }
        boolean z = true;
        switch (view.getId()) {
            case R.id.iv_camara_swith:
                long currentTimeMillis = System.currentTimeMillis();
                this.o = currentTimeMillis;
                if (this.m || currentTimeMillis - this.n > 3000) {
                    p.d("TakePictureActivity", "摄像头转换");
                    this.n = System.currentTimeMillis();
                    this.m = false;
                    try {
                        if (Camera.getNumberOfCameras() != 1) {
                            P(!this.f3312j);
                            if (this.f3312j) {
                                z = false;
                            }
                            this.f3312j = z;
                            if (z) {
                                this.f3308f.setVisibility(8);
                            } else {
                                this.f3308f.setVisibility(0);
                                this.f3308f.setBackgroundResource(R.drawable.flash_light_auto);
                                this.l = 2;
                                R(2);
                            }
                            if (this.f3313k && this.f3312j) {
                                R(0);
                                this.f3313k = false;
                                break;
                            }
                        } else {
                            Toast.makeText((Context) this, R.string.no_camera_1, 0).show();
                            break;
                        }
                    } catch (Exception e2) {
                        e2.printStackTrace();
                        return;
                    }
                }
                break;
            case R.id.iv_close_take_pictrue:
                finish();
                break;
            case R.id.iv_flash_light:
                long currentTimeMillis2 = System.currentTimeMillis();
                this.p = currentTimeMillis2;
                if (!this.f3313k && !this.f3312j && currentTimeMillis2 - this.q > 500) {
                    this.q = System.currentTimeMillis();
                    int i2 = this.l;
                    if (i2 == 0) {
                        this.f3308f.setBackgroundResource(R.drawable.flash_light_auto);
                        this.l = 2;
                        R(2);
                        this.w.putInt("flash_type", this.l);
                        this.w.commit();
                        break;
                    } else if (i2 == 1) {
                        this.f3308f.setBackgroundResource(R.drawable.flash_ligth_off);
                        this.l = 0;
                        R(0);
                        this.w.putInt("flash_type", this.l);
                        this.w.commit();
                        break;
                    } else if (i2 == 2) {
                        this.f3308f.setBackgroundResource(R.drawable.flash_light_open);
                        this.l = 1;
                        R(1);
                        this.w.putInt("flash_type", this.l);
                        this.w.commit();
                        break;
                    }
                }
                break;
            case R.id.iv_take_location_pictrue:
                File file = new File(e0.f3367h);
                if (file.exists()) {
                    file.delete();
                }
                startActivityForResult(new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 11);
                break;
            case R.id.iv_take_pictrue:
                this.c.setClickable(false);
                Camera camera = this.f3309g;
                if (camera != null) {
                    camera.autoFocus(new d());
                    break;
                }
                break;
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        if (configuration.orientation == 2) {
            this.f3309g.setDisplayOrientation(0);
        } else {
            this.f3309g.setDisplayOrientation(90);
        }
        super.onConfigurationChanged(configuration);
    }

    @Override
    protected void onCreate(Bundle bundle) {
        setContentView(R.layout.picture_audio);
        Intent intent = getIntent();
        this.t = intent;
        String stringExtra = intent.getStringExtra("classname");
        p.d("TakePictureActivity", "className = " + stringExtra);
        this.x = getWindowManager().getDefaultDisplay().getWidth();
        Q(false);
        if (!TextUtils.isEmpty(stringExtra)) {
            if ("PutvideoActivity".equals(stringExtra)) {
                this.u = 1;
            } else if ("ActvyPersonActivity".equals(stringExtra)) {
                this.u = 2;
            } else if ("ApplyActivity".equals(stringExtra)) {
                this.u = 3;
            }
        }
        SharedPreferences sharedPreferences = getSharedPreferences(SocialConstants.PARAM_AVATAR_URI, 0);
        this.v = sharedPreferences;
        this.w = sharedPreferences.edit();
        this.l = this.v.getInt("flash_type", 2);
        p.d("TakePictureActivity", "flashType = " + this.l);
        init();
        super.onCreate(bundle);
    }

    public boolean onKeyDown(int i2, KeyEvent keyEvent) {
        if (i2 != 4) {
            if (i2 == 27) {
                if (this.u == 1) {
                    Intent intent = new Intent();
                    intent.putExtra("picPath", this.r.getAbsolutePath());
                    setResult(111, intent);
                    finish();
                } else if (this.f3309g != null && keyEvent.getRepeatCount() == 0) {
                    this.f3309g.autoFocus(new a());
                }
            }
            return super/*android.app.Activity*/.onKeyDown(i2, keyEvent);
        }
        if (keyEvent.getRepeatCount() == 1) {
            N();
        }
        return super/*android.app.Activity*/.onKeyDown(i2, keyEvent);
    }

    @Override
    protected void onPause() {
        this.z = false;
        Camera camera = this.f3309g;
        if (camera != null) {
            camera.stopPreview();
            this.f3309g.release();
            this.f3309g = null;
        }
        Bitmap bitmap = this.s;
        if (bitmap != null) {
            bitmap.recycle();
            this.s = null;
        }
        super.onPause();
    }

    @Override
    protected void onResume() {
        SurfaceHolder holder = this.a.getHolder();
        this.f3311i = holder;
        holder.setType(3);
        holder.setKeepScreenOn(true);
        if (this.z) {
            holder.addCallback(new f());
        }
        if (!this.z) {
            M(holder);
            L(holder);
        }
        super.onResume();
    }

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