Skip to content

Instantly share code, notes, and snippets.

@oradkovsky
oradkovsky / generate-next-version-humber.sh
Created July 9, 2021 08:09
Automated versioning based on tags
#!/bin/bash
# The greatest value Google Play allows for versionCode is 2100000000 and is not checked here for simplicity :)
RES=$(git show-ref --tags)
if [ -z "$RES" ]; then
NEW_TAG="1.0.0-1"
else
LATEST_TAG=$(git describe --tags --abbrev=0 --match *.*.*-*)
echo "Latest detected tag is $LATEST_TAG"
@oradkovsky
oradkovsky / gist:ed9924a0d007ed10be44d244becb862b
Last active April 16, 2021 06:23
Glide shadow transformation
/**
* Quick and hacky way, tested under SDK19 and newer.
* How to use (key: in conjunction with CircleCrop):
* <code>transform(new CircleCrop(), new CircleShadowTransformation())</code>
*/
public class CircleShadowTransformation extends BitmapTransformation {
private static final int SHADOW_RADIUS = 10;
private static final String ID = "a.b.c.transformations.CircleShadowTransformation";
private static final byte[] ID_BYTES = ID.getBytes(Charset.forName(STRING_CHARSET_NAME));
1. ./adb shell pm list packages
2. ./adb shell pm path com.your.package
3. ./adb exec-out run-as com.your.package cat /data/data/com.your.package/shared_prefs/Login.xml
@oradkovsky
oradkovsky / gist:7055ec1dc2f5211ab8393d79aaffa736
Created September 11, 2020 08:25
Observables.combineLatest vs Singles.zip (rxkotlin)
@Test
fun withCombineLatest() {
val testScheduler = TestScheduler()
val observable1 = Single.defer {
Single.just(1)
.delay(1, TimeUnit.SECONDS, testScheduler)
}.toObservable()
val observable2 = Single.defer {
Single.just(2)
// declare view model
class MyViewModelWithState(
private val handle: SavedStateHandle, //always first param btw
private val gson: Gson
) : ViewModel() {
// make use of state bundle as usual
}
// modify corresponding module
val viewModelsModule = module {
class MyFragment1 : Fragment() {
private val myViewModel: MyViewModel by sharedGraphViewModel(R.id.myNavGraph)
}
class MyFragment2 : Fragment() {
private val myViewModel: MyViewModel by sharedGraphViewModel(R.id.myNavGraph)
}
class MyFragment1 : Fragment() {
private val myViewModel: MyViewModel by sharedViewModel()
}
class MyFragment2 : Fragment() {
private val myViewModel: MyViewModel by sharedViewModel()
}
// declare view model
class MyViewModel(private val gson: Gson) : ViewModel() {
//...
}
// modify corresponding module
val viewModelsModule = module {
viewModel { MyViewModel(get()) }
}
val appModule = module {
single<Gson> { GsonBuilder().setPrettyPrinting().create() }
}
//typically in a separate file
val appModule = module { }
//in a separate file as well
val viewModelsModule = module { }
//called in onCreate of your application class
startKoin {
androidLogger()
androidContext(applicationContext)