Commit 9921f315749aec0bcf17179ab6db4332dea4cea9

Authored by 谷俊
1 parent f436290c

添加编辑用户信息页面及接口

app/src/main/AndroidManifest.xml
@@ -78,7 +78,6 @@ @@ -78,7 +78,6 @@
78 <activity 78 <activity
79 android:name=".user.activity.UserPersonalActivity" 79 android:name=".user.activity.UserPersonalActivity"
80 android:configChanges="orientation|keyboardHidden|screenSize" 80 android:configChanges="orientation|keyboardHidden|screenSize"
81 - android:launchMode="singleTop"  
82 android:screenOrientation="portrait" 81 android:screenOrientation="portrait"
83 android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> 82 android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
84 </application> 83 </application>
app/src/main/java/com/cnlive/gundam/main/ui/activity/BackBaseActivity.java 0 → 100644
  1 +package com.cnlive.gundam.main.ui.activity;
  2 +
  3 +import android.support.v7.app.AppCompatActivity;
  4 +import android.support.v7.widget.Toolbar;
  5 +import android.view.MenuItem;
  6 +import android.view.View;
  7 +import android.widget.TextView;
  8 +
  9 +import com.cnlive.gundam.R;
  10 +
  11 +/**
  12 + * Created by gujun on 2017/5/31.
  13 + */
  14 +
  15 +public class BackBaseActivity extends AppCompatActivity {
  16 +
  17 + private Toolbar toolbar;
  18 +
  19 + protected void setupToolBar(String title) {
  20 + toolbar = (Toolbar) findViewById(R.id.toolbar);
  21 + toolbar.setTitle("");
  22 + TextView toolbarTitle = (TextView) findViewById(R.id.toolbarTitle);
  23 + toolbarTitle.setText(title);
  24 + toolbar.setVisibility(View.VISIBLE);
  25 + toolbar.setNavigationIcon(R.drawable.ic_close);
  26 + setSupportActionBar(toolbar);
  27 +
  28 + }
  29 +
  30 + public void setToolBarVisible(boolean show) {
  31 + if (toolbar == null) return;
  32 + toolbar.setVisibility(show ? View.VISIBLE : View.GONE);
  33 + }
  34 +
  35 + @Override
  36 + public boolean onOptionsItemSelected(MenuItem item) {
  37 + if (item.getItemId() == android.R.id.home) {
  38 + this.onBackPressed();
  39 + }
  40 + return super.onOptionsItemSelected(item);
  41 + }
  42 +}
