789娱乐城.apk(点击下载) / PgyFeedback.java


package com.pgyersdk.feedback;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.widget.Toast;
import com.pgyersdk.b.b;
import com.pgyersdk.d.b;
import com.pgyersdk.f.f;
import com.pgyersdk.utils.GLSurfaceUtils;
import com.pgyersdk.utils.h;
import com.pgyersdk.utils.j;
import com.pgyersdk.utils.l;
import com.pgyersdk.views.c;
import com.pgyersdk.views.d;
import java.io.File;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class PgyFeedback {
    public static boolean b = false;
    private static PgyFeedback e;

    /* renamed from: a  reason: collision with root package name */
    public a f2743a = null;
    public String c = "";
    public a d;
    private c f;
    private int g;
    private Handler h;
    private Dialog i;
    private WeakReference<Context> j;
    private String k = "";
    private File l;
    private Boolean m = false;
    private DialogInterface n;
    private boolean o = false;
    private Map<String, String> p = new HashMap();
    private b q;

    public interface a {
        void a();
    }

    public static PgyFeedback a() {
        if (e == null) {
            e = new PgyFeedback();
            e.d();
        }
        return e;
    }

    public void b() {
        GLSurfaceUtils.a().b();
        if (this.j == null || this.j.get() == null) {
            this.f = null;
            e = null;
        } else if (b(this.j.get())) {
            com.pgyersdk.utils.c.a().a(com.pgyersdk.b.c.a(this.j.get()).getAbsolutePath());
            com.pgyersdk.utils.c.a().b();
            if (this.f2743a != null) {
                this.f2743a.b();
            }
            this.f = null;
            e = null;
            this.o = false;
        }
    }

    public PgyFeedback a(a aVar) {
        this.f2743a = aVar;
        return e;
    }

    public PgyFeedback a(boolean z) {
        b = z;
        return e;
    }

    public c a(Context context, final boolean z) {
        this.j = new WeakReference<>(context);
        this.m = true;
        b.a(context);
        com.pgyersdk.a.a.b(context);
        if (this.f != null) {
            return this.f;
        }
        if (Build.VERSION.SDK_INT >= 11) {
            if (this.g == 0) {
                this.g = 3;
            }
            if (z) {
                this.f = new d(this.j.get(), this.g);
                this.f.setCancelable(true);
            } else {
                if (this.f2743a != null) {
                    this.f2743a.a();
                }
                this.f = new c(this.j.get(), this.g);
                this.f.setCancelable(false);
            }
        } else if (z) {
            this.f = new d(this.j.get());
            this.f.setCancelable(true);
        } else {
            if (this.f2743a != null) {
                this.f2743a.a();
            }
            this.f = new c(this.j.get());
            this.f.setCancelable(false);
        }
        if (!z) {
            if (context instanceof Activity) {
                if (!b) {
                    this.k = com.pgyersdk.utils.c.a().a(context);
                    a(this.j.get(), this.k);
                } else {
                    GLSurfaceUtils.a().a(this.j.get());
                    GLSurfaceUtils.a().a(true);
                }
            }
            this.f.setPositiveButton(com.pgyersdk.c.b.a(1048), new DialogInterface.OnClickListener() {
                /* class com.pgyersdk.feedback.PgyFeedback.AnonymousClass1 */

                public void onClick(DialogInterface dialogInterface, int i) {
                    PgyFeedback.b(dialogInterface, false);
                    PgyFeedback.e.n = dialogInterface;
                    PgyFeedback.this.l = PgyFeedback.this.f.l;
                    PgyFeedback.this.a((Context) PgyFeedback.this.j.get(), PgyFeedback.this.f.b().getText().toString(), PgyFeedback.this.f.c().getText().toString(), PgyFeedback.this.l, PgyFeedback.this.k, false);
                }
            });
            this.f.setNegativeButton(com.pgyersdk.c.b.a(1049), new DialogInterface.OnClickListener() {
                /* class com.pgyersdk.feedback.PgyFeedback.AnonymousClass2 */

                public void onClick(DialogInterface dialogInterface, int i) {
                    PgyFeedback.this.l = PgyFeedback.this.f.l;
                    if (!j.a(PgyFeedback.this.f.c().getText().toString()) || PgyFeedback.this.l != null || !j.a(PgyFeedback.this.f.b().getText().toString().trim())) {
                        PgyFeedback.b(dialogInterface, true);
                        Toast.makeText((Context) PgyFeedback.this.j.get(), com.pgyersdk.c.b.a(1056), 0).show();
                        if (PgyFeedback.this.i != null && PgyFeedback.this.i.isShowing()) {
                            PgyFeedback.this.i.dismiss();
                        }
                    } else {
                        PgyFeedback.b(dialogInterface, true);
                    }
                    dialogInterface.cancel();
                    PgyFeedback.this.f.f();
                }
            });
        }
        this.f.setOnCancelListener(new DialogInterface.OnCancelListener() {
            /* class com.pgyersdk.feedback.PgyFeedback.AnonymousClass3 */

            public void onCancel(DialogInterface dialogInterface) {
                PgyFeedback.this.f.f();
                h.a("selfmail", PgyFeedback.this.f.b().getText().toString().trim());
                h.a("feedback_des", PgyFeedback.this.f.c().getText().toString().trim());
                if (z) {
                    PgyFeedback.this.d.a();
                } else if (PgyFeedback.this.f2743a != null) {
                    PgyFeedback.this.f2743a.b();
                }
                PgyFeedback.this.f = null;
                PgyFeedback unused = PgyFeedback.e = null;
            }
        });
        if (Build.VERSION.SDK_INT >= 17) {
            this.f.setOnDismissListener(new DialogInterface.OnDismissListener() {
                /* class com.pgyersdk.feedback.PgyFeedback.AnonymousClass4 */

                public void onDismiss(DialogInterface dialogInterface) {
                    if (z) {
                        PgyFeedback.this.d.a();
                    } else if (PgyFeedback.this.f2743a != null) {
                        PgyFeedback.this.f2743a.b();
                    }
                    PgyFeedback unused = PgyFeedback.e = null;
                }
            });
        }
        this.i = this.f.create();
        this.i.show();
        return this.f;
    }

    public void a(Context context) {
        WeakReference weakReference = new WeakReference(context);
        if (!b((Context) weakReference.get())) {
            Toast.makeText((Context) weakReference.get(), com.pgyersdk.c.b.a(1077), 0).show();
        } else if (!this.o) {
            this.o = true;
            if (this.f2743a != null) {
                this.f2743a.a();
            }
            this.j = new WeakReference<>(weakReference.get());
            this.m = false;
            b.a(this.j.get());
            if (!(weakReference.get() instanceof Activity)) {
                return;
            }
            if (!b) {
                this.k = com.pgyersdk.utils.c.a().a(this.j.get());
                a((Context) weakReference.get(), this.k);
                return;
            }
            GLSurfaceUtils.a().a(this.j.get());
            GLSurfaceUtils.a().a(true);
        }
    }

    public void a(Context context, String str, String str2, File file, String str3, Boolean bool) {
        if (this.j == null) {
            this.j = new WeakReference<>(context);
        }
        if (this.j.get().checkCallingOrSelfPermission("android.permission.INTERNET") != 0) {
            Toast.makeText(this.j.get(), com.pgyersdk.c.b.a(1057), 0).show();
            return;
        }
        ArrayList arrayList = new ArrayList();
        if (!j.a(str3)) {
            if (bool.booleanValue()) {
                arrayList.add(str3);
            } else if (this.f.d() != null && this.f.d().isChecked() && b(this.j.get())) {
                arrayList.add(str3);
            } else {
                return;
            }
        }
        if (j.a(str)) {
            Toast.makeText(this.j.get(), com.pgyersdk.c.b.a(1063), 0).show();
        } else if (!l.a(str)) {
            Toast.makeText(this.j.get(), com.pgyersdk.c.b.a(1046), 0).show();
        } else {
            if (!bool.booleanValue()) {
                h.a(this.j.get(), "selfmail", this.f.b().getText().toString());
            }
            if (this.n != null) {
                b(this.n, true);
            }
            if (this.i != null && this.i.isShowing()) {
                this.i.dismiss();
            }
            f fVar = new f(this.j.get(), str, "https://www.pgyer.com/apiv1/feedback/add", str2, arrayList, file, "", this.h, this.c);
            fVar.a(true);
            com.pgyersdk.utils.a.a(fVar);
        }
    }

    /* access modifiers changed from: private */
    public static void b(DialogInterface dialogInterface, Boolean bool) {
        try {
            Field declaredField = dialogInterface.getClass().getSuperclass().getDeclaredField("mShowing");
            declaredField.setAccessible(true);
            try {
                declaredField.set(dialogInterface, bool);
            } catch (IllegalAccessException e2) {
                e2.printStackTrace();
            } catch (IllegalArgumentException e3) {
                e3.printStackTrace();
            }
        } catch (NoSuchFieldException e4) {
            e4.printStackTrace();
        }
    }

    private void a(final Context context, String str) {
        com.pgyersdk.b.b.a((Activity) context, new b.a() {
            /* class com.pgyersdk.feedback.PgyFeedback.AnonymousClass5 */
        });
    }

    private void d() {
        this.h = new Handler() {
            /* class com.pgyersdk.feedback.PgyFeedback.AnonymousClass6 */

            public void handleMessage(Message message) {
                switch (message.what) {
                    case 20001:
                        Toast.makeText((Context) PgyFeedback.this.j.get(), com.pgyersdk.c.b.a(1058), 0).show();
                        com.pgyersdk.utils.c.a().a(com.pgyersdk.utils.c.a().b((Context) PgyFeedback.this.j.get()));
                        break;
                    case 20002:
                        Toast.makeText((Context) PgyFeedback.this.j.get(), com.pgyersdk.c.b.a(1059), 0).show();
                        com.pgyersdk.utils.c.a().a(com.pgyersdk.utils.c.a().b((Context) PgyFeedback.this.j.get()));
                        break;
                }
                h.a("feedback_des", "");
                h.a("voicefile", "");
                h.a("voiceTime", "");
                PgyFeedback.this.b();
            }
        };
    }

    private boolean b(Context context) {
        return context.checkCallingOrSelfPermission("android.permission.WRITE_EXTERNAL_STORAGE") == 0;
    }

    public void a(b bVar) {
        this.q = bVar;
    }

    public void a(a aVar) {
        this.d = aVar;
    }
}