|
@@ -8,6 +8,7 @@ import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.view.ViewStub;
|
|
|
+import android.widget.FrameLayout;
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
|
|
import com.cooleshow.base.R;
|
|
@@ -20,14 +21,16 @@ import androidx.annotation.NonNull;
|
|
|
import androidx.fragment.app.DialogFragment;
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
+import androidx.viewbinding.ViewBinding;
|
|
|
|
|
|
-public abstract class BaseFragment extends Fragment implements BaseView {
|
|
|
+public abstract class BaseFragment<V extends ViewBinding> extends Fragment implements BaseView {
|
|
|
protected Context mContext;
|
|
|
private View rootView;
|
|
|
- private ViewStub mViewStubContent;
|
|
|
+ private FrameLayout mViewStubContent;
|
|
|
private ViewStub mViewStubNoData;
|
|
|
private ViewStub mViewStubError;
|
|
|
private ProgressLoading mLoading;
|
|
|
+ protected V mViewBinding;
|
|
|
|
|
|
@Override
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
@@ -60,12 +63,12 @@ public abstract class BaseFragment extends Fragment implements BaseView {
|
|
|
mViewStubContent = view.findViewById(R.id.view_stub_content);
|
|
|
mViewStubNoData = view.findViewById(R.id.view_stub_nodata);
|
|
|
mViewStubError = view.findViewById(R.id.view_stub_error);
|
|
|
- mViewStubContent.setLayoutResource(getLayoutResId());
|
|
|
- mViewStubContent.inflate();
|
|
|
+ mViewBinding = getLayoutView();
|
|
|
+ mViewStubContent.addView(mViewBinding.getRoot());
|
|
|
mLoading = ProgressLoading.Companion.create(requireContext());
|
|
|
}
|
|
|
|
|
|
- protected abstract int getLayoutResId();
|
|
|
+ protected abstract V getLayoutView();
|
|
|
|
|
|
protected abstract void initView(View rootView);
|
|
|
|