Commit 9cbee19cbb8fc093db454cc30043994824839f7d

Authored by xiongwei
1 parent 2338cf4c22
Exists in master

子账户的添加,修改,删除,查询等接口调试

Showing 18 changed files with 541 additions and 150 deletions   Show diff stats
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/AccountManagementActivity.java
1 1 package com.hjx.personalcenter.activity;
2 2  
3   -import android.app.Activity;
4 3 import android.content.Intent;
5 4 import android.os.Bundle;
6 5 import android.os.Handler;
7 6 import android.os.Message;
  7 +import android.support.v7.app.AppCompatActivity;
8 8 import android.support.v7.widget.LinearLayoutManager;
9 9 import android.support.v7.widget.RecyclerView;
10 10 import android.view.View;
  11 +import android.widget.ImageView;
  12 +import android.widget.LinearLayout;
11 13 import android.widget.TextView;
12 14  
13 15 import com.hjx.personalcenter.R;
14 16 import com.hjx.personalcenter.adapter.AccountChildsAdapter;
  17 +import com.hjx.personalcenter.customdialog.RecyclerViewSpaceItem;
15 18 import com.hjx.personalcenter.db.Content;
16 19 import com.hjx.personalcenter.db.SaveParam;
17 20 import com.hjx.personalcenter.http.HttpCode;
... ... @@ -25,9 +28,12 @@ import java.util.List;
25 28 * Created by h on 2017/8/12.
26 29 */
27 30  
28   -public class AccountManagementActivity extends Activity implements View.OnClickListener {
29   - private TextView changbangding,changpassword,usernames;
  31 +public class AccountManagementActivity extends AppCompatActivity implements View.OnClickListener {
  32 + private TextView changbangding,changpassword,usernames,
  33 + tv_username,tv_grade,tv_school,tv_adress, tv_delete;
  34 + private ImageView iv_account_head,cancel;
30 35 private RecyclerView listview;
  36 + private LinearLayout add_accunt;
31 37 private AccountChildsAdapter childsAdapter;
32 38 private ArrayList<ChildsInfo.DataBean> data = new ArrayList<>();
33 39 Handler handler = new Handler(){
... ... @@ -47,7 +53,15 @@ public class AccountManagementActivity extends Activity implements View.OnClickL
47 53 protected void onCreate(Bundle savedInstanceState) {
48 54 super.onCreate(savedInstanceState);
49 55 setContentView(R.layout.activity_account_management);
50   - HttpManager.getInstance().getchildAccountinfo(this,600,handler);
  56 + String userID = SaveParam.getInstance().getLoginParam(this,"userId");
  57 + try {
  58 + long auserID = Long.parseLong(userID);
  59 + HttpManager.getInstance().getchildAccountinfo(this,auserID,handler);
  60 +
  61 + } catch (NumberFormatException e) {
  62 + e.printStackTrace();
  63 + }
  64 +
51 65 initView();
52 66 initData();
53 67 initLister();
... ... @@ -57,16 +71,36 @@ public class AccountManagementActivity extends Activity implements View.OnClickL
57 71 changbangding = (TextView) findViewById(R.id.changBangding);
58 72 changpassword = (TextView) findViewById(R.id.changpassword);
59 73 usernames = (TextView) findViewById(R.id.cunt_username);
  74 + tv_username = (TextView) findViewById(R.id.tv_account_name);
  75 + tv_grade = (TextView) findViewById(R.id.tv_account_grade);
  76 + tv_school = (TextView) findViewById(R.id.tv_account_school);
  77 + tv_adress = (TextView) findViewById(R.id.tv_account_adress);
  78 + tv_delete = (TextView) findViewById(R.id.tv_account_delete);
  79 + iv_account_head = (ImageView) findViewById(R.id.tv_account_head);
  80 + cancel = (ImageView) findViewById(R.id.cancel);
  81 + add_accunt = (LinearLayout) findViewById(R.id.add_account);
  82 +
  83 +
60 84 listview = (RecyclerView) findViewById(R.id.id_recyclerview_horizontal);
61 85 }
62 86  
63 87 private void initData() {
64   - String cunt_username = SaveParam.getInstance().getLoginParam(this,"cunt_username");
  88 + String cunt_username = SaveParam.getInstance().getLoginParam(this,"username");
  89 + String tv_usernames = SaveParam.getInstance().getLoginParam(this,SaveParam.USERNAME);
  90 + String tv_grades = SaveParam.getInstance().getLoginParam(this,SaveParam.GRADES);
  91 + String tv_schools = SaveParam.getInstance().getLoginParam(this,SaveParam.SCHOOL);
  92 + String tv_adresss = SaveParam.getInstance().getLoginParam(this,SaveParam.ADRESS);
65 93 usernames.setText(cunt_username);
  94 + tv_username.setText(tv_usernames);
  95 + tv_grade.setText(tv_grades);
  96 + tv_school.setText(tv_schools);
  97 + tv_adress.setText(tv_adresss);
  98 +
66 99 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
67 100 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
68 101 listview.setLayoutManager(linearLayoutManager);
69 102 childsAdapter = new AccountChildsAdapter(data,this);
  103 + listview.addItemDecoration(new RecyclerViewSpaceItem(10));
70 104 listview.setAdapter(childsAdapter);
71 105  
72 106 }
... ... @@ -74,6 +108,9 @@ public class AccountManagementActivity extends Activity implements View.OnClickL
74 108 private void initLister() {
75 109 changbangding.setOnClickListener(this);
76 110 changpassword.setOnClickListener(this);
  111 + tv_delete.setOnClickListener(this);
  112 + cancel.setOnClickListener(this);
  113 + add_accunt.setOnClickListener(this);
77 114  
78 115  
79 116 }
... ... @@ -94,6 +131,18 @@ public class AccountManagementActivity extends Activity implements View.OnClickL
94 131 startActivity(changpwd);
95 132 overridePendingTransition(R.anim.rightin, R.anim.rightout);
96 133 break;
  134 + case R.id.add_account:
  135 +
  136 + Content.accountflag = 2;
  137 + Intent account = new Intent();
  138 + account.setClass(AccountManagementActivity.this,RegisterInfoActivity.class);
  139 + startActivity(account);
  140 + overridePendingTransition(R.anim.rightin, R.anim.rightout);
  141 +
  142 + break;
  143 + case R.id.cancel:
  144 + finish();
  145 + break;
97 146 }
98 147  
99 148 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/MainActivity.java
... ... @@ -14,6 +14,7 @@ import android.support.v4.content.FileProvider;
14 14 import android.support.v7.app.AppCompatActivity;
15 15 import android.support.v7.widget.LinearLayoutManager;
16 16 import android.support.v7.widget.RecyclerView;
  17 +import android.view.KeyEvent;
17 18 import android.view.View;
18 19 import android.widget.ImageView;
19 20 import android.widget.LinearLayout;
... ... @@ -27,7 +28,7 @@ import com.facebook.drawee.generic.RoundingParams;
27 28 import com.facebook.drawee.interfaces.DraweeController;
28 29 import com.facebook.drawee.view.SimpleDraweeView;
29 30 import com.hjx.personalcenter.R;
30   -import com.hjx.personalcenter.adapter.RecyclerViewAdapter;
  31 +import com.hjx.personalcenter.adapter.GalleryAdapter;
31 32 import com.hjx.personalcenter.customdialog.HeadDialog;
32 33 import com.hjx.personalcenter.db.SaveParam;
33 34 import com.hjx.personalcenter.http.HttpCode;
... ... @@ -50,6 +51,7 @@ import com.zaaach.toprightmenu.TopRightMenu;
50 51  
51 52 import java.io.File;
52 53 import java.util.ArrayList;
  54 +import java.util.Arrays;
53 55 import java.util.List;
54 56  
55 57 public class MainActivity extends AppCompatActivity implements View.OnClickListener, DialogCallBack.CallBackView {
... ... @@ -61,7 +63,9 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
61 63 private TopRightMenu mTopRightMenu;
62 64 //水平滑动
63 65 private RecyclerView mRecyclerView;
64   - private RecyclerViewAdapter RecyclerViewadapter;
  66 + private GalleryAdapter RecyclerViewadapter;
  67 + private List<Integer> mDatas = new ArrayList<Integer>(Arrays.asList(R.mipmap.default_avatar2,
  68 + R.mipmap.default_avatar2, R.mipmap.default_avatar2, R.mipmap.default_avatar2));
65 69 private boolean showIcon = true;
66 70 private boolean dimBg = true;
67 71 private boolean needAnim = true;
... ... @@ -147,17 +151,19 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
147 151  
148 152 }
149 153  
  154 +
150 155 private void initData() {
151 156 //加载最近学习视频
152   - List<String> datas = new ArrayList<>();
153   - datas.add("LiMing");
154   - datas.add("XiaoMing");
155   - datas.add("HanMeiMei");
  157 +
  158 +
  159 + //设置布局管理器
156 160 LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
157 161 linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
158 162 mRecyclerView.setLayoutManager(linearLayoutManager);
159   - RecyclerViewadapter = new RecyclerViewAdapter(this, datas);
  163 + //设置适配器
  164 + RecyclerViewadapter = new GalleryAdapter(this, mDatas);
160 165 mRecyclerView.setAdapter(RecyclerViewadapter);
  166 +
161 167 //加载个人信息
162 168 String xiongzuo = SaveParam.getInstance().getLoginParam(this,SaveParam.CONSTELLATION);
163 169 if (xiongzuo==null){
... ... @@ -485,4 +491,20 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
485 491 super.onRequestPermissionsResult(requestCode, permissions, grantResults);
486 492 }
487 493 }
  494 + private long exitTime = 0;
  495 + @Override
  496 + public boolean onKeyDown(int keyCode, KeyEvent event) {
  497 + if (keyCode == KeyEvent.KEYCODE_BACK) {
  498 + if ((System.currentTimeMillis() - exitTime) > 2000) {
  499 + Toast.makeText(getApplicationContext(), "再按一次退出程序",
  500 + Toast.LENGTH_SHORT).show();
  501 + exitTime = System.currentTimeMillis();
  502 + } else {
  503 + finish();
  504 + System.exit(0);
  505 + }
  506 + return false;
  507 + }
  508 + return super.onKeyDown(keyCode, event);
  509 + }
488 510 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/activity/RegisterInfoActivity.java
... ... @@ -16,7 +16,9 @@ import com.hjx.personalcenter.customdialog.CountryDialog;
16 16 import com.hjx.personalcenter.customdialog.GradeListDialog;
17 17 import com.hjx.personalcenter.customdialog.ProvinceListDialog;
18 18 import com.hjx.personalcenter.customdialog.SchoolListDialog;
  19 +import com.hjx.personalcenter.db.Content;
19 20 import com.hjx.personalcenter.db.SaveParam;
  21 +import com.hjx.personalcenter.http.HttpManager;
20 22 import com.hjx.personalcenter.interfaces.DialogCallBack;
21 23 import com.hjx.personalcenter.model.CityInfo;
22 24 import com.hjx.personalcenter.model.CountyInfo;
... ... @@ -57,6 +59,10 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
57 59 }
58 60  
59 61 private void initData() {
  62 + if (Content.accountflag ==2){
  63 + btn_ok.setText("提交");
  64 +
  65 + }
60 66  
61 67 }
62 68  
... ... @@ -97,11 +103,29 @@ public class RegisterInfoActivity extends AppCompatActivity implements View.OnCl
97 103 AlertUtils.showToast(RegisterInfoActivity.this, "请将必填项填写完整");
98 104 return;
99 105 }else{
100   - saveinfo();
101   - Intent intent = new Intent();
102   - intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class);
103   - startActivity(intent);
104   - overridePendingTransition(R.anim.rightin, R.anim.rightout);
  106 + if (Content.accountflag ==2){
  107 + String userID = SaveParam.getInstance().getLoginParam(this,"userId");
  108 + String register5 = et_username.getText().toString().trim();
  109 + String register6 = et_region.getText().toString().trim();
  110 + String register7 = et_grade.getText().toString().trim();
  111 + String register8 = et_school.getText().toString().trim();
  112 + try {
  113 + long auserID = Long.parseLong(userID);
  114 + HttpManager.getInstance().addchildAccountinfo(RegisterInfoActivity.this,auserID,"",
  115 + register5,register7,register8,register6);
  116 +
  117 + } catch (NumberFormatException e) {
  118 + e.printStackTrace();
  119 + }
  120 +
  121 + }else {
  122 + saveinfo();
  123 + Intent intent = new Intent();
  124 + intent.setClass(RegisterInfoActivity.this,ChoiseTextBookActivity.class);
  125 + startActivity(intent);
  126 + overridePendingTransition(R.anim.rightin, R.anim.rightout);
  127 + }
  128 +
