Skip to content

Instantly share code, notes, and snippets.

View iljaosintsev's full-sized avatar

Ilja Osintsev iljaosintsev

View GitHub Profile
@iljaosintsev
iljaosintsev / readme.md
Last active May 19, 2021 07:03
Daler MovieApplication feedback

Environment

  1. Remove local.properties from VCS
  2. Hide api key from VCS, multi-env support
  3. Craft and choose code style
  4. Know last android dev news

Dependencies

  1. Migrate from jCenter to Maven Central
  2. Use Material Components
import org.junit.Test
class ExampleUnitTest {
// any collection
private val set: MutableCollection<Int> = mutableSetOf()
@Test
fun test() {
val range = 1 until 6
import org.assertj.core.api.Assertions.*
import org.junit.Test
class DemoUnitTest {
@Test
fun additionIsCorrect() {
assertThat(2 + 2).isEqualTo(4)
}
import org.assertj.core.api.Assertions.assertThat
import org.junit.Assert.assertNotNull
import org.junit.Test
class ChainTest {
sealed class Chain<T> {
companion object {
@iljaosintsev
iljaosintsev / wip.kt
Created December 4, 2018 14:19
DateTimeFormatters
package ru.kontur.cashbox.presentation.settings.about
import ru.kontur.cashbox.R
import ru.kontur.cashbox.global.ResourceManager
import java.text.SimpleDateFormat
import java.util.*
class NotOccurredFormatter(private val stub: String): PossibilityFormatter() {
override fun should(diff: DiffTime) = diff.point.time < 1
@iljaosintsev
iljaosintsev / HeaderScrollingViewBehavior.java
Last active November 28, 2018 19:01
HeaderScrollingViewBehavior#onMeasureChild
abstract class HeaderScrollingViewBehavior extends ViewOffsetBehavior<View> {
// also code
@Override
public boolean onMeasureChild(CoordinatorLayout parent, View child,
int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec,
int heightUsed) {
final int childLpHeight = child.getLayoutParams().height;
if (childLpHeight == ViewGroup.LayoutParams.MATCH_PARENT
@iljaosintsev
iljaosintsev / BlinkAnimator.kt
Created October 19, 2018 07:16
Blink RecylerView ItemAnimator
/**
* Реализует выделение изменившейся ячейки RecyclerView. Ячейка лпавно изменяет свой фон от [primaryColor] до [accentColor].
* При повторном изменении ячейки состояние предыдущей анимации переносится на новую (происходит возобновление).
*
* @see <a href="https://github.com/google/android-ui-toolkit-demos/tree/master/RecyclerView/RecyclerViewAnimations">Пример от Google</a>
* @param primaryColor нормальный цвет ячейки
* @param accentColor выделенный цвет ячейки
* @param shouldSaveAnimation следует ли сохранять состояние анимации при ее возобновлении
*/
class BlinkAnimator(@ColorInt private val primaryColor: Int, @ColorInt private val accentColor: Int, private val shouldSaveAnimation: Boolean): DefaultItemAnimator() {
@iljaosintsev
iljaosintsev / GsonGeneric.java
Created October 1, 2018 17:54
Gson and generic
package com.turlir.abakgists;
import com.google.gson.Gson;
import org.junit.Test;
import java.util.Objects;
import static org.junit.Assert.*;
public class Demo {
@Test
@iljaosintsev
iljaosintsev / copy.kt
Last active July 23, 2018 19:34
use-site variance in kotlin
@Test
fun copyIntToString() {
val ints: Array<Int> = arrayOf(1, 2, 3)
val anys: Array<Any> = arrayOf("first", "second", "three")
copy(ints, anys)
for (a in anys) {
println(a) // 1, 2, 3
}
assertArrayEquals(ints, anys)
}
@iljaosintsev
iljaosintsev / preference_category_material.xml
Created November 7, 2017 09:47
Android Preference category Material
<!--
layout
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
android:textAppearance="@style/Preference_TextAppearanceMaterialBody2"
android:textColor="@color/preference_fallback_accent_color"