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
android.os.BadParcelableException: Parcelable encountered IOException writing serializable object (name = com.xx.xx.auxiliar.ErrorData) | |
at android.os.Parcel.writeSerializable(Parcel.java:2797) | |
at android.os.Parcel.writeValue(Parcel.java:2563) | |
at android.os.Parcel.writeValue(Parcel.java:2362) | |
at android.os.Parcel.writeArrayMapInternal(Parcel.java:1298) | |
at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1843) | |
at android.os.Bundle.writeToParcel(Bundle.java:1389) |
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 LuhnValidator { | |
fun isValid(cardNumber: String): Boolean { | |
var s1 = 0 | |
var s2 = 0 | |
val reverse = StringBuffer(cardNumber).reverse().toString() | |
for (i in reverse.indices) { | |
val digit = Character.digit(reverse[i], 10) | |
when { | |
i % 2 == 0 -> s1 += digit | |
else -> { |
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 LazyListState.animateScrollAndCentralizeItem(index: Int, scope: CoroutineScope) { | |
val itemInfo = this.layoutInfo.visibleItemsInfo.firstOrNull { it.index == index } | |
scope.launch { | |
when { | |
itemInfo != null -> { | |
val center = this@animateScrollAndCentralizeItem.layoutInfo.viewportEndOffset / 2 | |
val childCenter = itemInfo.offset + itemInfo.size / 2 | |
this@animateScrollAndCentralizeItem.animateScrollBy((childCenter - center).toFloat()) | |
} | |
else -> { |
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
items(rankingUIModel.rankingUIModel.challengeRankingItems) { | |
ItemQualifying(modifier= Modifier.animateItemPlacement( | |
spring( | |
stiffness = Spring.StiffnessVeryLow, | |
visibilityThreshold = IntOffset.VisibilityThreshold | |
) | |
), item = it, onRankingItemPressed = onRankingItemPressed) | |
} |
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
interface ApiRefreshToken { | |
companion object { | |
private const val REFRESH_TOKEN = "/refreshToken" | |
} | |
@FormUrlEncoded | |
@POST(REFRESH_TOKEN) | |
fun refreshToken(@Field("refreshToken") refreshToken: String?): Call<TokenModel> | |
} |
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
Viewmodel--> | |
private var _data: Channel<PagingData<Event>> = Channel() | |
var data = _data.receiveAsFlow() | |
fun callApiExample(){ | |
usecaseFoo... .collect{ _data.send(it)} | |
} | |
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
private val displayMetrics: DisplayMetrics by lazy { Resources.getSystem().displayMetrics } | |
/** | |
* Returns boundary of the screen in pixels (px). | |
*/ | |
val screenRectPx: Rect | |
get() = displayMetrics.run { Rect(0, 0, widthPixels, heightPixels) } | |
/** | |
* Returns boundary of the screen in density independent pixels (dp). |
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
.background( | |
brush = Brush.verticalGradient( | |
colors = listOf( | |
MaterialTheme.colors.primary, | |
MaterialTheme.colors.primary.copy(0.2f) | |
) | |
) | |
) |
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
package es.cityride.mantapp | |
import android.content.Context | |
import android.graphics.PorterDuff | |
import android.graphics.drawable.Drawable | |
import android.support.design.widget.TabLayout | |
import android.util.AttributeSet | |
import android.util.SparseArray | |
import android.view.LayoutInflater | |
import android.view.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
To not depend on the app locale, you can use the code from Matt Logan by replacing "Navigate up" with R.string.abc_action_bar_up_description: | |
onView(withContentDescription(R.string.abc_action_bar_up_description)).perform(click()); | |
This helped me a lot because I have an app in more than 5 languages and I had to act like this. |
NewerOlder