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
@Component(modules = [AppModule::class]) | |
@Singleton | |
interface AppComponent { | |
fun appContext(): Context | |
fun preferenceRepository(): PreferenceRepositoryAbs | |
fun quoteRepository(): QuoteRepositoryAbs | |
// fun quoteId(): String? | |
fun inject(fragment: SplashFragment) |
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 args by navArgs<QuoteDetailsFragmentArgs>() | |
oncreate() | |
viewModel.quoteLiveData.observe(this, Observer { | |
if (etAuthorName.text.toString() != it?.author) { | |
etAuthorName.setText(it?.author) | |
} | |
if (etQuoteName.text.toString() != it?.quote) { | |
etQuoteName.setText(it?.quote) |
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
object QuoteRepository : QuoteRepositoryAbs { | |
override val allQuotes: LiveData<List<Quote>> | |
private val quoteDao: QuoteDao = QuoteApplication.roomDataBase.quoteDao() | |
private val repositoryScope = MainScope() | |
init { | |
allQuotes = quoteDao.allQuotes | |
} |
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
@Module | |
class AppModule(context: Context) { | |
private var _context: Context = context | |
private val preferenceRepository = PreferenceRepository.initObject(context) | |
@Provides | |
@Singleton | |
fun provideAppContext(): Context = _context |
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 QuoteDetailsViewModel(application: Application) : AndroidViewModel(application) { | |
private val quoteRepository: QuoteRepository = QuoteRepository(application) | |
private val quoteId = MutableLiveData<String>("") | |
val quoteAuthor = MutableLiveData<String>("") | |
val quoteContent = MutableLiveData<String>("") | |
val quoteDescription = MutableLiveData<String>("") | |
val quoteLastUpdate = MutableLiveData<String>("") |
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 updateListItem(viewModel: ConnectionViewModel) { | |
data.mapIndexed { index, any -> index to (any as ConnectionViewModel) } | |
.firstOrNull { it.second.guid == viewModel.guid }?.let { (itemIndex, _) -> | |
updateItem(viewModel, itemIndex) | |
} | |
} |
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 SettingsListFragment : BaseFragment(), | |
OnBackPressListener { | |
override fun onBackPress(): Boolean { | |
// findNavController().navigate(R.id.authorizations_list) | |
findNavController().popBackStack() | |
return true | |
} |
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
MainActivity | |
viewModel.onShowSubmitActionEvent.observe(this, Observer { event -> | |
event.getContentIfNotHandled()?.let { actionAppLinkData -> | |
this.addFragment( | |
fragment = SubmitActionFragment.newInstance(actionAppLinkData = actionAppLinkData), | |
animateTransition = false | |
) | |
} | |
}) |
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 fun setupViewModel() { | |
viewModel = ViewModelProvider(this, viewModelFactory) | |
.get(ConsentsListViewModel::class.java) | |
lifecycle.addObserver(viewModel) | |
viewModel.onListItemClickEvent.observe(this, Observer<ViewModelEvent<Int>> { event -> | |
event.getContentIfNotHandled()?.let { itemIndex -> | |
//TODO: Show details of Consent | |
} | |
}) |
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
val typeface = ResourcesCompat.getFont(listItemView.context, R.font.roboto_bold) | |
val consentDescription = SpannableStringBuilder(item.consentDescription) | |
val statusDescription = SpannableStringBuilder(item.statusDescription) | |
val spannable = SpannableStringBuilder("$consentDescription $statusDescription") | |
spannable.apply { | |
setSpan(StyleSpan(typeface!!.style), 0, item.consentDescription.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) | |
setSpan( | |
ForegroundColorSpan( | |
ContextCompat.getColor( | |
listItemView.context, |
NewerOlder