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
@Override | |
protected void onResume() { | |
super.onResume(); | |
countToMillion(); | |
callHeavyMethod(); | |
} | |
private void countToMillion() { | |
int number = 0; | |
for (int i = 0; i < 1000000; i++) { |
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
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.frogermcs.androiddevmetrics:androiddevmetrics-plugin:0.4' | |
} | |
} |
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
public class ExampleApplication extends Application { | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
//Use it only in debug builds | |
if (BuildConfig.DEBUG) { | |
AndroidDevMetrics.initWith(this); | |
} | |
} |
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
@Provides | |
@Singleton | |
HeavyExternalLibrary provideHeavyExternalLibrary() { | |
HeavyExternalLibrary heavyExternalLibrary = new HeavyExternalLibrary(); | |
heavyExternalLibrary.init(); //This method takes about 500ms | |
return heavyExternalLibrary; | |
} |
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
@Singleton | |
@Provides | |
Observable<HeavyExternalLibrary> provideHeavyExternalLibraryObservable(final Lazy<HeavyExternalLibrary> heavyExternalLibraryLazy) { | |
return Observable.create(new Observable.OnSubscribe<HeavyExternalLibrary>() { | |
@Override | |
public void call(Subscriber<? super HeavyExternalLibrary> subscriber) { | |
subscriber.onNext(heavyExternalLibraryLazy.get()); | |
} | |
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); | |
} |
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
public class SplashActivity { | |
@Inject | |
Observable<HeavyExternalLibrary> heavyExternalLibraryObservable; | |
//This will be injected asynchronously | |
HeavyExternalLibrary heavyExternalLibrary; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { |
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
@Provides | |
HeavyExternalLibrary provideHeavyExternalLibrary() { | |
HeavyExternalLibrary heavyExternalLibrary = new HeavyExternalLibrary(); | |
heavyExternalLibrary.init(); //This method takes about 500ms | |
return heavyExternalLibrary; | |
} |
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
@Singleton | |
@Provides | |
Observable<HeavyExternalLibrary> provideHeavyExternalLibraryObservable(final Provider<HeavyExternalLibrary> heavyExternalLibraryProvider) { | |
return Observable.create(new Observable.OnSubscribe<HeavyExternalLibrary>() { | |
@Override | |
public void call(Subscriber<? super HeavyExternalLibrary> subscriber) { | |
subscriber.onNext(heavyExternalLibraryProvider.get()); | |
} | |
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()); | |
} |
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
heavyExternalLibraryObservable.subscribe(new SimpleObserver<HeavyExternalLibrary>() { | |
@Override | |
public void onNext(HeavyExternalLibrary heavyExternalLibrary) { | |
//New instance of HeavyExternalLibrary | |
} | |
}); |
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
public class SplashActivity extends BaseActivity { | |
@Inject | |
SplashActivityPresenter presenter; | |
@Inject | |
AnalyticsManager analyticsManager; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); |