app/src/main/java/com/cnlive/gundam/main/ui/adapter/DataBindingAdapter.java
@@ -17,11 +17,11 @@ import com.cnlive.gundam.main.ui.adapter.holder.DataBindingViewHolder; @@ -17,11 +17,11 @@ import com.cnlive.gundam.main.ui.adapter.holder.DataBindingViewHolder;
17 17
18 public class DataBindingAdapter<T> extends BaseRecyclerAdapter<T> { 18 public class DataBindingAdapter<T> extends BaseRecyclerAdapter<T> {
19 private int layoutId; 19 private int layoutId;
20 - private int itemBRId; 20 + protected int itemBRId;
21 private int imageHeightBRId = -1; 21 private int imageHeightBRId = -1;
22 private int imageHeight; 22 private int imageHeight;
23 23
24 - private OnAdapterViewClickListener<T> l; 24 + protected OnAdapterViewClickListener<T> l;
25 private OnAdapterViewLoadMoreListener loadMoreListener; 25 private OnAdapterViewLoadMoreListener loadMoreListener;
26 26
27 public DataBindingAdapter(Context context, int layoutId, int itemBRId) { 27 public DataBindingAdapter(Context context, int layoutId, int itemBRId) {
app/src/main/java/com/cnlive/gundam/main/ui/fragment/ConfigFragment.java
@@ -13,6 +13,7 @@ import com.cnlive.gundam.R; @@ -13,6 +13,7 @@ import com.cnlive.gundam.R;
13 import com.cnlive.gundam.databinding.UserFragmentBinding; 13 import com.cnlive.gundam.databinding.UserFragmentBinding;
14 import com.cnlive.gundam.user.activity.CommentActivity; 14 import com.cnlive.gundam.user.activity.CommentActivity;
15 import com.cnlive.gundam.user.activity.LoginActivity; 15 import com.cnlive.gundam.user.activity.LoginActivity;
  16 +import com.cnlive.gundam.user.activity.UserPersonalActivity;
16 import com.cnlive.gundam.user.auth.UserService; 17 import com.cnlive.gundam.user.auth.UserService;
17 18
18 19
@@ -70,7 +71,9 @@ public class ConfigFragment extends Fragment implements View.OnClickListener { @@ -70,7 +71,9 @@ public class ConfigFragment extends Fragment implements View.OnClickListener {
70 int uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid(); 71 int uid = UserService.getInstance(getActivity()).getActiveAccountInfo().getUid();
71 if (uid != 0) { 72 if (uid != 0) {
72 //进入个人中心页面 73 //进入个人中心页面
73 - //startActivity(new Intent(getActivity(), UserPersonalActivity.class)); 74 + Intent intent = new Intent(getActivity(), UserPersonalActivity.class);
  75 + intent.putExtra("isEdit",false);
  76 + startActivity(intent);
74 } else { 77 } else {
75 //进入登录页面 78 //进入登录页面
76 startActivity(new Intent(getActivity(), LoginActivity.class)); 79 startActivity(new Intent(getActivity(), LoginActivity.class));
app/src/main/java/com/cnlive/gundam/user/activity/UserPersonalActivity.java
1 package com.cnlive.gundam.user.activity; 1 package com.cnlive.gundam.user.activity;
2 2
  3 +import android.content.Intent;
3 import android.databinding.DataBindingUtil; 4 import android.databinding.DataBindingUtil;
4 import android.os.Bundle; 5 import android.os.Bundle;
5 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
6 -import android.support.v7.app.AppCompatActivity;  
7 7
8 import com.cnlive.gundam.R; 8 import com.cnlive.gundam.R;
  9 +import com.cnlive.gundam.main.ui.activity.BackBaseActivity;
  10 +import com.cnlive.gundam.user.fragment.UserPersonalEditFragment;
9 import com.cnlive.gundam.user.fragment.UserPersonalFragment; 11 import com.cnlive.gundam.user.fragment.UserPersonalFragment;
10 12
11 /** 13 /**
@@ -13,11 +15,24 @@ import com.cnlive.gundam.user.fragment.UserPersonalFragment; @@ -13,11 +15,24 @@ import com.cnlive.gundam.user.fragment.UserPersonalFragment;
13 * @time 2017/6/28 12:56 15 * @time 2017/6/28 12:56
14 * @desc ${TODD} 16 * @desc ${TODD}
15 */ 17 */
16 -public class UserPersonalActivity extends AppCompatActivity { 18 +public class UserPersonalActivity extends BackBaseActivity {
17 @Override 19 @Override
18 protected void onCreate(@Nullable Bundle savedInstanceState) { 20 protected void onCreate(@Nullable Bundle savedInstanceState) {
19 super.onCreate(savedInstanceState); 21 super.onCreate(savedInstanceState);
20 - DataBindingUtil.setContentView(this, R.layout.activity_setting);  
21 - getSupportFragmentManager().beginTransaction().replace(R.id.setting_fragment, UserPersonalFragment.newInstance()).commit(); 22 + DataBindingUtil.setContentView(this, R.layout.activity_user_personal);
  23 + addFragment(getIntent());
  24 + }
  25 +
  26 + private void addFragment(Intent intent ){
  27 + if (intent.hasExtra("isEdit")) {
  28 + getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout,
  29 + intent.getBooleanExtra("isEdit",false) ?
  30 + UserPersonalEditFragment.newInstance(intent.getIntExtra("type", 0)) :
  31 + UserPersonalFragment.newInstance()).commit();
  32 + }
  33 + }
  34 +
  35 + public void setTitle(String title){
  36 + setupToolBar(title);
22 } 37 }
23 } 38 }
app/src/main/java/com/cnlive/gundam/user/adapter/PersonalAdapter.java 0 → 100644
  1 +package com.cnlive.gundam.user.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.databinding.DataBindingUtil;
  5 +import android.databinding.ViewDataBinding;
  6 +import android.support.v7.widget.RecyclerView;
  7 +import android.view.LayoutInflater;
  8 +import android.view.ViewGroup;
  9 +
  10 +import com.cnlive.gundam.BR;
  11 +import com.cnlive.gundam.R;
  12 +import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter;
  13 +import com.cnlive.gundam.main.ui.adapter.holder.DataBindingViewHolder;
  14 +import com.cnlive.gundam.user.model.PersonalData;
  15 +
  16 +/**
  17 + * Created by gujun on 2017/6/28.
  18 + */
  19 +
  20 +public class PersonalAdapter extends DataBindingAdapter<PersonalData>{
  21 +
  22 + public PersonalAdapter(Context context, int layoutId, int itemBRId) {
  23 + super(context, layoutId, itemBRId);
  24 + }
  25 +
  26 + @Override
  27 + public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  28 + if(viewType == PersonalData.TYPE_HEADER){
  29 + ViewDataBinding binding = DataBindingUtil.inflate(LayoutInflater.from(mContext), R.layout.layout_personal_header_item, parent, false);
  30 + DataBindingViewHolder viewHolder = new DataBindingViewHolder(binding.getRoot());
  31 + viewHolder.setBinding(binding);
  32 + return viewHolder;
  33 + }else{
  34 + return super.onCreateViewHolder(parent, viewType);
  35 + }
  36 + }
  37 +
  38 + @Override
  39 + public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
  40 + if(getItem(position).getItemType() == PersonalData.TYPE_HEADER){
  41 + DataBindingViewHolder videoListViewHolder = (DataBindingViewHolder) holder;
  42 + videoListViewHolder.getBinding().setVariable(itemBRId, getItem(position));
  43 + if (l != null)
  44 + videoListViewHolder.getBinding().setVariable(BR.viewClickListner, l);
  45 + videoListViewHolder.getBinding().executePendingBindings();
  46 + }else{
  47 + super.onBindViewHolder(holder, position);
  48 + }
  49 + }
  50 +
  51 + @Override
  52 + public int getItemViewType(int position) {
  53 + return getItem(position).getItemType();
  54 + }
  55 +}
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalEditFragment.java 0 → 100644
  1 +package com.cnlive.gundam.user.fragment;
  2 +
  3 +import android.databinding.DataBindingUtil;
  4 +import android.os.Bundle;
  5 +import android.support.annotation.Nullable;
  6 +import android.support.v4.app.Fragment;
  7 +import android.view.LayoutInflater;
  8 +import android.view.View;
  9 +import android.view.ViewGroup;
  10 +import android.widget.Toast;
  11 +
  12 +import com.cnlive.gundam.R;
  13 +import com.cnlive.gundam.databinding.FragmentPersonalEditBinding;
  14 +import com.cnlive.gundam.user.activity.UserPersonalActivity;
  15 +import com.cnlive.gundam.user.auth.UserService;
  16 +import com.cnlive.gundam.user.model.User;
  17 +import com.cnlive.libs.user.IUserService;
  18 +import com.cnlive.libs.user.UserUtil;
  19 +import com.cnlive.libs.util.data.network.Callback;
  20 +
  21 +/**
  22 + * Created by gujun on 2017/6/28.
  23 + */
  24 +
  25 +public class UserPersonalEditFragment extends Fragment implements Callback, View.OnClickListener {
  26 +
  27 + public static final int TYPE_NICK = 0x1001;
  28 + public static final int TYPE_MOBILE = 0x1002;
  29 + public static final int TYPE_EMAIL = 0x1003;
  30 + public static final int TYPE_ADDRESS = 0x1004;
  31 +
  32 + private FragmentPersonalEditBinding binding;
  33 + private int type;
  34 + private User user;
  35 +
  36 + public static UserPersonalEditFragment newInstance(int type) {
  37 +
  38 + Bundle args = new Bundle();
  39 + args.putInt("type", type);
  40 + UserPersonalEditFragment fragment = new UserPersonalEditFragment();
  41 + fragment.setArguments(args);
  42 + return fragment;
  43 + }
  44 +
  45 + @Nullable
  46 + @Override
  47 + public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  48 + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_personal_edit, container, false);
  49 + return binding.getRoot();
  50 + }
  51 +
  52 + @Override
  53 + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  54 + super.onViewCreated(view, savedInstanceState);
  55 + init();
  56 + }
  57 +
  58 + private void init() {
  59 + binding.setUserPersonalEditFragment(this);
  60 + type = getArguments().getInt("type");
  61 + UserService userService = UserService.getInstance(getActivity());
  62 + user = userService.getActiveAccountInfo();
  63 + String title = "";
  64 + switch (type) {
  65 + case TYPE_NICK:
  66 + binding.editText.setText(user.getNickname());
  67 + binding.editText.setVisibility(View.VISIBLE);
  68 + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.GONE);
  69 + title = "修改昵称";
  70 + break;
  71 + case TYPE_MOBILE:
  72 + binding.editText.setVisibility(View.GONE);
  73 + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.VISIBLE);
  74 + binding.includeMobileLayout.edtLoginNumber.setText(user.getMobile());
  75 + binding.includeMobileLayout.getVerify.setOnClickListener(this);
  76 + title = "修改手机号";
  77 + break;
  78 + case TYPE_EMAIL:
  79 + binding.editText.setText(user.getEmail());
  80 + binding.editText.setVisibility(View.VISIBLE);
  81 + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.GONE);
  82 + title = "修改邮箱";
  83 + break;
  84 + case TYPE_ADDRESS:
  85 + binding.editText.setText(user.getLocation());
  86 + binding.editText.setVisibility(View.VISIBLE);
  87 + binding.includeMobileLayout.mobileKeycodeLayout.setVisibility(View.GONE);
  88 + title = "修改地址";
  89 + break;
  90 + }
  91 + ((UserPersonalActivity)getActivity()).setTitle(title);
  92 + }
  93 +
  94 + @Override
  95 + public void onClick(View v) {
  96 + if (v.getId() == R.id.submit) {
  97 + switch (type) {
  98 + case TYPE_NICK:
  99 + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "nickName", binding.editText.getText().toString(), this);
  100 + break;
  101 + case TYPE_MOBILE:
  102 + UserUtil.updateMobile(String.valueOf(user.getUid()), binding.includeMobileLayout.edtLoginNumber.getText().toString(), binding.includeMobileLayout.edtVerify.getText().toString(), this);
  103 + break;
  104 + case TYPE_EMAIL:
  105 + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "email", binding.editText.getText().toString(), this);
  106 + break;
  107 + case TYPE_ADDRESS:
  108 + UserUtil.modifyUserInfo(String.valueOf(user.getUid()), "location", binding.editText.getText().toString(), this);
  109 + break;
  110 + }
  111 + } else if (v.getId() == R.id.get_verify) {
  112 + //TODO 获取验证码
  113 + UserUtil.sendMessage(IUserService.REGISTER_OR_MODIFY_MOBILE, binding.includeMobileLayout.edtLoginNumber.getText().toString(), new Callback() {
  114 + @Override
  115 + public void onState(int i, String s, Object o) {
  116 + if (i == IUserService.SUCCESS) {
  117 + Toast.makeText(getActivity(), "验证码已发送", Toast.LENGTH_LONG).show();
  118 + } else {
  119 + Toast.makeText(getActivity(), "获取验证码失败" + s, Toast.LENGTH_LONG).show();
  120 + }
  121 +
  122 + }
  123 + });
  124 + }
  125 + }
  126 +
  127 + @Override
  128 + public void onState(int i, String s, Object o) {
  129 + if (i == IUserService.SUCCESS) {
  130 + Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_LONG).show();
  131 + } else {
  132 + Toast.makeText(getActivity(), "提交失败" + s, Toast.LENGTH_LONG).show();
  133 + }
  134 +
  135 + //TODO 更新一下本地数据
  136 + }
  137 +}
