| | |
| | | |
| | | import java.io.File; |
| | | |
| | | import cn.flightfeather.thirdapp.bean.Userinfo; |
| | | import cn.flightfeather.thirdapp.bean.entity.Userinfo; |
| | | import cn.flightfeather.thirdapp.common.net.RetrofitFactory; |
| | | import cn.flightfeather.thirdapp.util.GlobalConfig; |
| | | import cn.flightfeather.thirdapp.util.crashreport.MyCrashHandler; |
| | | import cn.flightfeather.thirdapp.util.notification.MyNotificationChannel; |
| | | import cn.flightfeather.thirdapp.util.push.PushService; |
| | | import cn.flightfeather.thirdapp.util.tbs.Tbs; |
| | | import retrofit2.Retrofit; |
| | | import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; |
| | | import retrofit2.converter.gson.GsonConverterFactory; |
| | |
| | | |
| | | public class CommonApplication extends Application { |
| | | // private final String ROOTURL="http://106.14.187.51:8801/supervision/"; |
| | | private final String ROOTURL="http://192.168.0.200:8080/"; |
| | | private final String ROOTURL_IMAGE="http://192.168.0.200:8080/images/"; |
| | | private final String ROOTURL_REALEASE = "http://47.100.191.150:9005/"; |
| | | public final String ROOTURL_REALEASE_IMAGE = "http://47.100.191.150:9005/images/"; |
| | | public final String ROOT_URL ="http://192.168.0.200:8080/"; |
| | | public final String ROOT_URL_IMAGE ="http://192.168.0.200:8080/images/"; |
| | | public final String ROOT_URL_RELEASE = "http://47.100.191.150:9005/"; |
| | | public final String ROOT_URL_RELEASE_IMAGE = "http://47.100.191.150:9005/images/"; |
| | | private Retrofit retrofit; |
| | | private Retrofit retrofitImage; |
| | | private DaoSession daoSession; |
| | |
| | | |
| | | //初始化网络请求 |
| | | RetrofitFactory.init(this); |
| | | |
| | | //x5内核初始化 |
| | | Tbs.Companion.init(this); |
| | | |
| | | //Android8.0后注册通知通道 |
| | | MyNotificationChannel.Companion.init(this); |
| | | |
| | | //初始化移动推送 |
| | | PushService.Companion.init(this); |
| | | |
| | | if (instance == null) { |
| | | instance = this; |
| | |
| | | |
| | | if (released){ |
| | | retrofit = new Retrofit.Builder() |
| | | .baseUrl(ROOTURL_REALEASE) |
| | | .baseUrl(ROOT_URL_RELEASE) |
| | | .addConverterFactory(GsonConverterFactory.create(gson)) |
| | | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) |
| | | .build(); |
| | | }else { |
| | | retrofit = new Retrofit.Builder() |
| | | .baseUrl(ROOTURL) |
| | | .baseUrl(ROOT_URL) |
| | | .addConverterFactory(GsonConverterFactory.create(gson)) |
| | | .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) |
| | | .build(); |
| | |
| | | .create(); |
| | | if (released){ |
| | | retrofitImage = new Retrofit.Builder() |
| | | .baseUrl(ROOTURL_REALEASE_IMAGE) |
| | | .baseUrl(ROOT_URL_RELEASE_IMAGE) |
| | | .addConverterFactory(GsonConverterFactory.create(gson)) |
| | | .build(); |
| | | }else { |
| | | retrofitImage = new Retrofit.Builder() |
| | | .baseUrl(ROOTURL_IMAGE) |
| | | .baseUrl(ROOT_URL_IMAGE) |
| | | .addConverterFactory(GsonConverterFactory.create(gson)) |
| | | .build(); |
| | | } |
| | |
| | | public Userinfo getCurrentUser() { |
| | | if (currentUser ==null){ |
| | | userinfoDao = this.getDaoSession().getUserinfoDao(); |
| | | currentUser = userinfoDao.queryBuilder().unique(); |
| | | String userId = GlobalConfig.Companion.getInstance().getUserId(); |
| | | if (userId == null) { |
| | | currentUser = userinfoDao.queryBuilder().unique(); |
| | | } else { |
| | | currentUser = userinfoDao.queryBuilder().where(UserinfoDao.Properties.Guid.eq(userId)).unique(); |
| | | } |
| | | } |
| | | return currentUser; |
| | | } |
| | | |
| | | public void setCurrentUser(Userinfo currentUser) { |
| | | GlobalConfig.Companion.getInstance().setUserId(currentUser.getGuid()); |
| | | this.currentUser = currentUser; |
| | | } |
| | | |