package com.bwie.monthmoni1.base;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
/**
* Created by ThinkPad on 2018/9/21.
*/
public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
previewAction();
setContentView(getContentView());
initView();
initData();
setListener();
setMoreAction();
}
protected void setMoreAction() {
}
protected void setListener() {
}
protected void initData() {
}
protected abstract void initView();
protected abstract int getContentView();
protected void previewAction() {
}
}
BaseApplication
package com.bwie.monthmoni1.base;
import android.app.Application;
import android.graphics.Bitmap;
import android.os.Environment;
import com.nostra13.universalimageloader.cache.disc.DiskCache;
import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
import com.nostra13.universalimageloader.cache.disc.naming.Md5FileNameGenerator;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import java.io.File;
import java.io.IOException;
/**
*
*/
public class BaseApplication extends Application{
@Override
public void onCreate() {
super.onCreate();
File file = null;
if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){
File rootSD = Environment.getExternalStorageDirectory();
file = new File(rootSD,"imgs");
if(!file.exists()){
file.mkdirs();
}
}
try {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.cacheOnDisk(true)
.cacheInMemory(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
DiskCache diskCache = new LruDiskCache(file,new Md5FileNameGenerator(),50*1024*1024);
ImageLoaderConfiguration configuration = new ImageLoaderConfiguration.Builder(this)
.diskCache(diskCache)
.defaultDisplayImageOptions(options)
.threadPoolSize(3)
.build();
ImageLoader.getInstance().init(configuration);
} catch (IOException e) {
e.printStackTrace();
}
}
}