View detekt.gradle
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
buildscript { | |
repositories { | |
mavenCentral() | |
gradlePluginPortal() | |
} | |
dependencies { | |
classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.17.1" | |
} | |
} |
View CustomSingleLiveEvent.kt
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
class CustomSingleLiveEvent<T> : SingleLiveEvent<T>() { | |
override fun setValue(t: T?) { | |
if (this.hasActiveObservers()) | |
super.setValue(t) | |
} | |
override fun postValue(value: T) { | |
if (this.hasActiveObservers()) | |
super.postValue(value) |
View convertUriToFile
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
Uri selectedImage = data.getData(); // or your uri | |
String selectedMediaPath; | |
Cursor cursor = getActivity().getContentResolver().query(selectedImage, null,null, null, null); | |
if (cursor == null) | |
selectedMediaPath = selectedImage.getPath; | |
else { | |
cursor.moveToFirst(); | |
int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); |