-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82c2741
commit 13a4712
Showing
65 changed files
with
3,255 additions
and
849 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
app/src/main/java/com/guoyang/androidutils/BaseActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.guoyang.androidutils | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.viewbinding.ViewBinding | ||
import com.guoyang.viewbinding_helper.ActivityBinding | ||
import com.guoyang.viewbinding_helper.ActivityBindingDelegate | ||
|
||
/** | ||
* @author yang.guo on 2022/11/13 | ||
* @describe Activity基类 | ||
*/ | ||
abstract class BaseActivity<T : ViewBinding> : AppCompatActivity(), | ||
ActivityBinding<T> by ActivityBindingDelegate() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentViewWithBinding() | ||
initView(savedInstanceState) | ||
} | ||
|
||
abstract fun initView(savedInstanceState: Bundle?) | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/com/guoyang/androidutils/InfoActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.guoyang.androidutils | ||
|
||
import android.os.Bundle | ||
import com.guoyang.androidutils.databinding.ActivityInfoBinding | ||
import com.guoyang.utils_helper.bundle | ||
import com.guoyang.utils_helper.doOnClick | ||
|
||
class InfoActivity : BaseActivity<ActivityInfoBinding>() { | ||
private val name: String? by bundle() | ||
private val age: Int? by bundle() | ||
|
||
override fun initView(savedInstanceState: Bundle?) { | ||
binding.apply { | ||
tvName.text = name.toString() | ||
tvAge.text = age.toString() | ||
btnSend.doOnClick { | ||
} | ||
} | ||
} | ||
} |
20 changes: 15 additions & 5 deletions
20
app/src/main/java/com/guoyang/androidutils/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
package com.guoyang.androidutils | ||
|
||
import androidx.appcompat.app.AppCompatActivity | ||
import android.os.Bundle | ||
import com.guoyang.androidutils.databinding.ActivityMainBinding | ||
import com.guoyang.utils_helper.* | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
class MainActivity : BaseActivity<ActivityMainBinding>() { | ||
override fun initView(savedInstanceState: Bundle?) { | ||
immersive(binding.toolBar) | ||
binding.button.doOnDebouncingClick { | ||
startActivity<InfoActivity>( | ||
"name" to "guoyang", | ||
"age" to 18, | ||
) | ||
} | ||
|
||
AppForegroundObserver().observe(this) { | ||
toast("当前状态: $it") | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/com/guoyang/androidutils/MyApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.guoyang.androidutils | ||
|
||
import android.app.Application | ||
|
||
/** | ||
* @author yang.guo on 2022/11/13 | ||
* @describe | ||
*/ | ||
class MyApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.guoyang.androidutils | ||
|
||
/** | ||
* @author yang.guo on 2022/11/13 | ||
* @describe | ||
*/ | ||
data class UserInfo(val name: String, val age: Int) : java.io.Serializable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?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" | ||
tools:context=".InfoActivity"> | ||
|
||
<TextView | ||
android:id="@+id/tv_name" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toTopOf="@id/tv_age" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_age" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="@id/tv_name" | ||
app:layout_constraintStart_toStartOf="@id/tv_name" | ||
app:layout_constraintTop_toBottomOf="@id/tv_name" /> | ||
|
||
<Button | ||
android:id="@+id/btn_send" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="SendEvent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/tv_age" /> | ||
</androidx.constraintlayout.widget.ConstraintLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
namespace 'com.guoyang.base' | ||
compileSdkVersion 33 | ||
|
||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 33 | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
// 开启module混淆 | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
|
||
//androidx | ||
implementation 'androidx.appcompat:appcompat:1.5.1' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4' | ||
implementation 'com.google.android.material:material:1.7.0' | ||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0' | ||
|
||
//kotlin | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.20" | ||
implementation 'androidx.core:core-ktx:1.9.0' | ||
implementation "androidx.fragment:fragment-ktx:1.5.3" | ||
|
||
//lifecycle | ||
def lifecycleVersion = '2.5.1' | ||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:${lifecycleVersion}" | ||
implementation "androidx.lifecycle:lifecycle-common-java8:${lifecycleVersion}" | ||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${lifecycleVersion}" | ||
|
||
//LiveData数据倒灌问题 https://github.com/KunMinX/UnPeek-LiveData | ||
implementation 'com.kunminx.arch:unpeek-livedata:7.8.0' | ||
//权限框架 https://github.com/guolindev/PermissionX | ||
implementation 'com.guolindev.permissionx:permissionx:1.7.1' | ||
|
||
implementation 'androidx.multidex:multidex:2.0.1' | ||
|
||
//test | ||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 图片选择库 https://github.com/LuckSiege/PictureSelector/blob/version_component/README_CN.md | ||
-keep class com.luck.picture.lib.** { *; } | ||
# 如果引入了Camerax库请添加混淆 | ||
-keep class com.luck.lib.camerax.** { *; } | ||
# 如果引入了Ucrop库请添加混淆 | ||
-dontwarn com.yalantis.ucrop** | ||
-keep class com.yalantis.ucrop** { *; } | ||
-keep interface com.yalantis.ucrop** { *; } |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.guoyang.base | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import androidx.multidex.MultiDex | ||
|
||
/*** | ||
* 提供基类的Application | ||
* @author Yang.Guo on 2021/5/31. | ||
*/ | ||
open class BaseApp : Application() { | ||
|
||
override fun attachBaseContext(base: Context?) { | ||
super.attachBaseContext(base) | ||
MultiDex.install(this) | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.guoyang.base.event | ||
|
||
import com.kunminx.architecture.ui.callback.UnPeekLiveData | ||
|
||
/*** | ||
* 解决数据倒灌的LiveData,可以用来做事件订阅 | ||
* @author Yang.Guo on 2021/6/3. | ||
*/ | ||
class EventLiveData<T> : UnPeekLiveData<T>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.guoyang.base.ext | ||
|
||
import android.content.Context | ||
import android.os.Process | ||
|
||
// <editor-fold desc="Context相关的扩展类"> | ||
/** | ||
* 判断当前是否是主进程 | ||
* @param block: 结果回调(回调在主进程中执行) | ||
*/ | ||
inline fun Context.runMainProcess(block: () -> Unit) { | ||
val myPid = Process.myPid() | ||
val mActivityManager = | ||
this.getSystemService(Context.ACTIVITY_SERVICE) as android.app.ActivityManager | ||
val var3 = mActivityManager.runningAppProcesses?.iterator() | ||
while (var3?.hasNext() == true) { | ||
val appProcessInfo = var3.next() as android.app.ActivityManager.RunningAppProcessInfo | ||
if (appProcessInfo.pid == myPid && appProcessInfo.processName.equals( | ||
this.packageName, ignoreCase = true | ||
) | ||
) { | ||
block() | ||
break | ||
} | ||
} | ||
} | ||
|
||
// </editor-fold> |
Oops, something went wrong.