companion

A collection of Android extensions and utilities

Лицензия

Лицензия

Группа

Группа

dev.sergiobelda.android.companion
Идентификатор

Идентификатор

companion
Последняя версия

Последняя версия

0.1.3
Дата

Дата

Тип

Тип

aar
Описание

Описание

companion
A collection of Android extensions and utilities
Система контроля версий

Система контроля версий

https://github.com/serbelga/companion/tree/main

Скачать companion

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/dev.sergiobelda.android.companion/companion/ -->
<dependency>
    <groupId>dev.sergiobelda.android.companion</groupId>
    <artifactId>companion</artifactId>
    <version>0.1.3</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/dev.sergiobelda.android.companion/companion/
implementation 'dev.sergiobelda.android.companion:companion:0.1.3'
// https://jarcasting.com/artifacts/dev.sergiobelda.android.companion/companion/
implementation ("dev.sergiobelda.android.companion:companion:0.1.3")
'dev.sergiobelda.android.companion:companion:aar:0.1.3'
<dependency org="dev.sergiobelda.android.companion" name="companion" rev="0.1.3">
  <artifact name="companion" type="aar" />
</dependency>
@Grapes(
@Grab(group='dev.sergiobelda.android.companion', module='companion', version='0.1.3')
)
libraryDependencies += "dev.sergiobelda.android.companion" % "companion" % "0.1.3"
[dev.sergiobelda.android.companion/companion "0.1.3"]

Зависимости

runtime (4)

Идентификатор библиотеки Тип Версия
org.jetbrains.kotlin : kotlin-stdlib jar 1.5.0
androidx.core » core-ktx jar 1.3.2
androidx.appcompat » appcompat jar 1.2.0
com.google.android.material » material jar 1.3.0

Модули Проекта

Данный проект не имеет модулей.

Companion

A collection of Android extensions and utilities.

implementation "dev.sergiobelda.android.companion:companion:0.1.3"

Dialogs

createMaterialDialog(this) {
    title(R.string.simple_dialog)
    message(R.string.lorem_ipsum_short)
    positiveButton(R.string.ok) {
        Toast.makeText(
            this@DialogsActivity,
            "Positive button click",
            Toast.LENGTH_SHORT
        ).show()
    }
    negativeButton("Cancel")
}.show()

createMaterialDialog(this) {
    title(R.string.single_choice_items)
    singleChoiceItems(R.array.items, checkedItem = 0) {
        Toast.makeText(this@DialogsActivity, "Selected: $it", Toast.LENGTH_SHORT).show()
    }
    positiveButton(R.string.ok)
    negativeButton(R.string.cancel)
}.show()

val items = arrayOf<CharSequence>("Item 0", "Item 1", "Item 2")
val booleanArray = booleanArrayOf(true, false, true)
createMaterialDialog(this) {
    isCancelable = false
    title(R.string.multiple_choice_items_dialog)
    multipleChoiceItems(items, booleanArray) { item, isChecked ->
        booleanArray[item] = isChecked
        Toast.makeText(this@DialogsActivity, "Item $item: $isChecked", Toast.LENGTH_SHORT).show()
    }
    positiveButton(R.string.ok) {
        Toast.makeText(this@DialogsActivity, booleanArray.joinToString(), Toast.LENGTH_SHORT).show()
    }
}.show()

createMaterialDialog(
    this,
    R.style.ThemeOverlay_MaterialComponents_MaterialAlertDialog_Centered
) {
    icon(R.drawable.ic_baseline_file_24)
    title(R.string.centered_dialog)
    message(R.string.lorem_ipsum_long)
    positiveButton(R.string.ok)
    neutralButton(R.string.other)
}.show()

Activity

Launch Activity

launchActivity<MyActivity>()

launchActivity<MyActivity> {
    putExtra(...)
}

Launch Activity for Result

launchActivityForResult<MyActivity>(REQUEST_CODE)

launchActivityForResult<MyActivity>(REQUEST_CODE) {
    putExtra(...)
}

Context

// Return Version name
val versionName: String? = getVersionName()
// Return Version code
val versionCode: Long? = getVersionCode()
// Return a color associated with a particular attribute ID
val color: Int? = getColorFromAttr(R.attr....)
// Convert Px to Dp
val dp: Float? = pxToDp(px)

License

Copyright 2021 Sergio Belda

Licensed 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 at

    http://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.

Версии библиотеки

Версия
0.1.3
0.1.2
0.1.1
0.1.0