Skip to content

Instantly share code, notes, and snippets.

@jayesh83
Created August 3, 2021 12:06
Show Gist options
  • Save jayesh83/f5e708bf10f7a5f1f8cdb28dd1922edb to your computer and use it in GitHub Desktop.
Save jayesh83/f5e708bf10f7a5f1f8cdb28dd1922edb to your computer and use it in GitHub Desktop.
Having this method in meta data model itself now. this will be used to fetch value based on current app language
package com.nascent.pcmc.model
import android.os.Parcelable
import androidx.room.Entity
import com.nascent.pcmc.common.Constant
import com.nascent.pcmc.common.Constant.Companion.LANGUAGE_CODE_ENG
import com.nascent.pcmc.common.Constant.Companion.LANGUAGE_CODE_MARATHI
import com.nascent.pcmc.utils.LocaleHelper
import kotlinx.parcelize.Parcelize
@Parcelize
@Entity(tableName = Constant.TABLE_APP_META_DATA, primaryKeys = ["type", "id"])
data class AppMetaDataModel(
val type: String,
val id: Int = 0,
val eng: String?,
val marathi: String?,
val parentId: Int = -1
) : Parcelable {
fun getLabel(): String? {
return when (LocaleHelper.currentLanguage) {
LANGUAGE_CODE_ENG -> this.eng
LANGUAGE_CODE_MARATHI -> this.marathi
else -> null
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment