Awesome Open Source
Awesome Open Source

licenceRepo

clone

RepoGitHub

Dagger ,Rxjava ,LiveData,ViewModelApp

Dagger,Rxjava,Retrofit,Greendao GoogleJetPackLiveData,ViewModelLifeCycleWorkManger

Main,NewsBaseAppAppSync .png

1.Base 2.MainNewgit Build 3.

ViewModel+LiveData

ViewModelLiveData JetPack

  • ViewModel Activity LiveData LiveData
  • LiveData Activity UI

onChange StateLiveData,

        //LiveData 
        //UI  
        blogViewModel.getAllBlog().observe(this, stateData -> {
            switch (stateData.getStatus()) {
                case SUCCESS:
                    disposeSuccessData(stateData.getData());
                    break;
                case ERROR:
                    //http UI . 
                    BaseDispose.errorDispose(mBaseLoadService, getActivity(), stateData.getMsg(), stateData.getCode());
                    break;
            }
        });

Retrofit 2json

    public StateLiveData<HotNewsResult> getStateLiveData() {
        //1.
        newsApiService.getNews()
                .compose(SwitchSchedulers.applyScheduler2()) //rxjava 
                .subscribe(new HttpObserver<NewsResult>() {
                    @Override
                    public void onSuccess(NewsResult newsResult) {
                        stateLiveData.postSuccess(newsResult);
                    }

                    @Override
                    public void onFailure(int code, String message) {
                        super.onFailure(code, message);
                        //UI
                        stateLiveData.postFailure(message + code);
                    }
                });
        return stateLiveData;
    }

Dagger ViewModel

Dagger2Dagger.androidDemo,) dagger

Dagger ViewModelViewModelKey class MyViewModelFactory implements ViewModelProvider.Factory Activity/FragmentDagger

BaseUrl,json

AppBaseUrl,PythonJava json Basedemo BlogNews

Retrofit

Retrofit2 api restful app Rxjava2

SP ORMDB Room,GreenDao,xx

  • Dagger.android Dagger android
  • BaseActivity Toolbar
  • Error,empty,Loading,timeoutDemoRoot
  • Http (Rxjava2+Retrofit2)
  • APIAPI thirdParty
  • StateLiveData
  • dagger ViewModel
  • http json

GitHub

  • [1]. Google
  • [2]. LiveData ViewModel Overview
  • [3]. Dagger - A fast dependency injector for Android and Java
  • [4]. Android JetPack

... ...


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Mvp (1,197
Livedata (928
Viewmodel (776
Dagger (273
Dagger2 Android (249
Related Projects