package com.lh.wallpaper2;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.lh.wallpaper2.file.ReadFile;
import com.lh.wallpaper2.json.Info;
import com.lh.wallpaper2.json.Url;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class Wallpaper extends Application {
    public static Context mAppContext;
    private static List<Info> userList = new ArrayList<Info>();
    private List<Url> urlList = new ArrayList<Url>();
    public static final  String dadgsfgsf = "app_database";
    public static final int aadasdasd = 1;

    @Override
    public void onCreate() {
        super.onCreate();
        mAppContext = this;
        try {
            InputStream open = getAssets().open("pink_wallpaper.json");
            String covertStr = ReadFile.getCovertStr(open);
            if (!covertStr.isEmpty()) {
                Gson gson = new Gson();
             Type type = new TypeToken<List<Info>>(){
             }.getType();
                userList = gson.fromJson(covertStr,type);
                for (Info info:userList) {
                    for (Url url:info.getList()){
                        urlList.add(url);
                    }
                }
                Log.d("22222222222222", "onCreate: "+urlList.size());
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public static List<Info> getUserList() {
        Log.d("------------","-------------userList="+userList);
        return userList;
    }
}
