Software ecology is the holistic study of socio-technical ecosystems that produce software — systems made of both people and technology that are deeply interlinked. You can't understand one without the other.
Notes from Effective Kotlin: Best Practice
The general rule is that one should not create unnecessary ways to mutate a state. Every way to mutate a state is a cost. Every mutation point needs to be understood and maintained. We prefer to limit mutability. General rules:
- Prefer val over var.
This file contains hidden or 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
| fun <T : View> Activity.bindView(viewId: Int) = | |
| lazy { this.findViewById<T>(viewId) } |
This file contains hidden or 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
| /** | |
| * Modifies a layout to ignore irs parents horizontal padding. This is useful if you have an item in a column, such as | |
| * a divider, that does not want to be constrained by the parents padding | |
| */ | |
| fun Modifier.ignoreHorizontalParentPadding(horizontal: Dp): Modifier { | |
| return this.layout { measurable, constraints -> | |
| val overriddenWidth = constraints.maxWidth + 2 * horizontal.roundToPx() | |
| val placeable = measurable.measure(constraints.copy(maxWidth = overriddenWidth)) | |
| layout(placeable.width, placeable.height) { | |
| placeable.place(0, 0) |
This file contains hidden or 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
| # Remove directories and files that aren’t in git from your own local working copy you can do so by running | |
| git clean -d -f -x |
This file contains hidden or 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
| import android.content.Context | |
| import java.time.temporal.ChronoField.DAY_OF_YEAR | |
| import java.time.temporal.ChronoField.INSTANT_SECONDS | |
| import java.time.temporal.ChronoField.YEAR | |
| import java.time.temporal.TemporalAccessor | |
| import java.util.Locale | |
| import javax.inject.Inject | |
| /** | |
| * Custom date and time formatter implementing custom formatting rules. |
This file contains hidden or 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
| import android.content.Context | |
| import androidx.annotation.PluralsRes | |
| import androidx.annotation.StringRes | |
| /** Provides access to localized strings and text using the resources from the application context. */ | |
| class AndroidStringsProvider @Inject constructor( | |
| private val context: Context | |
| ): StringsProvider { | |
| override fun get(@StringRes resId: Int): String { |
This file contains hidden or 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
| /** | |
| * | |
| * Safely run some delayed tasks in a view as they will be tied to the lifecycle. | |
| * | |
| * @param durationInMillis delay task in millisecons | |
| * @param dispatcher CoroutineDispatcher, defaults to Dispatchers.Main as view work is done on Main thread | |
| * @param block the block of work to be done | |
| * | |
| * example: | |
| * |