49 lines
1.3 KiB
Java
49 lines
1.3 KiB
Java
package com.prank.tool;
|
|
|
|
import android.app.Application;
|
|
import android.content.res.AssetManager;
|
|
import android.graphics.Typeface;
|
|
|
|
import com.prank.tool.jbean.Info;
|
|
|
|
import com.prank.tool.jbean.MyBean;
|
|
import com.prank.tool.utils.DbManager;
|
|
import com.prank.tool.utils.Tools;
|
|
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import java.util.List;
|
|
|
|
public class MyApp extends Application {
|
|
|
|
public static MyApp app;
|
|
public static Typeface defaultFont;
|
|
public static List<MyBean> bean;
|
|
|
|
@Override
|
|
public void onCreate() {
|
|
super.onCreate();
|
|
app = this;
|
|
AssetManager assets = getAssets();
|
|
defaultFont = Typeface.createFromAsset(assets, "font.ttf");
|
|
DbManager.init(this);
|
|
if (bean != null)
|
|
return;
|
|
try {
|
|
InputStream open = getAssets().open("prank.json");
|
|
String string = Tools.getString(open);
|
|
if (!string.isEmpty()) {
|
|
bean = Tools.getBean(string);
|
|
for (MyBean category:bean){
|
|
for (Info info1 : category.getInfoList()) {
|
|
info1.setLike(false);
|
|
DbManager.getBoxBean().put(info1);
|
|
}
|
|
}
|
|
}
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|