Jelajahi Sumber

添加部分基础结构

Frankensteinly 9 bulan lalu
induk
melakukan
cdd154a53f

+ 18 - 11
app/build.gradle

@@ -33,22 +33,17 @@ android {
     kotlinOptions {
         jvmTarget = '1.8'
     }
-    buildFeatures {
-        compose true
-    }
-    composeOptions {
-        kotlinCompilerExtensionVersion '1.5.1'
-    }
-    packaging {
-        resources {
-            excludes += '/META-INF/{AL2.0,LGPL2.1}'
-        }
-    }
 }
 
 dependencies {
 
     implementation libs.androidx.core.ktx
+    implementation libs.androidx.appcompat
+
+    implementation libs.material
+    implementation libs.androidx.activity
+    implementation libs.androidx.constraintlayout
+
     implementation libs.androidx.lifecycle.runtime.ktx
     implementation libs.androidx.activity.compose
     implementation platform(libs.androidx.compose.bom)
@@ -63,4 +58,16 @@ dependencies {
     androidTestImplementation libs.androidx.ui.test.junit4
     debugImplementation libs.androidx.ui.tooling
     debugImplementation libs.androidx.ui.test.manifest
+
+    implementation libs.okhttps
+    implementation libs.okhttps.stomp
+    implementation libs.log.interceptor
+    implementation libs.autosize
+
+    implementation 'androidx.multidex:multidex:2.0.1'
+
+    // https://github.com/googlesamples/easypermissions
+    implementation 'pub.devrel:easypermissions:3.0.0'
+
+    implementation 'com.wang.avi:library:2.1.3'
 }

+ 3 - 5
app/src/main/AndroidManifest.xml

@@ -3,6 +3,7 @@
     xmlns:tools="http://schemas.android.com/tools">
 
     <application
+        android:name=".MyApplication"
         android:allowBackup="true"
         android:dataExtractionRules="@xml/data_extraction_rules"
         android:fullBackupContent="@xml/backup_rules"
@@ -13,10 +14,8 @@
         android:theme="@style/Theme.ISCS_MC"
         tools:targetApi="31">
         <activity
-            android:name=".MainActivity"
-            android:exported="true"
-            android:label="@string/app_name"
-            android:theme="@style/Theme.ISCS_MC">
+            android:name=".view.activity.HomeActivity"
+            android:exported="true">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
 
@@ -24,5 +23,4 @@
             </intent-filter>
         </activity>
     </application>
-
 </manifest>

+ 0 - 47
app/src/main/java/com/grkj/iscs_mc/MainActivity.kt

@@ -1,47 +0,0 @@
-package com.grkj.iscs_mc
-
-import android.os.Bundle
-import androidx.activity.ComponentActivity
-import androidx.activity.compose.setContent
-import androidx.activity.enableEdgeToEdge
-import androidx.compose.foundation.layout.fillMaxSize
-import androidx.compose.foundation.layout.padding
-import androidx.compose.material3.Scaffold
-import androidx.compose.material3.Text
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Modifier
-import androidx.compose.ui.tooling.preview.Preview
-import com.grkj.iscs_mc.ui.theme.ISCS_MCTheme
-
-class MainActivity : ComponentActivity() {
-    override fun onCreate(savedInstanceState: Bundle?) {
-        super.onCreate(savedInstanceState)
-        enableEdgeToEdge()
-        setContent {
-            ISCS_MCTheme {
-                Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
-                    Greeting(
-                        name = "Android",
-                        modifier = Modifier.padding(innerPadding)
-                    )
-                }
-            }
-        }
-    }
-}
-
-@Composable
-fun Greeting(name: String, modifier: Modifier = Modifier) {
-    Text(
-        text = "Hello $name!",
-        modifier = modifier
-    )
-}
-
-@Preview(showBackground = true)
-@Composable
-fun GreetingPreview() {
-    ISCS_MCTheme {
-        Greeting("Android")
-    }
-}

+ 22 - 0
app/src/main/java/com/grkj/iscs_mc/MyApplication.kt

@@ -0,0 +1,22 @@
+package com.grkj.iscs_mc
+
+import android.app.Application
+import android.content.Context
+import androidx.multidex.MultiDex
+
+class MyApplication : Application() {
+
+    companion object {
+        var instance: MyApplication? = null
+    }
+
+    override fun onCreate() {
+        super.onCreate()
+        instance = this
+    }
+
+    override fun attachBaseContext(base: Context?) {
+        super.attachBaseContext(base)
+        MultiDex.install(base)
+    }
+}

