Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0
This file contains hidden or 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
// Slide up animation | |
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > | |
<translate | |
android:duration="@android:integer/config_mediumAnimTime" | |
android:fromYDelta="100%" | |
android:interpolator="@android:anim/accelerate_interpolator" | |
android:toXDelta="0" /> |
This file contains hidden or 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 Bundle convertMapToBundle(Map<String, String> data){ | |
Bundle bundle = new Bundle(); | |
for (Map.Entry<String, String> entry : data.entrySet()) { | |
bundle.putString(entry.getKey(), entry.getValue()); | |
} | |
return bundle; | |
} |
This file contains hidden or 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 ViewUtil { | |
fun disableButtonsTemporarily(viewList:ArrayList<View>){ | |
try{ | |
//DISABLE THE VIEW | |
updateViewsClickableAttribute(viewList, false) | |
//ENABLE THE VIEWS | |
val handler = Handler() | |
handler.postDelayed( { | |
// Do something after 5s = 5000ms |
This file contains hidden or 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
//https://cheesecakelabs.com/blog/using-viper-architecture-android/ | |
class LoginContracts { | |
interface View { | |
//1. this are the methods the presenter the contract can call (for displaying data) | |
// - implemented by fragment/activity/view | |
fun goToHomeScreen(user: User) | |
fun showError(message: String) | |
} | |
interface Presenter { |
This file contains hidden or 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
------------------------------------------------------------------- | |
------------------------build.gradle------------------------------- | |
------------------------------------------------------------------- | |
/** | |
* RxJava2 and RxAndroid2 gradle setup | |
implementation 'com.android.support:design:26.1.0' | |
compile group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.1.5' | |
compile 'io.reactivex.rxjava2:rxandroid:2.0.1' | |
*/ |
This file contains hidden or 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
/** | |
* Usage: | |
* val limit0to24 = EditTextInputFilter(0, 23) | |
* val limitChars = EditTextInputFilter(arrayListOf("a","b","c","d","e","f","g","h", "ab", "cd")) | |
* input1.setFilters(arrayOf(limit0to24)) | |
* input2.setFilters(arrayOf(limitChars)) | |
* | |
*/ | |
class EditTextInputFilter : InputFilter { |
This file contains hidden or 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 void animateCountdown(final View textView){ | |
ValueAnimator valueAnimator = ValueAnimator.ofFloat(1f, 0f); | |
valueAnimator.setDuration(800); | |
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { | |
@Override | |
public void onAnimationUpdate(ValueAnimator animation) { | |
float alpha = Float.parseFloat(animation.getAnimatedValue().toString()); | |
textView.setAlpha(alpha); | |
} | |
}); |
This file contains hidden or 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
//recyclerview list item layout xml with scrollable textview | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
xmlns:card_view="http://schemas.android.com/apk/res-auto" | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:orientation="vertical" | |
> <TextView |
This file contains hidden or 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
//kotlin code | |
editText. | |
filters = arrayOf<InputFilter>(object : InputFilter.AllCaps() { | |
override fun filter(source: CharSequence, start: Int, end: Int, dest: Spanned, dstart: Int, dend: Int): CharSequence { | |
return source.toString().toLowerCase() | |
} | |
}) | |
//xml layout | |
<?xml version="1.0" encoding="utf-8"?> |
OlderNewer