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 const val defaultDebounce: Long = 500 | |
/** | |
* Prevents that the click events gets called too often by fast clicking user | |
*/ | |
@UiThread | |
fun View.setDebounceOnClickListener(@IntRange(from = 0, to = Integer.MAX_VALUE.toLong()) debounceTime: Long = defaultDebounce, listener: (View) -> Unit) { | |
this.setOnClickListener(object : View.OnClickListener { | |
private var lastClickTime: Long = 0 | |
override fun onClick(v: View) { |
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
fun ProgressBar.handleState(resource: Resource<Any>) { | |
visibility = when (resource) { | |
is Loading -> View.VISIBLE | |
is Error -> View.GONE | |
is Success -> View.GONE | |
} | |
} |
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
import org.simpleframework.xml.Attribute; | |
import org.simpleframework.xml.Element; | |
import org.simpleframework.xml.ElementList; | |
import org.simpleframework.xml.Namespace; | |
import org.simpleframework.xml.NamespaceList; | |
import org.simpleframework.xml.Root; | |
import org.simpleframework.xml.Text; | |
import java.util.List; |
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
/** | |
* Call to populate new data for Bottomsheet. | |
* If Bottomsheet is shown it will collapse first, then it will invoke doWhenCollapsed | |
*/ | |
inline fun <reified T : View> BottomSheetBehavior<T>.colapseAndShow(noinline doWhenCollapsed: () -> Unit) { | |
when (state) { | |
STATE_EXPANDED, | |
STATE_HALF_EXPANDED -> { | |
addBottomSheetCallback(WaitForCollapsedState(this, doWhenCollapsed)) |
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
fun Intent.putAnyExtra(name: String, value: Any) { | |
when (value) { | |
is Int -> putExtra(name, value) | |
is Byte -> putExtra(name, value) | |
is Short -> putExtra(name, value) | |
is Long -> putExtra(name, value) | |
is Char -> putExtra(name, value) | |
is Float -> putExtra(name, value) | |
is Double -> putExtra(name, value) | |
is Boolean -> putExtra(name, value) |
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
Added in Android Jelly Bean (4.1) - API 16 : | |
Regular (default): | |
<item name="android:fontFamily">sans-serif</item> | |
<item name="android:textStyle">normal</item> | |
Italic: | |
<item name="android:fontFamily">sans-serif</item> |
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
import org.junit.rules.TestRule; | |
import org.junit.runner.Description; | |
import org.junit.runners.model.Statement; | |
import io.reactivex.android.plugins.RxAndroidPlugins; | |
import io.reactivex.plugins.RxJavaPlugins; | |
import io.reactivex.schedulers.Schedulers; | |
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
@Test | |
public void timezoneProblem() throws ParseException { | |
TimeZone utcTime = TimeZone.getTimeZone("UTC"); | |
TimeZone berlinTime = TimeZone.getTimeZone("Europe/Berlin"); | |
Calendar calendar = new GregorianCalendar(); | |
calendar.setTimeZone(utcTime); | |
int hourOfDay_1 = calendar.get(Calendar.HOUR_OF_DAY); | |
calendar.setTimeZone(berlinTime); | |
int hourOfDay_2 = calendar.get(Calendar.HOUR_OF_DAY); |
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
import android.util.Log; | |
import com.google.common.eventbus.EventBus; | |
/** | |
* An Proxy which allows better log control |
NewerOlder