| | |
| | | |
| | | import com.duqing.missions.MyApplication; |
| | | import com.duqing.missions.R; |
| | | import com.duqing.missions.base.ViewModelFactory; |
| | | import com.duqing.missions.data.ApkUpGradeResult; |
| | | import com.duqing.missions.util.MyLog; |
| | | import com.duqing.missions.util.ResPonse; |
| | |
| | | // get genericity "B" |
| | | setStatusBarBgColor(R.color.white); |
| | | setStatusBarTextColor(true); |
| | | final ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass(); |
| | | try { |
| | | final ParameterizedType type = (ParameterizedType) this.getClass().getGenericSuperclass(); |
| | | Class<B> entityClass = (Class<B>) type.getActualTypeArguments()[0]; |
| | | Method method = entityClass.getMethod("inflate", LayoutInflater.class);//get method from name "inflate"; |
| | | binding = (B) method.invoke(entityClass,getLayoutInflater());//execute method to create a objct of viewbind; |
| | | Class<VM> vmClass = (Class<VM>) type.getActualTypeArguments()[1]; |
| | | viewModel = new ViewModelProvider(this).get(vmClass); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | Class<VM> vmClass = (Class<VM>) type.getActualTypeArguments()[1]; |
| | | viewModel = new ViewModelProvider(this,getViewModelFactory()).get(vmClass); |
| | | setContentView(binding.getRoot()); |
| | | mContext = this; |
| | | try { |
| | |
| | | |
| | | public abstract void initViews(); |
| | | |
| | | public ViewModelProvider.Factory getViewModelFactory(){ |
| | | return ViewModelFactory.getInstance(); |
| | | } |
| | | |
| | | public void setStatusBarTransparent(boolean isBlack){ |
| | | //透明状态栏 |