Skip to content

Instantly share code, notes, and snippets.

View rygelouv's full-sized avatar

Rygel Louv rygelouv

View GitHub Profile
class TextMultiStateView : LinearLayout {
lateinit var text: TextView
lateinit var progress: ProgressBar
lateinit var image: ImageView
constructor(context: Context) : super(context) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
fun setText(text: String) {
this.text.text = text
}
fun setState(state: State) {
when (state) {
State.DISABLED -> {
image.setImageDrawable(resources.getDrawable(R.drawable.ic_more))
image.visibility = View.VISIBLE
progress.visibility = View.GONE
<com.rygelouv.fragmentstepperproject.testcustomviews.TextMultiStateView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="16dp"
/>
text1.text.text = "Upload profile picture"
text2.text.text = "Upload document"
text3.text.text = "Validate process"
text1.setState(State.LOADING)
// We simulate a running task
Handler().postDelayed({
text1.setState(State.DONE)
}, 1000)
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_vertical"
android:gravity="center"
>
@rygelouv
rygelouv / android-generate-keystores.md
Created May 30, 2018 09:43 — forked from henriquemenezes/android-generate-keystores.md
Android: Generate Release/Debug Keystores

Android: Generate Release/Debug Keystores

Generate Keystores

Debug Keystore

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
interface PostService {
@GET("posts/list")
fun getPostList(): Deferred<Response<PostResponse>>
}
data class PostResponse(val data: List<Post>): BaseApiResponse()
abstract class BaseApiResponse {
var status: Int = 0
var message: String? = null
}
val postListResponse = PostsAPI.postService.getPostList().awaitResult().getOrThrow()
try {
val postListResponse = PostsAPI.postService.getPostList().awaitResult().getOrThrow()
// Do something with the data you got
}
catch (e: Exception) {
// Handle the error case
}