app/src/main/java/com/cnlive/gundam/user/fragment/UserPersonalFragment.java
1 package com.cnlive.gundam.user.fragment; 1 package com.cnlive.gundam.user.fragment;
2 2
  3 +import android.content.Intent;
3 import android.databinding.DataBindingUtil; 4 import android.databinding.DataBindingUtil;
4 import android.os.Bundle; 5 import android.os.Bundle;
5 import android.support.annotation.Nullable; 6 import android.support.annotation.Nullable;
6 import android.support.v4.app.Fragment; 7 import android.support.v4.app.Fragment;
  8 +import android.support.v7.widget.LinearLayoutManager;
7 import android.view.LayoutInflater; 9 import android.view.LayoutInflater;
8 import android.view.View; 10 import android.view.View;
9 import android.view.ViewGroup; 11 import android.view.ViewGroup;
  12 +import android.widget.Toast;
10 13
  14 +import com.cnlive.gundam.BR;
11 import com.cnlive.gundam.R; 15 import com.cnlive.gundam.R;
12 import com.cnlive.gundam.databinding.FragmentUserPersonalBinding; 16 import com.cnlive.gundam.databinding.FragmentUserPersonalBinding;
  17 +import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter;
  18 +import com.cnlive.gundam.user.activity.UserPersonalActivity;
  19 +import com.cnlive.gundam.user.adapter.PersonalAdapter;
  20 +import com.cnlive.gundam.user.auth.UserService;
  21 +import com.cnlive.gundam.user.model.PersonalData;
  22 +import com.cnlive.gundam.user.model.User;
