diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa724b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,15 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..fb7f4a8 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..745ffe5 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,23 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..8d17fee --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0f34fef --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,51 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..bda3af8 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,42 @@ +apply plugin: 'com.android.application' +apply from: '../config.gradle' + + +def androidId = rootProject.ext.androidId +def support = rootProject.ext.dependencies +def url = rootProject.ext.url + + +android { + compileSdk 32 + + defaultConfig { + applicationId "com.hjx.parent" + minSdk 24 + targetSdk 32 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +dependencies { + support.each { k, v -> implementation v } + api project(path: ':libs:common') + implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'com.google.android.material:material:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fe14d75 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/AccountActivity.java b/app/src/main/java/com/hjx/parent/AccountActivity.java new file mode 100644 index 0000000..975eef2 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/AccountActivity.java @@ -0,0 +1,52 @@ +package com.hjx.parent; + +import android.widget.TextView; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.utils.SharedPreferencesUtil; + +public class AccountActivity extends BaseActivity { + + @Override + protected int layoutResId() { + return R.layout.activity_setac; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + + TextView tv_6; + @Override + protected void initView() { + tv_6 = findViewById(R.id.tv_6); + String phone = (String) SharedPreferencesUtil.getData("phone", ""); + if (phone != null && phone.length() > 0) + tv_6.setText(phone); + } + + @Override + protected void initListener() { + findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); + + findViewById(R.id.tv_7).setOnClickListener(view -> startActivity(ChangePwdActivity.class)); + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/AddStudentActivity.java b/app/src/main/java/com/hjx/parent/AddStudentActivity.java new file mode 100644 index 0000000..b9df720 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/AddStudentActivity.java @@ -0,0 +1,197 @@ +package com.hjx.parent; + +import android.graphics.Color; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.net.NetWorks; +import com.prws.common.utils.LogUtil; +import com.prws.common.utils.SharedPreferencesUtil; + +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import okhttp3.ResponseBody; + +public class AddStudentActivity extends BaseActivity { + @Override + protected int layoutResId() { + return R.layout.activity_add_stu; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + View view_2; + View view_3; + View view_4; + View view_5; + Button btn_next; + TextView tv_name, tv_sex, tv_nian, tv_shen; + + @Override + protected void initView() { + view_2 = findViewById(R.id.view_2); + view_3 = findViewById(R.id.view_3); + view_4 = findViewById(R.id.view_4); + view_5 = findViewById(R.id.view_5); + tv_name = findViewById(R.id.tv_name); + tv_sex = findViewById(R.id.tv_sex); + tv_nian = findViewById(R.id.tv_nian); + tv_shen = findViewById(R.id.tv_shen); + + + btn_next = findViewById(R.id.btn_next); + } + + boolean isName = false; + boolean isSex = false; + boolean isNian = false; + boolean isShen = false; + + @Override + protected void onStart() { + super.onStart(); + String name = (String) SharedPreferencesUtil.getData("setName", ""); + String sex = (String) SharedPreferencesUtil.getData("setSex", ""); + String nian = (String) SharedPreferencesUtil.getData("setNian", ""); + String shen = (String) SharedPreferencesUtil.getData("setShen", ""); + + if (name != null && name.length() > 0) { + tv_name.setText(name); + isName = true; + } else { + isName = false; + } + if (sex != null && sex.length() > 0) { + tv_sex.setText(sex); + isSex = true; + } else { + isSex = false; + } + if (nian != null && nian.length() > 0) { + tv_nian.setText(nian); + isNian = true; + } else { + isNian = false; + } + if (shen != null && shen.length() > 0) { + tv_shen.setText(shen); + isShen = true; + } else { + isShen = false; + } + + if (isName && isSex && isNian && isShen) { + btn_next.setTextColor(Color.WHITE); + btn_next.setBackground(getResources().getDrawable(R.drawable.bg_solid_btn)); + } + + } + + @Override + protected void initListener() { + view_2.setOnClickListener(view -> startActivity(NickActivity.class)); + view_3.setOnClickListener(view -> startActivity(SexActivity.class)); + view_4.setOnClickListener(view -> startActivity(NianActivity.class)); + view_5.setOnClickListener(view -> startActivity(ShenActivity.class)); + findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); + btn_next.setOnClickListener(view -> { + if (isName && isSex && isNian && isShen) { + addStudent(); + } else { + Toast.makeText(this, "请完成设置后点击", Toast.LENGTH_SHORT).show(); + } + }); + } + + @Override + protected void onDestroy() { + super.onDestroy(); + SharedPreferencesUtil.putData("setName", ""); + SharedPreferencesUtil.putData("setSex", ""); + SharedPreferencesUtil.putData("setNian", ""); + SharedPreferencesUtil.putData("setShen", ""); + SharedPreferencesUtil.putData("setXueq", ""); + + } + public void addStudent() { + String name = (String) SharedPreferencesUtil.getData("setName", ""); + String sex = (String) SharedPreferencesUtil.getData("setSex", ""); + String nian = (String) SharedPreferencesUtil.getData("setNian", ""); + String shen = (String) SharedPreferencesUtil.getData("setShen", ""); + String xueq = (String) SharedPreferencesUtil.getData("setXueq", ""); + + + Map map = new HashMap(); + map.put("nickName", name); + map.put("gender", "1"); + map.put("gradeId", 1); + map.put("parentIdentity", shen); + map.put("term", xueq); + + + NetWorks.registerStudent(NetWorks.getMapRequestBody(map), new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(ResponseBody responseBody) { + try { + + String str = responseBody.string().toString(); + LogUtil.e(TAG, "----" + str); + JSONObject jo = new JSONObject(str); + boolean isSucceed = jo.getBoolean("success"); + if (isSucceed) { + finish(); + } else { + Toast.makeText(AddStudentActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); + } + } catch (Exception e) { + e.printStackTrace(); + Toast.makeText(AddStudentActivity.this, "服务繁忙,请重试", Toast.LENGTH_SHORT).show(); + } + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + + }); + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} diff --git a/app/src/main/java/com/hjx/parent/ChangePwdActivity.java b/app/src/main/java/com/hjx/parent/ChangePwdActivity.java new file mode 100644 index 0000000..3e9a9da --- /dev/null +++ b/app/src/main/java/com/hjx/parent/ChangePwdActivity.java @@ -0,0 +1,125 @@ +package com.hjx.parent; + +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.net.NetWorks; +import com.prws.common.utils.LogUtil; +import com.prws.common.utils.SharedPreferencesUtil; + +import org.json.JSONObject; + +import java.util.HashMap; +import java.util.Map; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import okhttp3.ResponseBody; + +public class ChangePwdActivity extends BaseActivity { + + @Override + protected int layoutResId() { + return R.layout.activity_changem; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + + + EditText et_pwd; + @Override + protected void initView() { + + + et_pwd = findViewById(R.id.et_pwd); + } + + @Override + protected void initListener() { + findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); + + findViewById(R.id.btn_next).setOnClickListener(view -> { + String pwd = et_pwd.getText().toString().trim(); + if (pwd == null || pwd.length() == 0){ + Toast.makeText(this,"密码不能为空",Toast.LENGTH_SHORT).show(); + return; + } + + changePwd(pwd); + + }); + + } + + public void changePwd(String pwd){ + String userId = (String) SharedPreferencesUtil.getData("userId", ""); + Map map = new HashMap(); + map.put("userId",userId); + map.put("password",pwd); + + + NetWorks.changePassword(NetWorks.getMapRequestBody(map), new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(ResponseBody responseBody) { + try { + + String str = responseBody.string().toString(); + + + LogUtil.e(TAG,"----"+str); + JSONObject jo = new JSONObject(str); + boolean isSucceed = jo.getBoolean("success"); + if (isSucceed){ + Toast.makeText(ChangePwdActivity.this, "修改成功", Toast.LENGTH_SHORT).show(); + finish(); + + }else { + Toast.makeText(ChangePwdActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); + } + }catch (Exception e){ + e.printStackTrace(); + Toast.makeText(ChangePwdActivity.this,"服务繁忙,请重试",Toast.LENGTH_SHORT).show(); + } + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/LoginActivity.java b/app/src/main/java/com/hjx/parent/LoginActivity.java new file mode 100644 index 0000000..5bfc715 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/LoginActivity.java @@ -0,0 +1,213 @@ +package com.hjx.parent; + +import android.os.Bundle; +import android.telephony.PhoneNumberUtils; +import android.text.InputType; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.appcompat.app.AppCompatActivity; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.bean.BaseEntity; +import com.prws.common.net.NetWorks; +import com.prws.common.utils.LogUtil; +import com.prws.common.utils.SharedPreferencesUtil; +import com.prws.common.utils.acmanager.ActivityManager; + +import org.json.JSONObject; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import okhttp3.ResponseBody; + + +public class LoginActivity extends BaseActivity { + + + EditText et_phone; + EditText et_pwd; + ImageView iv_show; + ImageView iv_delete; + Button btn_login; + TextView tv_reg; + CheckBox cb_1; + TextView tv_user; + TextView tv_ys; + + + + @Override + protected int layoutResId() { + return R.layout.activity_login; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + + @Override + protected void initView() { + et_phone = findViewById(R.id.et_phone); + et_pwd = findViewById(R.id.et_pwd); + iv_show = findViewById(R.id.iv_4); + iv_delete = findViewById(R.id.iv_2); + btn_login = findViewById(R.id.btn_1); + tv_reg = findViewById(R.id.tv_2); + cb_1 = findViewById(R.id.cb_1); + tv_user = findViewById(R.id.tv_4); + tv_ys = findViewById(R.id.tv_6); + + + String role = (String) SharedPreferencesUtil.getData("role",""); + + if (role != null && role.length()> 0){ + LogUtil.e(TAG,"role 不是空----"); + startActivity(MainActivity.class); + finish(); + return; + }else { + LogUtil.e(TAG,"role 是空----"); + } + + + + + } + + @Override + protected void initListener() { + iv_delete.setOnClickListener(view -> { + et_phone.setText(""); + }); + iv_show.setOnClickListener(view -> { + + if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())){ + iv_show.setBackgroundResource(R.mipmap.yc); + et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + }else { + iv_show.setBackgroundResource(R.mipmap.xs); + et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); + } + + + }); + + + btn_login.setOnClickListener(view -> { + + String phone = et_phone.getText().toString().trim(); + String pwd = et_pwd.getText().toString().trim(); + if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0){ + Toast.makeText(this,"手机号以及密码不能为空",Toast.LENGTH_SHORT).show(); + return; + } + + if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())){ + Toast.makeText(this,"请输入正确的手机号码",Toast.LENGTH_SHORT).show(); + return; + } + + if (!cb_1.isChecked()){ + Toast.makeText(this,"请勾选协议",Toast.LENGTH_SHORT).show(); + return; + } + + login(phone,pwd); + + }); + + tv_reg.setOnClickListener(view -> { + startActivity(RegisterActivity.class); + finish(); + }); + + tv_ys.setOnClickListener(view -> { + startActivity(YinsiActivity.class); + }); + tv_user.setOnClickListener(view -> { + startActivity(UserActivity.class); + }); + } + + public void login(final String phone ,String pwd){ + + Map map = new HashMap(); + map.put("username",phone); + map.put("password",pwd); + + + NetWorks.login(NetWorks.getMapRequestBody(map), new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(ResponseBody responseBody) { + try { + + String str = responseBody.string().toString(); + + + LogUtil.e(TAG,"----"+str); + JSONObject jo = new JSONObject(str); + boolean isSucceed = jo.getBoolean("success"); + if (isSucceed){ + JSONObject jo2 = jo.getJSONObject("data"); + SharedPreferencesUtil.putData("phone",phone); + SharedPreferencesUtil.putData("role",jo2.getString("role")); + SharedPreferencesUtil.putData("userId",jo2.getString("userId")); + SharedPreferencesUtil.putData("token",jo2.getString("token")); + + startActivity(MainActivity.class); + + }else { + Toast.makeText(LoginActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); + } + }catch (Exception e){ + e.printStackTrace(); + Toast.makeText(LoginActivity.this,"服务繁忙,请重试",Toast.LENGTH_SHORT).show(); + } + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + } + + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/MainActivity.java b/app/src/main/java/com/hjx/parent/MainActivity.java new file mode 100644 index 0000000..c3aac8c --- /dev/null +++ b/app/src/main/java/com/hjx/parent/MainActivity.java @@ -0,0 +1,112 @@ +package com.hjx.parent; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.widget.ConstraintLayout; + +import android.graphics.Color; +import android.os.Bundle; +import android.widget.ImageView; +import android.widget.TextView; + +import com.hjx.parent.fragment.HomeFragment; +import com.hjx.parent.fragment.MeFragment; +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; + +public class MainActivity extends BaseActivity { + + @Override + protected int layoutResId() { + return R.layout.activity_main; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + + + + HomeFragment homeFragment; + MeFragment meFragment; + ConstraintLayout cl_home; + ConstraintLayout cl_me; + ImageView iv_3,iv_4; + TextView tv_1,tv_4; + + @Override + protected void initView() { + showFragment(getHomeFragment(),R.id.rl_content); + cl_home = findViewById(R.id.cl_home); + cl_me = findViewById(R.id.cl_me); + iv_3 = findViewById(R.id.iv_3); + iv_4 = findViewById(R.id.iv_4); + tv_1 = findViewById(R.id.tv_1); + tv_4 = findViewById(R.id.tv_4); + + + iv_3.setBackgroundResource(R.mipmap.hoss); + tv_1.setTextColor(Color.parseColor("#FE5E09")); + + + + } + + public HomeFragment getHomeFragment(){ + if (homeFragment == null) + homeFragment = new HomeFragment(); + return homeFragment; + } + + public MeFragment getMeFragment(){ + if (meFragment == null) + meFragment = new MeFragment(); + return meFragment; + } + + + + @Override + protected void initListener() { + cl_home.setOnClickListener(view -> { + showFragment(getHomeFragment(),R.id.rl_content); + iv_3.setBackgroundResource(R.mipmap.hoss); + tv_1.setTextColor(Color.parseColor("#FE5E09")); + + + iv_4.setBackgroundResource(R.mipmap.wmus); + tv_4.setTextColor(Color.parseColor("#333333")); + + + }); + + cl_me.setOnClickListener(view -> { + showFragment(getMeFragment(),R.id.rl_content); + + iv_3.setBackgroundResource(R.mipmap.hous); + tv_1.setTextColor(Color.parseColor("#333333")); + + + iv_4.setBackgroundResource(R.mipmap.wmss); + tv_4.setTextColor(Color.parseColor("#FE5E09")); + + + }); + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/MyApplication.java b/app/src/main/java/com/hjx/parent/MyApplication.java new file mode 100644 index 0000000..a03eeb3 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/MyApplication.java @@ -0,0 +1,18 @@ +package com.hjx.parent; + +import com.prws.common.CommonApplication; +import com.prws.common.utils.SharedPreferencesUtil; +import com.uuzuche.lib_zxing.activity.ZXingLibrary; + +public class MyApplication extends CommonApplication { + + @Override + public void onCreate() { + super.onCreate(); + + SharedPreferencesUtil.getInstance(this,"config"); + + ZXingLibrary.initDisplayOpinion(this); + + } +} diff --git a/app/src/main/java/com/hjx/parent/NianActivity.java b/app/src/main/java/com/hjx/parent/NianActivity.java new file mode 100644 index 0000000..b61996d --- /dev/null +++ b/app/src/main/java/com/hjx/parent/NianActivity.java @@ -0,0 +1,56 @@ +package com.hjx.parent; + +import android.widget.TextView; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.utils.SharedPreferencesUtil; + +public class NianActivity extends BaseActivity { + @Override + protected int layoutResId() { + return R.layout.activity_set_nian; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + TextView tv_nian; + TextView tv_xq; + + @Override + protected void initView() { + tv_nian = findViewById(R.id.tv_nian); + tv_xq = findViewById(R.id.tv_xq); + findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); + findViewById(R.id.tv_ok).setOnClickListener(view -> { + SharedPreferencesUtil.putData("setNian", tv_nian.getText()); + SharedPreferencesUtil.putData("setXueq", tv_xq.getText()); + finish(); + }); + + + } + + @Override + protected void initListener() { + + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} diff --git a/app/src/main/java/com/hjx/parent/NickActivity.java b/app/src/main/java/com/hjx/parent/NickActivity.java new file mode 100644 index 0000000..1d134a1 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/NickActivity.java @@ -0,0 +1,58 @@ +package com.hjx.parent; + +import android.widget.EditText; +import android.widget.TextView; +import android.widget.Toast; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.utils.SharedPreferencesUtil; + +public class NickActivity extends BaseActivity { + @Override + protected int layoutResId() { + return R.layout.activity_set_nick; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + EditText et_1; + + @Override + protected void initView() { + et_1 = findViewById(R.id.et_1); + findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); + findViewById(R.id.tv_ok).setOnClickListener(view -> { + String name = et_1.getText().toString().trim(); + if (name != null && name.length() > 0){ + SharedPreferencesUtil.putData("setName",name); + finish(); + }else { + Toast.makeText(this,"请设置昵称",Toast.LENGTH_SHORT).show(); + } + }); + } + + @Override + protected void initListener() { + + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} diff --git a/app/src/main/java/com/hjx/parent/QRActivity.java b/app/src/main/java/com/hjx/parent/QRActivity.java new file mode 100644 index 0000000..a2c4361 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/QRActivity.java @@ -0,0 +1,127 @@ +package com.hjx.parent; + +import android.graphics.Bitmap; +import android.widget.Toast; + +import com.google.gson.Gson; +import com.hjx.parent.bean.RegisterBean; +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.net.NetWorks; +import com.prws.common.utils.LogUtil; +import com.prws.common.utils.SharedPreferencesUtil; +import com.uuzuche.lib_zxing.activity.CaptureFragment; +import com.uuzuche.lib_zxing.activity.CodeUtils; + +import org.json.JSONObject; + +import java.io.IOException; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import okhttp3.ResponseBody; + +public class QRActivity extends BaseActivity { + @Override + protected int layoutResId() { + return R.layout.activity_qr; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + @Override + protected void initView() { + + findViewById(R.id.iv_back).setOnClickListener(view -> startActivity(MainActivity.class)); + + CaptureFragment captureFragment = new CaptureFragment(); + + captureFragment.setAnalyzeCallback(new CodeUtils.AnalyzeCallback() { + @Override + public void onAnalyzeSuccess(Bitmap mBitmap, String result) { + LogUtil.e(TAG,"result----:"+result); + + loginAnd(result); + + } + + @Override + public void onAnalyzeFailed() { + + } + }); + + + getSupportFragmentManager().beginTransaction().replace(R.id.rl_content, captureFragment).commit(); + + + } + + public void loginAnd(String str){ + NetWorks.scanAndLogin(str, new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(ResponseBody responseBody) { + try { + + String str = responseBody.string().toString(); + LogUtil.e(TAG,"----"+str); + JSONObject jo = new JSONObject(str); + boolean isSucceed = jo.getBoolean("success"); + if (isSucceed){ + startActivity(MainActivity.class); + finish(); + }else { + Toast.makeText(QRActivity.this, jo.getString("msg"), Toast.LENGTH_SHORT).show(); + } + }catch (Exception e){ + e.printStackTrace(); + Toast.makeText(QRActivity.this,"服务繁忙,请重试",Toast.LENGTH_SHORT).show(); + startActivity(MainActivity.class); + } + + + + + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + } + + @Override + protected void initListener() { + + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} diff --git a/app/src/main/java/com/hjx/parent/RegisterActivity.java b/app/src/main/java/com/hjx/parent/RegisterActivity.java new file mode 100644 index 0000000..b00a006 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/RegisterActivity.java @@ -0,0 +1,269 @@ +package com.hjx.parent; + +import android.content.Intent; +import android.os.Bundle; +import android.telephony.PhoneNumberUtils; +import android.text.InputType; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import com.google.gson.Gson; +import com.hjq.permissions.OnPermissionCallback; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; +import com.hjx.parent.bean.RegisterBean; +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.bean.BaseEntity; +import com.prws.common.net.NetWorks; +import com.prws.common.utils.GsonUtil; +import com.prws.common.utils.LogUtil; +import com.prws.common.utils.SharedPreferencesUtil; +import com.uuzuche.lib_zxing.activity.CaptureActivity; +import com.uuzuche.lib_zxing.activity.CodeUtils; + +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import okhttp3.ResponseBody; + +public class RegisterActivity extends BaseActivity { + + EditText et_phone; + EditText et_pwd; + EditText et_pwd_2; + ImageView iv_show; + ImageView iv_show_2; + ImageView iv_delete; + Button btn_reg; + TextView tv_log; + CheckBox cb_1; + TextView tv_user; + TextView tv_ys; + + + @Override + protected int layoutResId() { + return R.layout.activity_register; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + @Override + protected void initView() { + et_phone = findViewById(R.id.et_phone); + et_pwd = findViewById(R.id.et_pwd); + iv_show = findViewById(R.id.iv_4); + iv_show_2 = findViewById(R.id.iv_6); + et_pwd_2 = findViewById(R.id.et_pwd_2); + iv_delete = findViewById(R.id.iv_2); + btn_reg = findViewById(R.id.btn_1); + tv_log = findViewById(R.id.tv_2); + cb_1 = findViewById(R.id.cb_1); + tv_user = findViewById(R.id.tv_4); + tv_ys = findViewById(R.id.tv_6); + + + } + + @Override + protected void initListener() { + iv_delete.setOnClickListener(view -> { + et_phone.setText(""); + }); + iv_show.setOnClickListener(view -> { + + if (iv_show.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { + iv_show.setBackgroundResource(R.mipmap.yc); + et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + } else { + iv_show.setBackgroundResource(R.mipmap.xs); + et_pwd.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); + } + + + }); + + iv_show_2.setOnClickListener(view -> { + + if (iv_show_2.getBackground().getConstantState().equals(getDrawable(R.mipmap.xs).getConstantState())) { + iv_show_2.setBackgroundResource(R.mipmap.yc); + et_pwd_2.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + } else { + iv_show_2.setBackgroundResource(R.mipmap.xs); + et_pwd_2.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); + } + + + }); + + + btn_reg.setOnClickListener(view -> { + + String phone = et_phone.getText().toString().trim(); + String pwd = et_pwd.getText().toString().trim(); + String pwd2 = et_pwd_2.getText().toString().trim(); + if (phone.isEmpty() || pwd.isEmpty() || phone.length() == 0 || pwd.length() == 0) { + Toast.makeText(this, "手机号以及密码不能为空", Toast.LENGTH_SHORT).show(); + return; + } + + if (!PhoneNumberUtils.isGlobalPhoneNumber(et_phone.getText().toString())) { + Toast.makeText(this, "请输入正确的手机号码", Toast.LENGTH_SHORT).show(); + return; + } + + if (!cb_1.isChecked()) { + Toast.makeText(this, "请勾选协议", Toast.LENGTH_SHORT).show(); + return; + } + if (!pwd.equals(pwd2)) { + Toast.makeText(this, "两次密码需要一致", Toast.LENGTH_SHORT).show(); + return; + } + + reg(phone, pwd); + + }); + + tv_log.setOnClickListener(view -> { + startActivity(LoginActivity.class); + finish(); + }); + + tv_ys.setOnClickListener(view -> { + startActivity(YinsiActivity.class); + }); + tv_user.setOnClickListener(view -> { + startActivity(UserActivity.class); + }); + } + + public void reg(final String phone, String pwd) { + + Map map = new HashMap(); + map.put("username", phone); + map.put("password", pwd); + + + NetWorks.registerParent(NetWorks.getMapRequestBody(map), new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(ResponseBody responseBody) { + String str = null; + try { + str = responseBody.string(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (str == null || str.length() == 0) { + Toast.makeText(RegisterActivity.this, "服务器繁忙", Toast.LENGTH_SHORT).show(); + return; + } + + RegisterBean registerBean = new Gson().fromJson(str, RegisterBean.class); + + if (!registerBean.isSuccess()) { + Toast.makeText(RegisterActivity.this, registerBean.getMsg(), Toast.LENGTH_SHORT).show(); + return; + } + + if (registerBean.getData().getUserName() != null && registerBean.getData().getUserName().length() > 0) { + SharedPreferencesUtil.putData("phone",phone); + SharedPreferencesUtil.putData("role",registerBean.getData().getUserName()); + SharedPreferencesUtil.putData("userId",registerBean.getData().getUserName()); + + //进入扫码界面 + goQRView(); + + } + + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + } + + public void goQRView() { + + if (!XXPermissions.isGranted(this, Permission.CAMERA)) { + XXPermissions.with(this) + // 申请多个权限 + .permission(Permission.CAMERA) + .request(new OnPermissionCallback() { + @Override + public void onGranted(List permissions, boolean all) { + if (all) { + //开启扫码界面 + startQRView(); + + } else { + Toast.makeText(RegisterActivity.this, "需要相机权限", Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onDenied(List permissions, boolean never) { + XXPermissions.startPermissionActivity(RegisterActivity.this, permissions); + } + }); + + + } else { + startQRView(); + } + + + } + + public void startQRView() { + + startActivity(QRActivity.class); + finish(); + + } + + + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/SexActivity.java b/app/src/main/java/com/hjx/parent/SexActivity.java new file mode 100644 index 0000000..b8af458 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/SexActivity.java @@ -0,0 +1,72 @@ +package com.hjx.parent; + +import android.view.View; +import android.widget.ImageView; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.utils.SharedPreferencesUtil; + +public class SexActivity extends BaseActivity { + @Override + protected int layoutResId() { + return R.layout.activity_set_sex; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + View view_nv; + View view_nan; + boolean isNv = true; + ImageView cb_1,cb_2; + @Override + protected void initView() { + view_nv = findViewById(R.id.view_2); + view_nan = findViewById(R.id.view_3); + cb_1 = findViewById(R.id.cb_1); + cb_2 = findViewById(R.id.cb_2); + + findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); + findViewById(R.id.tv_ok).setOnClickListener(view -> { + SharedPreferencesUtil.putData("setSex", isNv?"女":"男"); + finish(); + }); + view_nv.setOnClickListener(view -> { + view_nv.setBackgroundResource(R.drawable.bg_solid_white_10_or); + view_nan.setBackgroundResource(R.drawable.bg_solid_white_10); + cb_1.setBackgroundResource(R.mipmap.gx); + cb_2.setBackgroundResource(R.mipmap.wsyq); + isNv = true; + }); + view_nan.setOnClickListener(view -> { + view_nv.setBackgroundResource(R.drawable.bg_solid_white_10); + view_nan.setBackgroundResource(R.drawable.bg_solid_white_10_or); + cb_1.setBackgroundResource(R.mipmap.wsyq); + cb_2.setBackgroundResource(R.mipmap.gx); + isNv = false; + }); + } + + @Override + protected void initListener() { + + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} diff --git a/app/src/main/java/com/hjx/parent/ShenActivity.java b/app/src/main/java/com/hjx/parent/ShenActivity.java new file mode 100644 index 0000000..39262b9 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/ShenActivity.java @@ -0,0 +1,157 @@ +package com.hjx.parent; + +import android.view.View; +import android.widget.ImageView; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; +import com.prws.common.utils.SharedPreferencesUtil; + +public class ShenActivity extends BaseActivity { + @Override + protected int layoutResId() { + return R.layout.activity_set_jia; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + View view_1; + View view_2,view_3,view_4,view_5,view_6; + ImageView iv_1,iv_2,iv_3,iv_4,iv_5,iv_6; + + String shen = "爸爸"; + @Override + protected void initView() { + findViewById(R.id.tv_cancel).setOnClickListener(view -> onBackPressed()); + findViewById(R.id.tv_ok).setOnClickListener(view -> { + SharedPreferencesUtil.putData("setShen", shen); + finish(); + }); + view_1 = findViewById(R.id.view_2); + view_2 = findViewById(R.id.view_3); + view_3 = findViewById(R.id.view_4); + view_4 = findViewById(R.id.view_5); + view_5 = findViewById(R.id.view_6); + view_6 = findViewById(R.id.view_7); + iv_1 = findViewById(R.id.iv_1); + iv_2 = findViewById(R.id.iv_2); + iv_3 = findViewById(R.id.iv_3); + iv_4 = findViewById(R.id.iv_4); + iv_5 = findViewById(R.id.iv_5); + iv_6 = findViewById(R.id.iv_6); + + view_1.setOnClickListener(view -> { + view_1.setBackgroundResource(R.drawable.bg_solid_white_10_or); + view_2.setBackgroundResource(R.drawable.bg_solid_white_10); + view_3.setBackgroundResource(R.drawable.bg_solid_white_10); + view_4.setBackgroundResource(R.drawable.bg_solid_white_10); + view_5.setBackgroundResource(R.drawable.bg_solid_white_10); + view_6.setBackgroundResource(R.drawable.bg_solid_white_10); + iv_1.setBackgroundResource(R.mipmap.gx); + iv_2.setBackgroundResource(R.mipmap.wsyq); + iv_3.setBackgroundResource(R.mipmap.wsyq); + iv_4.setBackgroundResource(R.mipmap.wsyq); + iv_5.setBackgroundResource(R.mipmap.wsyq); + iv_6.setBackgroundResource(R.mipmap.wsyq); + shen = "爸爸"; + }); + view_2.setOnClickListener(view -> { + view_1.setBackgroundResource(R.drawable.bg_solid_white_10); + view_2.setBackgroundResource(R.drawable.bg_solid_white_10_or); + view_3.setBackgroundResource(R.drawable.bg_solid_white_10); + view_4.setBackgroundResource(R.drawable.bg_solid_white_10); + view_5.setBackgroundResource(R.drawable.bg_solid_white_10); + view_6.setBackgroundResource(R.drawable.bg_solid_white_10); + shen = "妈妈"; + iv_1.setBackgroundResource(R.mipmap.wsyq); + iv_2.setBackgroundResource(R.mipmap.gx); + iv_3.setBackgroundResource(R.mipmap.wsyq); + iv_4.setBackgroundResource(R.mipmap.wsyq); + iv_5.setBackgroundResource(R.mipmap.wsyq); + iv_6.setBackgroundResource(R.mipmap.wsyq); + }); + view_3.setOnClickListener(view -> { + view_1.setBackgroundResource(R.drawable.bg_solid_white_10); + view_2.setBackgroundResource(R.drawable.bg_solid_white_10); + view_3.setBackgroundResource(R.drawable.bg_solid_white_10_or); + view_4.setBackgroundResource(R.drawable.bg_solid_white_10); + view_5.setBackgroundResource(R.drawable.bg_solid_white_10); + view_6.setBackgroundResource(R.drawable.bg_solid_white_10); + shen = "爷爷"; + iv_1.setBackgroundResource(R.mipmap.wsyq); + iv_2.setBackgroundResource(R.mipmap.wsyq); + iv_3.setBackgroundResource(R.mipmap.gx); + iv_4.setBackgroundResource(R.mipmap.wsyq); + iv_5.setBackgroundResource(R.mipmap.wsyq); + iv_6.setBackgroundResource(R.mipmap.wsyq); + }); + view_4.setOnClickListener(view -> { + view_1.setBackgroundResource(R.drawable.bg_solid_white_10); + view_2.setBackgroundResource(R.drawable.bg_solid_white_10); + view_3.setBackgroundResource(R.drawable.bg_solid_white_10); + view_4.setBackgroundResource(R.drawable.bg_solid_white_10_or); + view_5.setBackgroundResource(R.drawable.bg_solid_white_10); + view_6.setBackgroundResource(R.drawable.bg_solid_white_10); + shen = "奶奶"; + iv_1.setBackgroundResource(R.mipmap.wsyq); + iv_2.setBackgroundResource(R.mipmap.wsyq); + iv_3.setBackgroundResource(R.mipmap.wsyq); + iv_4.setBackgroundResource(R.mipmap.gx); + iv_5.setBackgroundResource(R.mipmap.wsyq); + iv_6.setBackgroundResource(R.mipmap.wsyq); + }); + view_5.setOnClickListener(view -> { + view_1.setBackgroundResource(R.drawable.bg_solid_white_10); + view_2.setBackgroundResource(R.drawable.bg_solid_white_10); + view_3.setBackgroundResource(R.drawable.bg_solid_white_10); + view_4.setBackgroundResource(R.drawable.bg_solid_white_10); + view_5.setBackgroundResource(R.drawable.bg_solid_white_10_or); + view_6.setBackgroundResource(R.drawable.bg_solid_white_10); + shen = "外公"; + iv_1.setBackgroundResource(R.mipmap.wsyq); + iv_2.setBackgroundResource(R.mipmap.wsyq); + iv_3.setBackgroundResource(R.mipmap.wsyq); + iv_4.setBackgroundResource(R.mipmap.wsyq); + iv_5.setBackgroundResource(R.mipmap.gx); + iv_6.setBackgroundResource(R.mipmap.wsyq); + }); + view_6.setOnClickListener(view -> { + view_1.setBackgroundResource(R.drawable.bg_solid_white_10); + view_2.setBackgroundResource(R.drawable.bg_solid_white_10); + view_3.setBackgroundResource(R.drawable.bg_solid_white_10); + view_4.setBackgroundResource(R.drawable.bg_solid_white_10); + view_5.setBackgroundResource(R.drawable.bg_solid_white_10); + view_6.setBackgroundResource(R.drawable.bg_solid_white_10_or); + shen = "外婆"; + iv_1.setBackgroundResource(R.mipmap.wsyq); + iv_2.setBackgroundResource(R.mipmap.wsyq); + iv_3.setBackgroundResource(R.mipmap.wsyq); + iv_4.setBackgroundResource(R.mipmap.wsyq); + iv_5.setBackgroundResource(R.mipmap.wsyq); + iv_6.setBackgroundResource(R.mipmap.gx); + }); + + } + + @Override + protected void initListener() { + + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} diff --git a/app/src/main/java/com/hjx/parent/UserActivity.java b/app/src/main/java/com/hjx/parent/UserActivity.java new file mode 100644 index 0000000..5673e1d --- /dev/null +++ b/app/src/main/java/com/hjx/parent/UserActivity.java @@ -0,0 +1,43 @@ +package com.hjx.parent; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; + +public class UserActivity extends BaseActivity { + + @Override + protected int layoutResId() { + return R.layout.activity_me; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + + @Override + protected void initView() { + + } + + @Override + protected void initListener() { + findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/YinsiActivity.java b/app/src/main/java/com/hjx/parent/YinsiActivity.java new file mode 100644 index 0000000..1a2ed03 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/YinsiActivity.java @@ -0,0 +1,43 @@ +package com.hjx.parent; + +import com.prws.common.base.BaseActivity; +import com.prws.common.base.BasePresenter; + +public class YinsiActivity extends BaseActivity { + + @Override + protected int layoutResId() { + return R.layout.activity_yin; + } + + @Override + public Object getContract() { + return null; + } + + @Override + public BasePresenter getPresenter() { + return null; + } + + + @Override + protected void initView() { + + } + + @Override + protected void initListener() { + findViewById(R.id.iv_back).setOnClickListener(view -> onBackPressed()); + } + + @Override + protected void initData() { + + } + + @Override + public void onNetChanged(int netWorkState) { + + } +} \ No newline at end of file diff --git a/app/src/main/java/com/hjx/parent/bean/RegisterBean.java b/app/src/main/java/com/hjx/parent/bean/RegisterBean.java new file mode 100644 index 0000000..d8ebfa1 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/bean/RegisterBean.java @@ -0,0 +1,43 @@ +package com.hjx.parent.bean; + +import java.io.Serializable; + +public class RegisterBean implements Serializable { + + Integer code; + String msg; + RegisterDataBean data; + boolean success; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public RegisterDataBean getData() { + return data; + } + + public void setData(RegisterDataBean data) { + this.data = data; + } + + public boolean isSuccess() { + return success; + } + + public void setSuccess(boolean success) { + this.success = success; + } +} diff --git a/app/src/main/java/com/hjx/parent/bean/RegisterDataBean.java b/app/src/main/java/com/hjx/parent/bean/RegisterDataBean.java new file mode 100644 index 0000000..a581da5 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/bean/RegisterDataBean.java @@ -0,0 +1,149 @@ +package com.hjx.parent.bean; + +public class RegisterDataBean { + Integer id; + String userName; + String account; + String password; + String nickName; + String phone; + String mail; + String identity; + String photo; + String qrCode; + Integer sex; + Integer createBy; + String createTime; + Integer updateBy; + String updateTime; + Integer delFlag; + + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getMail() { + return mail; + } + + public void setMail(String mail) { + this.mail = mail; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public String getPhoto() { + return photo; + } + + public void setPhoto(String photo) { + this.photo = photo; + } + + public String getQrCode() { + return qrCode; + } + + public void setQrCode(String qrCode) { + this.qrCode = qrCode; + } + + public Integer getSex() { + return sex; + } + + public void setSex(Integer sex) { + this.sex = sex; + } + + public Integer getCreateBy() { + return createBy; + } + + public void setCreateBy(Integer createBy) { + this.createBy = createBy; + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public Integer getUpdateBy() { + return updateBy; + } + + public void setUpdateBy(Integer updateBy) { + this.updateBy = updateBy; + } + + public String getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(String updateTime) { + this.updateTime = updateTime; + } + + public Integer getDelFlag() { + return delFlag; + } + + public void setDelFlag(Integer delFlag) { + this.delFlag = delFlag; + } +} diff --git a/app/src/main/java/com/hjx/parent/bean/StudentBean.java b/app/src/main/java/com/hjx/parent/bean/StudentBean.java new file mode 100644 index 0000000..62ad040 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/bean/StudentBean.java @@ -0,0 +1,171 @@ +package com.hjx.parent.bean; + +public class StudentBean { + + String stuId; + String stuName; + int gender; + String term; + String account; + String nickName; + String address; + String phone; + String photo; + int fromType; + int gradeId; + String oriSchool; + String parentPhone; + String parentIdentity; + String teacherName; + int teacherId; + + @Override + public String toString() { + return "StudentBean{" + + "stuId='" + stuId + '\'' + + ", stuName='" + stuName + '\'' + + ", gender=" + gender + + ", term='" + term + '\'' + + ", account='" + account + '\'' + + ", nickName='" + nickName + '\'' + + ", address='" + address + '\'' + + ", phone='" + phone + '\'' + + ", photo='" + photo + '\'' + + ", fromType=" + fromType + + ", gradeId=" + gradeId + + ", oriSchool='" + oriSchool + '\'' + + ", parentPhone='" + parentPhone + '\'' + + ", parentIdentity='" + parentIdentity + '\'' + + ", teacherName='" + teacherName + '\'' + + ", teacherId=" + teacherId + + '}'; + } + + public String getStuId() { + return stuId; + } + + public void setStuId(String stuId) { + this.stuId = stuId; + } + + public String getStuName() { + return stuName; + } + + public void setStuName(String stuName) { + this.stuName = stuName; + } + + public int getGender() { + return gender; + } + + public void setGender(int gender) { + this.gender = gender; + } + + public String getTerm() { + return term; + } + + public void setTerm(String term) { + this.term = term; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getPhoto() { + return photo; + } + + public void setPhoto(String photo) { + this.photo = photo; + } + + public int getFromType() { + return fromType; + } + + public void setFromType(int fromType) { + this.fromType = fromType; + } + + public int getGradeId() { + return gradeId; + } + + public void setGradeId(int gradeId) { + this.gradeId = gradeId; + } + + public String getOriSchool() { + return oriSchool; + } + + public void setOriSchool(String oriSchool) { + this.oriSchool = oriSchool; + } + + public String getParentPhone() { + return parentPhone; + } + + public void setParentPhone(String parentPhone) { + this.parentPhone = parentPhone; + } + + public String getParentIdentity() { + return parentIdentity; + } + + public void setParentIdentity(String parentIdentity) { + this.parentIdentity = parentIdentity; + } + + public String getTeacherName() { + return teacherName; + } + + public void setTeacherName(String teacherName) { + this.teacherName = teacherName; + } + + public int getTeacherId() { + return teacherId; + } + + public void setTeacherId(int teacherId) { + this.teacherId = teacherId; + } +} diff --git a/app/src/main/java/com/hjx/parent/fragment/HomeFragment.java b/app/src/main/java/com/hjx/parent/fragment/HomeFragment.java new file mode 100644 index 0000000..44bb604 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/fragment/HomeFragment.java @@ -0,0 +1,107 @@ +package com.hjx.parent.fragment; + +import android.content.Intent; +import android.os.Bundle; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.annotation.Nullable; + +import com.hjq.permissions.OnPermissionCallback; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; +import com.hjx.parent.R; +import com.prws.common.base.BaseFragment; +import com.prws.common.utils.SharedPreferencesUtil; +import com.uuzuche.lib_zxing.activity.CaptureActivity; +import com.uuzuche.lib_zxing.activity.CodeUtils; + +import java.util.List; + +public class HomeFragment extends BaseFragment { + @Override + protected int getLayoutRes() { + return R.layout.fragment_home; + } + + ImageView iv_sapmiao; + TextView tv_name; + @Override + protected void initDatas() { + super.initDatas(); + iv_sapmiao = mRootView.findViewById(R.id.iv_sapmiao); + tv_name = mRootView.findViewById(R.id.tv_name); + iv_sapmiao.setOnClickListener(view -> { + + if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)){ + XXPermissions.with(getActivity()) + // 申请多个权限 + .permission(Permission.CAMERA) + .request(new OnPermissionCallback() { + @Override + public void onGranted(List permissions, boolean all) { + if (all){ + //开启扫码界面 + startQRView(); + + + }else { + Toast.makeText(getActivity(),"需要相机权限",Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onDenied(List permissions, boolean never) { + XXPermissions.startPermissionActivity(getActivity(), permissions); + } + }); + + + + + }else { + startQRView(); + } + + + }); + + String role = (String) SharedPreferencesUtil.getData("role",""); + String userId = (String) SharedPreferencesUtil.getData("userId",""); + String token = (String) SharedPreferencesUtil.getData("token",""); + String phone = (String) SharedPreferencesUtil.getData("phone",""); + if (role != null && role.length() > 0) + tv_name.setText(role); + + } + + public void startQRView(){ + + + startActivityForResult(new Intent(getActivity(), CaptureActivity.class),101); + + + } + + @Override + public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + if (requestCode == 101){ + if (null != data) { + Bundle bundle = data.getExtras(); + if (bundle == null) { + return; + } + if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { + String result = bundle.getString(CodeUtils.RESULT_STRING); + Toast.makeText(getActivity(), "解析结果:" + result, Toast.LENGTH_LONG).show(); + } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) { + Toast.makeText(getActivity(), "解析二维码失败", Toast.LENGTH_LONG).show(); + } + } + } + + + } +} diff --git a/app/src/main/java/com/hjx/parent/fragment/MeFragment.java b/app/src/main/java/com/hjx/parent/fragment/MeFragment.java new file mode 100644 index 0000000..dfad160 --- /dev/null +++ b/app/src/main/java/com/hjx/parent/fragment/MeFragment.java @@ -0,0 +1,306 @@ +package com.hjx.parent.fragment; + +import android.content.Intent; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; +import android.widget.Toast; + +import androidx.constraintlayout.widget.Group; + +import com.bumptech.glide.Glide; +import com.developer.wang.utils.PermissionUtils; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.hjq.permissions.OnPermissionCallback; +import com.hjq.permissions.Permission; +import com.hjq.permissions.XXPermissions; +import com.hjx.parent.AccountActivity; +import com.hjx.parent.AddStudentActivity; +import com.hjx.parent.LoginActivity; +import com.hjx.parent.MainActivity; +import com.hjx.parent.QRActivity; +import com.hjx.parent.R; +import com.hjx.parent.UserActivity; +import com.hjx.parent.YinsiActivity; +import com.hjx.parent.bean.StudentBean; +import com.prws.common.base.BaseFragment; +import com.prws.common.net.NetWorks; +import com.prws.common.utils.LogUtil; +import com.prws.common.utils.SharedPreferencesUtil; + +import org.json.JSONArray; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import io.reactivex.Observer; +import io.reactivex.disposables.Disposable; +import okhttp3.ResponseBody; + +public class MeFragment extends BaseFragment { + @Override + protected int getLayoutRes() { + return R.layout.fragment_me; + } + + ImageView iv_bann; + Group group_1; + TextView tv_name; + TextView tv_phone; + ImageView iv_21, iv_22, iv_23; + TextView tv_21, tv_22, tv_23; + + + @Override + protected void initDatas() { + super.initDatas(); + + + iv_bann = mRootView.findViewById(R.id.iv_bann); + group_1 = mRootView.findViewById(R.id.group_1); + + String role = (String) SharedPreferencesUtil.getData("role", ""); + String userId = (String) SharedPreferencesUtil.getData("userId", ""); + String token = (String) SharedPreferencesUtil.getData("token", ""); + String phone = (String) SharedPreferencesUtil.getData("phone", ""); + if (role == null || role.length() == 0) { + iv_bann.setVisibility(View.VISIBLE); + group_1.setVisibility(View.GONE); + + iv_bann.setOnClickListener(view -> { + + if (!XXPermissions.isGranted(getActivity(), Permission.CAMERA)) { + XXPermissions.with(getActivity()) + // 申请多个权限 + .permission(Permission.CAMERA) + .request(new OnPermissionCallback() { + @Override + public void onGranted(List permissions, boolean all) { + if (all) { + //开启扫码界面 + startActivity(new Intent(getActivity(), QRActivity.class)); + getActivity().finish(); + } else { + Toast.makeText(getActivity(), "需要相机权限", Toast.LENGTH_SHORT).show(); + } + } + + @Override + public void onDenied(List permissions, boolean never) { + XXPermissions.startPermissionActivity(getActivity(), permissions); + } + }); + + + } + + + }); + return; + } else { + iv_bann.setVisibility(View.GONE); + group_1.setVisibility(View.VISIBLE); + } + tv_name = mRootView.findViewById(R.id.tv_name); + tv_phone = mRootView.findViewById(R.id.tv_phone); + iv_21 = mRootView.findViewById(R.id.iv_21); + iv_22 = mRootView.findViewById(R.id.iv_22); + iv_23 = mRootView.findViewById(R.id.iv_23); + tv_21 = mRootView.findViewById(R.id.tv_21); + tv_22 = mRootView.findViewById(R.id.tv_22); + tv_23 = mRootView.findViewById(R.id.tv_23); + + tv_phone.setText(phone); + tv_name.setText(role); + + iv_21.setOnClickListener(view -> { + if (iv_21.getBackground().getConstantState().equals(getActivity().getDrawable(R.mipmap.tjxss).getConstantState())) { + startActivity(new Intent(getActivity(), AddStudentActivity.class)); + } + + }); + + iv_22.setOnClickListener(view -> { + if (iv_22.getBackground().getConstantState().equals(getActivity().getDrawable(R.mipmap.tjxss).getConstantState())) { + startActivity(new Intent(getActivity(), AddStudentActivity.class)); + + } + }); + iv_23.setOnClickListener(view -> { + if (iv_23.getBackground().getConstantState().equals(getActivity().getDrawable(R.mipmap.tjxss).getConstantState())) { + startActivity(new Intent(getActivity(), AddStudentActivity.class)); + } + }); + + + } + + @Override + public void onResume() { + super.onResume(); + loadChildList(); + } + + ArrayList alist = new ArrayList<>(); + + public void loadChildList() { + + + NetWorks.listChildren(new Observer() { + @Override + public void onSubscribe(Disposable d) { + + } + + @Override + public void onNext(ResponseBody responseBody) { + try { + + String str = responseBody.string().toString(); + + + LogUtil.e("TAG", "----" + str); + JSONObject jo = new JSONObject(str); + boolean isSucceed = jo.getBoolean("success"); + if (isSucceed) { + JSONArray jarr = jo.getJSONArray("data"); + alist.clear(); + for (int i = 0; i < jarr.length(); i++) { + JSONObject jo2 = jarr.getJSONObject(i); + StudentBean sb = new StudentBean(); + try { + sb.setStuId(jo2.getString("stuId")); + } catch (Exception e) { + } + try { + sb.setStuName(jo2.getString("stuName")); + } catch (Exception e) { + } + try { + sb.setGender(jo2.getInt("gender")); + } catch (Exception e) { + } + try { + sb.setTerm(jo2.getString("term")); + } catch (Exception e) { + } + try { + sb.setAccount(jo2.getString("account")); + } catch (Exception e) { + } + try { + sb.setNickName(jo2.getString("nickName")); + } catch (Exception e) { + } + try { + sb.setAddress(jo2.getString("address")); + } catch (Exception e) { + } + try { + sb.setPhone(jo2.getString("phone")); + } catch (Exception e) { + } + try { + sb.setPhoto(jo2.getString("photo")); + } catch (Exception e) { + } + try { + sb.setFromType(jo2.getInt("fromType")); + } catch (Exception e) { + } + try { + sb.setGradeId(jo2.getInt("gradeId")); + } catch (Exception e) { + } + try { + sb.setTeacherId(jo2.getInt("teacherId")); + } catch (Exception e) { + } + try { + sb.setOriSchool(jo2.getString("oriSchool")); + } catch (Exception e) { + } + try { + sb.setParentPhone(jo2.getString("parentPhone")); + } catch (Exception e) { + } + try { + sb.setParentIdentity(jo2.getString("parentIdentity")); + } catch (Exception e) { + } + try { + sb.setTeacherName(jo2.getString("teacherName")); + } catch (Exception e) { + } + alist.add(sb); + } + + if (alist.size() > 0) + loadList(); + + } else { + + } + } catch (Exception e) { + e.printStackTrace(); + + } + + } + + @Override + public void onError(Throwable e) { + + } + + @Override + public void onComplete() { + + } + }); + + + mRootView.findViewById(R.id.view_4).setOnClickListener(view -> startActivity(new Intent(getActivity(), YinsiActivity.class))); + mRootView.findViewById(R.id.view_5).setOnClickListener(view -> startActivity(new Intent(getActivity(), UserActivity.class))); + mRootView.findViewById(R.id.view_3).setOnClickListener(view -> startActivity(new Intent(getActivity(), AccountActivity.class))); + + } + + public void loadList() { + iv_21.setBackgroundResource(R.mipmap.tjxss); + tv_21.setText("添加学生"); + + + iv_22.setBackgroundResource(R.mipmap.tjxss); + tv_22.setText("添加学生"); + + iv_23.setBackgroundResource(R.mipmap.tjxss); + tv_23.setText("添加学生"); + + if (alist.size() >= 1) { +// if (alist.get(0).getPhoto() != null && alist.get(0).getPhoto().length() > 0) +// Glide.with(getActivity()).load(alist.get(0).getPhoto()).into(iv_21); +// else + iv_21.setBackgroundResource(R.mipmap.txz); + tv_21.setText(alist.get(0).getStuName()); + } + if (alist.size() >= 2) { +// if (alist.get(1).getPhoto() != null && alist.get(1).getPhoto().length() > 0) +// Glide.with(getActivity()).load(alist.get(1).getPhoto()).into(iv_22); +// else + iv_22.setBackgroundResource(R.mipmap.txz); + tv_22.setText(alist.get(1).getStuName()); + } + if (alist.size() >= 3) { +// if (alist.get(2).getPhoto() != null && alist.get(2).getPhoto().length() > 0) +// Glide.with(getActivity()).load(alist.get(2).getPhoto()).into(iv_23); +// else + iv_23.setBackgroundResource(R.mipmap.txz); + tv_23.setText(alist.get(2).getStuName()); + } + } +} diff --git a/app/src/main/res/drawable/bg_solid_btn.xml b/app/src/main/res/drawable/bg_solid_btn.xml new file mode 100644 index 0000000..0191239 --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_btn.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_btn_grad.xml b/app/src/main/res/drawable/bg_solid_btn_grad.xml new file mode 100644 index 0000000..ab3dd2f --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_btn_grad.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_white.xml b/app/src/main/res/drawable/bg_solid_white.xml new file mode 100644 index 0000000..a79f693 --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_white.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_white_10.xml b/app/src/main/res/drawable/bg_solid_white_10.xml new file mode 100644 index 0000000..1c19ebd --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_white_10.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_white_10_bottom.xml b/app/src/main/res/drawable/bg_solid_white_10_bottom.xml new file mode 100644 index 0000000..ed04f68 --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_white_10_bottom.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_white_10_or.xml b/app/src/main/res/drawable/bg_solid_white_10_or.xml new file mode 100644 index 0000000..33c8b03 --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_white_10_or.xml @@ -0,0 +1,15 @@ + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_white_10_top.xml b/app/src/main/res/drawable/bg_solid_white_10_top.xml new file mode 100644 index 0000000..70e3d75 --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_white_10_top.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/bg_solid_white_20.xml b/app/src/main/res/drawable/bg_solid_white_20.xml new file mode 100644 index 0000000..8858698 --- /dev/null +++ b/app/src/main/res/drawable/bg_solid_white_20.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/checked_xc.xml b/app/src/main/res/drawable/checked_xc.xml new file mode 100644 index 0000000..aa77125 --- /dev/null +++ b/app/src/main/res/drawable/checked_xc.xml @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..07d5da9 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/select_b_1.xml b/app/src/main/res/drawable/select_b_1.xml new file mode 100644 index 0000000..50af681 --- /dev/null +++ b/app/src/main/res/drawable/select_b_1.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/select_b_2.xml b/app/src/main/res/drawable/select_b_2.xml new file mode 100644 index 0000000..7602b37 --- /dev/null +++ b/app/src/main/res/drawable/select_b_2.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/select_t_1.xml b/app/src/main/res/drawable/select_t_1.xml new file mode 100644 index 0000000..682c1fc --- /dev/null +++ b/app/src/main/res/drawable/select_t_1.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/welcome_bg.xml b/app/src/main/res/drawable/welcome_bg.xml new file mode 100644 index 0000000..4fe45f3 --- /dev/null +++ b/app/src/main/res/drawable/welcome_bg.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_add_stu.xml b/app/src/main/res/layout/activity_add_stu.xml new file mode 100644 index 0000000..52594bb --- /dev/null +++ b/app/src/main/res/layout/activity_add_stu.xml @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +