|
|
|
@ -1,10 +1,13 @@
|
|
|
|
|
package com.example.PersonalCenter;
|
|
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
@ -15,12 +18,20 @@ import androidx.fragment.app.Fragment;
|
|
|
|
|
import androidx.fragment.app.FragmentStatePagerAdapter;
|
|
|
|
|
import androidx.viewpager.widget.ViewPager;
|
|
|
|
|
|
|
|
|
|
import com.example.PersonalCenter.Login_Register.LoginActivity;
|
|
|
|
|
import com.example.Util.User;
|
|
|
|
|
import com.example.cmknowledgegraph.MainActivity;
|
|
|
|
|
import com.example.cmknowledgegraph.R;
|
|
|
|
|
import com.github.florent37.materialviewpager.MaterialViewPager;
|
|
|
|
|
import com.github.florent37.materialviewpager.header.HeaderDesign;
|
|
|
|
|
|
|
|
|
|
import de.hdodenhof.circleimageview.CircleImageView;
|
|
|
|
|
|
|
|
|
|
public class MyPersonCenter extends Fragment {
|
|
|
|
|
private CircleImageView iv_avatar;
|
|
|
|
|
private TextView iv_avatar_username;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MainActivity mainActivity;
|
|
|
|
|
@Override
|
|
|
|
|
public void onAttach(Context context) {
|
|
|
|
@ -39,6 +50,18 @@ public class MyPersonCenter extends Fragment {
|
|
|
|
|
super.onActivityCreated(savedInstanceState);
|
|
|
|
|
//包装处理逻辑
|
|
|
|
|
//得到MaterViewPager实例
|
|
|
|
|
iv_avatar = mainActivity.findViewById(R.id.iv_avatar);
|
|
|
|
|
iv_avatar_username = mainActivity.findViewById(R.id.iv_avatar_username);
|
|
|
|
|
iv_avatar.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
if(!User.isLogin){
|
|
|
|
|
Intent intent=new Intent();
|
|
|
|
|
intent.setClass(getActivity(), LoginActivity.class);
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
MaterialViewPager materialViewPager = (MaterialViewPager) getActivity().findViewById(R.id.materialViewPager);
|
|
|
|
|
//为MaterialViewPager添加监听
|
|
|
|
|
materialViewPager.setMaterialViewPagerListener(new MaterialViewPager.Listener() {
|
|
|
|
@ -120,4 +143,13 @@ public class MyPersonCenter extends Fragment {
|
|
|
|
|
.getViewPager().getAdapter().getCount());
|
|
|
|
|
materialViewPager.getPagerTitleStrip().setViewPager(materialViewPager.getViewPager());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
|
|
|
|
if(User.isLogin){
|
|
|
|
|
|
|
|
|
|
iv_avatar_username.setText("Hello"+User.getUser().getUsername());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|