13 23
  24 +import java.util.ArrayList;
  25 +import java.util.List;
14 26
15 27
16 /** 28 /**
@@ -18,35 +30,93 @@ import com.cnlive.gundam.databinding.FragmentUserPersonalBinding; @@ -18,35 +30,93 @@ import com.cnlive.gundam.databinding.FragmentUserPersonalBinding;
18 * @time 2017/6/28 13:06 30 * @time 2017/6/28 13:06
19 * @desc ${TODD} 31 * @desc ${TODD}
20 */ 32 */
21 -public class UserPersonalFragment extends Fragment{ 33 +public class UserPersonalFragment extends Fragment implements DataBindingAdapter.OnAdapterViewClickListener<PersonalData> {
22 34
23 private FragmentUserPersonalBinding binding; 35 private FragmentUserPersonalBinding binding;
24 36
  37 + private PersonalAdapter adapter;
25 38
26 - @Nullable  
27 - @Override  
28 - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  
29 - binding = DataBindingUtil.inflate(inflater, R.layout.fragment_user_personal, container, false);  
30 - return binding.getRoot();  
31 - } 39 + private List<PersonalData> personalData;
32 40
33 public static UserPersonalFragment newInstance() { 41 public static UserPersonalFragment newInstance() {
  42 +
  43 + Bundle args = new Bundle();
  44 +
34 UserPersonalFragment fragment = new UserPersonalFragment(); 45 UserPersonalFragment fragment = new UserPersonalFragment();
  46 + fragment.setArguments(args);
35 return fragment; 47 return fragment;
36 } 48 }
37 49
  50 + @Nullable
38 @Override 51 @Override
39 - public void onActivityCreated(Bundle savedInstanceState) {  
40 - super.onActivityCreated(savedInstanceState);  
41 - initToolBar();  
42 - /*init();  
43 - PersonalHeadItem.getContent(getActivity());  
44 - PersonalItem.getContent(getActivity());*/ 52 + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  53 + binding = DataBindingUtil.inflate(inflater, R.layout.fragment_user_personal, container, false);
  54 + return binding.getRoot();
45 } 55 }
46 - private void initToolBar() {  
47 - binding.personalIncludeLayout.toolbarTitle.setText("个人资料"); 56 +
  57 + @Override
  58 + public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  59 + super.onViewCreated(view, savedInstanceState);
  60 + initData();
  61 + init();
48 } 62 }
49 63
  64 + private void initData() {
  65 + UserService userService = UserService.getInstance(getActivity());
  66 + User user = userService.getActiveAccountInfo();
  67 + personalData = new ArrayList<>();
  68 + personalData.add(new PersonalData("头像", user.getFaceurl(), PersonalData.TYPE_HEADER));
  69 + personalData.add(new PersonalData("昵称", user.getNickname(), PersonalData.TYPE_NICK));
  70 + personalData.add(new PersonalData("性别", user.getGender(), PersonalData.TYPE_GENDER));
  71 + personalData.add(new PersonalData("手机号", user.getMobile(), PersonalData.TYPE_MOBILE));
  72 + personalData.add(new PersonalData("邮箱", user.getEmail(), PersonalData.TYPE_EMAIL));
  73 + personalData.add(new PersonalData("联系地址", user.getLocation(), PersonalData.TYPE_ADDRESS));
  74 + }