+ 0 - 11
app/src/main/java/com/grkj/iscs_mc/ui/theme/Color.kt

@@ -1,11 +0,0 @@
-package com.grkj.iscs_mc.ui.theme
-
-import androidx.compose.ui.graphics.Color
-
-val Purple80 = Color(0xFFD0BCFF)
-val PurpleGrey80 = Color(0xFFCCC2DC)
-val Pink80 = Color(0xFFEFB8C8)
-
-val Purple40 = Color(0xFF6650a4)
-val PurpleGrey40 = Color(0xFF625b71)
-val Pink40 = Color(0xFF7D5260)

+ 0 - 58
app/src/main/java/com/grkj/iscs_mc/ui/theme/Theme.kt

@@ -1,58 +0,0 @@
-package com.grkj.iscs_mc.ui.theme
-
-import android.app.Activity
-import android.os.Build
-import androidx.compose.foundation.isSystemInDarkTheme
-import androidx.compose.material3.MaterialTheme
-import androidx.compose.material3.darkColorScheme
-import androidx.compose.material3.dynamicDarkColorScheme
-import androidx.compose.material3.dynamicLightColorScheme
-import androidx.compose.material3.lightColorScheme
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.platform.LocalContext
-
-private val DarkColorScheme = darkColorScheme(
-    primary = Purple80,
-    secondary = PurpleGrey80,
-    tertiary = Pink80
-)
-
-private val LightColorScheme = lightColorScheme(
-    primary = Purple40,
-    secondary = PurpleGrey40,
-    tertiary = Pink40
-
-    /* Other default colors to override
-    background = Color(0xFFFFFBFE),
-    surface = Color(0xFFFFFBFE),
-    onPrimary = Color.White,
-    onSecondary = Color.White,
-    onTertiary = Color.White,
-    onBackground = Color(0xFF1C1B1F),
-    onSurface = Color(0xFF1C1B1F),
-    */
-)
-
-@Composable
-fun ISCS_MCTheme(
-    darkTheme: Boolean = isSystemInDarkTheme(),
-    // Dynamic color is available on Android 12+
-    dynamicColor: Boolean = true,
-    content: @Composable () -> Unit
-) {
-    val colorScheme = when {
-        dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
-            val context = LocalContext.current
-            if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
-        }
-
-        darkTheme -> DarkColorScheme
-        else -> LightColorScheme
-    }
-
-    MaterialTheme(
-        colorScheme = colorScheme,
-        typography = Typography,
-        content = content
-    )
-}

+ 0 - 34
app/src/main/java/com/grkj/iscs_mc/ui/theme/Type.kt

@@ -1,34 +0,0 @@
-package com.grkj.iscs_mc.ui.theme
-
-import androidx.compose.material3.Typography
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.text.font.FontFamily
-import androidx.compose.ui.text.font.FontWeight
-import androidx.compose.ui.unit.sp
-
-// Set of Material typography styles to start with
-val Typography = Typography(
-    bodyLarge = TextStyle(
-        fontFamily = FontFamily.Default,
-        fontWeight = FontWeight.Normal,
-        fontSize = 16.sp,
-        lineHeight = 24.sp,
-        letterSpacing = 0.5.sp
-    )
-    /* Other default text styles to override
-    titleLarge = TextStyle(
-        fontFamily = FontFamily.Default,
-        fontWeight = FontWeight.Normal,
-        fontSize = 22.sp,
-        lineHeight = 28.sp,
-        letterSpacing = 0.sp
-    ),
-    labelSmall = TextStyle(
-        fontFamily = FontFamily.Default,
-        fontWeight = FontWeight.Medium,
-        fontSize = 11.sp,
-        lineHeight = 16.sp,
-        letterSpacing = 0.5.sp
-    )
-    */
-)

+ 291 - 0
app/src/main/java/com/grkj/iscs_mc/util/ActivityUtils.kt

