develop
yanzs 2023-11-14 15:58:52 +08:00
parent 1857cdb0b8
commit 732932ec75
15 changed files with 334 additions and 46 deletions

View File

@ -12,18 +12,19 @@
android:supportsRtl="true"
android:theme="@style/Theme.Android_ulsService"
tools:targetApi="31" >
<activity
android:name=".module.home.MainActivity"
android:exported="true"
android:label="@string/app_name">
android:name=".module.wecome.WecomeActivity"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".module.home.MainActivity"
android:launchMode="singleTask">
</activity>
<activity
android:name=".module.test.FuncListActivity"
android:exported="false" />

View File

@ -19,18 +19,5 @@ class MainActivity : AppCompatActivity() {
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
val navView: BottomNavigationView = binding.navView
val navController = findNavController(R.id.nav_host_fragment_activity_main)
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.navigation_home, R.id.navigation_dashboard, R.id.navigation_notifications
)
)
setupActionBarWithNavController(navController, appBarConfiguration)
navView.setupWithNavController(navController)
}
}

View File

@ -0,0 +1,28 @@
package com.uls.service.module.home.view
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.LinearLayout
import com.uls.service.databinding.HomeItemViewBinding
import com.util.extension.dp
import com.util.extension.roundCorner
/**
Created by yanzs on 2023/11/14
*/
class HomeItemView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null
) : LinearLayout(context, attrs) {
private var binding = HomeItemViewBinding.inflate(LayoutInflater.from(context), this, true)
init {
roundCorner(30.dp)
background = GradientDrawable(
GradientDrawable.Orientation.LEFT_RIGHT,
intArrayOf(Color.parseColor("#ff36C1C8"), Color.parseColor("#ff37D1D9"))
)
}
}

View File

@ -0,0 +1,25 @@
package com.uls.service.module.wecome
import android.annotation.SuppressLint
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.uls.service.R
import com.uls.service.module.home.MainActivity
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Flowable
import java.util.concurrent.TimeUnit
class WecomeActivity : AppCompatActivity() {
@SuppressLint("CheckResult")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_wecome)
Flowable.timer(300,TimeUnit.MILLISECONDS)
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
finish()
startActivity(Intent(this,MainActivity::class.java))
}
}
}

View File

@ -1,33 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:background="?android:attr/windowBackground"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<fragment
android:id="@+id/nav_host_fragment_activity_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/nav_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/mobile_navigation" />
android:orientation="horizontal"
>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
</LinearLayout>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
tools:context=".module.wecome.WecomeActivity">
<RelativeLayout
android:layout_width="466dp"
android:layout_height="466dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@mipmap/wecom_logo"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff3D3D3D"
android:textSize="80sp"
android:text="尤岚氏机器人"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/wecom_logo_subtitle"
/>
</androidx.appcompat.widget.LinearLayoutCompat>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#36C1C8"
android:padding="12dp">
<ImageView
android:layout_width="90dp"
android:layout_height="90dp"/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_weight="1">
<TextView
android:id="@+id/tv_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="家庭医生"
android:textColor="#FFFFFF"
android:textSize="38sp"
/>
<TextView
android:id="@+id/tv_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="26sp"
android:textColor="#FFFFFF"
android:text="专家坐诊,线上咨询"
/>
</LinearLayout>
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -12,5 +12,6 @@
<!-- Status bar color. -->
<item name="android:statusBarColor">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:screenOrientation">landscape</item>
</style>
</resources>

View File

