Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
Building Coinverse's Android app

AdamHurwitz AdamSHurwitz

🚀
Building Coinverse's Android app
View GitHub Profile
@AdamSHurwitz
AdamSHurwitz / EditTextUtils.java
Last active Jan 29, 2021
ODG - EditText Utils
View EditTextUtils.java
// Handle input length
private void handleInputLength(){
editTextViewName.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 6){animateMethod();}
@AdamSHurwitz
AdamSHurwitz / AvoidConcurrentModificationException.kt
Last active Jan 11, 2021
ODG - Kotlin: Avoiding ConcurrentModificationException
View AvoidConcurrentModificationException.kt
val integers = arrayListOf(1, 2, 3)
// Filter using streams.
val newIntegers = integers.filter { it != 2 }
// Use removeIf()
integers.removeIf { it == 2 }
// Use an iterator directly.
val iterator = integers.iterator()
@AdamSHurwitz
AdamSHurwitz / activity_main.xml
Created Jan 2, 2021
ODG - Android NavHost Fragment
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/nav_graph" />
@AdamSHurwitz
AdamSHurwitz / someLayout.md
Last active Dec 18, 2020
ODG - Android Data Binding Samples
View someLayout.md

Strings

  • Static: android:text="@string/sell_recommend_views_label"

  • Concat resources: android:text="@{'Hello ' + user.firstName}"

  • Concat resource and var (Include %1s formatting in String resource): android:text='@{String.format(@string/string_name, uxContent.reduceByPrice)}'

  • Formatted: android:text='@{@string/some_string(uxContent.someVal, uxContent.someVal)}'

@AdamSHurwitz
AdamSHurwitz / 1. Pull the APK from the phone
Last active Dec 4, 2020
ODG - Android Security: Decompile App
View 1. Pull the APK from the phone
adb shell pm list package | grep lyft
adb shell pm path me.lyft.android
// Access the terminal of the phone.
adb shell
// Copy the APK to the phone's SD card.
cp /data/app/me.lyft.android-1/base.apk /mnt/sdcard
@AdamSHurwitz
AdamSHurwitz / build.gradle
Last active Oct 4, 2020
Android Model-View-Intent with Unit Tests - Libraries in build.gradle (App)
View build.gradle
buildscript {
dependencies {
...
classpath "de.mannodermaus.gradle.plugins:android-junit5:X.X.X"
}
}
@AdamSHurwitz
AdamSHurwitz / build.gradle
Last active Oct 4, 2020
Android Model-View-Intent with Unit Tests - Libraries in build.gradle (Module)
View build.gradle
apply plugin: 'de.mannodermaus.android-junit5'
dependencies {
...
testImplementation "org.junit.jupiter:junit-jupiter-api:X.X.X"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:X.X.X"
testImplementation "org.junit.jupiter:junit-jupiter-params:X.X.X"
testImplementation "io.mockk:mockk:X.X.X"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:X.X.X"
testImplementation "org.assertj:assertj-core:X.X.X"
@AdamSHurwitz
AdamSHurwitz / FeedViewTest.kt
Last active Oct 4, 2020
Android Model-View-Intent with Unit Tests - FeedViewTest.kt Verify and Confirm
View FeedViewTest.kt
...
private lateinit var test: FeedViewTestCase
...
@ParameterizedTest
@MethodSource("FeedViewTestCaseStream")
fun `FeedView`(feedViewTestCase: FeedViewTestCase) = testCoroutineDispatcher.runBlockingTest {
test = feedViewTestCase
mockComponents(test)
val viewModel = FeedViewModel(...)
@AdamSHurwitz
AdamSHurwitz / FeedViewTest.kt
Last active Oct 4, 2020
Android Model-View-Intent with Unit Tests - FeedViewTest.kt Init Intent and Render State
View FeedViewTest.kt
private lateinit var test: FeedViewTestCase
private val intent = FeedViewIntent()
@ParameterizedTest
@MethodSource("FeedViewTestCaseStream")
fun `FeedView`(feedViewTestCase: FeedViewTestCase) = testCoroutineDispatcher.runBlockingTest {
test = feedViewTestCase
mockComponents(test)
val viewModel = FeedViewModel(...)
viewModel.bindIntents(object : FeedView {
@AdamSHurwitz
AdamSHurwitz / FeedViewTest.kt
Last active Oct 4, 2020
Android Model-View-Intent with Unit Tests - FeedViewTest.kt Bind Interface
View FeedViewTest.kt
private lateinit var test: FeedViewTestCase
private val intent = FeedViewIntent()
@ParameterizedTest
@MethodSource("FeedViewTestCaseStream")
fun `FeedView`(feedViewTestCase: FeedViewTestCase) = testCoroutineDispatcher.runBlockingTest {
test = feedViewTestCase
mockComponents(test)
val viewModel = FeedViewModel(...)
viewModel.bindIntents(object : FeedView {