From 5065a7b3b1248657fc17c0ed7abbf485c6fe70cf Mon Sep 17 00:00:00 2001 From: Jung Date: Tue, 15 Oct 2019 15:09:41 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8D=B0=EB=AA=A8=EB=A5=BC=20=EC=9D=B4?= =?UTF-8?q?=EC=81=98=EA=B2=8C=20=EC=88=98=EC=A0=95=ED=96=88=EC=8A=B5?= =?UTF-8?q?=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bluecat/view404Demo/MainActivity.kt | 29 ++++++++++++------- app/src/main/res/layout/activity_main.xml | 22 ++++++++++++-- app/src/main/res/layout/layout_404.xml | 6 ---- 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/bluecat/view404Demo/MainActivity.kt b/app/src/main/java/com/bluecat/view404Demo/MainActivity.kt index 32ddbe1..aab4035 100644 --- a/app/src/main/java/com/bluecat/view404Demo/MainActivity.kt +++ b/app/src/main/java/com/bluecat/view404Demo/MainActivity.kt @@ -22,30 +22,39 @@ import androidx.appcompat.app.AppCompatActivity import com.bluecat.view404.View404 import com.bluecat.view404.show404 import kotlinx.android.synthetic.main.activity_main.* +import kotlinx.android.synthetic.main.activity_main.dismissError +import kotlinx.android.synthetic.main.layout_404.* import kotlinx.android.synthetic.main.layout_404.view.* class MainActivity : AppCompatActivity() { private var view404: View404? = null - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) + showError.setOnClickListener { + if (view404 == null) { + view404 = View404(this, R.layout.layout_404) + Toast.makeText(this, "shown", Toast.LENGTH_SHORT).show() - button2.setOnClickListener { - view404 = View404(this, R.layout.layout_404) - Toast.makeText(this, "shown", Toast.LENGTH_SHORT).show() + //parentLayout.show404(view404!!) + errorLayout.show404(view404!!, R.anim.abc_fade_in) + } else { + Toast.makeText(this, "already shown", Toast.LENGTH_SHORT).show() + } + } - view404?.view404?.button?.setOnClickListener { - //view404?.dismiss() - view404?.dismiss(R.anim.abc_fade_out) + dismissError.setOnClickListener { + if (view404 != null) { Toast.makeText(this, "dismissed", Toast.LENGTH_SHORT).show() - } - //parentLayout.show404(view404!!) - parentLayout.show404(view404!!, R.anim.abc_fade_in) + view404?.dismiss(R.anim.abc_fade_out) + view404 = null + } else { + Toast.makeText(this, "already dismissed", Toast.LENGTH_SHORT).show() + } } } } diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index ddf6c18..93a6a60 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -7,10 +7,28 @@ android:layout_height="match_parent" android:background="@color/background"> + + + +