| | |
| | | import android.widget.PopupWindow; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.annotation.Nullable; |
| | | import androidx.databinding.DataBindingUtil; |
| | | import androidx.databinding.ViewDataBinding; |
| | |
| | | import com.android.app_base.base.view.BaseFragment; |
| | | import com.android.app_base.base.viewmodel.BaseViewModel; |
| | | import com.android.app_base.manager.AppManager; |
| | | import com.android.app_base.manager.UserManager; |
| | | import com.android.app_base.utils.GlideUtil; |
| | | import com.application.zhangshi_app_android.R; |
| | | import com.application.zhangshi_app_android.ui.function.CertificateOfHonorActivity; |
| | | import com.application.zhangshi_app_android.ui.function.CleanStorageActivity; |
| | |
| | | import com.application.zhangshi_app_android.ui.function.PrivacyActivity; |
| | | import com.application.zhangshi_app_android.ui.function.PropertyActivity; |
| | | import com.application.zhangshi_app_android.ui.function.TourismActivity; |
| | | import com.application.zhangshi_app_android.ui.home.HomeFragment; |
| | | import com.hjq.bar.TitleBar; |
| | | |
| | | import java.util.HashMap; |
| | |
| | | mDrawerLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); |
| | | VDB mBinding = DataBindingUtil.inflate(inflater, getLayoutId(), mDrawerLayout, true); |
| | | if (getDrawerLayoutId() > 0){ |
| | | getLayoutInflater().inflate(getDrawerLayoutId(), mDrawerLayout, true); |
| | | inflater.inflate(getDrawerLayoutId(), mDrawerLayout, true); |
| | | }else { |
| | | throw new IllegalArgumentException("没给侧拉栏布局就不要开启侧拉栏啦"); |
| | | } |
| | |
| | | return super.initViewBinding(inflater, container); |
| | | } |
| | | |
| | | @Nullable |
| | | @Override |
| | | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| | | isLoaded = false; |
| | | if (getLayoutId() > 0){ |
| | | binding = initViewBinding(inflater, container); |
| | | if (isDrawerLayoutEnabled()) { |
| | | //如果开启了侧拉栏,就把布局放到侧拉栏里面 |
| | | mRootView = mDrawerLayout; |
| | | }else { |
| | | mRootView = binding.getRoot(); |
| | | } |
| | | return mRootView; |
| | | } |
| | | return null; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 是否开启侧拉栏 |
| | |
| | | */ |
| | | protected int getDrawerLayoutId(){ |
| | | return R.layout.layout_drawer; |
| | | }; |
| | | } |
| | | |
| | | @Override |
| | | public void onCreate(@Nullable Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | |
| | | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
| | | super.onViewCreated(view, savedInstanceState); |
| | | if (mDrawerLayout != null) { |
| | | classMap.put(null,(LinearLayout) findViewById(R.id.dl_home_root_net)); |
| | | classMap.put(HomeFragment.class,(LinearLayout) findViewById(R.id.dl_home_root_net)); |
| | | classMap.put(FamilyMemorabiliaActivity.class,(LinearLayout) findViewById(R.id.dl_family_memorabilia)); |
| | | classMap.put(FamilyAssetsActivity.class,(LinearLayout) findViewById(R.id.dl_family_assets)); |
| | | classMap.put(HomeDevicesActivity.class,(LinearLayout) findViewById(R.id.dl_home_devices)); |
| | |
| | | } |
| | | } |
| | | mDrawerLayout.setScrimColor(getResources().getColor(R.color.color_shadow)); |
| | | GlideUtil.loadImage(UserManager.getInstance().getUserAvatar(), findViewById(R.id.dl_home_user_avatar)); |
| | | TextView userNameTv = findViewById(R.id.dl_home_user_name); |
| | | userNameTv.setText(UserManager.getInstance().getUserName()); |
| | | } |
| | | } |
| | | private void setSelectItem(LinearLayout linearLayout) { |
| | |
| | | mDrawerLayout.open(); |
| | | } |
| | | |
| | | |
| | | |
| | | public PopupWindow initPopUpWindow(View view){ |
| | | PopupWindow popupWindow = new PopupWindow(getSelfActivity()); |
| | | // 设置布局文件 |