/*
|
* Copyright (c) 2020 WildFireChat. All rights reserved.
|
*/
|
|
package com.highdatas.madeasy.patient;
|
|
import android.content.Context;
|
import android.os.Handler;
|
import android.widget.Toast;
|
import androidx.multidex.MultiDexApplication;
|
|
public class BaseApp extends MultiDexApplication {
|
|
//以下属性应用于整个应用程序,合理利用资源,减少资源浪费
|
private static Context mContext;//上下文
|
private static long mMainThreadId;//主线程id
|
private static Handler mHandler;//主线程Handler
|
|
@Override
|
public void onCreate() {
|
super.onCreate();
|
|
//对全局属性赋值
|
mContext = getApplicationContext();
|
mMainThreadId = android.os.Process.myTid();
|
mHandler = new Handler();
|
}
|
|
public static Context getContext() {
|
return mContext;
|
}
|
|
public static void setContext(Context mContext) {
|
BaseApp.mContext = mContext;
|
}
|
|
public static long getMainThreadId() {
|
return mMainThreadId;
|
}
|
|
public static Handler getMainHandler() {
|
return mHandler;
|
}
|
|
public static void showToast(Context context, String content) {
|
showToast(context, content, false);
|
}
|
|
public static void showToast( String content) {
|
showToast(getContext(), content, false);
|
}
|
|
public static void showToast(Context context, String content, boolean isLong) {
|
if (isLong) {
|
Toast.makeText(context, content, Toast.LENGTH_LONG).show();
|
} else {
|
Toast.makeText(context, content, Toast.LENGTH_SHORT).show();
|
}
|
|
}
|
}
|