package epson.print.Util;

import android.app.Service;
import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.StatFs;
import android.view.MotionEvent;
import android.view.View;
import androidx.annotation.RequiresApi;
import epson.print.CommonDefine;

public class Utils implements CommonDefine {
    public static Utils mUtils;

    public static Utils getInstance() {
        if (mUtils == null) {
            mUtils = new Utils();
        }
        return mUtils;
    }

    public int saveToSD(android.graphics.Bitmap r5, String r6) {

        throw new UnsupportedOperationException("Method not decompiled: epson.print.Util.Utils.saveToSD(android.graphics.Bitmap, java.lang.String):int");
    }

    public boolean downloadFile(String r7, String r8, String r9, Context r10) {

        throw new UnsupportedOperationException("Method not decompiled: epson.print.Util.Utils.downloadFile(java.lang.String, java.lang.String, java.lang.String, android.content.Context):boolean");
    }

    public boolean isNetworkAvailable(Context context) {
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Service.CONNECTIVITY_SERVICE);
        if (connectivityManager == null) {
            EPLog.m318w("INTERNET", "couldn't get connectivity manager");
        } else {
            NetworkInfo[] allNetworkInfo = connectivityManager.getAllNetworkInfo();
            if (allNetworkInfo != null) {
                for (NetworkInfo state : allNetworkInfo) {
                    if (state.getState() == NetworkInfo.State.CONNECTED) {
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public String editNumber(int i) {
        if (i < 10) {
            return "00" + i;
        } else if (i >= 100) {
            return String.valueOf(i);
        } else {
            return "0" + i;
        }
    }

    public Drawable onItemTouch(Context context, View view, MotionEvent motionEvent, int i) {
        Drawable drawable = context.getResources().getDrawable(i);
        if (motionEvent.getAction() == 0) {
            drawable.setColorFilter(-7829368, PorterDuff.Mode.MULTIPLY);
        } else if (motionEvent.getAction() == 1) {
            drawable.setColorFilter(-1, PorterDuff.Mode.MULTIPLY);
        }
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        return drawable;
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
    public boolean checkFreeSdcard(double d) {
        StatFs statFs = new StatFs(DEFAULT_DIR);
        return statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong() > d;
    }
}
