Skip to content

Instantly share code, notes, and snippets.

View muratcanbur's full-sized avatar

Murat Can BUR muratcanbur

View GitHub Profile
@muratcanbur
muratcanbur / DolapSubscriber.java
Last active July 24, 2017 06:42
DolapSubscriber is a base Rx Subscriber class that handles all API requests.
public abstract class DolapSubscriber<T> extends Subscriber<T> {
private MVPView mvpView;
public DolapSubscriber(MVPView mvpView) {
this.mvpView = mvpView;
}
@Override
public void onCompleted() {
@muratcanbur
muratcanbur / android_lifecycle_recommendations.md
Created April 26, 2017 06:45 — forked from kaushikgopal/android_lifecycle_recommendations.md
Notes on opportune moments to do "stuff" in the Android Lifecycle
  • In general you want to try and put things in onStart and onStop for logical start and stops.

Activity

onCreate

  • Dagger inject self into graph
  • setContentView(R.layout.xxx)
  • Butterknife.bind(this)
  • RxJava CompositeSubscription.add (if NON UI related work being done)
  • realm = Realm.getDefaultInstance();

Make your multiple type view adapter with annotations!

Gist for Making a Multiple View Types Adapter With Annotations

Pretty easy to use.

  1. Create your delegate adapters, implementing DelegateAdapter, and with the annotation DelegateAdapterType. e.g:
@DelegateAdapterType(itemType = 0)
@muratcanbur
muratcanbur / BaseMockitoTest.kt
Last active April 15, 2019 10:50 — forked from ufuk/BaseMockito2JUnit4Test.java
Performs "verify no more interactions" check automatically for all mock objects (works with Mockito version 2). For detailed description: https://ufukuzun.wordpress.com/2019/04/09/ne-olup-bittiginden-habersiz-testlere-derman-mockscollector/ (Turkish)
@RunWith(AndroidJUnit4::class)
abstract class BaseMockitoTest {
private val mockitoMocksCollector = MockitoMocksCollector()
@After
fun after() {
val allMocks = mockitoMocksCollector.getAllMocks()
allMocks.forEach { mock ->
verifyNoMoreInteractions(mock)