@@ -0,0 +1,291 @@
+package com.grkj.iscs_mc.util
+
+import android.R
+import android.app.Activity
+import android.app.ActivityManager
+import android.app.ActivityOptions
+import android.content.Context
+import android.content.Intent
+import android.os.Bundle
+import android.util.Pair
+import android.view.View
+import androidx.core.app.ActivityCompat
+import androidx.core.app.ActivityOptionsCompat
+import java.util.*
+import kotlin.system.exitProcess
+
+/**
+ * @author tamsiree
+ * @date 2016/1/24
+ *
+ *
+ * 封装Activity相关工具类
+ */
+object ActivityUtils {
+    var activityStack: Stack<Activity?>? = null
+
+    /**
+     * 获取栈中指定Activity实例
+     *
+     * @param T activity
+     * @return 栈中存在的指定Activity/null
+     */
+    inline fun <reified T>  getSpecActivity(): T? {
+        activityStack?.forEach {
+            it?.let { itActivity ->
+                if (itActivity is T) {
+                    return itActivity
+                }
+            }
+        }
+        return null
+    }
+
+    /**
+     * 清理指定activity之后的activity
+     */
+    inline fun <reified T> clearSpecTop() {
+        activityStack?.asReversed()?.forEach {
+            if (it !is T) {
+                it?.finish()
+            }
+        }
+    }
+
+    /**
+     * 添加Activity 到栈
+     *
+     * @param activity Activity
+     */
+    @JvmStatic
+    fun addActivity(activity: Activity?) {
+        if (activityStack == null) {
+            activityStack = Stack()
+        }
+        activityStack?.add(activity)
+    }
+
+    /**
+     * 从List中移除活动
+     *
+     * @param activity 活动
+     */
+    @JvmStatic
+    fun removeActivity(activity: Activity?) {
+        if (activity != null) {
+            if (activityStack!!.contains(activity)) {
+                activityStack?.remove(activity)
+            }
+        }
+    }
+
+
+    /**
+     * 获取当前的Activity(堆栈中最后一个压入的)
+     */
+    @JvmStatic
+    fun currentActivity(): Activity? {
+        return activityStack?.lastElement()
+    }
+
+    /**
+     * 结束当前Activity(堆栈中最后一个压入的)
+     */
+    @JvmStatic
+    @JvmOverloads
+    fun finishActivity(isTransition: Boolean = false) {
+        val activity = activityStack?.lastElement()
+        if (isTransition) {
+            activity?.onBackPressed()
+        } else {
+            activity?.finish()
+        }
+    }
+
+    /**
+     * 结束指定类名的Activity
+     */
+    @JvmStatic
+    fun finishActivity(cls: Class<out Activity>) {
+        for (activity in activityStack!!) {
+            if (activity!!.javaClass == cls) {
+                finishActivity(activity)
+            }
+        }
+    }
+
+    /**
+     * 结束所有的Activity
+     */
+    @JvmStatic
+    fun finishAllActivity() {
+        val size = activityStack!!.size
+        for (i in 0 until size) {
+            if (null != activityStack!![i]) {
+                activityStack!![i]!!.finish()
+            }
+        }
+        activityStack!!.clear()
+        exitProcess(0)
+    }
+
+    /**
+     * 判断是否存在指定Activity
+     *
+     * @param context     上下文
+     * @param packageName 包名
+     * @param className   activity全路径类名
+     * @return `true`: 是<br></br>`false`: 否
+     */
+    @JvmStatic
+    fun isExistActivity(context: Context, packageName: String?, className: String?): Boolean {
+        val intent = Intent()
+        intent.setClassName(packageName!!, className!!)
+        return !(context.packageManager.resolveActivity(intent, 0) == null || intent.resolveActivity(context.packageManager) == null || context.packageManager.queryIntentActivities(intent, 0).size == 0)
+    }
+
+    /**
+     * 要求最低API为11
+     * Activity 跳转
+     * 跳转后Finish之前所有的Activity
+     *
+     * @param context Context
+     * @param goal    Activity
+     */
+    /**
+     * 要求最低API为11
+     * Activity 跳转
+     * 跳转后Finish之前所有的Activity
+     *
+     * @param context Context
+     * @param goal    Activity
+     */
+    @JvmStatic
+    @JvmOverloads
+    fun skipActivityAndFinishAll(context: Context, goal: Class<out Activity>?, bundle: Bundle? = null, isFade: Boolean = false) {
+        val intent = Intent(context, goal)
+        if (bundle != null) {
+            intent.putExtras(bundle)
+        }
+        intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
+        context.startActivity(intent)
+        finishActivity(context, false)
+        if (isFade) {
+            fadeTransition(context)
+        }
+    }
+
+    /**
+     * Activity 跳转
+     *
+     * @param context Context
+     * @param goal    Activity
+     */
+    @JvmStatic
+    fun skipActivityAndFinish(context: Context, goal: Class<out Activity>?, isFade: Boolean = false, isTransition: Boolean = false) {
+        skipActivity(context, goal, null, isFade)
+        finishActivity(context, isTransition)
+    }
+
+    /**
+     * Activity 跳转
+     *
+     * @param context Context
+     * @param goal    Activity
+     */
+    @JvmStatic
+    @JvmOverloads
+    fun skipActivityAndFinish(context: Context, goal: Class<out Activity>?, bundle: Bundle? = null, isFade: Boolean = false, isTransition: Boolean = false) {
+        skipActivity(context, goal, bundle, isFade)
+        finishActivity(context, isTransition)
+    }
+
+    /**
+     * Activity 跳转
+     *
+     * @param context Context
+     * @param goal    Activity
+     */
+    @JvmStatic
+    @JvmOverloads
+    fun skipActivity(context: Context, goal: Class<out Activity>?, bundle: Bundle? = null, isFade: Boolean = false) {
+        val intent = Intent(context, goal)
+        if (bundle != null) {
+            intent.putExtras(bundle)
+        }
+        context.startActivity(intent)
+        if (isFade) {
+            fadeTransition(context)
+        }
+    }
+
+    @JvmStatic
+    @JvmOverloads
+    fun skipActivityForResult(context: Activity, goal: Class<out Activity>?, bundle: Bundle? = null, requestCode: Int) {
+        val intent = Intent(context, goal)
+        if (bundle != null) {
+            intent.putExtras(bundle)
+        }
+        context.startActivityForResult(intent, requestCode)
+    }
+
+    @JvmStatic
+    @JvmOverloads
+    fun skipActivityOnTransitions(mContext: Context?, goal: Class<out Activity>?, bundle: Bundle? = null, vararg pairs: Pair<View, String>?) {
+        val intent = Intent(mContext, goal)
+        val bundle1 = ActivityOptions.makeSceneTransitionAnimation(mContext as Activity?, *pairs).toBundle()
+        if (bundle != null) {
+            intent.putExtras(bundle)
+        }
+        ActivityCompat.startActivity(mContext!!, intent, bundle1)
+    }
+
+    @JvmStatic
+    @JvmOverloads
+    fun skipActivityTransition(mContext: Context, goal: Class<out Activity>?, bundle: Bundle? = null, view: View?, elementName: String?) {
+        val intent = Intent(mContext, goal)
+        val bundle1 = ActivityOptionsCompat.makeSceneTransitionAnimation((mContext as Activity), view!!, elementName!!).toBundle()
+        if (bundle != null) {
+            intent.putExtras(bundle)
+        }
+        mContext.startActivity(intent, bundle1)
+    }
+
+    /**
+     * 获取launcher activity
+     *
+     * @param context     上下文
+     * @param packageName 包名
+     * @return launcher activity
+     */
+    @JvmStatic
+    fun getLauncherActivity(context: Context, packageName: String): String {
+        val intent = Intent(Intent.ACTION_MAIN, null)
+        intent.addCategory(Intent.CATEGORY_LAUNCHER)
+        val pm = context.packageManager
+        val infos = pm.queryIntentActivities(intent, 0)
+        for (info in infos) {
+            if (info.activityInfo.packageName == packageName) {
+                return info.activityInfo.name
+            }
+        }
+        return "no $packageName"
+    }
+
+    @JvmStatic
+    @JvmOverloads
+    fun finishActivity(mContext: Context, isTransition: Boolean = false) {
+        removeActivity((mContext as Activity))
+        if (isTransition) {
+            mContext.onBackPressed()
+        } else {
+            mContext.finish()
+        }
+    }
+
+    @JvmStatic
+    fun fadeTransition(mContext: Context) {
+        (mContext as Activity).overridePendingTransition(R.anim.fade_in, R.anim.fade_out)
+    }
+
+}