@ -32,7 +32,7 @@ android {
dependencies {
api project(":uikit")
api project(":util")
api androidxLibs.bundles.androidx
api googleLibs.material

View File

@ -39,5 +39,6 @@ dependencies {
api 'com.squareup.retrofit2:adapter-rxjava3:2.9.0'
api 'com.squareup.retrofit2:converter-gson:2.9.0'
api 'com.squareup.okhttp3:okhttp:4.2.2'
api 'com.ljx.rxlife3:rxlife-rxjava:3.0.0'
}

View File

@ -0,0 +1,29 @@
package com.util.extension
import android.content.res.Resources
// see https://github.com/nitrico/kema/blob/master/kema/src/main/java/com/github/nitrico/kema/Conversions.kt
// dp to pixels
val Int.dp: Int get() = (this * Resources.getSystem().displayMetrics.density + 0.5f).toInt()
// float dp to pixels
val Float.dp: Float get() = (this * Resources.getSystem().displayMetrics.density + 0.5f)
val Int.sp: Int get() = (this * Resources.getSystem().displayMetrics.scaledDensity + 0.5f).toInt()
val Float.sp: Float get() = (this * Resources.getSystem().displayMetrics.scaledDensity + 0.5f)
// integer to float
val Int.f: Float get() = toFloat()
// integer to double
val Int.d: Double get() = toDouble()
// float to integer
val Float.i: Int get() = toInt()
// double to integer
val Double.i: Int get() = toInt()

View File

@ -0,0 +1,155 @@
package com.util.extension
import android.graphics.Outline
import android.os.Handler
import android.os.Looper
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.view.ViewOutlineProvider
import android.widget.EditText
import android.widget.TextView
import kotlin.math.abs
fun View.visible() {
visibility = View.VISIBLE
}
fun View.invisible() {
visibility = View.INVISIBLE
}
fun View.gone() {
visibility = View.GONE
}
fun View.setVisible(isVisible: Boolean) {
visibility = if (isVisible) {
View.VISIBLE
} else {
View.GONE
}
}
/**
* 设置防抖动的点击事件
*
* @param intervalInMillis 防抖动阈值默认800ms
*/
fun View.setOnThrottledClickListener(
intervalInMillis: Long = 800L,
action: (View) -> Unit
) {
setOnClickListener(
object : View.OnClickListener {
private var lastClickedTimeInMillis: Long = 0
override fun onClick(v: View) {
if (abs(System.currentTimeMillis() - lastClickedTimeInMillis) >= intervalInMillis) {
lastClickedTimeInMillis = System.currentTimeMillis()
action.invoke(v)
}
}
}
)
}
/**
* 用于让类继承在onClick方法中统一用view.id区分
*/
fun View.setOnThrottledClickListener(
onThrottledClickListener: OnThrottledClickListener,
intervalInMillis: Long = 800L
) {
setOnClickListener(
object : View.OnClickListener {
private var lastClickedTimeInMillis: Long = 0
override fun onClick(v: View) {
if (abs(System.currentTimeMillis() - lastClickedTimeInMillis) >= intervalInMillis) {
onThrottledClickListener.onClick(v)
lastClickedTimeInMillis = System.currentTimeMillis()
}
}
}
)
}
fun TextView.setOnDebouncedAfterTextChanged(
intervalInMillis: Long = 200L,
onAfterChanged: (text: Editable?) -> Unit
) {
this.addTextChangedListener(object : TextWatcher {
val handler = Handler(Looper.getMainLooper())
var runnable: Runnable? = null
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
runnable?.let {
handler.removeCallbacks(it)
}
}
override fun afterTextChanged(s: Editable?) {
runnable = Runnable {
onAfterChanged(s)
}.also {
handler.postDelayed(it, intervalInMillis)
}
}
})
}
var EditText.trimText: String?
set(value) {
this.setText(value)//设置的数据不处理
}
get() {
return this.text.toString().trim()
}
interface OnThrottledClickListener {
fun onClick(v: View)
}
fun View.roundCorner(
round: Int
) {
outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(0, 0, view.width, view.height, round.toFloat())
}
}
clipToOutline = true
}
fun View.roundTopCorner(
round: Int
) {
outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(0, 0, view.width, view.height + round, round.toFloat())
}
}
clipToOutline = true
}
fun View.roundBottomCorner(
radius: Int
) {
outlineProvider = object : ViewOutlineProvider() {
override fun getOutline(view: View, outline: Outline) {
outline.setRoundRect(0, -radius, view.width, view.height, radius.toFloat())
}
}
clipToOutline = true
}