This file contains 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
allprojects { | |
repositories { | |
....... | |
maven { url "https://jitpack.io" } | |
} | |
-------------------- | |
//ext lib | |
implementation 'com.github.wada811:DataBinding-ktx:2.0.2' | |
------------------------------------- |
This file contains 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
//my sample | |
//https://github.com/alexshr/android-kotlin-fundamentals-apps/tree/master/MarsRealEstateFinal | |
//doc | |
//https://developer.android.com/reference/kotlin/androidx/fragment/app/package-summary#viewmodels | |
version_fragment = '1.2.0-alpha01' | |
implementation "androidx.fragment:fragment-ktx:${version_fragment}" | |
-------------------------------------------------------------------------------------- |
This file contains 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
/** | |
* Snackbar LiveEvent | |
* (see https://github.com/hadilq/LiveEvent) | |
* This is private because we don't want to expose setting this value to the Fragment. | |
*/ | |
private val snackBarEvent = LiveEvent<String>() | |
val showSnackBarEvent: LiveData<String> = snackBarEvent | |
//https://github.com/hadilq/LiveEvent |
This file contains 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
// Observe snackbar event | |
sleepTrackerViewModel.showSnackBarEvent.observe(this, Observer { | |
binding.clearButton.snackbar(it) | |
}) | |
//Anko | |
implementation "org.jetbrains.anko:anko-commons:$version_anko" | |
implementation "org.jetbrains.anko:anko-design:$version_anko" // For SnackBars | |
This file contains 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
@file:Suppress("EXPERIMENTAL_API_USAGE") |
This file contains 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
/** | |
* Created by alexshr on 02.05.2017. | |
*/ | |
package com.skb.goodsapp; | |
import android.os.SystemClock; | |
import android.util.Log; | |
import java.util.Date; |
This file contains 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
private boolean isServiceRunning() { | |
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE); | |
boolean isRunning = false; | |
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) { | |
if (LocationService.class.getName().equals(service.service.getClassName())) { | |
isRunning = true; | |
} | |
} | |
Timber.d("isRunning=%b", isRunning); | |
return isRunning; |
This file contains 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
public static Bitmap drawableToBitmap(Drawable drawable) { | |
if (drawable instanceof BitmapDrawable) { | |
return ((BitmapDrawable) drawable).getBitmap(); | |
} | |
int width = drawable.getIntrinsicWidth(); | |
width = width > 0 ? width : 1; | |
int height = drawable.getIntrinsicHeight(); | |
height = height > 0 ? height : 1; |
NewerOlder