首页>代码>最新架构(KotLin+Retrofit2+RxJava2+MVP)基础框架搭建实例,直接可以使用>/kotlinM-master/app/src/main/java/com/hao/m/base/BaseFragment.java
package com.hao.m.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.hao.m.utils.Density;
import com.trello.rxlifecycle2.components.support.RxFragment;

import java.util.Objects;

/**
 * Created by wangpw
 */

public abstract class BaseFragment extends RxFragment {

    private View view;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        base();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        view = inflater.inflate(layoutResId(), container, false);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        init();
        logic();
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }

    public void base() {
        Density.INSTANCE.setDefault(Objects.requireNonNull(this.getActivity()));
    }
    protected <T extends View> T getViewById(int resId) {
        return this.view.findViewById(resId);
    }
    public abstract int layoutResId();

    public abstract void init();

    public abstract void logic();


}
最近下载更多
wangzhiguo  LV1 2023年1月1日
tangtang111  LV1 2021年3月19日
鸣伟天下  LV1 2021年2月24日
li1373203469  LV1 2020年12月15日
luolukka  LV8 2020年11月22日
慵懒的蚊子  LV1 2020年10月28日
自己人  LV5 2020年5月9日
a417298302  LV3 2020年5月8日
licheng798  LV3 2020年4月26日
zdm点点滴滴  LV1 2020年4月25日
最近浏览更多
wangzhiguo  LV1 2023年1月1日
流连瓦盖法  LV7 2022年11月8日
ctr1990 2022年7月29日
暂无贡献等级
诗意的成长  LV5 2022年5月11日
xueys123  LV13 2022年1月17日
lvbs977  LV2 2021年6月25日
阿风啦  LV14 2021年4月16日
tangtang111  LV1 2021年3月19日
鸣伟天下  LV1 2021年2月24日
luolukka  LV8 2020年11月22日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友