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 fun showToolbarContent(isAuthenticated: Boolean, destinationId: Int) { | |
val content = when (destinationId) { | |
R.id.homeFragment -> if (isAuthenticated) FeedbackFragment() else CountdownFragment() | |
R.id.feedFragment -> TitleFragment().also { | |
val args = Bundle() | |
args.putString("title", getString(R.string.feed)) | |
it.arguments = args | |
} | |
R.id.sessionsFragment -> TitleFragment().also { |
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 class PreviousRideRepo { | |
// define a new executor of type single thread | |
private Executor executor= Executors.newSingleThreadExecutor(); | |
private void insert(){ | |
executor.execute(()->{ | |
// do your insert here inside this block |
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
//omitted class definations for brevity | |
private val sessionDataStateMediatorLiveData = MediatorLiveData<SessionsModel>() | |
private val error = MediatorLiveData<String>() | |
fun getSessionDetails(dayNumber: String, sessionId: Int) { | |
viewModelScope.launch { | |
when (val value = sessionDataRepo.getSessionData(dayNumber, sessionId)) { | |
is FirebaseResult.Success -> sessionDataStateMediatorLiveData.postValue(value.data) | |
is FirebaseResult.Error -> error.postValue(value.exception) |
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
val retrofit = module(override = true) { | |
single { | |
val interceptor = HttpLoggingInterceptor() | |
if (BuildConfig.DEBUG) { | |
interceptor.apply { interceptor.level = HttpLoggingInterceptor.Level.BODY } | |
} else { | |
interceptor.apply { interceptor.level = HttpLoggingInterceptor.Level.NONE } | |
} |
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
@Dao | |
interface SongsDao { | |
@Insert(targetEntity = Song::class) | |
fun inserNameamdId(nameAndId : NameAndId) | |
} | |
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
@Dao | |
interface SongsDao { | |
@Query("SELECT * FROM song") | |
suspend fun getAllSongs(): List<NameAndId> | |
} | |
// data class with only name and id | |
data class NameAndId(val id: Long, val songName: String) |
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
@Entity | |
data class Song( | |
@PrimaryKey | |
val id: Long, | |
val url: String, | |
val songName: String, | |
val artistName: String, | |
val albumName: String | |
) |
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
android { | |
... | |
defaultConfig { | |
... | |
javaCompileOptions { | |
annotationProcessorOptions { | |
arguments = [ | |
"room.expandProjection":"true" | |
] | |
} |
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
android { | |
... | |
defaultConfig { | |
... | |
javaCompileOptions { | |
annotationProcessorOptions { | |
arguments = [ | |
"room.incremental":"true" | |
] | |
} |
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
@Dao | |
interface FavoritesDao { | |
@Query("SELECT * FROM Work") | |
fun getAll(): Flow<Work> | |
} | |
suspend fun getAll(){ |