/cityguide

Android mobile application with Dagger, rxjava, Retrofit, logging with Timber and logentries, crashlytics, greendao ORM and more

Primary LanguageJava

CityGuide

Related resources

repos

Android requirements

  • Android 4.4+. Testing on Android 4.4, 7.0

Standard telephone with

  • Google Play
  • WebView (such as chrome)

Architecture overview

POIs

PoiProvider interface with 2 implementations:

  • OfflinePoiProvider.java - saved to SQLite via greendao ORM. Images saved to app cache storage (which does not require permission)
  • ServerPoiProvider.java - REST requests with retrofit2

Internally, then(at app startup) created WrappedPoiProvider object which delegate calls to necessary implementation (which is determined by SettingsService#isOffline)

And every object just inject via Dagger2

WrappedPoiProvider is used to allow change implementation at runtime without change dagger graph

Event bus

Main implementation is RxEventBus which use rxjava. You can inject EventBus as dagger component(injected to BaseFragment and BaseActivity, by default)

You can send event :

eventBus.post(new ReloadLocationProvider());

And subscribe e.g:

 private void subscribeToReInjectPoiProvider() {
        eventBus.observable(ReInjectPoiProvider.class)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(Schedulers.io())
                .subscribe(new Observer<ReInjectPoiProvider>() {
            @Override
            public void onSubscribe(Disposable d) {
            }

            @Override
            public void onNext(ReInjectPoiProvider value) {
                // doSomethingOnNewIvent();
            }

            @Override
            public void onError(Throwable e) {
            }

            @Override
            public void onComplete() {
            }
        });
    }

code snippets

FragmentsWalker can be used to walk(replace) fragment to each other

start map with some POI open

FragmentsWalker.startMapFragmentWithPoiOpen(getSupportFragmentManager(), poiId);

pull db from device via adb

adb pull /data/data/com.nbakaev.cityguide/databases/poi-db.db .

test notification on boot

  1. set in Developer options to Select debug app debug com.nbakaev.cityguide
  2. check wait to debugger
  3. adb shell su 0 am broadcast -a android.intent.action.BOOT_COMPLETED
  4. On android you will see prompt to debug app
  5. in idea click attach debugger to android process

debug / release builds

Timber is used to log

feature debug release notes
logs to standard logs output (logcat) send to logentries
crashes to standard logs output (logcat) send to Crashlytics

Notes:

Offline distance algorithms