50 75
  76 + private void init() {
  77 + ((UserPersonalActivity)getActivity()).setTitle("个人资料");
  78 + binding.setListAdapter(adapter = new PersonalAdapter(getActivity(), R.layout.layout_personal_item, BR.data));
  79 + binding.setLayoutManager(new LinearLayoutManager(getActivity()));
  80 + adapter.updateItems(personalData);
  81 + adapter.setOnViewClickListener(this);
  82 + }
51 83
  84 + @Override
  85 + public void onViewClick(View v, PersonalData program) {
  86 + if (v.getId() == R.id.itemLayout) {
  87 + Intent intent = null;
  88 + switch (program.getItemType()) {
  89 + case PersonalData.TYPE_HEADER:
  90 + Toast.makeText(getActivity(), "头像点击", Toast.LENGTH_LONG).show();
  91 + break;
  92 + case PersonalData.TYPE_NICK:
  93 + intent = new Intent(getActivity(), UserPersonalActivity.class);
  94 + intent.putExtra("isEdit",true);
  95 + intent.putExtra("type", UserPersonalEditFragment.TYPE_NICK);
  96 + startActivity(intent);
  97 + break;
  98 + case PersonalData.TYPE_GENDER:
  99 + Toast.makeText(getActivity(), "性别点击", Toast.LENGTH_LONG).show();
  100 + break;
  101 + case PersonalData.TYPE_MOBILE:
  102 + intent = new Intent(getActivity(), UserPersonalActivity.class);
  103 + intent.putExtra("isEdit",true);
  104 + intent.putExtra("type", UserPersonalEditFragment.TYPE_MOBILE);
  105 + startActivity(intent);
  106 + break;
  107 + case PersonalData.TYPE_EMAIL:
  108 + intent = new Intent(getActivity(), UserPersonalActivity.class);
  109 + intent.putExtra("isEdit",true);
  110 + intent.putExtra("type", UserPersonalEditFragment.TYPE_EMAIL);
  111 + startActivity(intent);
  112 + break;
  113 + case PersonalData.TYPE_ADDRESS:
  114 + intent = new Intent(getActivity(), UserPersonalActivity.class);
  115 + intent.putExtra("isEdit",true);
  116 + intent.putExtra("type", UserPersonalEditFragment.TYPE_ADDRESS);
  117 + startActivity(intent);
  118 + break;
  119 + }
  120 + }
  121 + }
