增加开机启动,食堂切换功能
This commit is contained in:
@@ -2,9 +2,13 @@ package com.shuwei.dish.match.base
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.content.SharedPreferences
|
||||
import com.shuwei.dish.match.R
|
||||
import com.shuwei.dish.match.db.DatabaseProvider
|
||||
import com.shuwei.dish.match.utils.BootReceiver
|
||||
|
||||
|
||||
class BaseApp : Application() {
|
||||
|
||||
@@ -16,12 +20,15 @@ class BaseApp : Application() {
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
instance = this
|
||||
|
||||
val filter = IntentFilter(Intent.ACTION_BOOT_COMPLETED)
|
||||
registerReceiver(BootReceiver(), filter)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
// const val canteenId = "1678234139391512577"
|
||||
const val canteenId = "0"
|
||||
var canteenId = "0"
|
||||
@Volatile
|
||||
private var sharedPref: SharedPreferences? = null
|
||||
|
||||
|
||||
@@ -114,6 +114,7 @@ class BottomDialog(
|
||||
}
|
||||
}
|
||||
binding.refreshLayout.setEnableRefresh(false)
|
||||
binding.refreshLayout.setEnableLoadMore(false)
|
||||
}
|
||||
|
||||
private fun searchGoods(v: View) {
|
||||
|
||||
@@ -6,8 +6,8 @@ object UrlConfig {
|
||||
// const val DISH_DETAIL = "$BASE_URL/scales/goodsUseList?foodId={foodId}&foodWeight={foodWeight}"
|
||||
// const val DISH_LIST = "$BASE_URL/scales/getRestInfoFoods?eaId=99&type=0&foodName"
|
||||
|
||||
const val BASE_URL = "http://192.168.1.207:9102"
|
||||
// const val BASE_URL = "https://yyjk.shuziweidao.com/gateway"
|
||||
// const val BASE_URL = "http://192.168.1.207:9102"
|
||||
const val BASE_URL = "https://yyjk.shuziweidao.com/gateway"
|
||||
// const val DISH_LIST = "$BASE_URL/scales/getRestInfoFoods?eaId=99&type=0&foodName"
|
||||
|
||||
const val DISH_DETAIL = "$BASE_URL/food/stFoodInfoMatching/queryById"
|
||||
|
||||
@@ -47,7 +47,14 @@ class HomeActivity : BaseActivity() {
|
||||
binding = ActivityHomeBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
setHeaderBackground(isHomePage = true)
|
||||
|
||||
binding.radioGroup?.setOnCheckedChangeListener { group, checkedId ->
|
||||
if (checkedId == R.id.radioSw) {
|
||||
BaseApp.canteenId = "1678234139391512577"
|
||||
} else {
|
||||
BaseApp.canteenId = "0"
|
||||
}
|
||||
}
|
||||
binding.radioGroup?.check(R.id.radioZk)
|
||||
initRecyclerView()
|
||||
getAppToken()
|
||||
WeightUtil.connect { connect ->
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.shuwei.dish.match.utils
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.shuwei.dish.match.ui.HomeActivity
|
||||
|
||||
class BootReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (Intent.ACTION_BOOT_COMPLETED == intent.action) {
|
||||
// 启动服务或Activity
|
||||
val launchIntent = Intent(context, HomeActivity::class.java)
|
||||
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(launchIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user