+ 14 - 0
app/src/main/java/com/grkj/iscs_mc/view/activity/HomeActivity.kt

@@ -0,0 +1,14 @@
+package com.grkj.iscs_mc.view.activity
+
+import com.grkj.iscs_mc.databinding.ActivityHomeBinding
+import com.grkj.iscs_mc.view.base.BaseActivity
+
+class HomeActivity : BaseActivity<ActivityHomeBinding>() {
+
+    override val viewBinding: ActivityHomeBinding
+        get() = ActivityHomeBinding.inflate(layoutInflater)
+
+    override fun initView() {
+
+    }
+}

+ 61 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/BaseActivity.kt

@@ -0,0 +1,61 @@
+package com.grkj.iscs_mc.view.base
+
+import android.os.Bundle
+import androidx.appcompat.app.AppCompatActivity
+import androidx.viewbinding.ViewBinding
+import com.grkj.iscs_mc.view.dialog.LoadingProgressDialog
+import com.grkj.iscs_mc.util.ActivityUtils
+import pub.devrel.easypermissions.EasyPermissions
+
+/**
+ * 页面基类
+ */
+abstract class BaseActivity<T : ViewBinding?> : AppCompatActivity() {
+
+    protected var mBinding: T? = null
+    abstract val viewBinding: T
+    private var loadingProgressDialog: LoadingProgressDialog? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+        mBinding = viewBinding
+        setContentView(mBinding!!.root)
+        ActivityUtils.addActivity(this)
+        initView()
+    }
+
+    /**
+     * 控件初始化
+     */
+    abstract fun initView()
+
+    override fun onDestroy() {
+        super.onDestroy()
+        mBinding = null
+        ActivityUtils.removeActivity(this)
+    }
+
+    fun handleLoading(isShow: Boolean, progressStr: String? = null) {
+        if (isShow) {
+            loadingProgressDialog ?: let {
+                loadingProgressDialog = LoadingProgressDialog(this)
+            }
+            loadingProgressDialog?.show()
+            loadingProgressDialog?.setProgress(progressStr)
+        } else {
+            loadingProgressDialog?.dismiss()
+        }
+    }
+
+    override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<out String>, grantResults: IntArray) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults)
+        EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
+    }
+
+    /**
+     * 退出页面,默认直接finish
+     */
+    open fun exitPage() {
+        finish()
+    }
+}

