package com.bxzk.afxj.util;

import android.content.Context;
import android.content.SharedPreferences;

import com.bxzk.afxj.application.BApplication;


/**
 * Created by Daniel on 2018/7/23.
 */
public class ProgramUtils {
//    public static void clearCache() {
//        FileUtils.deleteDirectory(new File(ProgramConfig.BaseCachePath));
//    }
//
//    public static String getCacheSize(){
//        return FileUtils.getAutoFileOrFilesSize(ProgramConfig.BaseCachePath);
//    }

    public static boolean firstOpen(){
        SharedPreferences preferences = getContext().getSharedPreferences("config", Context.MODE_PRIVATE);
        boolean flag = preferences.getBoolean("firstOpen",true);
        if (flag){
            preferences.edit().putBoolean("firstOpen",false).apply();
        }
        return flag;
    }

    public static int getLanguage() {
        SharedPreferences preferences = getContext().getSharedPreferences("language", Context.MODE_PRIVATE);
        return preferences.getInt("language", 1);
    }



    public static void setLanguage(int position) {
        SharedPreferences preferences = getContext().getSharedPreferences("language", Context.MODE_PRIVATE);
        preferences.edit().putInt("language", position).apply();
    }

    public static Context getContext(){
        return BApplication.getInstance().getApplicationContext();
    }
}
