Commit 6643e444c4bd9cdc1e748112186aec8cccdaa002

Authored by wwx
2 parents 16962567 edbb9eeb

Merge branch 'yxb_dev' of http://git.shunzhi.net/taohd/parentwork into wwx

# Conflicts:
#	app/src/main/java/com/shunzhi/parent/AppConfig.java
#	app/src/main/java/com/shunzhi/parent/api/ApplyReplaceCardApi.java
#	app/src/main/java/com/shunzhi/parent/model/apply/ApplyReplaceCardModel.java
#	app/src/main/java/com/shunzhi/parent/ui/fragment/apply/ApplyReplaceCardFragment.java
app/src/main/AndroidManifest.xml
... ... @@ -203,6 +203,10 @@
203 203 <activity
204 204 android:name=".ui.activity.report.ReportSceneActivity"
205 205 android:launchMode="singleInstance" />
  206 + <activity
  207 + android:name=".ui.activity.ActivationActivity"
  208 + android:launchMode="singleInstance"
  209 + android:windowSoftInputMode="adjustPan|stateAlwaysHidden"/>
206 210  
207 211 <activity
208 212 android:name=".ui.activity.apply.ApplyReplaceCardActivity"
... ...
app/src/main/java/com/shunzhi/parent/AppConfig.java
... ... @@ -37,7 +37,7 @@ public class AppConfig {
37 37 public static String USER_ID = "user_id";
38 38 public static String APP_IS_START = "app_is_start";
39 39  
40   - //http://campus.myjxt.com/
  40 + //测试
41 41 public static String BASE_URL="http://60.190.202.57:1000/";
42 42 public static String BASE_URL_ORDER="http://60.190.202.57:8101/";
43 43 public static String BASE_URL_FILE="http://60.190.202.57:8196";
... ...
app/src/main/java/com/shunzhi/parent/AppContext.java
... ... @@ -18,8 +18,8 @@ import com.netease.nimlib.sdk.auth.LoginInfo;
18 18 import com.share.mvpsdk.global.GlobalApplication;
19 19 import com.share.mvpsdk.helper.RetrofitCreateHelper;
20 20 import com.shunzhi.parent.bean.message.DaoMaster;
21   -import com.shunzhi.parent.bean.message.DaoMaster.DevOpenHelper;
22 21 import com.shunzhi.parent.bean.message.DaoSession;
  22 +import com.shunzhi.parent.db.DBControl;
23 23 import com.shunzhi.parent.dbhelper.GreenDaoDatabaseOpenHelper;
24 24 import com.shunzhi.parent.manager.MessageManager;
25 25 import com.shunzhi.parent.ui.MainActivity;
... ... @@ -62,6 +62,8 @@ public class AppContext extends GlobalApplication {
62 62 public void onCreate() {
63 63 appContext = this;
64 64 super.onCreate();
  65 +
  66 + DBControl.init(appContext);
65 67 NIMClient.init(this, loginInfo(), options());
66 68 if (inMainProcess(this)) {
67 69 //开启地图地位
... ...
app/src/main/java/com/shunzhi/parent/bean/ChildBean.java
1 1 package com.shunzhi.parent.bean;
2 2  
  3 +import com.j256.ormlite.field.DatabaseField;
  4 +
3 5 import java.io.Serializable;
4 6  
5 7 /**
... ... @@ -7,25 +9,65 @@ import java.io.Serializable;
7 9 */
8 10  
9 11 public class ChildBean implements Serializable {
  12 + @DatabaseField
10 13 private String studentUserId;
  14 + @DatabaseField
11 15 private int parentMobile;
  16 + @DatabaseField
12 17 private int parentId;
  18 + @DatabaseField
13 19 private boolean mobileFlag;
  20 + @DatabaseField
14 21 private boolean bindingState;
  22 + @DatabaseField
15 23 private boolean cooperateFlag;
  24 + @DatabaseField
16 25 private int schoolId;
  26 + @DatabaseField
17 27 private String schoolName;
  28 + @DatabaseField
18 29 private int grade;
  30 + @DatabaseField
19 31 private String gradename;
  32 + @DatabaseField
20 33 private String areaName;
  34 + @DatabaseField
21 35 private String studentCode;
  36 + @DatabaseField
22 37 private int classId;
  38 + @DatabaseField
23 39 private String className;
  40 + @DatabaseField(id = true)
24 41 private int studentId;
  42 + @DatabaseField
25 43 private String studentName;
  44 + @DatabaseField
26 45 private String photo;
  46 + @DatabaseField
27 47 private String cityName;
  48 + @DatabaseField
  49 + private String cardNumber;
  50 + @DatabaseField
28 51 private int sex;
  52 + @DatabaseField
  53 + private int count;
  54 +
  55 +
  56 + public String getCardNumber() {
  57 + return cardNumber;
  58 + }
  59 +
  60 + public void setCardNumber(String cardNumber) {
  61 + this.cardNumber = cardNumber;
  62 + }
  63 +
  64 + public int getCount() {
  65 + return count;
  66 + }
  67 +
  68 + public void setCount(int count) {
  69 + this.count = count;
  70 + }
29 71  
30 72 public String getCityName() {
31 73 return cityName;
... ... @@ -200,6 +242,8 @@ public class ChildBean implements Serializable {
200 242 ",studentCode='" + studentCode + '\'' +
201 243 ",areaName='" + areaName + '\'' +
202 244 ",cityName='" + cityName + '\'' +
  245 + ",count='" + count + '\'' +
  246 + ",cardNumber='" + cardNumber + '\'' +
203 247 ", sex=" + sex +
204 248 "}";
205 249 }
... ...
app/src/main/java/com/shunzhi/parent/db/ChildInfoDao.java 0 → 100644
... ... @@ -0,0 +1,70 @@
  1 +package com.shunzhi.parent.db;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.j256.ormlite.dao.Dao;
  6 +import com.j256.ormlite.stmt.QueryBuilder;
  7 +import com.shunzhi.parent.bean.ChildBean;
  8 +import com.shunzhi.parent.util.DatabaseHelper;
  9 +
  10 +import java.sql.SQLException;
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * Created by Administrator on 2018/4/19 0019.
  16 + */
  17 +
  18 +public class ChildInfoDao {
  19 + private Context context;
  20 + private DatabaseHelper databaseHelper;
  21 + private Dao<ChildBean, Integer> dao;
  22 +
  23 + public ChildInfoDao(Context context) {
  24 + this.context = context;
  25 + try {
  26 + databaseHelper = DatabaseHelper.getHelper(context);
  27 + dao = databaseHelper.getDao(ChildBean.class);
  28 + } catch (SQLException e) {
  29 + e.printStackTrace();
  30 + }
  31 + }
  32 +
  33 + public boolean onCreate(ChildBean childBean) {
  34 + try {
  35 + return dao.create(childBean) > 0;
  36 + } catch (SQLException e) {
  37 + e.printStackTrace();
  38 + return false;
  39 + }
  40 + }
  41 +
  42 +
  43 + public synchronized List<ChildBean> getAllChildren() {
  44 + List<ChildBean> children = null;
  45 + try {
  46 + children = dao.queryForAll();
  47 + if (children != null && children.size() > 0) return children;
  48 + } catch (SQLException e) {
  49 + e.printStackTrace();
  50 + return new ArrayList<>();
  51 + }
  52 + return new ArrayList<>();
  53 + }
  54 +
  55 +
  56 + public synchronized ChildBean getChildBystudentId(int studentId) {
  57 + QueryBuilder queryBuilder = dao.queryBuilder();
  58 + try {
  59 + queryBuilder.where().eq("studentId", studentId);
  60 + List<ChildBean> list = dao.query(queryBuilder.prepare());
  61 + ChildBean studentInfo = list.get(0);
  62 + return studentInfo;
  63 +// return dao.queryForFirst(queryBuilder.prepare());
  64 + } catch (SQLException e) {
  65 + e.printStackTrace();
  66 + return null;
  67 + }
  68 + }
  69 +
  70 + }
... ...
app/src/main/java/com/shunzhi/parent/db/DBControl.java 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +package com.shunzhi.parent.db;
  2 +
  3 +import android.content.Context;
  4 +
  5 +/**
  6 + * Created by Administrator on 2018/4/19 0019.
  7 + */
  8 +
  9 +public class DBControl {
  10 + public static ChildInfoDao childInfoDao;
  11 +
  12 + public static void init(Context context){
  13 + childInfoDao=new ChildInfoDao(context);
  14 + }
  15 +}
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/ActivationActivity.java
1 1 package com.shunzhi.parent.ui.activity;
2 2  
  3 +import android.app.Activity;
  4 +import android.content.Intent;
3 5 import android.os.Bundle;
  6 +import android.support.v4.app.FragmentTransaction;
4 7  
5 8 import com.share.mvpsdk.base.activity.BaseCompatActivity;
6 9 import com.shunzhi.parent.R;
7 10 import com.shunzhi.parent.ui.fragment.ActivationFragment;
8 11  
9   -import me.yokeyword.fragmentation.SupportFragment;
10   -
11 12 /**
12 13 * Created by Administrator on 2018/4/18 0018.
13 14 */
14 15  
15 16 public class ActivationActivity extends BaseCompatActivity {
16   - private SupportFragment[] mFragments = new SupportFragment[1];
  17 +
  18 + private ActivationFragment activationFragment = null;
  19 + private FragmentTransaction fragmentTransaction = null;
  20 +
  21 + public static void newInstance(Activity activity, String cardNum, int studentId, int isactivation,String childName) {
  22 + Intent intent = new Intent(activity, ActivationActivity.class);
  23 + intent.putExtra("cardNum", cardNum);
  24 + intent.putExtra("childName", childName);
  25 + intent.putExtra("studentId", studentId);
  26 + intent.putExtra("isactivation", isactivation);
  27 + activity.startActivity(intent);
  28 +
  29 +
  30 + }
17 31  
18 32 @Override
19 33 protected void initView(Bundle savedInstanceState) {
20 34 if (savedInstanceState == null) {
21   - loadRootFragment(R.id.frame, mFragments[0]);
22   - } else {
23   - mFragments[0] = findFragment(ActivationFragment.class);
  35 + activationFragment = new ActivationFragment();
  36 + String cardNum = getIntent().getStringExtra("cardNum");
  37 + String childName = getIntent().getStringExtra("childName");
  38 + int studentId = getIntent().getIntExtra("studentId", 0);
  39 + int isactivation = getIntent().getIntExtra("isactivation", 0);
  40 + Bundle bundle = new Bundle();
  41 + bundle.putString("cardNum", cardNum);
  42 + bundle.putString("childName", childName);
  43 + bundle.putInt("studentId", studentId);
  44 + bundle.putInt("isactivation", isactivation);
  45 + activationFragment.setArguments(bundle);
  46 + fragmentTransaction = getSupportFragmentManager().beginTransaction();
  47 + fragmentTransaction.add(R.id.frame, activationFragment)
  48 + .show(activationFragment).commit();
  49 +
24 50 }
25 51 }
26 52  
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/ChildDetialActivity.java
... ... @@ -29,8 +29,11 @@ import java.util.List;
29 29  
30 30 public class ChildDetialActivity extends BaseMVPCompatActivity<MyChildContract.MyChildPresenter, MyChildContract.IMyChildModel>
31 31 implements MyChildContract.IMyChildView, View.OnClickListener {
32   - TextView child_name, child_school, child_class, school_area, student_code, center_title,btn_jihuo,btn_unBinding;
  32 + TextView child_name, child_school, child_class, school_area, student_code, center_title, btn_jihuo, btn_unBinding;
33 33 ImageView back;
  34 + String childName, cardNumber;
  35 + int studentId;
  36 + int isactivation = 0;
34 37  
35 38 @Override
36 39 protected void initView(Bundle savedInstanceState) {
... ... @@ -61,6 +64,13 @@ public class ChildDetialActivity extends BaseMVPCompatActivity&lt;MyChildContract.M
61 64 private void initChild(String childJson) {
62 65 Gson g = new Gson();
63 66 ChildBean childBean = g.fromJson(childJson, ChildBean.class);
  67 + if (!TextUtils.isEmpty(childBean.getCardNumber())) {
  68 + cardNumber = childBean.getCardNumber();
  69 + isactivation = 1;
  70 +
  71 + }
  72 + childName = childBean.getStudentName();
  73 + studentId = childBean.getStudentId();
64 74 child_name.setText(childBean.getStudentName());
65 75 child_school.setText(childBean.getSchoolName());
66 76 child_class.setText(childBean.getClassName());
... ... @@ -76,10 +86,10 @@ public class ChildDetialActivity extends BaseMVPCompatActivity&lt;MyChildContract.M
76 86  
77 87 @Override
78 88 public void onClick(View v) {
79   - if(v==btn_unBinding){
  89 + if (v == btn_unBinding) {
80 90 delectChild();
81   - }else if(v==btn_jihuo){
82   -
  91 + } else if (v == btn_jihuo) {
  92 + ActivationActivity.newInstance(this, cardNumber, studentId, isactivation, childName);
83 93 }
84 94  
85 95 }
... ...
app/src/main/java/com/shunzhi/parent/ui/activity/MyChildActivity.java
... ... @@ -6,13 +6,10 @@ import android.graphics.Color;
6 6 import android.os.Bundle;
7 7 import android.support.annotation.NonNull;
8 8 import android.support.v7.widget.LinearLayoutManager;
9   -import android.view.Gravity;
10   -import android.view.LayoutInflater;
11 9 import android.view.View;
12 10 import android.view.ViewGroup;
13 11 import android.view.WindowManager;
14 12 import android.widget.ImageView;
15   -import android.widget.PopupWindow;
16 13 import android.widget.TextView;
17 14  
18 15 import com.share.mvpsdk.base.BasePresenter;
... ... @@ -25,14 +22,13 @@ import com.shunzhi.parent.bean.ChildBean;
25 22 import com.shunzhi.parent.bean.ChildClass;
26 23 import com.shunzhi.parent.bean.CurrentBean;
27 24 import com.shunzhi.parent.contract.mine.MyChildContract;
  25 +import com.shunzhi.parent.db.DBControl;
28 26 import com.shunzhi.parent.presenter.mine.MyChildPresenter;
29 27 import com.shunzhi.parent.ui.activity.binding.SelectSchoolActivity;
30 28 import com.shunzhi.parent.ui.activity.mywebview.WebViewActivity;
31 29 import com.yanzhenjie.recyclerview.swipe.SwipeMenu;
32   -import com.yanzhenjie.recyclerview.swipe.SwipeMenuBridge;
33 30 import com.yanzhenjie.recyclerview.swipe.SwipeMenuCreator;
34 31 import com.yanzhenjie.recyclerview.swipe.SwipeMenuItem;
35   -import com.yanzhenjie.recyclerview.swipe.SwipeMenuItemClickListener;
36 32 import com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView;
37 33  
38 34 import java.util.ArrayList;
... ... @@ -73,41 +69,41 @@ public class MyChildActivity extends BaseMVPCompatActivity&lt;MyChildContract.MyChi
73 69  
74 70 private void initRecyclerView() {
75 71 child_recycle.setLayoutManager(new LinearLayoutManager(this));
76   - child_recycle.smoothOpenRightMenu(0);
77   - child_recycle.setSwipeMenuCreator(swipeMenuCreator);
78   - child_recycle.setSwipeMenuItemClickListener(new SwipeMenuItemClickListener() {
79   - @Override
80   - public void onItemClick(final SwipeMenuBridge menuBridge) {
81   - final PopupWindow popupWindow = new PopupWindow();
82   - popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
83   - popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
84   - backgroundAlpha(0.5f);
85   - View view = LayoutInflater.from(MyChildActivity.this).inflate(R.layout.dialog_view, null);
86   - TextView tv = view.findViewById(R.id.dialog_info);
87   - tv.setText("是否解除绑定?");
88   - TextView btn_cancel = view.findViewById(R.id.cancel_btn);
89   - btn_cancel.setOnClickListener(new View.OnClickListener() {
90   - @Override
91   - public void onClick(View v) {
92   - popupWindow.dismiss();
93   - backgroundAlpha(1f);
94   - }
95   - });
96   - TextView btn_right = view.findViewById(R.id.right_btn);
97   - btn_right.setOnClickListener(new View.OnClickListener() {
98   - @Override
99   - public void onClick(View v) {
100   - popupWindow.dismiss();
101   - backgroundAlpha(1f);
102   - mPresenter.unBinndingResult(Integer.parseInt(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.PARENT_ID))
103   - , currlist.get(menuBridge.getAdapterPosition()).getStudentId());
104   - }
105   - });
106   - popupWindow.setContentView(view);
107   - popupWindow.showAtLocation(child_recycle, Gravity.CENTER, 0, 0);
108   -
109   - }
110   - });
  72 +// child_recycle.smoothOpenRightMenu(0);
  73 +// child_recycle.setSwipeMenuCreator(swipeMenuCreator);
  74 +// child_recycle.setSwipeMenuItemClickListener(new SwipeMenuItemClickListener() {
  75 +// @Override
  76 +// public void onItemClick(final SwipeMenuBridge menuBridge) {
  77 +// final PopupWindow popupWindow = new PopupWindow();
  78 +// popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
  79 +// popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
  80 +// backgroundAlpha(0.5f);
  81 +// View view = LayoutInflater.from(MyChildActivity.this).inflate(R.layout.dialog_view, null);
  82 +// TextView tv = view.findViewById(R.id.dialog_info);
  83 +// tv.setText("是否解除绑定?");
  84 +// TextView btn_cancel = view.findViewById(R.id.cancel_btn);
  85 +// btn_cancel.setOnClickListener(new View.OnClickListener() {
  86 +// @Override
  87 +// public void onClick(View v) {
  88 +// popupWindow.dismiss();
  89 +// backgroundAlpha(1f);
  90 +// }
  91 +// });
  92 +// TextView btn_right = view.findViewById(R.id.right_btn);
  93 +// btn_right.setOnClickListener(new View.OnClickListener() {
  94 +// @Override
  95 +// public void onClick(View v) {
  96 +// popupWindow.dismiss();
  97 +// backgroundAlpha(1f);
  98 +// mPresenter.unBinndingResult(Integer.parseInt(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.PARENT_ID))
  99 +// , currlist.get(menuBridge.getAdapterPosition()).getStudentId());
  100 +// }
  101 +// });
  102 +// popupWindow.setContentView(view);
  103 +// popupWindow.showAtLocation(child_recycle, Gravity.CENTER, 0, 0);
  104 +//
  105 +// }
  106 +// });
111 107 mPresenter.loadChildList(AppConfig.getAppConfig(AppContext.getInstance()).get(AppConfig.LOGIN_NAME), 0, "");
112 108 }
113 109  
... ... @@ -136,6 +132,10 @@ public class MyChildActivity extends BaseMVPCompatActivity&lt;MyChildContract.MyChi
136 132 public void updateChildList(CurrentBean currentBean) {
137 133 currlist.clear();
138 134 List<ChildBean> list = currentBean.getStudentClass();
  135 + for(int i=0;i<list.size();i++){
  136 + DBControl.childInfoDao.onCreate(list.get(i));
  137 + }
  138 +
139 139 currlist.addAll(list);
140 140 if (childAdapter == null) {
141 141 childAdapter = new ChildAdapter(this);
... ...
app/src/main/java/com/shunzhi/parent/ui/fragment/ActivationFragment.java
... ... @@ -4,20 +4,52 @@ import android.os.Bundle;
4 4 import android.support.annotation.NonNull;
5 5 import android.support.annotation.Nullable;
6 6 import android.view.View;
  7 +import android.widget.EditText;
  8 +import android.widget.ImageView;
  9 +import android.widget.TextView;
7 10  
8 11 import com.share.mvpsdk.base.BasePresenter;
9 12 import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment;
  13 +import com.share.mvpsdk.utils.ToastUtils;
10 14 import com.shunzhi.parent.R;
  15 +import com.shunzhi.parent.contract.apply.ApplyReplaceCardContract;
  16 +import com.shunzhi.parent.presenter.apply.ApplyReplaceCardPresenter;
11 17  
12 18 /**
13 19 * Created by Administrator on 2018/4/19 0019.
14 20 */
15 21  
16   -public class ActivationFragment extends BaseMVPCompatFragment{
  22 +public class ActivationFragment extends BaseMVPCompatFragment<ApplyReplaceCardContract.ApplyReplaceCardPreenter, ApplyReplaceCardContract.IApplyReplaceCardModel>
  23 + implements View.OnClickListener {
  24 +
  25 +
  26 + TextView center_title, tv_name, tv_submit;
  27 + EditText et_cardnum;
  28 + ImageView iv_back;
  29 +
  30 + String cardNum = "",childName="";
  31 + int studentId;
  32 +
  33 + @Override
  34 + public void onClick(View v) {
  35 + if (v == tv_submit) {
  36 +
  37 + if (et_cardnum.getText().toString() != null) {
  38 + cardNum=et_cardnum.getText().toString();
  39 + mPresenter.showReplaceCardDetail(studentId, cardNum);
  40 + } else {
  41 + ToastUtils.showToast("请输入卡号");
  42 + }
  43 + }else if(v==iv_back){
  44 + getActivity().finish();
  45 + }
  46 +
  47 + }
  48 +
17 49 @NonNull
18 50 @Override
19 51 public BasePresenter initPresenter() {
20   - return null;
  52 + return new ApplyReplaceCardPresenter();
21 53 }
22 54  
23 55 @Override
... ... @@ -27,6 +59,28 @@ public class ActivationFragment extends BaseMVPCompatFragment{
27 59  
28 60 @Override
29 61 public void initUI(View view, @Nullable Bundle savedInstanceState) {
  62 + center_title = view.findViewById(R.id.center_title);
  63 + iv_back = view.findViewById(R.id.back_top);
  64 + center_title.setText("校卡激活");
  65 + tv_name = view.findViewById(R.id.tv_name);
  66 +
  67 + et_cardnum = view.findViewById(R.id.et_cardnum);
  68 + tv_submit = view.findViewById(R.id.tv_submit);
  69 + cardNum = getArguments().getString("cardNum");
  70 + childName = getArguments().getString("childName");
  71 + tv_name.setText(childName);
  72 + studentId = getArguments().getInt("studentId", 0);
  73 + int isactivation = getArguments().getInt("isactivation", 0);
  74 + if (isactivation == 0) {
  75 + et_cardnum.setEnabled(true);
  76 + tv_submit.setVisibility(View.VISIBLE);
  77 + tv_submit.setOnClickListener(this);
  78 +
  79 + } else {
  80 + et_cardnum.setEnabled(false);
  81 + tv_submit.setVisibility(View.GONE);
  82 + et_cardnum.setText(cardNum);
  83 + }
30 84  
31 85 }
32 86 }
... ...
app/src/main/java/com/shunzhi/parent/util/DatabaseHelper.java 0 → 100644
... ... @@ -0,0 +1,99 @@
  1 +package com.shunzhi.parent.util;
  2 +
  3 +import android.content.Context;
  4 +import android.database.sqlite.SQLiteDatabase;
  5 +
  6 +import com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper;
  7 +import com.j256.ormlite.dao.Dao;
  8 +import com.j256.ormlite.support.ConnectionSource;
  9 +import com.j256.ormlite.table.TableUtils;
  10 +import com.shunzhi.parent.bean.ChildBean;
  11 +
  12 +import java.sql.SQLException;
  13 +import java.util.HashMap;
  14 +import java.util.Map;
  15 +
  16 +/**
  17 + * Created by ToaHanDong on 2017/3/24.
  18 + */
  19 +
  20 +public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
  21 + private static final String TABLE_NAME = "parent.db";
  22 + private Map<String, Dao> daos = new HashMap<String, Dao>();
  23 + private static DatabaseHelper instance;
  24 +
  25 + public DatabaseHelper(Context context){
  26 + super(context,TABLE_NAME,null,1);
  27 + }
  28 +
  29 + /*
  30 + 创建数据库
  31 + */
  32 + @Override
  33 + public void onCreate(SQLiteDatabase database, ConnectionSource connectionSource) {
  34 + try {
  35 + TableUtils.createTableIfNotExists(connectionSource, ChildBean.class);
  36 + } catch (SQLException e) {
  37 + e.printStackTrace();
  38 + }
  39 + }
  40 +
  41 + @Override
  42 + public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
  43 + try {
  44 + TableUtils.dropTable(connectionSource,ChildBean.class,true);
  45 + onCreate(database,connectionSource);
  46 + } catch (SQLException e) {
  47 + e.printStackTrace();
  48 + }
  49 + }
  50 +
  51 + //删除数据库
  52 + public void deleteAll(){
  53 + try {
  54 + TableUtils.dropTable(connectionSource,ChildBean.class,true);
  55 + } catch (SQLException e) {
  56 + e.printStackTrace();
  57 + }
  58 + }
  59 +
  60 + public static synchronized DatabaseHelper getHelper(Context context){
  61 + context=context.getApplicationContext();
  62 + if (null==instance){
  63 + synchronized (DatabaseHelper.class){
  64 + if (null==instance){
  65 + instance=new DatabaseHelper(context);
  66 + }
  67 + }
  68 + }
  69 + return instance;
  70 + }
  71 +
  72 + public synchronized Dao getDao(Class clazz) throws SQLException {
  73 + Dao dao = null;
  74 + String className = clazz.getSimpleName();
  75 +
  76 + if (daos.containsKey(className)) {
  77 + dao = daos.get(className);
  78 + }
  79 + if (dao == null) {
  80 + dao = super.getDao(clazz);
  81 + daos.put(className, dao);
  82 + }
  83 + return dao;
  84 + }
  85 +
  86 + /**
  87 + * 释放资源
  88 + */
  89 + @Override
  90 + public void close() {
  91 + super.close();
  92 +
  93 + for (String key : daos.keySet())
  94 + {
  95 + Dao dao = daos.get(key);
  96 + dao = null;
  97 + }
  98 + }
  99 +}
... ...
app/src/main/res/layout/fragment_activation.xml
... ... @@ -15,8 +15,8 @@
15 15 android:layout_width="match_parent"
16 16 android:layout_height="200dp"
17 17 android:layout_centerInParent="true"
18   - android:layout_marginLeft="20dp"
19   - android:layout_marginRight="20dp"
  18 + android:layout_marginLeft="30dp"
  19 + android:layout_marginRight="30dp"
20 20 android:paddingTop="30dp"
21 21 android:background="@drawable/report_white"
22 22 android:orientation="vertical">
... ... @@ -33,6 +33,7 @@
33 33 android:textSize="@dimen/textSize18" />
34 34  
35 35 <TextView
  36 + android:id="@+id/tv_name"
36 37 android:layout_width="wrap_content"
37 38 android:layout_height="wrap_content"
38 39 android:layout_weight="1"
... ... @@ -55,6 +56,7 @@
55 56 android:textSize="@dimen/textSize18" />
56 57  
57 58 <EditText
  59 + android:id="@+id/et_cardnum"
58 60 android:layout_width="wrap_content"
59 61 android:layout_height="wrap_content"
60 62 android:layout_marginLeft="10dp"
... ... @@ -72,6 +74,7 @@
72 74 android:layout_weight="1"
73 75 />
74 76 <TextView
  77 + android:id="@+id/tv_submit"
75 78 android:layout_width="match_parent"
76 79 android:layout_height="wrap_content"
77 80 android:textSize="@dimen/textSize20"
... ...
mvpsdk/build.gradle
... ... @@ -121,5 +121,9 @@ dependencies {
121 121  
122 122 //悬浮窗
123 123 // compile 'com.github.yhaolpz:FloatWindow:1.0.8'
  124 +//数据库
  125 + compile 'com.j256.ormlite:ormlite-core:4.48'
  126 + compile 'com.j256.ormlite:ormlite-android:4.48'
  127 +
124 128  
125 129 }
... ...