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
| fun getFiles() { | |
| result.value = "Getting all files..." | |
| viewModelScope.launch { | |
| when(val response = avengerAIManager.getFiles()) { | |
| is RemoteResponse.Error -> { | |
| result.value = response.toString() | |
| } | |
| is RemoteResponse.Success -> { | |
| result.value = response.toString() |
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 generateTextAndUpdateResult( | |
| fileUriItems : List<FileUriInfo>, prompt : String, defaultErrorMessage : String) { | |
| viewModelScope.launch { | |
| avengerAIManager.generateTextStreamContent( | |
| getModelInputList(fileUriItems, prompt), null, defaultErrorMessage, | |
| ).collectLatest { | |
| result.value = it.toString() | |
| isModelStartedGeneratingText.value = false |
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
| package com.androidai.module.geminiapi.ui | |
| import androidx.activity.compose.rememberLauncherForActivityResult | |
| import androidx.activity.result.contract.ActivityResultContracts | |
| import androidx.compose.foundation.ExperimentalFoundationApi | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.clickable | |
| import androidx.compose.foundation.combinedClickable | |
| import androidx.compose.foundation.layout.Arrangement | |
| import androidx.compose.foundation.layout.Box |
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
| package com.androidai.learning.moti.quote | |
| import android.os.Bundle | |
| import androidx.activity.ComponentActivity | |
| import androidx.activity.compose.setContent | |
| import androidx.activity.enableEdgeToEdge | |
| import androidx.compose.material3.Text | |
| import androidx.compose.runtime.Composable | |
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.tooling.preview.Preview |
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
| package com.androidai.learning.moti.quote.remoteservice | |
| import okhttp3.ResponseBody | |
| import retrofit2.Call | |
| import retrofit2.http.GET | |
| interface QuoteService { | |
| @GET("/quotes/random") | |
| fun getRandomQuote() : Call<ResponseBody> // Replace with actual endpoint and response data structure |
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
| package com.androidai.learning.moti.quote.data.response | |
| import kotlinx.serialization.Serializable | |
| @Serializable | |
| data class QuoteResponse(val _id: String, | |
| val content: String, | |
| val author: String, | |
| val tags: List<String>, | |
| val authorSlug: 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
| package com.androidai.learning.moti.quote.repository.remote | |
| import com.androidai.learning.moti.quote.repository.QuoteRepository | |
| import com.androidai.learning.moti.quote.data.domain.Quote | |
| import com.androidai.learning.moti.quote.data.response.QuoteResponse | |
| import com.androidai.learning.moti.quote.remoteservice.QuoteService | |
| import kotlinx.serialization.decodeFromString | |
| import kotlinx.serialization.json.Json | |
| import org.json.JSONArray |
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
| package com.androidai.learning.moti.quote.data.domain | |
| import android.text.SpannableString | |
| import android.text.SpannableStringBuilder | |
| data class Quote(val text: String, val author: String? = null){ | |
| fun getCopyShareContent() : String { | |
| val spannableString = SpannableStringBuilder(text) | |
| if(author != null){ |
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
| package com.androidai.learning.moti.quote.ui.feature.viewmodel | |
| import android.util.Log | |
| import androidx.lifecycle.LiveData | |
| import androidx.lifecycle.MutableLiveData | |
| import androidx.lifecycle.ViewModel | |
| import androidx.lifecycle.viewModelScope | |
| import com.androidai.learning.moti.quote.data.domain.Quote | |
| import com.androidai.learning.moti.quote.repository.QuoteRepository | |
| import kotlinx.coroutines.flow.MutableStateFlow |
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
| package com.androidai.learning.moti.quote.ui.feature | |
| import android.util.Log | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.clickable | |
| import androidx.compose.foundation.layout.Arrangement | |
| import androidx.compose.foundation.layout.Box | |
| import androidx.compose.foundation.layout.Column | |
| import androidx.compose.foundation.layout.Row | |
| import androidx.compose.foundation.layout.fillMaxSize |
NewerOlder