导航菜单

页面标题

页面副标题

管控平台 v5.2.3.0. - ToastReceiver.java 源代码

正在查看: 管控平台 v5.2.3.0. 应用的 ToastReceiver.java JAVA 源代码文件

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


package com.iflytek.mdmservice.receiver;

import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.iflytek.mdmcommon.LogUtil;
import com.iflytek.mdmcommon.SpHelper;
import com.iflytek.mdmservice.MDMApp;
import com.iflytek.mdmservice.R$dimen;
import com.iflytek.mdmservice.R$id;
import com.iflytek.mdmservice.R$layout;
import com.iflytek.mdmservice.R$string;
import com.iflytek.mdmservice.R$style;
import com.iflytek.mdmservice.ui.MainActivity;
import net.sqlcipher.database.SQLiteDatabase;

public class ToastReceiver extends BroadcastReceiver {

    static Dialog f378a;

    static long f379b;

    static Handler f380c = new a(Looper.getMainLooper());

    static class a extends Handler {
        a(Looper looper) {
            super(looper);
        }

        @Override
        public void handleMessage(Message message) {
            synchronized (this) {
                if (ToastReceiver.f378a == null || !ToastReceiver.f378a.isShowing()) {
                    b poll = MDMApp.j().n().poll();
                    if (poll != null) {
                        try {
                            ToastReceiver.d(MDMApp.j(), poll.c());
                        } catch (Exception e) {
                            Intent intent = new Intent(MDMApp.j(), (Class<?>) MainActivity.class);
                            intent.setFlags(SQLiteDatabase.CREATE_IF_NECESSARY);
                            MDMApp.j().startActivity(intent);
                            LogUtil.e(e.getMessage());
                        }
                    }
                }
            }
        }
    }

    public static class b implements Comparable<b> {

        private String f381a;

        private long f382b;

        public b(String str, long j) {
            this.f381a = str;
            this.f382b = j;
        }

        @Override
        public int compareTo(@NonNull b bVar) {
            return bVar.b() > this.f382b ? -1 : 1;
        }

        public long b() {
            return this.f382b;
        }

        public String c() {
            return this.f381a;
        }
    }

    static void b() {
        Dialog dialog = f378a;
        if (dialog == null || !dialog.isShowing()) {
            return;
        }
        f378a.dismiss();
        f378a = null;
        f380c.sendEmptyMessage(2);
    }

    public static void c(long j) {
        f379b = j;
    }

    public static void d(Context context, String str) {
        View inflate = LayoutInflater.from(context).inflate(R$layout.layout_toast, (ViewGroup) null);
        ((TextView) inflate.findViewById(R$id.tv_common_toast)).setText(str);
        Dialog dialog = new Dialog(context, R$style.ToastStyle);
        f378a = dialog;
        Window window = dialog.getWindow();
        window.setWindowAnimations(R$style.ToastStyle);
        WindowManager.LayoutParams attributes = window.getAttributes();
        attributes.y = context.getResources().getDimensionPixelSize(R$dimen.toast_offset_y);
        attributes.gravity = 80;
        attributes.width = -2;
        attributes.height = -2;
        window.setAttributes(attributes);
        f378a.setCanceledOnTouchOutside(true);
        if (Build.VERSION.SDK_INT >= 26) {
            window.setType(2038);
        } else {
            window.setType(2003);
        }
        f378a.addContentView(inflate, new RelativeLayout.LayoutParams(-2, -2));
        f378a.show();
        f380c.postDelayed(new Runnable() {
            @Override
            public final void run() {
                ToastReceiver.b();
            }
        }, com.igexin.push.config.c.t);
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        LogUtil.z("ToastReceiver onReceive===");
        LogUtil.z("ToastReceiver this===" + this);
        int intExtra = intent.getIntExtra("type", 0);
        String stringExtra = intent.getStringExtra("tip");
        if (intExtra == 0) {
            if (System.currentTimeMillis() - f379b < com.igexin.push.config.c.t) {
                return;
            } else {
                c(System.currentTimeMillis());
            }
        } else if (intExtra == 1) {
            if (SpHelper.getBoolean("spShowNfcFlag", false)) {
                return;
            }
            SpHelper.putBoolean("spShowNfcFlag", true);
            stringExtra = context.getResources().getString(R$string.toast_first_nfc_tip);
        } else if (intExtra == 2) {
            stringExtra = context.getResources().getString(R$string.toast_first_wifi_tip);
        } else if (intExtra == 3) {
            if (SpHelper.getBoolean("spShowBluetoothFlag", false)) {
                return;
            }
            SpHelper.putBoolean("spShowBluetoothFlag", true);
            stringExtra = context.getResources().getString(R$string.toast_first_bluetooth_tip);
        }
        LogUtil.z("===cur " + System.currentTimeMillis() + " time " + f379b);
        MDMApp.j().n().add(new b(stringExtra, System.currentTimeMillis()));
        f380c.sendEmptyMessage(1);
    }
}