Dola TENG 1 vuosi sitten
vanhempi
commit
599ef1ae86

+ 31 - 0
app/src/main/java/com/sambath/sbc/screen/register/RegisterActivity.kt

@@ -2,9 +2,15 @@ package com.sambath.sbc.screen.register
 
 import androidx.appcompat.app.AppCompatActivity
 import android.os.Bundle
+import android.view.View
 import android.widget.ArrayAdapter
 import com.sambath.sbc.R
 import kotlinx.android.synthetic.main.activity_register.et_gender
+import kotlinx.android.synthetic.main.activity_register.radioButtonEmail
+import kotlinx.android.synthetic.main.activity_register.radioButtonPhone
+import kotlinx.android.synthetic.main.activity_register.radioGroup
+import kotlinx.android.synthetic.main.activity_register.til_email
+import kotlinx.android.synthetic.main.activity_register.til_phone
 
 class RegisterActivity : AppCompatActivity() {
     override fun onCreate(savedInstanceState: Bundle?) {
@@ -16,5 +22,30 @@ class RegisterActivity : AppCompatActivity() {
         adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
         et_gender.adapter = adapter
         et_gender.setSelection(0)
+
+        setGender()
+    }
+
+    private fun setGender() {
+        if (radioGroup.checkedRadioButtonId == R.id.radioButtonEmail) {
+            til_email.visibility = View.VISIBLE
+            til_phone.visibility = View.GONE
+        } else if (radioGroup.checkedRadioButtonId == R.id.radioButtonPhone) {
+            til_email.visibility = View.GONE
+            til_phone.visibility = View.VISIBLE
+        }
+
+        radioGroup.setOnCheckedChangeListener { _, checkedId ->
+            when (checkedId) {
+                R.id.radioButtonEmail -> {
+                    til_email.visibility = View.VISIBLE
+                    til_phone.visibility = View.GONE
+                }
+                R.id.radioButtonPhone -> {
+                    til_email.visibility = View.GONE
+                    til_phone.visibility = View.VISIBLE
+                }
+            }
+        }
     }
 }

+ 4 - 4
app/src/main/java/com/sambath/sbc/screen/splash/SplashScreenActivity.kt

@@ -55,16 +55,16 @@ class SplashScreenActivity : BaseActivity() {
             override fun onAnimationEnd(animation: Animation?) {
 
                     //Test
-                    val intent = Intent(this@SplashScreenActivity, MainActivity::class.java)
-                    startActivity(intent)
+//                    val intent = Intent(this@SplashScreenActivity, MainActivity::class.java)
+//                    startActivity(intent)
 
-                    /*if (prefHelper.getToken().isNotEmpty()) {
+                    if (prefHelper.getToken().isNotEmpty()) {
                         val intent = Intent(this@SplashScreenActivity, ShareActivity::class.java)
                         startActivity(intent)
                     }else{
                         val intent = Intent(this@SplashScreenActivity, LoginActivity::class.java)
                         startActivity(intent)
-                    }*/
+                    }
 
                     finishAffinity()
 

+ 9 - 17
app/src/main/res/layout/activity_register.xml

@@ -72,24 +72,16 @@
                 android:padding="0dp" />
         </com.google.android.material.textfield.TextInputLayout>
 
-        <com.google.android.material.textfield.TextInputLayout
-            android:id="@+id/til_gender"
-            style="@style/BoxInputLayout"
+        <androidx.appcompat.widget.AppCompatSpinner
+            android:id="@+id/et_gender"
             android:layout_width="match_parent"
-            android:layout_height="48dp"
-            app:endIconMode="clear_text"
-            app:hintEnabled="false">
-
-            <androidx.appcompat.widget.AppCompatSpinner
-                android:id="@+id/et_gender"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="@color/color_white"
-                android:hint="@string/hint_lastname"
-                android:inputType="text"
-                android:maxLength="50"
-                android:padding="0dp" />
-        </com.google.android.material.textfield.TextInputLayout>
+            android:layout_height="wrap_content"
+            android:background="@color/color_white"
+            android:hint="@string/hint_lastname"
+            android:inputType="text"
+            android:maxLength="50"
+            android:paddingTop="10dp"
+            android:paddingBottom="10dp" />
 
         <LinearLayout
             android:layout_width="match_parent"