Skip to content

Instantly share code, notes, and snippets.

View muratcanbur's full-sized avatar

Murat Can BUR muratcanbur

View GitHub Profile
@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)

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 / 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();
@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 / gradle.build
Created November 10, 2016 18:58
Gradle Config Fields
buildTypes {
debug {
buildConfigField “String”, “BASE_URL”, “\”http://api-qa.com/\""
}
release {
buildConfigField “String”, “BASE_URL”,“\”https://api.com/\""
}
}
@muratcanbur
muratcanbur / Proguard config
Created November 8, 2016 12:28 — forked from PaNaVTEC/Proguard config
Proguard config
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/panavtec/Documents/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
@muratcanbur
muratcanbur / MessagingService.java
Last active November 7, 2019 00:02
a background service that handles incoming FCM messages.
package co.mobiwise.firebasetraining.service;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
@muratcanbur
muratcanbur / RadioListFragment.java
Created October 19, 2015 12:54
RadioListFragment
public class RadioListFragment extends Fragment implements RadioListView, SwipeRefreshLayout.OnRefreshListener {
@Inject
RadioListPresenter radioListPresenter;
public RadioListFragment() {
}
public static RadioListFragment newInstance() {
RadioListFragment fragment = new RadioListFragment();
@muratcanbur
muratcanbur / BaseService.java
Created September 3, 2015 06:23
Creating RestInterface Class
public final class BaseService {
private BaseService() {
}
private static Builder getBuilder() {
OkHttpClient client = new OkHttpClient();
client.setConnectTimeout(BuildConfig.CONNECTION_TIMEOUT,
TimeUnit.MILLISECONDS);
client.setReadTimeout(BuildConfig.CONNECTION_TIMEOUT,