上海工程测量
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

125 lines
3.8 KiB

package com.project.survey;
import static com.bingce.AppChannel.customChannel;
import android.app.Application;
import android.util.Log;
import com.bingce.AppChannel;
import com.bingce.data.database.DBQueryConstant;
import com.bingce.data.database.KeyValueDb;
import com.bingce.data.database.ProjectCoordinateDatabase;
import com.bingce.data.database.ProjectDb;
import com.bingce.data.database.RoadJobLineDatabase;
import com.bingce.data.database.SurveyRecordDatabase;
import com.bingce.data.database.SyncRecordDatabase;
import com.bingce.data.surveyor.designdata.project.ProjectConstants;
import com.bingce.data.surveyor.designdata.project.ProjectRecord;
import com.bingce.device.Device;
import com.bingce.device.DeviceProgressDialogBuilderImpl;
import com.bingce.rtk.command.RTK;
import com.bingce.utils.CoordinatorSystemNotifierImpl;
import com.bingce.utils.ThreadPoolUtil;
import org.polaric.colorful.Colorful;
import blankj.utilcode.util.Utils;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
public class App extends Application {
private final CoordinatorSystemNotifierImpl coordinatorSystemNotifier = new CoordinatorSystemNotifierImpl();
private static App app;
public boolean isThemeDark;
/**
* 磁偏角,用于校正指南针
*/
public float magneticDeclination = 0;
public int lastRecordBrowseType = 0;
/**
* 是否在记录界面显示当前工程全部数据
*/
public boolean isShowAllRecordInCurrentProject = true;
public boolean isLandscape() {
return false;
}
@Override
public void onCreate() {
customChannel = AppChannel.CUSTOM_CONTROL_PRO;//AppChannel.CUSTOM_PUBLIC;
super.onCreate();
app = this;
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
Log.e("rxThrowable", String.valueOf(throwable));
}
});
initThemeDark();
Utils.init(this);
initDatabase();
initDevice();
}
private void initDevice() {
//初始化设备相关代码
Device.init(
DeviceProgressDialogBuilderImpl.builder(),
coordinatorSystemNotifier,
coordinateSystem -> {
ThreadPoolUtil.execute(() -> {
//查询当前项目
String currentProjectId = KeyValueDb.currentProjectId();
ProjectRecord currentProject = ProjectDb.getInstance()
.rawQueryData(DBQueryConstant.findById(ProjectConstants.DB_NAME, currentProjectId));
if (currentProject != null) {
currentProject.coordinateSystem = coordinateSystem;
ProjectDb.getInstance().save(currentProject);
}
});
});
RTK.init(coordinatorSystemNotifier);
}
private void initDatabase() {
ProjectCoordinateDatabase.openDb(this, null);
SurveyRecordDatabase.openDb(this, null);
SyncRecordDatabase.openDb(this, null);
RoadJobLineDatabase.openDb(this, null);
}
public boolean isThemeDark() {
return false;
}
private void initThemeDark() {
Colorful.defaults()
.primaryColor(Colorful.ThemeColor.BLUE)
.accentColor(Colorful.ThemeColor.BLUE)
.translucent(false)
.dark(false);
Colorful.init(this);
// Colorful.config(this).primaryColor(Colorful.ThemeColor.BROWN).apply();
// Colorful.config(this).accentColor(Colorful.ThemeColor.BROWN).apply();
}
public static App getApp() {
return app;
}
}