| | |
| | | |
| | | import androidx.annotation.Nullable; |
| | | import androidx.fragment.app.Fragment; |
| | | import androidx.lifecycle.ViewModel; |
| | | import androidx.lifecycle.ViewModelProvider; |
| | | import androidx.viewbinding.ViewBinding; |
| | | |
| | | import com.auto.lyric.base.activities.BaseActivity; |
| | | import com.auto.lyric.base.model.BaseViewModel; |
| | | import com.auto.lyric.base.model.ViewModelFactory; |
| | | |
| | | import java.lang.reflect.Method; |
| | |
| | | * fragment 封装 |
| | | * Created by Administrator on 2021/10/28 0028. |
| | | */ |
| | | public abstract class BaseFragment<B extends ViewBinding,VM extends ViewModel> extends Fragment { |
| | | public abstract class BaseFragment<B extends ViewBinding,VM extends BaseViewModel> extends Fragment { |
| | | |
| | | protected BaseActivity activity; |
| | | protected B binding; |
| | |
| | | public void onActivityCreated(@Nullable Bundle savedInstanceState) { |
| | | super.onActivityCreated(savedInstanceState); |
| | | activity = (BaseActivity) getActivity(); |
| | | viewModel.onCreate(activity); |
| | | initViews(); |
| | | } |
| | | |