package com.seewo.remote.g;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import java.util.HashMap;
import java.util.Map;

/* JADX INFO: compiled from: SPUtils.java */
/* JADX INFO: loaded from: classes.dex */
@SuppressLint({"ApplySharedPref"})
public final class q {
    private static final Map<String, q> b = new HashMap();
    private SharedPreferences a;

    private q(Context context, String str, int i2) {
        this.a = context.getSharedPreferences(str, i2);
    }

    public static q b(Context context) {
        return c(context, "", 0);
    }

    public static q c(Context context, String str, int i2) {
        if (d(str)) {
            str = "spUtils";
        }
        q qVar = b.get(str);
        if (qVar == null) {
            synchronized (q.class) {
                qVar = b.get(str);
                if (qVar == null) {
                    qVar = new q(context, str, i2);
                    b.put(str, qVar);
                }
            }
        }
        return qVar;
    }

    private static boolean d(String str) {
        if (str == null) {
            return true;
        }
        int length = str.length();
        for (int i2 = 0; i2 < length; i2++) {
            if (!Character.isWhitespace(str.charAt(i2))) {
                return false;
            }
        }
        return true;
    }

    public boolean a(String str, boolean z) {
        return this.a.getBoolean(str, z);
    }

    public void e(String str, boolean z) {
        f(str, z, false);
    }

    public void f(String str, boolean z, boolean z2) {
        if (z2) {
            this.a.edit().putBoolean(str, z).commit();
        } else {
            this.a.edit().putBoolean(str, z).apply();
        }
    }
}
