Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jyygithub/koonny-appcompat
Android开发组件封装
https://github.com/jyygithub/koonny-appcompat
android android-library androidx app baseactivity basefragment core toast viewbinding
Last synced: about 2 months ago
JSON representation
Android开发组件封装
- Host: GitHub
- URL: https://github.com/jyygithub/koonny-appcompat
- Owner: jyygithub
- License: apache-2.0
- Created: 2023-03-06T03:13:38.000Z (almost 2 years ago)
- Default Branch: canary
- Last Pushed: 2023-12-19T04:03:01.000Z (about 1 year ago)
- Last Synced: 2024-10-12T22:35:08.252Z (3 months ago)
- Topics: android, android-library, androidx, app, baseactivity, basefragment, core, toast, viewbinding
- Language: Kotlin
- Homepage:
- Size: 180 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Android通用Core
## Gradle
```groovy
implementation 'com.koonny.appcompat:appcompat:LATEST_VERSION'
```## 用法
### BaseActivity/BaseFragment/BaseDialogFragment
```kotlin
class MainActivity : BaseActivity(ActivityMainBinding::inflate) {override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// TODO
}}
``````kotlin
class FirstFragment : BaseFragment(ActivityMainBinding::inflate) {override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// TODO
}}
``````kotlin
class DoneDialog : BaseDialogFragment(DialogDoneBinding::inflate) {override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// TODO
}}
```### 点击事件
```kotlin
class MainActivity {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
button.click {
// 点击间隔3秒
// TODO
}
button.click(200) {
// 点击间隔200毫秒
// TODO
}
}
}
```### 日期工具
```kotlin
// Date、String、Long的格式转换
class MainActivity {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val nowMill = NOW_MILLS
val nowDate = NOW_DATE
val nowString = NOW_STRING
val result = NOW_MILLS.toDate().time.formatString("yyyy-MM-dd")
}
}
```### 版本号
```kotlin
class MainActivity {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val versionCode = appVersion.versionCode
val versionName = appVersion.versionName
}
}
```### Intent封装
```kotlin
class FirstActivity {
fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
startActivity(
Intent(this, MainActivity::class.java).apply {
putExtra("result", "abc")
})
}
}
``````kotlin
class MainActivity {
fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val result by intentString("result")
}
}
```### 正则表达式
```kotlin
class MainActivity {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val result = "2132133".isPassword
val result1 = "sdasd".isPhoneNumber
}
}
```### FlowEventBus
```kotlin
FlowEventBus.post("action1", "success")
``````kotlin
FlowEventBus.subscribe("action1") {
Log.d("event", it)
}
```## License
```
Copyright 2023 jyygithubLicensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```