+ 50 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/BaseDialog.kt

@@ -0,0 +1,50 @@
+package com.grkj.iscs_mc.view.base
+
+import android.app.Dialog
+import android.content.Context
+import android.os.Bundle
+import android.view.Gravity
+import android.view.ViewGroup
+import android.view.Window
+import androidx.viewbinding.ViewBinding
+
+/**
+ * Dialog基类
+ *
+ * @param mGravity dialog显示位置
+ * @param isCanCancel 是否允许点击外部取消
+ */
+abstract class BaseDialog<T : ViewBinding?>(
+    context: Context,
+    private var mWidth: Int = ViewGroup.LayoutParams.WRAP_CONTENT,
+    private var mHeight: Int = ViewGroup.LayoutParams.WRAP_CONTENT,
+    private var mGravity: Int = Gravity.CENTER,
+    private var isCanCancel: Boolean = true
+) : Dialog(context) {
+
+    protected var mBinding: T? = null
+    abstract val viewBinding: T
+
+    init {
+        requestWindowFeature(Window.FEATURE_NO_TITLE)
+        mBinding = viewBinding
+        setContentView(mBinding!!.root)
+    }
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        super.onCreate(savedInstanceState)
+
+        window?.setBackgroundDrawableResource(android.R.color.transparent)
+        val layoutParams = window?.attributes
+        layoutParams?.width = mWidth
+        layoutParams?.height = mHeight
+        window?.setGravity(mGravity)
+        window?.attributes = layoutParams
+
+        setCanceledOnTouchOutside(isCanCancel)
+
+        initView()
+    }
+
+    abstract fun initView()
+}

+ 43 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/BaseFragment.kt

