This file contains hidden or 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
import android.arch.lifecycle.GenericLifecycleObserver | |
import android.arch.lifecycle.Lifecycle | |
import android.arch.lifecycle.Lifecycle.Event.ON_DESTROY | |
import android.arch.lifecycle.LifecycleOwner | |
import kotlinx.coroutines.experimental.CoroutineScope | |
import kotlinx.coroutines.experimental.Dispatchers | |
import kotlinx.coroutines.experimental.Job | |
import kotlinx.coroutines.experimental.android.Main | |
fun Lifecycle.createJob(cancelEvent: Lifecycle.Event = ON_DESTROY): Job { |
This file contains hidden or 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
// file 2 | |
import java.io.IOException | |
import java.net.InetAddress | |
import java.net.Socket | |
import java.net.UnknownHostException | |
import java.security.KeyManagementException | |
import java.security.NoSuchAlgorithmException | |
import javax.net.ssl.SSLContext |
This file contains hidden or 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
# Keep all Room Entities. | |
-keep @androidx.room.Entity class * {*;} | |
-keepclasseswithmembers class * { | |
@androidx.room.Entity <methods>; | |
} | |
-keepclasseswithmembers class * { | |
@androidx.room.Entity <fields>; | |
} |
This file contains hidden or 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
task clean(type: Delete) { | |
delete fileTree(rootProject.buildDir) { | |
exclude 'ant.properties', 'build.xml', 'library.xml' | |
} | |
} |
This file contains hidden or 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
String t = "foo"; // newer obj created and added string pool | |
System.out.println("hashCode of t: " + t.hashCode()); | |
t = "foo"; // shares the same memory location - same hashCode() | |
System.out.println("hashCode of 2 t: " + t.hashCode()); | |
t = "fuc"; // newer value added - newer obj created and added string pool - different hashCode() | |
System.out.println("hashCode of 3 t: " + t.hashCode()); | |
t = new String("foo"); // shares the same memory location - same hashCode() |
This file contains hidden or 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
open class GitHubDelegate : Application() { | |
open lateinit var appDaggerComponent: GitHubAppComponent | |
override fun onCreate() { | |
super.onCreate() | |
appDaggerComponent = getAppComponent() | |
appDaggerComponent.inject(this) | |
} |
This file contains hidden or 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
@Module | |
class TestApplicationModule(application: GitHubDelegate) : ApplicationModule(application) { | |
@Singleton | |
@Provides | |
fun giveRetrofit(okHttpClient: OkHttpClient): Retrofit = | |
Retrofit.Builder() | |
.baseUrl("http://localhost:8080/") | |
.addConverterFactory(GsonConverterFactory.create(GsonBuilder().create())) | |
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) |
This file contains hidden or 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
open class UiGitHubDelegate : GitHubDelegate() { | |
override fun getAppComponent(): GitHubAppComponent { | |
return DaggerGitHubAppComponent.builder() | |
.applicationModule(TestApplicationModule(this)) | |
.build() | |
} | |
} |
This file contains hidden or 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
open class UiRunner : AndroidJUnitRunner() { | |
override fun onCreate(arguments: Bundle?) { | |
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build()) | |
super.onCreate(arguments) | |
} | |
override fun newApplication(cl: ClassLoader?, className: String?, context: Context?): Application { | |
return super.newApplication(cl, UiGitHubDelegate::class.java.name, context) | |
} |
This file contains hidden or 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
class MockServerDispatcher { | |
// response dispatcher | |
class ResponseDispatcher : Dispatcher() { | |
override fun dispatch(request: RecordedRequest): MockResponse { | |
if (request.path.equals("/todos/1", true)) | |
return MockResponse().setResponseCode(200).setBody( | |
"{\n" + | |
" \"id\" : 1,\n" + | |
" \"title\" : \"delectus aut autem\",\n" + |