52 } 122 }
app/src/main/java/com/cnlive/gundam/user/model/PersonalDate.java renamed to app/src/main/java/com/cnlive/gundam/user/model/PersonalData.java
@@ -5,7 +5,25 @@ package com.cnlive.gundam.user.model; @@ -5,7 +5,25 @@ package com.cnlive.gundam.user.model;
5 * @time 2017/6/28 13:55 5 * @time 2017/6/28 13:55
6 * @desc ${TODD} 6 * @desc ${TODD}
7 */ 7 */
8 -public class PersonalDate { 8 +public class PersonalData {
  9 +
  10 + private String itemName;
  11 + private String itemMessage;
  12 + private int itemType;
  13 +
  14 + public static final int TYPE_HEADER = 0x1001;
  15 + public static final int TYPE_NICK = 0x1002;
  16 + public static final int TYPE_GENDER = 0x1003;
  17 + public static final int TYPE_MOBILE = 0x1004;
  18 + public static final int TYPE_EMAIL = 0x1005;
  19 + public static final int TYPE_ADDRESS = 0x1006;
  20 +
  21 + public PersonalData(String itemName, String itemMessage, int itemType) {
  22 + this.itemName = itemName;
  23 + this.itemMessage = itemMessage;
  24 + this.itemType = itemType;
  25 + }
  26 +
9 public String getItemName() { 27 public String getItemName() {
10 return itemName; 28 return itemName;
11 } 29 }
@@ -14,8 +32,6 @@ public class PersonalDate { @@ -14,8 +32,6 @@ public class PersonalDate {
14 this.itemName = itemName; 32 this.itemName = itemName;
15 } 33 }
16 34
17 - private String itemName;  
18 -  
19 public String getItemMessage() { 35 public String getItemMessage() {
20 return itemMessage; 36 return itemMessage;
21 } 37 }
@@ -24,18 +40,11 @@ public class PersonalDate { @@ -24,18 +40,11 @@ public class PersonalDate {
24 this.itemMessage = itemMessage; 40 this.itemMessage = itemMessage;
25 } 41 }
26 42
27 - private String itemMessage;  
28 -  
29 -  
30 -  
31 - public PersonalDate(String itemName, String itemMessage) {  
32 - this.itemName = itemName;  
33 - this.itemMessage = itemMessage; 43 + public int getItemType() {
  44 + return itemType;
34 } 45 }
35 46
36 -  
37 -  
38 -  
39 -  
40 - 47 + public void setItemType(int itemType) {
  48 + this.itemType = itemType;
  49 + }
41 } 50 }
app/src/main/res/layout/activity_user_personal.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <data>
  5 +
  6 + </data>
  7 +
  8 + <LinearLayout
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:orientation="vertical">
  12 +
  13 + <include
  14 + layout="@layout/layout_actionbar_back"/>
  15 +
  16 + <RelativeLayout
  17 + android:id="@+id/contentLayout"
  18 + android:layout_width="match_parent"
  19 + android:layout_height="match_parent"/>
  20 +
  21 + </LinearLayout>
  22 +
  23 +</layout>
0 \ No newline at end of file 24 \ No newline at end of file
app/src/main/res/layout/fragment_personal_edit.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <data>
  5 +
  6 + <import type="com.cnlive.gundam.user.fragment.UserPersonalEditFragment" />
  7 +
  8 + <variable
  9 + name="userPersonalEditFragment"
  10 + type="UserPersonalEditFragment" />
  11 +
  12 + </data>
  13 +
  14 + <RelativeLayout
  15 + android:layout_width="match_parent"
  16 + android:layout_height="match_parent">
  17 +
  18 + <EditText
  19 + android:id="@+id/editText"
  20 + android:layout_width="match_parent"
  21 + android:layout_height="50dp"
  22 + android:visibility="gone"/>
  23 +
  24 + <include
  25 + android:id="@+id/includeMobileLayout"
  26 + layout="@layout/mobile_keycode_layout"/>
  27 +
  28 + <Button
  29 + android:id="@+id/submit"
  30 + android:layout_width="match_parent"
  31 + android:layout_height="50dp"
  32 + android:layout_alignParentBottom="true"
  33 + android:layout_marginBottom="200dp"
  34 + android:onClick="@{userPersonalEditFragment.onClick}"
  35 + android:text="提交" />
  36 +
  37 + </RelativeLayout>
  38 +
  39 +</layout>