@@ -0,0 +1,43 @@
+package com.grkj.iscs_mc.view.base
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import androidx.viewbinding.ViewBinding
+import com.grkj.iscs_mc.view.dialog.LoadingProgressDialog
+
+abstract class BaseFragment<T : ViewBinding?> : Fragment() {
+    protected var mBinding: T? = null
+    abstract val viewBinding: T
+    private var loadingProgressDialog: LoadingProgressDialog? = null
+
+    override fun onCreateView(
+        inflater: LayoutInflater,
+        container: ViewGroup?,
+        savedInstanceState: Bundle?
+    ): View? {
+        mBinding = viewBinding
+        return mBinding!!.root
+    }
+
+    override fun onActivityCreated(savedInstanceState: Bundle?) {
+        super.onActivityCreated(savedInstanceState)
+        initView()
+    }
+
+    abstract fun initView()
+
+    fun handleLoading(isShow: Boolean, progressStr: String? = null) {
+        if (isShow) {
+            loadingProgressDialog ?: let {
+                loadingProgressDialog = context?.let { itCtx -> LoadingProgressDialog(itCtx) }
+            }
+            loadingProgressDialog?.show()
+            loadingProgressDialog?.setProgress(progressStr)
+        } else {
+            loadingProgressDialog?.dismiss()
+        }
+    }
+}

+ 29 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/BaseMvpActivity.kt

@@ -0,0 +1,29 @@
+package com.grkj.iscs_mc.view.base
+
+import android.os.Bundle
+import androidx.viewbinding.ViewBinding
+
+/**
+ * MVP基类Activity
+ */
+abstract class BaseMvpActivity<V : IView?, T : BasePresenter<V>?, B : ViewBinding> : BaseActivity<B>(),
+    IView {
+
+    var presenter: T? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        presenter = initPresenter()
+        presenter?.onCreate(this as V, this)
+        super.onCreate(savedInstanceState)
+    }
+
+    override fun onDestroy() {
+        presenter?.onDestroy()
+        super.onDestroy()
+    }
+
+    /**
+     * 实例化Presenter对象
+     */
+    abstract fun initPresenter(): T
+}

+ 28 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/BaseMvpFragment.kt

@@ -0,0 +1,28 @@
+package com.grkj.iscs_mc.view.base
+
+import android.os.Bundle
+import androidx.viewbinding.ViewBinding
+
+/**
+ * MVP基类Fragment
+ */
+abstract class BaseMvpFragment<V : IView?, T : BasePresenter<V>?, B : ViewBinding> : BaseFragment<B>(),
+    IView {
+    var presenter: T? = null
+
+    override fun onCreate(savedInstanceState: Bundle?) {
+        presenter = initPresenter()
+        presenter?.onCreate(this as V, this.context!!)
+        super.onCreate(savedInstanceState)
+    }
+
+    override fun onDestroy() {
+        presenter?.onDestroy()
+        super.onDestroy()
+    }
+
+    /**
+     * 实例化Presenter对象
+     */
+    abstract fun initPresenter(): T
+}

+ 24 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/BasePresenter.kt

@@ -0,0 +1,24 @@
+package com.grkj.iscs_mc.view.base
+
+import android.content.Context
+
+/**
+ * MVP基类Presenter
+ */
+abstract class BasePresenter<T : IView?> {
+    protected var mvpView: T? = null
+    protected var mContext: Context? = null
+
+    fun onCreate(mvpView: T, context: Context) {
+        this.mvpView = mvpView
+        mContext = context
+    }
+
+    open fun onDestroy() {
+        mvpView = null
+    }
+
+    fun onLowMemory() {
+        mvpView = null
+    }
+}

+ 8 - 0
app/src/main/java/com/grkj/iscs_mc/view/base/IView.kt

@@ -0,0 +1,8 @@
+package com.grkj.iscs_mc.view.base
+
+interface IView {
+    /**
+     * Loading显隐
+     */
+//    fun setLoadingState(isShow: Boolean, process: String? = null)
+}

+ 43 - 0
app/src/main/java/com/grkj/iscs_mc/view/dialog/LoadingProgressDialog.kt

