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
dependencies { | |
testImplementation 'junit:junit:4.12' | |
testImplementation 'org.mockito:mockito-core:2.23.4' | |
testImplementation 'org.mockito:mockito-android:2.22.0' | |
} |
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
@RunWith(AndroidJUnit4::class) | |
class MainActivityTest { | |
@get:Rule | |
val rule = ActivityTestRule(MainActivity::class.java) | |
@Test | |
fun testAssertHelloText() { | |
onView(withId(R.id.hello)).check(matches(withText("Hello World!"))) | |
} | |
} |
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
android | |
{ | |
testOptions { | |
unitTests { | |
includeAndroidResources = true | |
} | |
} | |
} | |
dependency |
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
android { | |
compileSdkVersion 28 | |
defaultConfig { | |
minSdkVersion 21 | |
targetSdkVersion 28 | |
versionCode 1 | |
versionName "1" | |
} |
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
open class RxAwareViewModel : ViewModel() { | |
var disposables = CompositeDisposable() | |
override fun onCleared() { | |
super.onCleared() | |
if (!disposables.isDisposed) { | |
disposables.dispose() | |
} | |
} |
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
inline fun <T> dependantLiveData( | |
vararg dependencies: LiveData<*>, | |
crossinline mapper: () -> T? | |
) = MediatorLiveData<T>().also { mediatorLiveData -> | |
val observer = Observer<Any> { mediatorLiveData.value = mapper() } | |
dependencies.forEach { dependencyLiveData -> | |
mediatorLiveData.addSource(dependencyLiveData, observer) | |
} | |
} |
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
fun <T : ViewDataBinding> Activity.bind(layoutId: Int): T { | |
return DataBindingUtil.setContentView(this, layoutId) | |
} |
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 fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
loginViewModel = ViewModelProviders.of(this@LoginActivity, viewModelFactory) | |
.get(LoginViewModel::class.java) | |
val binding = bind<ActivityLoginLayoutBinding>(R.layout.activity_login_layout) | |
binding.lifecycleOwner = this | |
binding.viewmodel = loginViewModel | |
} |
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
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<data> | |
<import type="android.text.TextUtils" /> | |
<variable | |
name="viewmodel" |
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
Encrypt: openssl aes-256-cbc -e -in test.txt -out test-cipher.txt -k 12345 | |
Decrypt: openssl aes-256-cbc -d -in test-cipher.txt -out test-decrypt.txt -k 12345 |