-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
605 additions
and
1 deletion.
There are no files selected for viewing
488 changes: 488 additions & 0 deletions
488
kakao/src/main/kotlin/io/github/kakaocup/kakao/viewswitcher/TextSwitcherAssertions.kt
Large diffs are not rendered by default.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
kakao/src/main/kotlin/io/github/kakaocup/kakao/viewswitcher/ViewSwitcher.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@file:Suppress("unused") | ||
|
||
package io.github.kakaocup.kakao.viewswitcher | ||
|
||
import android.view.View | ||
import android.widget.EditText | ||
import androidx.test.espresso.DataInteraction | ||
import io.github.kakaocup.kakao.common.builders.ViewBuilder | ||
import io.github.kakaocup.kakao.common.views.KBaseView | ||
import io.github.kakaocup.kakao.edit.KEditText | ||
import io.github.kakaocup.kakao.text.KTextView | ||
import org.hamcrest.Matcher | ||
|
||
class KTextSwitcher : KBaseView<KTextSwitcher>, TextSwitcherAssertions { | ||
constructor(function: ViewBuilder.() -> Unit) : super(function) | ||
constructor(parent: Matcher<View>, function: ViewBuilder.() -> Unit) : super(parent, function) | ||
constructor(parent: DataInteraction, function: ViewBuilder.() -> Unit) : super(parent, function) | ||
} |
25 changes: 25 additions & 0 deletions
25
sample/src/androidTest/kotlin/io/github/kakaocup/sample/SwitchersViewTest.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.github.kakaocup.sample | ||
|
||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner | ||
import io.github.kakaocup.kakao.screen.Screen | ||
import io.github.kakaocup.sample.screen.SwitchersScreen | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4ClassRunner::class) | ||
class SwitchersViewTest { | ||
@Rule | ||
@JvmField | ||
val rule = ActivityScenarioRule(SwitchersActivity::class.java) | ||
|
||
@Test | ||
fun testTextSwitcher() { | ||
Screen.onScreen<SwitchersScreen> { | ||
textSwitcher { | ||
hasText("Counter: 1") | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
sample/src/androidTest/kotlin/io/github/kakaocup/sample/screen/SwitchersScreen.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.github.kakaocup.sample.screen | ||
|
||
import io.github.kakaocup.kakao.screen.Screen | ||
import io.github.kakaocup.kakao.viewswitcher.ViewSwitcher | ||
import io.github.kakaocup.sample.R | ||
|
||
class SwitchersScreen : Screen<SwitchersScreen>() { | ||
val textSwitcher = ViewSwitcher { withId(R.id.text_switcher) } | ||
} |
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
38 changes: 38 additions & 0 deletions
38
sample/src/main/kotlin/io/github/kakaocup/sample/SwitchersActivity.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.github.kakaocup.sample | ||
|
||
import android.graphics.Color | ||
import android.os.Bundle | ||
import android.view.Gravity | ||
import android.widget.Button | ||
import android.widget.TextSwitcher | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
class SwitchersActivity : AppCompatActivity() { | ||
|
||
private val textSwitcher: TextSwitcher by lazy { findViewById(R.id.text_switcher) } | ||
private val nextButton: Button by lazy { findViewById(R.id.next) } | ||
|
||
private var counter = 0 | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_textswitcher) | ||
textSwitcher.setFactory { | ||
val textView = TextView(this) | ||
textView.textSize = 24f | ||
textView.gravity = Gravity.CENTER_HORIZONTAL | ||
textView.setTextColor(Color.parseColor("#0F9D58")) | ||
textView | ||
} | ||
textSwitcher.setCurrentText(getNextText()) | ||
nextButton.setOnClickListener { | ||
textSwitcher.setText(getNextText()) | ||
} | ||
} | ||
|
||
private fun getNextText(): String { | ||
counter++ | ||
return "Counter: $counter" | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical" | ||
android:id="@+id/top_layout"> | ||
|
||
<TextSwitcher android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:id="@+id/text_switcher"/> | ||
|
||
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" | ||
android:id="@+id/next" | ||
android:text="Next"/> | ||
|
||
</LinearLayout> |