105 129 }
106 130  
107 131 break;
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/AccountChildsAdapter.java
1 1 package com.hjx.personalcenter.adapter;
2 2  
3 3 import android.content.Context;
  4 +import android.support.v4.app.FragmentActivity;
4 5 import android.support.v7.widget.RecyclerView;
5 6 import android.view.LayoutInflater;
6 7 import android.view.View;
... ... @@ -9,7 +10,9 @@ import android.widget.ImageView;
9 10 import android.widget.TextView;
10 11  
11 12 import com.hjx.personalcenter.R;
  13 +import com.hjx.personalcenter.http.HttpManager;
12 14 import com.hjx.personalcenter.model.ChildsInfo;
  15 +import com.mylhyl.circledialog.CircleDialog;
13 16  
14 17 import java.util.ArrayList;
15 18 import java.util.List;
... ... @@ -54,13 +57,53 @@ public class AccountChildsAdapter extends RecyclerView.Adapter&lt;AccountChildsAdap
54 57  
55 58 @Override
56 59 public void onBindViewHolder(AccountChildsHolder holder, int position) {
57   - ChildsInfo.DataBean bean = specailList.get(position);
  60 + final ChildsInfo.DataBean bean = specailList.get(position);
58 61 if (bean != null) {
59 62 holder.iv_child_head.setImageResource(R.mipmap.header_default);
60 63 holder.iv_child_name.setText(bean.getName());
61 64 holder.iv_child_grade.setText(bean.getGrade());
62 65 holder.iv_child_school.setText(bean.getSchool());
63 66 holder.iv_child_adress.setText(bean.getRegion());
  67 + holder.delete_account.setOnClickListener(new View.OnClickListener() {
  68 + @Override
  69 + public void onClick(View v) {
  70 + new CircleDialog.Builder((FragmentActivity)mContext)
  71 + .setCanceledOnTouchOutside(false)
  72 + .setWidth(0.4f)
  73 + .setCancelable(false)
  74 + .setText("您确定删除该子账户?")
  75 + .setNegative("取消", null)
  76 + .setPositive("确定", new View.OnClickListener() {
  77 + @Override
  78 + public void onClick(View v) {
  79 + HttpManager.getInstance().deletechildAccountinfo(mContext,bean.getSubAccountId());
  80 + }
  81 + })
  82 + .show();
  83 +
  84 +
  85 +
  86 + }
  87 + });
  88 + holder.chang_account.setOnClickListener(new View.OnClickListener() {
  89 + @Override
  90 + public void onClick(View v) {
  91 + new CircleDialog.Builder((FragmentActivity)mContext)
  92 + .setCanceledOnTouchOutside(false)
  93 + .setWidth(0.4f)
  94 + .setCancelable(false)
  95 + .setText("您确定切换为该子账户?")
  96 + .setNegative("取消", null)
  97 + .setPositive("确定", new View.OnClickListener() {
  98 + @Override
  99 + public void onClick(View v) {
  100 + HttpManager.getInstance().changechildAccountinfo(mContext,bean.getSubAccountId(),bean.getParentId());
  101 + }
  102 + })
  103 + .show();
  104 +
  105 + }
  106 + });
64 107  
65 108 }
66 109  
... ... @@ -74,7 +117,8 @@ public class AccountChildsAdapter extends RecyclerView.Adapter&lt;AccountChildsAdap
74 117  
75 118 class AccountChildsHolder extends RecyclerView.ViewHolder {
76 119 ImageView iv_child_head;
77   - TextView iv_child_name, iv_child_grade, iv_child_school, iv_child_adress;
  120 + TextView iv_child_name, iv_child_grade, iv_child_school, iv_child_adress,
  121 + delete_account,chang_account;
78 122 public AccountChildsHolder(View itemView) {
79 123 super(itemView);
80 124 iv_child_head = (ImageView) itemView.findViewById(R.id.iv_child_head);
... ... @@ -82,6 +126,8 @@ public class AccountChildsAdapter extends RecyclerView.Adapter&lt;AccountChildsAdap
82 126 iv_child_grade = (TextView) itemView.findViewById(R.id.iv_child_grade);
83 127 iv_child_school = (TextView) itemView.findViewById(R.id.iv_child_school);
84 128 iv_child_adress = (TextView) itemView.findViewById(R.id.iv_child_adress);
  129 + delete_account = (TextView) itemView.findViewById(R.id.delete_child_account);
  130 + chang_account = (TextView) itemView.findViewById(R.id.chang_account);
85 131  
86 132 }
87 133 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/GalleryAdapter.java
... ... @@ -0,0 +1,69 @@
  1 +package com.hjx.personalcenter.adapter;
  2 +
  3 +import android.content.Context;
  4 +import android.support.v7.widget.RecyclerView;
  5 +import android.view.LayoutInflater;
  6 +import android.view.View;
  7 +import android.view.ViewGroup;
  8 +import android.widget.ImageView;
  9 +import android.widget.TextView;
  10 +
  11 +import com.hjx.personalcenter.R;
  12 +
  13 +import java.util.List;
  14 +
  15 +public class GalleryAdapter extends
  16 + RecyclerView.Adapter<GalleryAdapter.ViewHolder>
  17 +{
  18 +
  19 + private LayoutInflater mInflater;
  20 + private List<Integer> mDatas;
  21 +
  22 + public GalleryAdapter(Context context, List<Integer> datats)
  23 + {
  24 + mInflater = LayoutInflater.from(context);
  25 + mDatas = datats;
  26 + }
  27 +
  28 + public static class ViewHolder extends RecyclerView.ViewHolder
  29 + {
  30 + public ViewHolder(View arg0)
  31 + {
  32 + super(arg0);
  33 + }
  34 +
  35 + ImageView mImg;
  36 + TextView mTxt;
  37 + }
  38 +
  39 + @Override
  40 + public int getItemCount()
  41 + {
  42 + return mDatas.size();
  43 + }
  44 +
  45 + /**
  46 + * 创建ViewHolder
  47 + */
  48 + @Override
  49 + public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i)
  50 + {
  51 + View view = mInflater.inflate(R.layout.recycler_study_tem_view,
  52 + viewGroup, false);
  53 + ViewHolder viewHolder = new ViewHolder(view);
  54 +
  55 + viewHolder.mImg = (ImageView) view
  56 + .findViewById(R.id.id_index_gallery_item_image);
  57 + return viewHolder;
  58 + }
  59 +
  60 + /**
  61 + * 设置值
  62 + */
  63 + @Override
  64 + public void onBindViewHolder(final ViewHolder viewHolder, final int i)
  65 + {
  66 + viewHolder.mImg.setImageResource(mDatas.get(i));
  67 + }
  68 +
  69 +}
0 70 \ No newline at end of file
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/adapter/RecyclerViewAdapter.java
... ... @@ -1,78 +0,0 @@
1   -package com.hjx.personalcenter.adapter;
2   -
3   -import android.content.Context;
4   -import android.support.v7.widget.RecyclerView;
5   -import android.view.LayoutInflater;
6   -import android.view.View;
7   -import android.view.ViewGroup;
8   -import android.widget.Button;
9   -import android.widget.TextView;
10   -
11   -import com.hjx.personalcenter.R;
12   -
13   -import java.util.List;
14   -
15   -/**
16   - * Author: zhangmiao
17   - * Date: 2017/6/14
18   - */
19   -public class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.RecyclerHolder> {
20   -
21   - private static final String TAG = RecyclerViewAdapter.class.getSimpleName();
22   -
23   - private List<String> dataList;
24   - private Context mContext;
25   - private RecyclerView recyclerView;
26   -
27   - public static int position = 0;
28   -
29   - public RecyclerViewAdapter(Context context, List<String> dataList) {
30   - mContext = context;
31   - this.dataList = dataList;
32   - }
33   -
34   - @Override
35   - public RecyclerHolder onCreateViewHolder(ViewGroup parent, int viewType) {
36   - View view = LayoutInflater.from(mContext).inflate(R.layout.recycler_study_tem_view, parent, false);
37   - RecyclerHolder holder = new RecyclerHolder(view);
38   - return holder;
39   - }
40   -
41   - @Override
42   - public void onBindViewHolder(RecyclerHolder holder, final int position) {
43   - holder.textView.setText(dataList.get(position));
44   - if (position == dataList.size() - 1) {
45   - holder.button.setVisibility(View.GONE);
46   - }
47   - holder.button.setOnClickListener(new View.OnClickListener() {
48   - @Override
49   - public void onClick(View v) {
50   - recyclerView.smoothScrollToPosition(position + 1);
51   - RecyclerViewAdapter.position++;
52   - }
53   - });
54   - }
55   -
56   - @Override
57   - public void onAttachedToRecyclerView(RecyclerView recyclerView) {
58   - super.onAttachedToRecyclerView(recyclerView);
59   - this.recyclerView = recyclerView;
60   - }
61   -
62   - @Override
63   - public int getItemCount() {
64   - return dataList.size();
65   - }
66   -
67   - public class RecyclerHolder extends RecyclerView.ViewHolder {
68   - TextView textView;
69   - Button button;
70   -
71   - public RecyclerHolder(View itemView) {
72   - super(itemView);
73   - textView = (TextView) itemView.findViewById(R.id.item_text);
74   - button = (Button) itemView.findViewById(R.id.item_button);
75   - }
76   - }
77   -
78   -}
PersonalCenter/app/src/main/java/com/hjx/personalcenter/customdialog/RecyclerViewSpaceItem.java
... ... @@ -0,0 +1,29 @@
  1 +package com.hjx.personalcenter.customdialog;
  2 +
  3 +import android.graphics.Rect;
  4 +import android.support.v7.widget.RecyclerView;
  5 +import android.view.View;
  6 +
  7 +/**
  8 + * Created by h on 2017/8/28.
  9 + */
  10 +
  11 +public class RecyclerViewSpaceItem extends RecyclerView.ItemDecoration{
  12 + int mSpace;
  13 +
  14 + @Override
  15 + public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
  16 + super.getItemOffsets(outRect, view, parent, state);
  17 + outRect.left = mSpace;
  18 + outRect.right = mSpace;
  19 + outRect.bottom = mSpace;
  20 + if (parent.getChildAdapterPosition(view) == 0) {
  21 + outRect.left = mSpace;
  22 + }
  23 +
  24 + }
  25 +
  26 + public RecyclerViewSpaceItem(int space) {
  27 + this.mSpace = space;
  28 + }
  29 +}
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/Content.java
... ... @@ -7,4 +7,5 @@ package com.hjx.personalcenter.db;
7 7 public class Content {
8 8 public static int authcodeflag;//1是进入填写保卡信息验证,2是修改保卡手机号验证,3是更改绑定验证
9 9 public static int adressflag;//1购买地址,2客户地址
  10 + public static int accountflag;//1主账户注册信息,2子账户注册信息
10 11 }
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/db/SaveParam.java
... ... @@ -17,7 +17,7 @@ public class SaveParam {
17 17 public static String GRADENS = "gradens";//年级id
18 18 public static String SCHOOOlID = "schoolid";//年级id
19 19 //个人信息
20   - public static String USERNAME = "username";//昵称
  20 + public static String USERNAME = "usernames";//昵称
21 21 public static String ADRESS = "adress";//地址
22 22 public static String GRADES = "gadens";//年级
23 23 public static String SCHOOL = "school";//学校
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpKey.java
... ... @@ -29,6 +29,14 @@ public class HttpKey {
29 29 public static String DEVICENUMBER = "deviceNumber";
30 30 public static String MACADRESS = "macAddress";
31 31 public static String MOBILPHONE = "customerPhone";
  32 + //提交子账户信息
  33 + public static String PARENTID = "parentId";
  34 + public static String IMAGE = "image";
  35 + public static String NAME = "name";
  36 + public static String GRADE = "grade";
  37 + public static String SCHOOL = "school";
  38 + public static String REGION = "region";
  39 +
32 40  
33 41  
34 42  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpManager.java
... ... @@ -29,6 +29,7 @@ import com.hjx.personalcenter.model.PesonalInfo;
29 29 import com.hjx.personalcenter.model.ProvinceInfo;
30 30 import com.hjx.personalcenter.model.SchoolInfo;
31 31 import com.hjx.personalcenter.model.SignInfo;
  32 +import com.hjx.personalcenter.util.AlertUtils;
32 33 import com.hjx.personalcenter.util.DialogPermission;
33 34 import com.loopj.android.http.AsyncHttpResponseHandler;
34 35 import com.loopj.android.http.JsonHttpResponseHandler;
... ... @@ -1052,12 +1053,24 @@ public class HttpManager {
1052 1053 public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
1053 1054 closeProgress();
1054 1055 Log.e("test", "子账户信息" + new String(arg2));
1055   - ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据
1056   - List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData();
1057   - Message msg = Message.obtain();
1058   - msg.what = HttpCode.CHILDS_SUCESS;
1059   - msg.obj = schoolInfoBeanList;
1060   - handler.sendMessage(msg);
  1056 + try {
  1057 + JSONObject jsonObject = new JSONObject(new String(arg2));
  1058 + int status = jsonObject.optInt("status");
  1059 + if (status ==1000){
  1060 + AlertUtils.showToast(mContext,"你好,你还未添加子账号,子账号为空!");
  1061 + }else {
  1062 + ChildsInfo childsInfo = GsonTool.getPerson(new String(arg2), ChildsInfo.class);//解析json数据
  1063 + List<ChildsInfo.DataBean> schoolInfoBeanList = childsInfo.getData();
  1064 + Message msg = Message.obtain();
  1065 + msg.what = HttpCode.CHILDS_SUCESS;
  1066 + msg.obj = schoolInfoBeanList;
  1067 + handler.sendMessage(msg);
  1068 +
  1069 + }
  1070 + } catch (JSONException e) {
  1071 + e.printStackTrace();
  1072 + }
  1073 +
1061 1074 }
1062 1075  
1063 1076 @Override
... ... @@ -1089,6 +1102,201 @@ public class HttpManager {
1089 1102 });
1090 1103  
1091 1104 }
  1105 + /**
  1106 + * 删除子账户信息
  1107 + * @param mContext
  1108 + * @param subAccountId
  1109 + *
  1110 + */
  1111 + public void deletechildAccountinfo(final Context mContext, long subAccountId ) {
  1112 + mProgress = DialogPermission.showProgress(mContext, null, "正在删除子账户...",
  1113 + false, true, null);
  1114 + HttpClient.getInstance().setTimeout(5 * 1000);
  1115 + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  1116 + HttpClient.getInstance().get(HttpUrl.deletechildUserURL+ "?subAccountId=" + subAccountId , new AsyncHttpResponseHandler() {
  1117 + @Override
  1118 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  1119 + closeProgress();
  1120 + Log.e("test", "子账户信息" + new String(arg2));
  1121 + try {
  1122 + JSONObject jsonObject = new JSONObject(new String(arg2));
  1123 + int status = jsonObject.optInt("status");
  1124 + if (status ==1){
  1125 + AlertUtils.showToast(mContext,"子账号删除成功!");
  1126 + }else {
  1127 + AlertUtils.showToast(mContext,"你好,子账号删除失败!");
  1128 +
  1129 + }
  1130 + } catch (JSONException e) {
  1131 + e.printStackTrace();
  1132 + }
  1133 +
  1134 + }
  1135 +
  1136 + @Override
  1137 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  1138 + closeProgress();
  1139 + Log.e("test", "错误信息" + new String(arg2));
  1140 + new CircleDialog.Builder((FragmentActivity) mContext)
  1141 + .setCanceledOnTouchOutside(false)
  1142 + .setCancelable(false)
  1143 + .setWidth(0.5f)
  1144 + .configText(new ConfigText() {
  1145 + @Override
  1146 + public void onConfig(TextParams params) {
  1147 + params.gravity = Gravity.CENTER;
  1148 + params.padding = new int[]{50, 50, 50, 50};
  1149 + }
  1150 + })
  1151 + .setText("当前无网络,请检查网络设置")
  1152 + .setNegative("继续使用", null)
  1153 + .setPositive("设置网络", new View.OnClickListener() {
  1154 + @Override
  1155 + public void onClick(View v) {
  1156 + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面
  1157 + mContext.startActivity(intent);
  1158 + }
  1159 + })
  1160 + .show();
  1161 + }
  1162 + });
  1163 +
  1164 + }
  1165 + /**
  1166 + * 添加子账户信息
  1167 + *
  1168 + */
  1169 + public void addchildAccountinfo(final Context mContext, long parentId,String image,
  1170 + String name,String grade,String school,String region) {
  1171 + mProgress = DialogPermission.showProgress(mContext, null, "正在添加子账户...",
  1172 + false, true, null);
  1173 + RequestParams params = new RequestParams();
  1174 +
  1175 + params.put(HttpKey.PARENTID, parentId);
  1176 + params.put(HttpKey.IMAGE, image);
  1177 + params.put(HttpKey.NAME, name);
  1178 + params.put(HttpKey.GRADE, grade);
  1179 + params.put(HttpKey.SCHOOL, school);
  1180 + params.put(HttpKey.REGION, region);
  1181 +
  1182 +
  1183 + HttpClient.getInstance().addHeader("Accept", "*/*");
  1184 + HttpClient.getInstance().setTimeout(5 * 1000);
  1185 + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  1186 + HttpClient.getInstance().post(HttpUrl.addchildUserURL ,params, new AsyncHttpResponseHandler() {
  1187 + @Override
  1188 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  1189 + closeProgress();
  1190 +
  1191 + Log.e("test", "子账户信息" + new String(arg2));
  1192 + try {
  1193 + JSONObject jsonObject = new JSONObject(new String(arg2));
  1194 + int status = jsonObject.optInt("status");
  1195 + if (status ==1){
  1196 + AlertUtils.showToast(mContext,"子账号添加成功!");
  1197 + ((Activity) mContext).finish();
  1198 + }else {
  1199 + AlertUtils.showToast(mContext,"你好,子账号添加失败!");
  1200 +
  1201 + }
  1202 + } catch (JSONException e) {
  1203 + e.printStackTrace();
  1204 + }
  1205 +
  1206 + }
  1207 +
  1208 + @Override
  1209 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  1210 + closeProgress();
  1211 + Log.e("test", "错误信息" + new String(arg2));
  1212 + new CircleDialog.Builder((FragmentActivity) mContext)
  1213 + .setCanceledOnTouchOutside(false)
  1214 + .setCancelable(false)
  1215 + .setWidth(0.5f)
  1216 + .configText(new ConfigText() {
  1217 + @Override
  1218 + public void onConfig(TextParams params) {
  1219 + params.gravity = Gravity.CENTER;
  1220 + params.padding = new int[]{50, 50, 50, 50};
  1221 + }
  1222 + })
  1223 + .setText("当前无网络,请检查网络设置")
  1224 + .setNegative("继续使用", null)
  1225 + .setPositive("设置网络", new View.OnClickListener() {
  1226 + @Override
  1227 + public void onClick(View v) {
  1228 + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面
  1229 + mContext.startActivity(intent);
  1230 + }
  1231 + })
  1232 + .show();
  1233 + }
  1234 + });
  1235 +
  1236 + }
  1237 +
  1238 + /**
  1239 + * 切换子账户信息
  1240 + * @param mContext
  1241 + * @param subAccountId
  1242 + *
  1243 + */
  1244 + public void changechildAccountinfo(final Context mContext, long subAccountId ,long userId) {
  1245 + mProgress = DialogPermission.showProgress(mContext, null, "正在切换子账户...",
  1246 + false, true, null);
  1247 + HttpClient.getInstance().setTimeout(5 * 1000);
  1248 + HttpClient.getInstance().addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  1249 + HttpClient.getInstance().get(HttpUrl.changechildUserURL+ "?subAccountId=" + subAccountId+"&userId="+ userId, new AsyncHttpResponseHandler() {
  1250 + @Override
  1251 + public void onSuccess(int arg0, Header[] arg1, byte[] arg2) {
  1252 + closeProgress();
  1253 + Log.e("test", "子账户信息" + new String(arg2));
  1254 + try {
  1255 + JSONObject jsonObject = new JSONObject(new String(arg2));
  1256 + int status = jsonObject.optInt("status");
  1257 + if (status ==1){
  1258 + AlertUtils.showToast(mContext,"子账号切换成功!");
  1259 +
  1260 + }else {
  1261 + AlertUtils.showToast(mContext,"你好,子账号切换失败!");
  1262 +
  1263 + }
  1264 + } catch (JSONException e) {
  1265 + e.printStackTrace();
  1266 + }
  1267 +
  1268 + }
  1269 +
  1270 + @Override
  1271 + public void onFailure(int arg0, Header[] arg1, byte[] arg2, Throwable arg3) {
  1272 + closeProgress();
  1273 + Log.e("test", "错误信息" + new String(arg2));
  1274 + new CircleDialog.Builder((FragmentActivity) mContext)
  1275 + .setCanceledOnTouchOutside(false)
  1276 + .setCancelable(false)
  1277 + .setWidth(0.5f)
  1278 + .configText(new ConfigText() {
  1279 + @Override
  1280 + public void onConfig(TextParams params) {
  1281 + params.gravity = Gravity.CENTER;
  1282 + params.padding = new int[]{50, 50, 50, 50};
  1283 + }
  1284 + })
  1285 + .setText("当前无网络,请检查网络设置")
  1286 + .setNegative("继续使用", null)
  1287 + .setPositive("设置网络", new View.OnClickListener() {
  1288 + @Override
  1289 + public void onClick(View v) {
  1290 + Intent intent = new Intent(Settings.ACTION_SETTINGS);//系统设置界面
  1291 + mContext.startActivity(intent);
  1292 + }
  1293 + })
  1294 + .show();
  1295 + }
  1296 + });
  1297 +
  1298 + }
  1299 +
