Skip to content
This repository has been archived by the owner on Apr 9, 2019. It is now read-only.

💊 [deprecated] Android clean arch with data binding. Based on MVP pattern.

License

Notifications You must be signed in to change notification settings

isfaaghyth/Clean-Architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Arch

Android clean architecture with data binding. Based on MVP pattern.

Clean Arch adalah turunan dari pola arsitektur model-view-presenter (MVP). Paradigma ini di buat dalam memaksimalkan maintenable code. Sehingga, hal-hal yang esensial sudah di bundle dalam satu package. Pola nya salam seperti MVP. Hanya saja saya coba refactor untuk menerapkan prinsip "clean code". Lifecycle nya pun saya coba buat sedikit berbeda (tidak secara keseluruhan), baik Activity maupun Fragment.

Kurang lebih paradigma nya seperti ini:

arch

Dan menggunakan pustaka dari:

  • RxJava2
  • Retrofit2
  • Android DataBinding
  • Glide
  • Retrolambda

contoh activity

public class MainActivity extends BaseActivity<ActivityMainBinding, MainPresenter> implements MainView {

    @Override protected MainPresenter initPresenter() {
        return new MainPresenter(this);
    }

    @Override protected ActivityMainBinding contentView() {
        return DataBindingUtil.setContentView(this, R.layout.activity_main);
    }

    @Override protected void onCreated() {
        //do anything in here! or with android:onClick="doClick" and create doClick(view) method in this place.
        view.btnTest.onClickListener(v -> {
            Toast("Hi!");
        });
    }
    
}

dengan utilitas kostuminisasi rxJava

contoh presenter

class MainPresenter extends BasePresenter<MainView> {

    MainPresenter(MainView view) {
        super.attachView(view);
    }

    void example() {
        subscribe(service.getHome()
                .compose(new MainScheduler<>())
                .subscribe(res -> {
                    if (res.isSuccessful()) {
                        view.onSuccess(res.body());
                    }
                }, err -> {
                    view.onError(err.getMessage());
                })
        );
    }

}

Ruang kerja yang nyaman dapat mempengaruhi mobilitas pekerjaan, semakin nyaman dengan ruang lingkup, semakin fokus dalam bekerja.

cheers!

@isfaaghyth, 2018.

About

💊 [deprecated] Android clean arch with data binding. Based on MVP pattern.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages