Giter Site home page Giter Site logo

nishinotakuma / conference-app-2020 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from droidkaigi/conference-app-2020

0.0 1.0 0.0 3.31 MB

The Official Conference App for DroidKaigi 2020 Tokyo

Home Page: https://droidkaigi.jp/2020/en/

License: Apache License 2.0

Kotlin 94.26% Java 2.07% Swift 1.77% Ruby 0.53% Shell 1.31% HTML 0.05%

conference-app-2020's Introduction

DroidKaigi LogoDroidKaigi 2020 official Android app Build Status

We are currently working on the event. We are looking for contributors!

DroidKaigi 2020 is a conference tailored for developers on 20th and 21st February 2020.

You can install the prodution app via Get it on Google Play.
// TODO: Add link to Google Play

And also, you can try the binary under development built on master branch through Try it on your device via DeployGate

Try it on your device via DeployGate

Features

top drawer

Contributing

We always welcome any and all contributions! See CONTRIBUTING.md for more information

For Japanese speakers, please see CONTRIBUTING.ja.md

Requirements

Android Studio 3.6 and higher. You can download it from this page.

Development Environment

Multi module project

We separate the modules for each feature. We use the Dynamic feature modules for additional features.

Kotlin Multiplatform Project

// TODO: Add MultiPlatform

Architecture

This app uses an AndroidJetpack(AAC) based architecture using AAC(LiveData, ViewModel, Room), Kotlin, Kotlin Coroutines Flow, DataBinding, Dagger, Firebase.

It is designed to be a unidirectional data flow within the ViewModel.

Fragment

Just observe() the LiveData<UiModel> of the ViewModel.

@Inject lateinit var sessionDetailViewModelFactory: SessionDetailViewModel.Factory
private val sessionDetailViewModel by assistedViewModels {
    sessionDetailViewModelFactory.create(navArgs.sessionId)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    super.onViewCreated(view, savedInstanceState)
    ...
    sessionDetailViewModel.uiModel
        .observe(viewLifecycleOwner) { uiModel: SessionDetailViewModel.UiModel ->
            ...
            progressTimeLatch.loading = uiModel.isLoading
            uiModel.session
                ?.let { session -> setupSessionViews(session) }
        }
    }

ViewModel

The LiveData Kotlin Coroutines builder runs when LiveData becomes active.
And observe the data of the Coroutiens Flow of the repository.

The LiveData becomes LoadState.Loading before the Coroutiens Flow is executed by Flow.toLoadingState(), and becomes LoadState.Loaded when finished.

class SessionsViewModel @Inject constructor(
    val sessionRepository: SessionRepository
) : ViewModel() {

...
    private val sessionLoadState: LiveData<LoadState<SessionContents>> = liveData {
        emitSource(
            sessionRepository.sessionContents()
                .toLoadingState()
                .asLiveData()
        )
        sessionRepository.refresh()
    }

Construct UiModel LiveData from some such LiveData.
The combine method works like RxJava's combineLatest.
You can make the loading state of the screen from multiple LiveData states like sessionLoadState.isLoading || favoriteState.isLoading.

class SessionDetailViewModel @AssistedInject constructor(
    @Assisted private val sessionId: SessionId,
    private val sessionRepository: SessionRepository
) : ViewModel() {
...
    val uiModel: LiveData<UiModel> = combine(
        initialValue = UiModel.EMPTY,
        liveData1 = sessionLoadStateLiveData,
        liveData2 = favoriteLoadingStateLiveData
    ) { current: UiModel,
        sessionLoadState: LoadState<Session>,
        favoriteState: LoadingState ->
        // You can create loading state by multiple LiveData
        val isLoading = sessionLoadState.isLoading || favoriteState.isLoading
        UiModel(
            isLoading = isLoading,
            error = sessionLoadState
                .getErrorIfExists()
                .toAppError()
                ?: favoriteState
                    .getErrorIfExists()
                    .toAppError()
            ,
            session = sessionLoadState.value
        )
    }

Run Coroutines with viewModelScope when data changes, such as adding a session to Favorites.
Because we do not want to end the process of adding a session to favorites with the back button, we use WorkManager to do the processing.

class SessionDetailViewModel @AssistedInject constructor(
    @Assisted private val sessionId: SessionId,
    private val sessionRepository: SessionRepository
) : ViewModel() {
..
    private var favoriteLoadingStateLiveData: MutableLiveData<LoadingState> = MutableLiveData(LoadingState.Loaded)
...
    fun favorite(session: Session) {
        viewModelScope.launch {
            favoriteLoadingStateLiveData.value = LoadingState.Loading
            try {
                sessionRepository.toggleFavoriteWithWorker(session.id)
                favoriteLoadingStateLiveData.value = LoadingState.Loaded
            } catch (e: Exception) {
                favoriteLoadingStateLiveData.value = LoadingState.Error(e)
            }
        }
    }

Design

Thanks

Thank you for contributing!

Credit

This project uses some modern Android libraries and source codes.

Android

iOS

// TODO: Add iOS Libraries

conference-app-2020's People

Contributors

takahirom avatar jmatsu avatar numeroanddev avatar yurihondo avatar roana0229 avatar pluu avatar rmakiyama avatar e10dokup avatar masayukisuda avatar mhidaka avatar fujikinaga avatar koutamatsushita avatar 5hyn3 avatar chibatching avatar tomoyashibata avatar tommykw avatar tarumzu avatar takasy00 avatar shiraji avatar masaibar avatar kyanro avatar ham-burger avatar imsakuu avatar atsushieno avatar ypresto avatar kwmt avatar syarihu avatar sadashi-ota avatar rnitame avatar nhosoya avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.