管灌系统巡查员智能手机App
zuoxiao
2024-09-20 13b3e727a6c252887cea8aa6b0856c967f036731
app/src/main/java/com/dayu/pipirrapp/fragment/MyFragment.java
@@ -10,6 +10,8 @@
import androidx.annotation.Nullable;
import com.dayu.pipirrapp.activity.ChangePSActivity;
import com.dayu.pipirrapp.bean.db.LoginBean;
import com.dayu.pipirrapp.dao.DaoSingleton;
import com.dayu.pipirrapp.databinding.FragmentMapBinding;
import com.dayu.pipirrapp.databinding.FragmentMyBinding;
import com.dayu.pipirrapp.view.TitleBar;
@@ -28,11 +30,11 @@
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = FragmentMyBinding.inflate(inflater, container, false);
        initView();
        initData();
        return binding.getRoot();
    }
    private void initView() {
        new TitleBar(this.getActivity()).setTitleText("我的");
        binding.changePS.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
@@ -40,7 +42,20 @@
                MyFragment.this.getActivity().startActivity(intent);
            }
        });
        LoginBean loginBean = DaoSingleton.getInstance(MyFragment.this.getContext()).loginDao().findFirst();
        if (loginBean != null) {
            binding.name.setText(loginBean.getName());
            binding.phone.setText(loginBean.getPhone());
        }
    }
    private void initData() {
        LoginBean loginBean = DaoSingleton.getInstance(MyFragment.this.getContext()).loginDao().findFirst();
        if (loginBean != null) {
            binding.name.setText(loginBean.getName());
            binding.phone.setText(loginBean.getPhone());
        }
    }
}