@@ -0,0 +1,43 @@
+package com.grkj.iscs_mc.view.dialog
+
+import android.content.Context
+import android.view.View
+import android.view.View.GONE
+import com.grkj.iscs_mc.view.base.BaseDialog
+import com.grkj.iscs_mc.databinding.CommonDialogLoadingProgressBinding
+
+class LoadingProgressDialog(context: Context) :
+    BaseDialog<CommonDialogLoadingProgressBinding>(context) {
+
+    override val viewBinding: CommonDialogLoadingProgressBinding
+        get() = CommonDialogLoadingProgressBinding.inflate(layoutInflater)
+
+    override fun initView() {
+        setCanceledOnTouchOutside(false)
+    }
+
+    override fun show() {
+        super.show()
+        if (!mBinding!!.avlivCommon.isShown) mBinding!!.avlivCommon.smoothToShow()
+    }
+
+    override fun cancel() {
+        super.cancel()
+        try {
+            mBinding?.avlivCommon?.smoothToHide()
+        } catch (e: Exception) {
+        }
+    }
+
+    fun setProgress(proStr: String?) {
+        try {
+            if (proStr.isNullOrEmpty()) {
+                mBinding?.tvCommonProgress?.visibility = GONE
+            } else {
+                mBinding?.tvCommonProgress?.visibility = View.VISIBLE
+                mBinding?.tvCommonProgress?.text = proStr
+            }
+        } catch (e: Exception) {
+        }
+    }
+}

+ 9 - 0
app/src/main/res/layout/activity_home.xml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/main"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context=".view.activity.HomeActivity">
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 38 - 0
app/src/main/res/layout/common_dialog_loading_progress.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout 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="wrap_content"
+    android:layout_height="wrap_content"
+    android:gravity="center_horizontal"
+    android:orientation="vertical"
+    android:paddingHorizontal="20dp"
+    android:paddingVertical="3dp"
+    tools:background="@android:color/darker_gray">
+
+    <TextView
+        android:id="@+id/tv_common_title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textColor="@android:color/white"
+        android:visibility="gone"
+        tools:text="title"
+        tools:visibility="visible" />
+
+    <com.wang.avi.AVLoadingIndicatorView
+        android:id="@+id/avliv_common"
+        style="@style/AVLoadingIndicatorView.Large"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:indicatorColor="@android:color/white"
+        app:indicatorName="PacmanIndicator" />
+
+    <TextView
+        android:id="@+id/tv_common_progress"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textColor="@android:color/white"
+        android:visibility="gone"
+        tools:text="adjfksadfj"
+        tools:visibility="visible" />
+</LinearLayout>

TEMPAT SAMPAH
app/src/main/res/mipmap/main_bg.png


+ 5 - 1
app/src/main/res/values/themes.xml

@@ -1,5 +1,9 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
+    <style name="Base.Theme.ISCS_MC" parent="Theme.Material3.DayNight.NoActionBar">
+        <!-- Customize your light theme here. -->
+        <!-- <item name="colorPrimary">@color/my_light_primary</item> -->
+    </style>
 
-    <style name="Theme.ISCS_MC" parent="android:Theme.Material.Light.NoActionBar" />
+    <style name="Theme.ISCS_MC" parent="Base.Theme.ISCS_MC" />
 </resources>

+ 20 - 0
gradle/libs.versions.toml

@@ -8,6 +8,15 @@ espressoCore = "3.5.1"
 lifecycleRuntimeKtx = "2.6.1"
 activityCompose = "1.8.0"
 composeBom = "2024.04.01"
+appcompat = "1.7.0"
+
+okhttps = "4.0.3"
+log-interceptor = "3.14.9"
+autosize = "v1.2.1"
+fastble = "2.4.0"
+material = "1.10.0"
+activity = "1.8.0"
+constraintlayout = "2.1.4"
 
 [libraries]
 androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -24,6 +33,17 @@ androidx-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-toolin
 androidx-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
 androidx-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" }
 androidx-material3 = { group = "androidx.compose.material3", name = "material3" }
+androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
+
+okhttps = { group = "cn.zhxu", name = "okhttps-gson", version.ref = "okhttps" }
+okhttps-stomp = { group = "cn.zhxu", name = "okhttps-stomp", version.ref = "okhttps" }
+log-interceptor = { group = "com.squareup.okhttp3", name = "logging-interceptor", version.ref = "log-interceptor" }
+autosize = { group = "com.github.JessYanCoding", name = "AndroidAutoSize", version.ref = "autosize" }
+fastble = { group = "com.github.Jasonchenlijian", name = "FastBle", version.ref = "fastble" }
+
+material = { group = "com.google.android.material", name = "material", version.ref = "material" }
+androidx-activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
+androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
 
 [plugins]
 android-application = { id = "com.android.application", version.ref = "agp" }