1092 1300  
1093 1301  
1094 1302  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/http/HttpUrl.java
... ... @@ -27,11 +27,15 @@ public class HttpUrl {
27 27 public static String changecardinfo=GetDomain()+"/electronicCard/updateByUserId";//修改保卡信息
28 28 public static String cardcheck=GetDomain()+"/electronicCard/check";//检查保卡是否填写
29 29 public static String changepresonalinfo=GetDomain()+"/personal/update";//修改个人信息
30   - public static String getpresonalinfo=GetDomain()+"/personal/get";//修改个人信息
  30 + public static String getpresonalinfo=GetDomain()+"/personal/get";//获取个人信息
31 31 public static String signature=GetDomain()+"/signature/addOrUpdateSignature";//修改个性签名
32 32 public static String getsignature=GetDomain()+"/signature/info";//获取个性签名
33 33 public static String feedbackURL=GetDomain()+"/feedback/add";//用户反馈
34   - public static String childUserURL=GetDomain()+"/childUser/info";//用户反馈
  34 + public static String childUserURL=GetDomain()+"/childUser/info";//获取子账户信息
  35 + public static String deletechildUserURL=GetDomain()+"/childUser/delete";//删除子账户
  36 + public static String addchildUserURL=GetDomain()+"/childUser/addChildUser";//添加子账户
  37 + public static String changechildUserURL=GetDomain()+"/childUser/update";//切换子账户
  38 +
35 39  
36 40  
37 41  
... ...
PersonalCenter/app/src/main/java/com/hjx/personalcenter/model/ChildsInfo.java
... ... @@ -76,7 +76,7 @@ public class ChildsInfo implements Serializable {
76 76 */
77 77  
78 78 private String region;
79   - private int parentId;
  79 + private long parentId;
80 80 private String school;
81 81 private String status;
82 82 private String name;
... ... @@ -92,7 +92,7 @@ public class ChildsInfo implements Serializable {
92 92 this.region = region;
93 93 }
94 94  
95   - public int getParentId() {
  95 + public long getParentId() {
96 96 return parentId;
97 97 }
98 98  
... ...
PersonalCenter/app/src/main/res/layout/activity_account_management.xml
... ... @@ -191,6 +191,7 @@
191 191 android:orientation="horizontal">
192 192  
193 193 <ImageView
  194 + android:id="@+id/tv_account_head"
194 195 android:layout_width="wrap_content"
195 196 android:layout_height="wrap_content"
196 197 android:layout_margin="10dp"
... ... @@ -205,27 +206,31 @@
205 206 android:orientation="vertical">
206 207  
207 208 <TextView
  209 + android:id="@+id/tv_account_name"
208 210 android:layout_width="wrap_content"
209 211 android:layout_height="wrap_content"
210   - android:text="删除用户"
  212 + android:text=""
211 213 android:textSize="18sp" />
212 214  
213 215 <TextView
  216 + android:id="@+id/tv_account_grade"
214 217 android:layout_width="wrap_content"
215 218 android:layout_height="wrap_content"
216   - android:text="使用中"
  219 + android:text=""
217 220 android:textSize="18sp" />
218 221  
219 222 <TextView
  223 + android:id="@+id/tv_account_school"
220 224 android:layout_width="wrap_content"
221 225 android:layout_height="wrap_content"
222   - android:text="删除用户"
  226 + android:text=""
223 227 android:textSize="18sp" />
224 228  
225 229 <TextView
  230 + android:id="@+id/tv_account_adress"
226 231 android:layout_width="wrap_content"
227 232 android:layout_height="wrap_content"
228   - android:text="使用中"
  233 + android:text=""
229 234 android:textSize="18sp" />
230 235  
231 236  
... ... @@ -255,6 +260,7 @@
255 260 android:orientation="horizontal">
256 261  
257 262 <TextView
  263 + android:id="@+id/tv_account_delete"
258 264 android:layout_width="0dp"
259 265 android:layout_height="wrap_content"
260 266 android:layout_weight="1"
... ... @@ -293,22 +299,27 @@
293 299 </LinearLayout>
294 300 </LinearLayout>
295 301  
296   - <LinearLayout
  302 + <RelativeLayout
297 303 android:layout_width="match_parent"
298 304 android:layout_height="wrap_content"
  305 + android:layout_marginTop="20dp"
299 306 android:orientation="horizontal">
300 307 <android.support.v7.widget.RecyclerView
301 308 android:id="@+id/id_recyclerview_horizontal"
302 309 android:layout_width="wrap_content"
  310 + android:layout_toLeftOf="@+id/add_account"
303 311 android:layout_height="wrap_content"
304 312 android:layout_centerVertical="true"
305 313 android:scrollbars="none"
306 314 >
307 315 </android.support.v7.widget.RecyclerView>
308 316 <LinearLayout
309   - android:layout_width="wrap_content"
310   - android:layout_height="wrap_content"
311   - android:background="@drawable/corcle_blue_bg"
  317 + android:id="@+id/add_account"
  318 + android:layout_width="415dp"
  319 + android:layout_height="165dp"
  320 + android:layout_marginLeft="10dp"
  321 + android:layout_alignParentRight="true"
  322 + android:background="@drawable/corcle_black_bg"
312 323 android:gravity="center">
313 324 <ImageView
314 325 android:layout_width="wrap_content"
... ... @@ -320,7 +331,7 @@
320 331  
321 332  
322 333  
323   - </LinearLayout>
  334 + </RelativeLayout>
324 335  
325 336 </LinearLayout>
326 337  
... ...
PersonalCenter/app/src/main/res/layout/activity_main.xml
... ... @@ -353,12 +353,9 @@
353 353 <android.support.v7.widget.RecyclerView
354 354 android:id="@+id/id_recyclerview_horizontal"
355 355 android:layout_width="match_parent"
356   - android:layout_height="wrap_content"
  356 + android:layout_height="match_parent"
357 357 android:layout_centerVertical="true"
358   - android:scrollbars="none"
359   - >
360   -
361   - </android.support.v7.widget.RecyclerView>
  358 + android:scrollbars="none" />
362 359 </LinearLayout>
363 360  
364 361 <View
... ...
PersonalCenter/app/src/main/res/layout/custom_adilog_school_list_items.xml
... ... @@ -5,6 +5,7 @@
5 5 <TextView
6 6 android:id="@+id/list_school_items"
7 7 android:textSize="18sp"
  8 + android:gravity="center_vertical"
8 9 android:layout_width="match_parent"
9 10 android:layout_height="50dp"
10 11 android:textColor="@color/btn_text_color"/>
... ...
PersonalCenter/app/src/main/res/layout/recycler_childaccunt_item_view.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3   - android:orientation="vertical" android:layout_width="match_parent"
  3 + android:orientation="vertical" android:layout_width="415dp"
4 4 android:layout_height="match_parent">
5 5 <LinearLayout
6 6 android:layout_width="wrap_content"
... ... @@ -9,7 +9,7 @@
9 9 android:orientation="vertical">
10 10  
11 11 <LinearLayout
12   - android:layout_width="match_parent"
  12 + android:layout_width="wrap_content"
13 13 android:layout_height="wrap_content"
14 14 android:orientation="horizontal">
15 15  
... ... @@ -63,7 +63,7 @@
63 63 </LinearLayout>
64 64  
65 65 <View
66   - android:layout_width="match_parent"
  66 + android:layout_width="wrap_content"
67 67 android:layout_height="0.7dp"
68 68 android:layout_margin="10dp"
69 69 android:background="@color/cutoff_line">
... ... @@ -77,6 +77,7 @@
77 77 android:orientation="horizontal">
78 78  
79 79 <TextView
  80 + android:id="@+id/delete_child_account"
80 81 android:layout_width="0dp"
81 82 android:layout_height="wrap_content"
82 83 android:layout_weight="1"
... ... @@ -85,6 +86,7 @@
85 86 android:textSize="18sp" />
86 87  
87 88 <TextView
  89 + android:id="@+id/chang_account"
88 90 android:layout_width="0dp"
89 91 android:layout_height="wrap_content"
90 92 android:layout_weight="1"
... ...
PersonalCenter/app/src/main/res/layout/recycler_study_tem_view.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2   -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3   - android:layout_width="match_parent"
4   - android:layout_height="match_parent"
5   - android:orientation="vertical">
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="120dp"
  4 + android:layout_height="120dp"
  5 + >
6 6  
7   - <LinearLayout
  7 + <ImageView
  8 + android:id="@+id/id_index_gallery_item_image"
  9 + android:layout_width="80dp"
  10 + android:layout_height="80dp"
  11 + android:layout_alignParentTop="true"
  12 + android:layout_centerHorizontal="true"
  13 + android:layout_margin="5dp"
  14 + android:scaleType="centerCrop" />
  15 +
  16 + <TextView
  17 + android:id="@+id/id_index_gallery_item_text"
8 18 android:layout_width="wrap_content"
9 19 android:layout_height="wrap_content"
10   - android:layout_gravity="center"
11   - android:gravity="center"
12   - android:orientation="vertical">
13   -
14   - <TextView
15   - android:id="@+id/item_text"
16   - android:layout_width="wrap_content"
17   - android:layout_height="wrap_content"
18   - android:text="test"
19   - android:textColor="@android:color/black"
20   - android:textSize="36sp" />
  20 + android:layout_below="@id/id_index_gallery_item_image"
  21 + android:layout_centerHorizontal="true"
  22 + android:layout_marginBottom="5dp"
  23 + android:layout_marginTop="5dp"
  24 + android:textColor="#ff0000"
  25 + android:text="some info"
  26 + android:textSize="12dp" />
21 27  
22   - <Button
23   - android:id="@+id/item_button"
24   - android:layout_width="wrap_content"
25   - android:layout_height="wrap_content"
26   - android:layout_marginTop="36dp"
27   - android:text="下一页"
28   - android:textSize="24sp" />
29   - </LinearLayout>
30   -</LinearLayout>
31 28 \ No newline at end of file
  29 +</RelativeLayout>
32 30 \ No newline at end of file
... ...