0 \ No newline at end of file 40 \ No newline at end of file
app/src/main/res/layout/fragment_user_personal.xml
@@ -2,47 +2,34 @@ @@ -2,47 +2,34 @@
2 <layout xmlns:android="http://schemas.android.com/apk/res/android" 2 <layout xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:app="http://schemas.android.com/apk/res-auto"> 3 xmlns:app="http://schemas.android.com/apk/res-auto">
4 4
5 - <!--<data> 5 + <data>
  6 +
  7 + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter"/>
  8 + <import type="android.support.v7.widget.LinearLayoutManager"/>
  9 +
  10 + <variable
  11 + name="listAdapter"
  12 + type="DataBindingAdapter"/>
6 13
7 <variable 14 <variable
8 - name="liLayoutManager"  
9 - type="android.support.v7.widget.LinearLayoutManager" /> 15 + name="layoutManager"
  16 + type="LinearLayoutManager"/>
10 </data> 17 </data>
11 ---> 18 +
12 <RelativeLayout 19 <RelativeLayout
13 - android:id="@+id/main_view"  
14 android:layout_width="match_parent" 20 android:layout_width="match_parent"
15 android:layout_height="match_parent"> 21 android:layout_height="match_parent">
16 22
17 - <LinearLayout  
18 - android:id="@+id/persion_layout" 23 + <android.support.v7.widget.RecyclerView
  24 + android:id="@+id/recyclerView"
19 android:layout_width="match_parent" 25 android:layout_width="match_parent"
20 android:layout_height="match_parent" 26 android:layout_height="match_parent"
21 - android:orientation="vertical">  
22 -  
23 - <include  
24 - android:id="@+id/personalIncludeLayout"  
25 - layout="@layout/user_toolbar_title" />  
26 -  
27 -  
28 - <android.support.v7.widget.RecyclerView  
29 - android:id="@+id/lv_personal"  
30 - android:layout_width="match_parent"  
31 - android:layout_height="match_parent"  
32 - android:divider="@null"  
33 - android:fastScrollEnabled="true"  
34 - android:scrollbars="none"  
35 - />  
36 -  
37 - </LinearLayout>  
38 -  
39 - <ImageView  
40 - android:id="@+id/back_selector"  
41 - android:layout_width="30dp"  
42 - android:layout_height="30dp"  
43 - android:layout_marginLeft="@dimen/_20px"  
44 - android:layout_marginTop="@dimen/_28px"  
45 - android:src="@drawable/btn_return" /> 27 + android:clipToPadding="true"
  28 + android:clipChildren="true"
  29 + android:paddingTop="5dp"
  30 + android:background="@color/list_divider"
  31 + app:adapter="@{listAdapter}"
  32 + app:layoutManager="@{layoutManager}"/>
46 33
47 </RelativeLayout> 34 </RelativeLayout>
48 </layout> 35 </layout>
49 \ No newline at end of file 36 \ No newline at end of file
app/src/main/res/layout/layout_actionbar_back.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
  4 + android:id="@+id/toolbar"
  5 + xmlns:app="http://schemas.android.com/apk/res-auto"
  6 + xmlns:tools="http://schemas.android.com/tools"
  7 + android:layout_width="match_parent"
  8 + android:layout_height="?attr/actionBarSize"
  9 + android:background="@drawable/toolbar_bg"
  10 + android:theme="@style/ThemeOverlay.AppCompat.Light"
  11 + app:contentInsetEnd="?attr/actionBarSize"
  12 + android:visibility="gone"
  13 + tools:visibility="visible">
  14 +
  15 +
  16 + <TextView
  17 + android:id="@+id/toolbarTitle"
  18 + style="@style/ActionbarTitleStyle"
  19 + android:layout_width="wrap_content"
  20 + android:layout_height="wrap_content"
  21 + android:layout_gravity="center"
  22 + android:lines="1"
  23 + tools:text="here is title"/>
  24 +
  25 +</android.support.v7.widget.Toolbar>
0 \ No newline at end of file 26 \ No newline at end of file
app/src/main/res/layout/layout_personal_header_item.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + xmlns:app="http://schemas.android.com/apk/res-auto">
  5 +
  6 + <data>
  7 +
  8 + <import type="com.cnlive.gundam.user.model.PersonalData" />
  9 + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/>
  10 +
  11 + <variable
  12 + name="data"
  13 + type="PersonalData" />
  14 +
  15 + <variable
  16 + name="viewClickListner"
  17 + type="OnAdapterViewClickListener&lt;PersonalData>"/>
  18 +
  19 + </data>
  20 +
  21 + <RelativeLayout
  22 + android:id="@+id/itemLayout"
  23 + android:layout_width="match_parent"
  24 + android:layout_height="80dp"
  25 + android:onClick="@{(view)->viewClickListner.onViewClick(view,data)}">
  26 +
  27 + <RelativeLayout
  28 + android:layout_width="match_parent"
  29 + android:layout_height="match_parent"
  30 + android:layout_above="@+id/divider"
  31 + android:background="@android:color/white">
  32 +
  33 + <TextView
  34 + android:id="@+id/itemName"
  35 + android:layout_width="wrap_content"
  36 + android:layout_height="match_parent"
  37 + android:gravity="center_vertical"
  38 + android:text="@{data.getItemName()}"
  39 + android:textColor="@color/black"
  40 + android:textSize="18sp"
  41 + tools:text="nick" />
  42 +
  43 + <ImageView
  44 + android:layout_width="50dp"
  45 + android:layout_height="50dp"
  46 + android:layout_marginRight="50dp"
  47 + android:layout_alignParentRight="true"
  48 + android:layout_centerVertical="true"
  49 + android:scaleType="centerCrop"
  50 + app:error="@{@drawable/image_error}"
  51 + app:imageUrl="@{data.getItemMessage()}"/>
  52 +
  53 + <ImageView
  54 + android:layout_width="wrap_content"
  55 + android:layout_height="wrap_content"
  56 + android:layout_alignParentRight="true"
  57 + android:layout_centerVertical="true"
  58 + android:src="@drawable/ic_close" />
  59 +
  60 + </RelativeLayout>
  61 +
  62 + <View
  63 + android:id="@+id/divider"
  64 + android:layout_width="match_parent"
  65 + android:layout_height="5dp"
  66 + android:layout_alignParentBottom="true"/>
  67 +
  68 + </RelativeLayout>
  69 +
  70 +</layout>
0 \ No newline at end of file 71 \ No newline at end of file
app/src/main/res/layout/layout_personal_item.xml 0 → 100644
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<layout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools">
  4 +
  5 + <data>
  6 +
  7 + <import type="com.cnlive.gundam.user.model.PersonalData" />
  8 + <import type="com.cnlive.gundam.main.ui.adapter.DataBindingAdapter.OnAdapterViewClickListener"/>
  9 +
  10 + <variable
  11 + name="data"
  12 + type="PersonalData" />
  13 +
  14 + <variable
  15 + name="viewClickListner"
  16 + type="OnAdapterViewClickListener&lt;PersonalData>"/>
  17 +
  18 + </data>
  19 +
  20 + <RelativeLayout
  21 + android:id="@+id/itemLayout"
  22 + android:layout_width="match_parent"
  23 + android:layout_height="60dp"
  24 + android:onClick="@{(view)->viewClickListner.onViewClick(view,data)}">
  25 +
  26 + <RelativeLayout
  27 + android:layout_width="match_parent"
  28 + android:layout_height="match_parent"
  29 + android:layout_above="@+id/divider"
  30 + android:background="@android:color/white">
  31 +
  32 + <TextView
  33 + android:id="@+id/itemName"
  34 + android:layout_width="wrap_content"
  35 + android:layout_height="match_parent"
  36 + android:gravity="center_vertical"
  37 + android:text="@{data.getItemName()}"
  38 + android:textColor="@color/black"
  39 + android:textSize="18sp"
  40 + tools:text="nick" />
  41 +
  42 + <TextView
  43 + android:id="@+id/itemMsg"
  44 + android:layout_width="wrap_content"
  45 + android:layout_height="match_parent"
  46 + android:layout_alignParentRight="true"
  47 + android:layout_marginRight="50dp"
  48 + android:layout_toRightOf="@+id/itemName"
  49 + android:gravity="center_vertical|right"
  50 + android:text="@{data.getItemMessage()}"
  51 + android:textColor="@color/black"
  52 + android:textSize="18sp"
  53 + tools:text="haha" />
  54 +
  55 + <ImageView
  56 + android:layout_width="wrap_content"
  57 + android:layout_height="wrap_content"
  58 + android:layout_alignParentRight="true"
  59 + android:layout_centerVertical="true"
  60 + android:src="@drawable/ic_close" />
  61 +
  62 + </RelativeLayout>
  63 +
  64 + <View
  65 + android:id="@+id/divider"
  66 + android:layout_width="match_parent"
  67 + android:layout_height="5dp"
  68 + android:layout_alignParentBottom="true"/>
  69 +
  70 + </RelativeLayout>
  71 +
  72 +</layout>
0 \ No newline at end of file 73 \ No newline at end of file
app/src/main/res/layout/mobile_keycode_layout.xml
1 <?xml version="1.0" encoding="utf-8"?> 1 <?xml version="1.0" encoding="utf-8"?>
2 -<layout xmlns:android="http://schemas.android.com/apk/res/android"  
3 - > 2 +<layout xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <data>
  5 +
  6 + </data>
  7 +
4 <LinearLayout 8 <LinearLayout
5 android:id="@+id/mobile_keycode_layout" 9 android:id="@+id/mobile_keycode_layout"
6 android:layout_width="match_parent" 10 android:layout_width="match_parent"