| @@ -47,15 +47,37 @@ android { | |||||
| signingConfig signingConfigs.release | signingConfig signingConfigs.release | ||||
| // 移除无用的resource文件 | // 移除无用的resource文件 | ||||
| // shrinkResources false | // shrinkResources false | ||||
| buildConfigField "String", "BASE_URL", '"https://oa.qbjjyyun.net/api"' | |||||
| buildConfigField "String", "M_URL", '"https://m.qbjjyyun.net"' | |||||
| buildConfigField "String", "APP_NAME", '"家校互通"' | |||||
| // buildConfigField "String", "BASE_URL", '"http://192.168.69.99:9009"' | |||||
| // buildConfigField "String", "M_URL", '"http://192.168.69.99:8098"' | |||||
| // buildConfigField "String", "APP_NAME", '"家校互通(测试)"' | |||||
| } | } | ||||
| debug { | debug { | ||||
| minifyEnabled false | minifyEnabled false | ||||
| proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||||
| // debuggable true | |||||
| signingConfig signingConfigs.release | |||||
| // 移除无用的resource文件 | |||||
| // shrinkResources false | |||||
| buildConfigField "String", "BASE_URL", '"http://192.168.69.99:9009"' | |||||
| buildConfigField "String", "M_URL", '"http://192.168.69.112:8098"' | |||||
| buildConfigField "String", "APP_NAME", '"家校互通(开发)"' | |||||
| } | |||||
| yzx_test { | |||||
| minifyEnabled false | |||||
| proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |||||
| debuggable true | debuggable true | ||||
| signingConfig signingConfigs.yzx | |||||
| signingConfig signingConfigs.release | |||||
| // 移除无用的resource文件 | // 移除无用的resource文件 | ||||
| shrinkResources false | |||||
| // shrinkResources false | |||||
| buildConfigField "String", "BASE_URL", '"http://192.168.69.99:9009"' | |||||
| buildConfigField "String", "M_URL", '"http://192.168.69.99:8098"' | |||||
| buildConfigField "String", "APP_NAME", '"家校互通(测试)"' | |||||
| } | } | ||||
| applicationVariants.all { variant -> | applicationVariants.all { variant -> | ||||
| @@ -65,6 +87,7 @@ android { | |||||
| output.outputFileName = fileName | output.outputFileName = fileName | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| lintOptions { | lintOptions { | ||||
| @@ -102,4 +125,6 @@ dependencies { | |||||
| // 友盟统计SDK | // 友盟统计SDK | ||||
| implementation 'com.umeng.umsdk:common:9.3.6' // 必选 | implementation 'com.umeng.umsdk:common:9.3.6' // 必选 | ||||
| implementation 'com.umeng.umsdk:asms:1.2.1' // 必选 | implementation 'com.umeng.umsdk:asms:1.2.1' // 必选 | ||||
| implementation 'com.github.thomhurst:RoundImageView:1.0.2' | |||||
| implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4' | |||||
| } | } | ||||
| @@ -13,7 +13,6 @@ | |||||
| <uses-permission android:name="android.permission.READ_MEDIA_STORAGE" /> | <uses-permission android:name="android.permission.READ_MEDIA_STORAGE" /> | ||||
| <uses-permission android:name="android.permission.WAKE_LOCK" /> | <uses-permission android:name="android.permission.WAKE_LOCK" /> | ||||
| <application | <application | ||||
| android:name=".App" | android:name=".App" | ||||
| android:allowBackup="true" | android:allowBackup="true" | ||||
| @@ -23,11 +22,7 @@ | |||||
| android:supportsRtl="true" | android:supportsRtl="true" | ||||
| android:theme="@style/AppTheme"> | android:theme="@style/AppTheme"> | ||||
| <activity | <activity | ||||
| android:name=".activity.NoteActivity" | |||||
| android:configChanges="orientation|keyboard" | |||||
| android:screenOrientation="portrait" /> | |||||
| <activity | |||||
| android:name=".activity.WebActivity" | |||||
| android:name=".activity.HomeActivity" | |||||
| android:configChanges="orientation|keyboard" | android:configChanges="orientation|keyboard" | ||||
| android:launchMode="singleTask" | android:launchMode="singleTask" | ||||
| android:screenOrientation="portrait"> | android:screenOrientation="portrait"> | ||||
| @@ -39,6 +34,14 @@ | |||||
| <category android:name="android.intent.category.LAUNCHER" /> | <category android:name="android.intent.category.LAUNCHER" /> | ||||
| </intent-filter> | </intent-filter> | ||||
| </activity> | </activity> | ||||
| <activity | |||||
| android:name=".activity.NoteActivity" | |||||
| android:configChanges="orientation|keyboard" | |||||
| android:screenOrientation="portrait" /> | |||||
| <activity | |||||
| android:name=".activity.WebActivity" | |||||
| android:configChanges="orientation|keyboard" | |||||
| android:screenOrientation="portrait" /> | |||||
| <activity | <activity | ||||
| android:name=".MainActivity" | android:name=".MainActivity" | ||||
| android:configChanges="orientation|keyboard" | android:configChanges="orientation|keyboard" | ||||
| @@ -48,10 +51,10 @@ | |||||
| android:name=".activity.BookActivity" | android:name=".activity.BookActivity" | ||||
| android:configChanges="orientation|keyboard" | android:configChanges="orientation|keyboard" | ||||
| android:screenOrientation="portrait" /> | android:screenOrientation="portrait" /> | ||||
| <activity android:name=".activity.Main1Activity" | |||||
| <activity | |||||
| android:name=".activity.Main1Activity" | |||||
| android:configChanges="orientation|keyboard" | android:configChanges="orientation|keyboard" | ||||
| android:screenOrientation="portrait"/> | |||||
| android:screenOrientation="portrait" /> | |||||
| <provider | <provider | ||||
| android:name=".utils.YzxFileProvider" | android:name=".utils.YzxFileProvider" | ||||
| @@ -4,16 +4,17 @@ import android.annotation.SuppressLint | |||||
| import android.app.Activity | import android.app.Activity | ||||
| import android.content.Intent | import android.content.Intent | ||||
| import android.text.TextUtils | import android.text.TextUtils | ||||
| import com.blankj.utilcode.util.StringUtils | |||||
| import com.bumptech.glide.Glide | import com.bumptech.glide.Glide | ||||
| import com.yzx.webebook.activity.BookActivity | |||||
| import com.yzx.webebook.activity.Main1Activity | |||||
| import com.yzx.webebook.activity.NoteActivity | |||||
| import com.yzx.webebook.activity.WebActivity | |||||
| import com.yzx.webebook.activity.* | |||||
| import com.yzx.webebook.activity.base.BaseActivity | import com.yzx.webebook.activity.base.BaseActivity | ||||
| import com.yzx.webebook.config.Config | |||||
| import com.yzx.webebook.model.User | |||||
| import com.yzx.webebook.presenter.base.BasePresenter | import com.yzx.webebook.presenter.base.BasePresenter | ||||
| import kotlinx.android.synthetic.main.activity_main.* | import kotlinx.android.synthetic.main.activity_main.* | ||||
| import org.jetbrains.anko.startActivity | import org.jetbrains.anko.startActivity | ||||
| import java.io.File | |||||
| import org.jetbrains.anko.toast | |||||
| /** | /** | ||||
| * Yun.Lei | * Yun.Lei | ||||
| @@ -28,16 +29,42 @@ class MainActivity : BaseActivity<BasePresenter<*>>() { | |||||
| override fun initView() { | override fun initView() { | ||||
| btn1.setOnClickListener { | btn1.setOnClickListener { | ||||
| WebActivity.active(this, "https://m.qbjjyyun.net/") | |||||
| Config.APP_NAME = "家校互通" | |||||
| Config.BASE_URL = "https://oa.qbjjyyun.net/api" | |||||
| Config.M_URL = "https://m.qbjjyyun.net" | |||||
| User.clearUserInfo() | |||||
| startActivity<HomeActivity>() | |||||
| } | } | ||||
| btn2.setOnClickListener { | btn2.setOnClickListener { | ||||
| WebActivity.active(this, "https://m.live.educlouddata.com/") | |||||
| Config.APP_NAME = "家校互通(LIVE)" | |||||
| Config.BASE_URL = "https://oa.live.educlouddata.com/api" | |||||
| Config.M_URL = "https://m.live.educlouddata.com" | |||||
| User.clearUserInfo() | |||||
| startActivity<HomeActivity>() | |||||
| } | } | ||||
| btn6.setOnClickListener { | btn6.setOnClickListener { | ||||
| WebActivity.active(this, "http://192.168.69.200:8098/") | |||||
| Config.APP_NAME = "家校互通(测试)" | |||||
| Config.BASE_URL = "http://192.168.69.99:9009" | |||||
| Config.M_URL = "http://192.168.69.99:8098" | |||||
| User.clearUserInfo() | |||||
| startActivity<HomeActivity>() | |||||
| } | } | ||||
| btn3.setOnClickListener { | btn3.setOnClickListener { | ||||
| WebActivity.active(this, editText.text.toString()) | |||||
| val mBaseUrl = mBaseUrlTv.text.toString() | |||||
| if(StringUtils.isTrimEmpty(mBaseUrl)){ | |||||
| toast("请输入BASE_URL") | |||||
| return@setOnClickListener | |||||
| } | |||||
| val mUrl = mUrlTv.text.toString() | |||||
| if(StringUtils.isTrimEmpty(mUrl)){ | |||||
| toast("请输入M_URL") | |||||
| return@setOnClickListener | |||||
| } | |||||
| Config.APP_NAME = "家校互通(本地)" | |||||
| Config.BASE_URL = mBaseUrl | |||||
| Config.M_URL = mUrl | |||||
| User.clearUserInfo() | |||||
| startActivity<HomeActivity>() | |||||
| } | } | ||||
| btn4.setOnClickListener { | btn4.setOnClickListener { | ||||
| BookActivity.active( | BookActivity.active( | ||||
| @@ -0,0 +1,251 @@ | |||||
| package com.yzx.webebook.activity | |||||
| import android.annotation.SuppressLint | |||||
| import android.app.AlertDialog | |||||
| import android.app.Dialog | |||||
| import android.content.Context | |||||
| import android.content.DialogInterface | |||||
| import android.util.Log | |||||
| import android.view.View | |||||
| import android.widget.TextView | |||||
| import androidx.core.widget.ContentLoadingProgressBar | |||||
| import androidx.recyclerview.widget.GridLayoutManager | |||||
| import com.allenliu.versionchecklib.v2.AllenVersionChecker | |||||
| import com.allenliu.versionchecklib.v2.builder.UIData | |||||
| import com.allenliu.versionchecklib.v2.callback.CustomDownloadingDialogListener | |||||
| import com.blankj.utilcode.util.AppUtils | |||||
| import com.blankj.utilcode.util.NetworkUtils | |||||
| import com.blankj.utilcode.util.SPUtils | |||||
| import com.blankj.utilcode.util.StringUtils | |||||
| import com.google.gson.Gson | |||||
| import com.google.gson.reflect.TypeToken | |||||
| import com.lzy.okgo.OkGo | |||||
| import com.lzy.okgo.callback.StringCallback | |||||
| import com.lzy.okgo.model.Response | |||||
| import com.yzx.webebook.MainActivity | |||||
| import com.yzx.webebook.R | |||||
| import com.yzx.webebook.activity.base.BaseActivity | |||||
| import com.yzx.webebook.adapter.HomeAdapter | |||||
| import com.yzx.webebook.config.Config | |||||
| import com.yzx.webebook.model.BaseBean | |||||
| import com.yzx.webebook.model.HomeItem | |||||
| import com.yzx.webebook.model.User | |||||
| import com.yzx.webebook.model.Version | |||||
| import com.yzx.webebook.presenter.base.BasePresenter | |||||
| import com.yzx.webebook.widget.BaseDialog | |||||
| import kotlinx.android.synthetic.main.activity_home.* | |||||
| import kotlinx.android.synthetic.main.activity_home.titleTv | |||||
| import org.jetbrains.anko.find | |||||
| import org.jetbrains.anko.startActivity | |||||
| import org.jetbrains.anko.toast | |||||
| import java.util.* | |||||
| class HomeActivity : BaseActivity<BasePresenter<*>>() { | |||||
| private val mAdapter: HomeAdapter by lazy { | |||||
| val list = mutableListOf<HomeItem>() | |||||
| list.add(HomeItem("家庭作业", R.mipmap.ic_home_work, "/homework/ebook_list")) | |||||
| list.add(HomeItem("笔记本", R.mipmap.ic_home_notebook, "/notebook/list")) | |||||
| list.add(HomeItem("背诵默写", R.mipmap.ic_home_write, "/write/index")) | |||||
| list.add(HomeItem("书架", R.mipmap.ic_home_rack)) | |||||
| list.add(HomeItem("错题本", R.mipmap.ic_home_errorbook, "/errorbook/ebookindex")) | |||||
| list.add(HomeItem("我的", R.mipmap.ic_home_my, "/mine/ebook")) | |||||
| HomeAdapter(list) | |||||
| } | |||||
| private var count = 0 | |||||
| private val run = Runnable { | |||||
| count = 0 | |||||
| } | |||||
| override val inflateId: Int | |||||
| get() = R.layout.activity_home | |||||
| override fun initView() { | |||||
| val layoutManager = GridLayoutManager(this, 3) | |||||
| homeGridView.layoutManager = layoutManager | |||||
| homeGridView.adapter = mAdapter | |||||
| switchBtn.setOnClickListener { | |||||
| val url = "${Config.M_URL}/choiceunit.html?from=ehome" | |||||
| WebActivity.active(this, url) | |||||
| } | |||||
| loginBtn.setOnClickListener { | |||||
| val url = "${Config.M_URL}/login.html?from=ehome" | |||||
| WebActivity.active(this, url) | |||||
| } | |||||
| testBtn.setOnClickListener { | |||||
| count++ | |||||
| testBtn.removeCallbacks(run) | |||||
| testBtn.postDelayed(run, 1000) | |||||
| if (count >= 5) { | |||||
| startActivity<MainActivity>() | |||||
| } | |||||
| } | |||||
| } | |||||
| override fun initData() { | |||||
| mAdapter.setOnItemClickListener { adapter, view, position -> | |||||
| if (User.getUser().user_id == 0) { | |||||
| val url = "${Config.M_URL}/login.html?from=ehome" | |||||
| WebActivity.active(this, url) | |||||
| } else { | |||||
| val list = mAdapter.data | |||||
| val item = list[position] | |||||
| if (StringUtils.isTrimEmpty(item.url)) { | |||||
| toast("功能设计中,敬请期待") | |||||
| } else { | |||||
| val url = Config.M_URL + item.url | |||||
| WebActivity.active(this, url) | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| override fun initPresenter(): BasePresenter<*>? { | |||||
| return null | |||||
| } | |||||
| @SuppressLint("SetTextI18n") | |||||
| override fun onResume() { | |||||
| super.onResume() | |||||
| val user = User.getUser() | |||||
| if (user.user_id != 0) { | |||||
| userNameTv.text = "你好,${user.user_name}" | |||||
| userInfoTv.text = "${user.school_name} | ${user.grade_name}${user.class_name}" | |||||
| userInfoTv.visibility = View.VISIBLE | |||||
| loginBtn.visibility = View.GONE | |||||
| switchBtn.visibility = if (User.getUnitCount() > 1) { | |||||
| View.VISIBLE | |||||
| } else { | |||||
| View.GONE | |||||
| } | |||||
| } else { | |||||
| userNameTv.text = "未登录" | |||||
| userInfoTv.text = "" | |||||
| userInfoTv.visibility = View.GONE | |||||
| loginBtn.visibility = View.VISIBLE | |||||
| switchBtn.visibility = View.GONE | |||||
| } | |||||
| titleTv.text = Config.APP_NAME | |||||
| if (NetworkUtils.isConnected()) { | |||||
| checkVersion(false) | |||||
| }else{ | |||||
| checkNetwork() | |||||
| } | |||||
| } | |||||
| private fun checkNetwork() { | |||||
| val builder = AlertDialog.Builder(this) | |||||
| builder.setTitle("温馨提示") | |||||
| builder.setMessage("你还没有链接网络,请先连接网络!") | |||||
| builder.setPositiveButton("去设置") { _, _ -> | |||||
| NetworkUtils.openWirelessSettings() | |||||
| } | |||||
| builder.setCancelable(false) | |||||
| val dialog = builder.create() | |||||
| dialog.setCanceledOnTouchOutside(false) | |||||
| dialog.getButton(DialogInterface.BUTTON_NEGATIVE)?.visibility = View.GONE | |||||
| dialog.show() | |||||
| } | |||||
| private fun checkVersion(userCheck: Boolean = false): Unit { | |||||
| val BASE_URL = Config.BASE_URL | |||||
| OkGo.post<String>("$BASE_URL/parent/common/getInkBottleMaxVersion") | |||||
| .tag(this) | |||||
| .execute(object : StringCallback() { | |||||
| override fun onSuccess(response: Response<String>) { | |||||
| val json = response.body() | |||||
| Log.d("checkVersion", "onSuccess: ${json}") | |||||
| val resultType = object : TypeToken<BaseBean<Version>>() {}.type | |||||
| val gson = Gson() | |||||
| val res = gson.fromJson<BaseBean<Version>>(json, resultType) | |||||
| if (res.code == 0) { | |||||
| val appVersion = AppUtils.getAppVersionName() | |||||
| val appVersionCode = AppUtils.getAppVersionCode() | |||||
| val versionCode = res?.data?.version_code ?: 0 | |||||
| val curr = Date().time | |||||
| val lastTipTime = SPUtils.getInstance() | |||||
| .getLong("last_tip_time${res.data.version_code}", 0) | |||||
| if (versionCode > appVersionCode) { //有新版本 | |||||
| when { | |||||
| res.data.type == 1 -> { //强制升级 | |||||
| updateApp(res.data) | |||||
| } | |||||
| curr - lastTipTime > 24 * 60 * 60 * 1000 -> { //非强制一天以内提示一次 | |||||
| updateApp(res.data) | |||||
| } | |||||
| userCheck -> { // | |||||
| updateApp(res.data) | |||||
| } | |||||
| } | |||||
| } else { | |||||
| if (userCheck) { | |||||
| toast("已经是最新版本了!") | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| }) | |||||
| } | |||||
| private fun updateApp(version: Version) { | |||||
| AllenVersionChecker | |||||
| .getInstance() | |||||
| .downloadOnly( | |||||
| UIData.create() | |||||
| .setTitle("检测到新版本") | |||||
| .setContent(version.explain) | |||||
| .setDownloadUrl(version.app_src) | |||||
| ) | |||||
| .setCustomVersionDialogListener { context, versionBundle -> | |||||
| val dialog = BaseDialog(context, R.style.BaseDialog, R.layout.version_dialog) | |||||
| val title = dialog.find<TextView>(R.id.tv_title) | |||||
| title.text = "检测到新版本" | |||||
| val content = dialog.find<TextView>(R.id.tv_msg) | |||||
| content.text = version.explain | |||||
| dialog.window?.setDimAmount(0.5f) | |||||
| val cancelBtn = dialog.find<View>(R.id.cancel_btn) | |||||
| if (version.type == 1) { | |||||
| cancelBtn.visibility = View.GONE | |||||
| } | |||||
| return@setCustomVersionDialogListener dialog | |||||
| } | |||||
| .setOnCancelListener { | |||||
| SPUtils.getInstance().put("last_tip_time${version.version_code}", Date().time) | |||||
| } | |||||
| .setCustomDownloadingDialogListener(object : CustomDownloadingDialogListener { | |||||
| @SuppressLint("SetTextI18n") | |||||
| override fun updateUI(dialog: Dialog?, progress: Int, versionBundle: UIData?) { | |||||
| val tvProgress: TextView = dialog!!.findViewById(R.id.tv_progress) | |||||
| val progressBar: ContentLoadingProgressBar = dialog.findViewById(R.id.pb) | |||||
| progressBar.progress = progress | |||||
| tvProgress.text = "$progress%" | |||||
| Log.d("checkVersion", "onSuccess: ${progress}") | |||||
| } | |||||
| override fun getCustomDownloadingDialog( | |||||
| context: Context?, | |||||
| progress: Int, | |||||
| versionBundle: UIData? | |||||
| ): Dialog { | |||||
| return BaseDialog( | |||||
| context!!, | |||||
| R.style.BaseDialog, | |||||
| R.layout.download_dialog | |||||
| ) | |||||
| } | |||||
| }) | |||||
| .executeMission(this) | |||||
| } | |||||
| } | |||||
| @@ -32,7 +32,9 @@ import com.lzy.okgo.model.Response | |||||
| import com.yzx.webebook.MainActivity | import com.yzx.webebook.MainActivity | ||||
| import com.yzx.webebook.R | import com.yzx.webebook.R | ||||
| import com.yzx.webebook.activity.base.BaseActivity | import com.yzx.webebook.activity.base.BaseActivity | ||||
| import com.yzx.webebook.config.Config | |||||
| import com.yzx.webebook.model.BaseBean | import com.yzx.webebook.model.BaseBean | ||||
| import com.yzx.webebook.model.User | |||||
| import com.yzx.webebook.model.Version | import com.yzx.webebook.model.Version | ||||
| import com.yzx.webebook.presenter.base.BasePresenter | import com.yzx.webebook.presenter.base.BasePresenter | ||||
| import com.yzx.webebook.widget.BaseDialog | import com.yzx.webebook.widget.BaseDialog | ||||
| @@ -79,9 +81,7 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| } | } | ||||
| fun checkVersion(userCheck: Boolean = false): Unit { | fun checkVersion(userCheck: Boolean = false): Unit { | ||||
| val test = "192.168.69.112:9009" | |||||
| val online = "https://oa.qbjjyyun.net/api" | |||||
| val BASE_URL = online | |||||
| val BASE_URL = Config.BASE_URL | |||||
| OkGo.post<String>("$BASE_URL/parent/common/getInkBottleMaxVersion") | OkGo.post<String>("$BASE_URL/parent/common/getInkBottleMaxVersion") | ||||
| .tag(this) | .tag(this) | ||||
| .execute(object : StringCallback() { | .execute(object : StringCallback() { | ||||
| @@ -132,8 +132,6 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| UIData.create() | UIData.create() | ||||
| .setTitle("检测到新版本") | .setTitle("检测到新版本") | ||||
| .setContent(version.explain) | .setContent(version.explain) | ||||
| // .setDownloadUrl("https://oa-edu-1259243469.cos.ap-chengdu.myqcloud.com/public/Yzx_2.0.0.apk") | |||||
| // .setDownloadUrl("https://filea.oa.qbjjyyun.net/edufile/202102/5986/27a58c0b85cb42aee37ce85fe956b743.apk") | |||||
| .setDownloadUrl(version.app_src) | .setDownloadUrl(version.app_src) | ||||
| ) | ) | ||||
| .setCustomVersionDialogListener { context, versionBundle -> | .setCustomVersionDialogListener { context, versionBundle -> | ||||
| @@ -183,17 +181,18 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| @SuppressLint("SetJavaScriptEnabled") | @SuppressLint("SetJavaScriptEnabled") | ||||
| override fun initView() { | override fun initView() { | ||||
| url = intent?.getStringExtra("link") ?: "https://m.qbjjyyun.net/" | url = intent?.getStringExtra("link") ?: "https://m.qbjjyyun.net/" | ||||
| titleTv.setOnClickListener { | |||||
| count++ | |||||
| titleTv.removeCallbacks(run) | |||||
| titleTv.postDelayed(run, 1000) | |||||
| if (count >= 5) { | |||||
| startActivity<MainActivity>() | |||||
| } | |||||
| } | |||||
| // titleTv.setOnClickListener { | |||||
| // count++ | |||||
| // titleTv.removeCallbacks(run) | |||||
| // titleTv.postDelayed(run, 1000) | |||||
| // if (count >= 5) { | |||||
| // startActivity<MainActivity>() | |||||
| // } | |||||
| // } | |||||
| btnBack.setOnClickListener { onBackPressed() } | btnBack.setOnClickListener { onBackPressed() } | ||||
| btnClose.setOnClickListener { | btnClose.setOnClickListener { | ||||
| webView.loadUrl(url) | |||||
| // webView.loadUrl(url) | |||||
| finish() | |||||
| } | } | ||||
| btnRefresh.setOnClickListener { | btnRefresh.setOnClickListener { | ||||
| webView.reload() | webView.reload() | ||||
| @@ -261,11 +260,11 @@ class WebActivity : BaseActivity<BasePresenter<*>>() { | |||||
| view?.post { | view?.post { | ||||
| progressbar.visibility = View.GONE | progressbar.visibility = View.GONE | ||||
| if (view.canGoBack()) { | if (view.canGoBack()) { | ||||
| btnBack.visibility = View.VISIBLE | |||||
| // btnClose.visibility = View.VISIBLE | |||||
| // btnBack.visibility = View.VISIBLE | |||||
| btnClose.visibility = View.VISIBLE | |||||
| } else { | } else { | ||||
| btnBack.visibility = View.GONE | |||||
| // btnClose.visibility = View.GONE | |||||
| // btnBack.visibility = View.GONE | |||||
| btnClose.visibility = View.GONE | |||||
| } | } | ||||
| } | } | ||||
| } else { | } else { | ||||
| @@ -436,6 +435,47 @@ class YzxJavascriptInterface(var ctx: Activity) { | |||||
| val act = ctx as WebActivity | val act = ctx as WebActivity | ||||
| act.checkVersion(true) | act.checkVersion(true) | ||||
| } | } | ||||
| /** | |||||
| * 保存用户信息 | |||||
| */ | |||||
| @JavascriptInterface | |||||
| fun saveUserInfo(json:String){ | |||||
| val resultType = object : TypeToken<User>() {}.type | |||||
| val gson = Gson() | |||||
| val user = gson.fromJson<User>(json, resultType) | |||||
| user?.save() | |||||
| } | |||||
| @JavascriptInterface | |||||
| fun saveUnitCount(count:Int){ | |||||
| User.saveUnitCount(count) | |||||
| } | |||||
| @JavascriptInterface | |||||
| fun toHome(){ | |||||
| ctx.startActivity<HomeActivity>() | |||||
| } | |||||
| @JavascriptInterface | |||||
| fun logout(){ | |||||
| val sp = SPUtils.getInstance() | |||||
| sp.remove("user_name") | |||||
| sp.remove("user_id") | |||||
| sp.remove("type") | |||||
| sp.remove("token") | |||||
| sp.remove("school_id") | |||||
| sp.remove("school_name") | |||||
| sp.remove("phone") | |||||
| sp.remove("grade_name") | |||||
| sp.remove("grade_id") | |||||
| sp.remove("class_name") | |||||
| sp.remove("class_id") | |||||
| sp.remove("ticket") | |||||
| sp.remove("login_start") | |||||
| sp.remove("unit_count") | |||||
| ctx.startActivity<HomeActivity>() | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,14 @@ | |||||
| package com.yzx.webebook.adapter | |||||
| import com.chad.library.adapter.base.BaseQuickAdapter | |||||
| import com.chad.library.adapter.base.viewholder.BaseViewHolder | |||||
| import com.yzx.webebook.R | |||||
| import com.yzx.webebook.model.HomeItem | |||||
| import kotlinx.android.synthetic.main.item_home.view.* | |||||
| class HomeAdapter(list: MutableList<HomeItem>) : BaseQuickAdapter<HomeItem, BaseViewHolder>(R.layout.item_home,list) { | |||||
| override fun convert(holder: BaseViewHolder, item: HomeItem) { | |||||
| holder.itemView.img.setImageResource(item.img) | |||||
| holder.itemView.name.text = item.title | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,9 @@ | |||||
| package com.yzx.webebook.config | |||||
| import com.yzx.webebook.BuildConfig | |||||
| object Config { | |||||
| var BASE_URL = BuildConfig.BASE_URL | |||||
| var APP_NAME = BuildConfig.APP_NAME | |||||
| var M_URL = BuildConfig.M_URL | |||||
| } | |||||
| @@ -0,0 +1,7 @@ | |||||
| package com.yzx.webebook.model | |||||
| class HomeItem ( | |||||
| var title:String, | |||||
| var img:Int, | |||||
| var url:String = "" | |||||
| ) | |||||
| @@ -0,0 +1,82 @@ | |||||
| package com.yzx.webebook.model | |||||
| import android.content.Context | |||||
| import com.blankj.utilcode.util.SPUtils | |||||
| class User( | |||||
| var user_name: String, | |||||
| var user_id: Int, | |||||
| var type: Int, | |||||
| var token: String, | |||||
| var school_id: Int, | |||||
| var school_name: String, | |||||
| var phone: String, | |||||
| var grade_name: String, | |||||
| var grade_id: Int, | |||||
| var class_name: String, | |||||
| var class_id: Int, | |||||
| var ticket: String, | |||||
| var login_start: String | |||||
| ) { | |||||
| fun save() { | |||||
| val sp = SPUtils.getInstance() | |||||
| sp.put("user_name", user_name) | |||||
| sp.put("user_id", user_id) | |||||
| sp.put("type", type) | |||||
| sp.put("token", token) | |||||
| sp.put("school_id", school_id) | |||||
| sp.put("school_name", school_name) | |||||
| sp.put("phone", phone) | |||||
| sp.put("grade_name", grade_name) | |||||
| sp.put("grade_id", grade_id) | |||||
| sp.put("class_name", class_name) | |||||
| sp.put("class_id", class_id) | |||||
| sp.put("ticket", ticket) | |||||
| sp.put("login_start", login_start) | |||||
| } | |||||
| companion object { | |||||
| fun getUser(): User { | |||||
| val sp = SPUtils.getInstance() | |||||
| return User( | |||||
| sp.getString("user_name", ""), | |||||
| sp.getInt("user_id", 0), | |||||
| sp.getInt("type", 0), | |||||
| sp.getString("token", ""), | |||||
| sp.getInt("school_id", 0), | |||||
| sp.getString("school_name", ""), | |||||
| sp.getString("phone", ""), | |||||
| sp.getString("grade_name", ""), | |||||
| sp.getInt("grade_id", 0), | |||||
| sp.getString("class_name", ""), | |||||
| sp.getInt("class_id", 0), | |||||
| sp.getString("ticket", ""), | |||||
| sp.getString("login_start", "") | |||||
| ) | |||||
| } | |||||
| fun getUnitCount():Int = SPUtils.getInstance().getInt("unit_count",1) | |||||
| fun saveUnitCount(count:Int){ | |||||
| SPUtils.getInstance().put("unit_count",count); | |||||
| } | |||||
| fun clearUserInfo(){ | |||||
| val sp = SPUtils.getInstance() | |||||
| sp.remove("user_name") | |||||
| sp.remove("user_id") | |||||
| sp.remove("type") | |||||
| sp.remove("token") | |||||
| sp.remove("school_id") | |||||
| sp.remove("school_name") | |||||
| sp.remove("phone") | |||||
| sp.remove("grade_name") | |||||
| sp.remove("grade_id") | |||||
| sp.remove("class_name") | |||||
| sp.remove("class_id") | |||||
| sp.remove("ticket") | |||||
| sp.remove("login_start") | |||||
| sp.remove("unit_count") | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,6 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <stroke android:width="1px" android:color="#000"/> | |||||
| <corners android:radius="30dp"/> | |||||
| <solid android:color="@color/white"/> | |||||
| </shape> | |||||
| @@ -0,0 +1,145 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||||
| xmlns:tools="http://schemas.android.com/tools" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:background="#fff" | |||||
| tools:context=".activity.HomeActivity"> | |||||
| <TextView | |||||
| android:id="@+id/titleTv" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="@dimen/title_height" | |||||
| android:gravity="center" | |||||
| android:text="家校互通" | |||||
| android:textAlignment="center" | |||||
| android:textColor="#000" | |||||
| android:textSize="@dimen/title_text_size" | |||||
| android:textStyle="bold" | |||||
| app:layout_constraintEnd_toEndOf="parent" | |||||
| app:layout_constraintStart_toStartOf="parent" | |||||
| app:layout_constraintTop_toTopOf="parent" /> | |||||
| <View | |||||
| android:id="@+id/titleDivider" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="1px" | |||||
| android:background="#000" | |||||
| app:layout_constraintEnd_toEndOf="parent" | |||||
| app:layout_constraintStart_toStartOf="parent" | |||||
| app:layout_constraintTop_toBottomOf="@+id/titleTv" /> | |||||
| <LinearLayout | |||||
| android:id="@+id/userInfoLayout" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="horizontal" | |||||
| android:paddingHorizontal="50dp" | |||||
| android:paddingVertical="@dimen/d_30" | |||||
| app:layout_constraintEnd_toEndOf="parent" | |||||
| app:layout_constraintStart_toStartOf="parent" | |||||
| app:layout_constraintTop_toBottomOf="@+id/titleDivider"> | |||||
| <com.tomlonghurst.roundimageview.RoundImageView | |||||
| android:layout_width="60dp" | |||||
| android:layout_height="60dp" | |||||
| app:riv_border_color="#333" | |||||
| app:riv_border_width="1px"> | |||||
| <ImageView | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:src="@mipmap/student" /> | |||||
| </com.tomlonghurst.roundimageview.RoundImageView> | |||||
| <LinearLayout | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="match_parent" | |||||
| android:layout_marginStart="@dimen/d_12" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="vertical"> | |||||
| <TextView | |||||
| android:id="@+id/userNameTv" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="你好,张小小" | |||||
| android:textColor="#000" | |||||
| android:textSize="16sp" | |||||
| android:textStyle="bold" /> | |||||
| <TextView | |||||
| android:id="@+id/userInfoTv" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="成都市青白江区大弯小学 | 一年级三班" | |||||
| android:textColor="#666" | |||||
| android:textSize="14sp" | |||||
| android:textStyle="bold" /> | |||||
| </LinearLayout> | |||||
| <TextView | |||||
| android:id="@+id/switchBtn" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:background="@drawable/shape_switch_btn" | |||||
| android:drawableStart="@mipmap/ic_unit_switch" | |||||
| android:drawablePadding="@dimen/d_4" | |||||
| android:paddingStart="@dimen/d_8" | |||||
| android:paddingTop="@dimen/d_5" | |||||
| android:paddingEnd="@dimen/d_8" | |||||
| android:paddingBottom="@dimen/d_5" | |||||
| android:text="切换身份" | |||||
| android:textSize="@dimen/sp18" /> | |||||
| <TextView | |||||
| android:id="@+id/loginBtn" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:background="@drawable/shape_switch_btn" | |||||
| android:paddingStart="@dimen/d_8" | |||||
| android:paddingTop="@dimen/d_5" | |||||
| android:paddingEnd="@dimen/d_8" | |||||
| android:paddingBottom="@dimen/d_5" | |||||
| android:text="去登录" | |||||
| android:textSize="@dimen/sp18" /> | |||||
| </LinearLayout> | |||||
| <View | |||||
| android:id="@+id/userInfoDivider" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="1px" | |||||
| android:background="#000" | |||||
| app:layout_constraintEnd_toEndOf="parent" | |||||
| app:layout_constraintStart_toStartOf="parent" | |||||
| app:layout_constraintTop_toBottomOf="@+id/userInfoLayout" /> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="0dp" | |||||
| android:paddingTop="@dimen/d_15" | |||||
| app:layout_constraintBottom_toBottomOf="parent" | |||||
| app:layout_constraintEnd_toEndOf="parent" | |||||
| app:layout_constraintStart_toStartOf="parent" | |||||
| app:layout_constraintTop_toBottomOf="@+id/userInfoDivider"> | |||||
| <androidx.recyclerview.widget.RecyclerView | |||||
| android:id="@+id/homeGridView" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| app:layoutManager="androidx.recyclerview.widget.GridLayoutManager" | |||||
| app:spanCount="3" | |||||
| tools:itemCount="5" | |||||
| tools:listitem="@layout/item_home" /> | |||||
| </LinearLayout> | |||||
| <View | |||||
| android:id="@+id/testBtn" | |||||
| android:layout_width="100dp" | |||||
| android:layout_height="100dp" | |||||
| app:layout_constraintBottom_toBottomOf="parent" | |||||
| app:layout_constraintStart_toStartOf="parent" /> | |||||
| </androidx.constraintlayout.widget.ConstraintLayout> | |||||
| @@ -52,17 +52,53 @@ | |||||
| android:id="@+id/btn6" | android:id="@+id/btn6" | ||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="家校本地" | |||||
| android:text="家校测试" | |||||
| android:layout_marginTop="@dimen/d_20"/> | android:layout_marginTop="@dimen/d_20"/> | ||||
| <androidx.appcompat.widget.AppCompatEditText | |||||
| android:id="@+id/editText" | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:orientation="horizontal" | |||||
| android:layout_marginTop="@dimen/d_20" | android:layout_marginTop="@dimen/d_20" | ||||
| android:hint="输入网址" | |||||
| android:paddingHorizontal="15dp" | |||||
| android:text="http://192.168.69.112:8098/"/> | |||||
| android:gravity="center" | |||||
| android:paddingHorizontal="@dimen/d_15"> | |||||
| <TextView | |||||
| android:layout_width="80dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_gravity="center_vertical" | |||||
| android:text="BASE_API:"/> | |||||
| <androidx.appcompat.widget.AppCompatEditText | |||||
| android:id="@+id/mBaseUrlTv" | |||||
| android:layout_width="0dp" | |||||
| android:layout_weight="1" | |||||
| android:layout_height="wrap_content" | |||||
| android:hint="输入网址" | |||||
| android:paddingHorizontal="15dp" | |||||
| android:text="http://192.168.69.99:9009/"/> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal" | |||||
| android:layout_marginTop="@dimen/d_20" | |||||
| android:gravity="center" | |||||
| android:paddingHorizontal="@dimen/d_15"> | |||||
| <TextView | |||||
| android:layout_width="80dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_gravity="center_vertical" | |||||
| android:text="M_URl:"/> | |||||
| <androidx.appcompat.widget.AppCompatEditText | |||||
| android:id="@+id/mUrlTv" | |||||
| android:layout_width="0dp" | |||||
| android:layout_weight="1" | |||||
| android:layout_height="wrap_content" | |||||
| android:hint="输入网址" | |||||
| android:paddingHorizontal="15dp" | |||||
| android:text="http://192.168.69.112:8098/"/> | |||||
| </LinearLayout> | |||||
| <androidx.appcompat.widget.AppCompatButton | <androidx.appcompat.widget.AppCompatButton | ||||
| android:id="@+id/btn3" | android:id="@+id/btn3" | ||||
| @@ -21,7 +21,7 @@ | |||||
| android:layout_height="@dimen/title_height" | android:layout_height="@dimen/title_height" | ||||
| android:scaleType="centerInside" | android:scaleType="centerInside" | ||||
| android:src="@mipmap/ic_back_def" | android:src="@mipmap/ic_back_def" | ||||
| android:visibility="gone"/> | |||||
| android:visibility="visible"/> | |||||
| <ImageView | <ImageView | ||||
| android:id="@+id/btnClose" | android:id="@+id/btnClose" | ||||
| @@ -29,7 +29,7 @@ | |||||
| android:layout_height="@dimen/title_height" | android:layout_height="@dimen/title_height" | ||||
| android:layout_toEndOf="@+id/btnBack" | android:layout_toEndOf="@+id/btnBack" | ||||
| android:scaleType="centerInside" | android:scaleType="centerInside" | ||||
| android:src="@mipmap/ic_home_def" | |||||
| android:src="@mipmap/ic_close" | |||||
| android:visibility="gone" /> | android:visibility="gone" /> | ||||
| <ImageView | <ImageView | ||||
| @@ -0,0 +1,26 @@ | |||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="vertical" | |||||
| android:gravity="center" | |||||
| android:paddingTop="@dimen/dp_40" | |||||
| android:paddingBottom="@dimen/dp_40"> | |||||
| <ImageView | |||||
| android:id="@+id/img" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="80dp" | |||||
| android:adjustViewBounds="true" | |||||
| android:src="@mipmap/ic_home_work" /> | |||||
| <TextView | |||||
| android:id="@+id/name" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="学生成绩" | |||||
| android:gravity="center" | |||||
| android:textColor="#000" | |||||
| android:textSize="@dimen/sp18" | |||||
| android:layout_marginTop="@dimen/d_10"/> | |||||
| </LinearLayout> | |||||