Browse Source

first init

Dola TENG 1 năm trước cách đây
mục cha
commit
6407ccabdd

+ 1 - 0
.idea/gradle.xml

@@ -7,6 +7,7 @@
         <option name="testRunner" value="GRADLE" />
         <option name="distributionType" value="DEFAULT_WRAPPED" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
+        <option name="gradleJvm" value="corretto-15" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />

+ 22 - 17
app/src/main/java/com/sambath/sbc/screen/login/LoginActivity.kt

@@ -6,6 +6,7 @@ import androidx.appcompat.app.AppCompatActivity
 import androidx.lifecycle.Observer
 import com.sambath.sbc.R
 import com.sambath.sbc.app.App
+import com.sambath.sbc.app.MainActivity
 import com.sambath.sbc.app.ShareActivity
 import com.sambath.sbc.remote.User
 import com.sambath.sbc.screen.register.RegisterActivity
@@ -26,23 +27,27 @@ class LoginActivity : AppCompatActivity() {
         if (user != null) et_username.setText(user?.userName)
         loginViewModel.state.observe(this, Observer(this::render))
         btn_login.setOnClickListener {
-            til_username.isErrorEnabled = false
-            til_username.error = null
-            til_password.isErrorEnabled = false
-            til_password.error = null
-            val username = et_username.text //aaaaaa004  Bbbbbb001
-            val password = et_password.text
-            if (username.isNullOrEmpty()) {
-                til_username.error = getString(R.string.err_not_empty)
-                til_username.requestFocus()
-                return@setOnClickListener
-            }
-            if (password.isNullOrEmpty()) {
-                til_password.error = getString(R.string.err_not_empty)
-                til_password.requestFocus()
-                return@setOnClickListener
-            }
-            loginViewModel.login(username.toString(), password.toString())
+//            til_username.isErrorEnabled = false
+//            til_username.error = null
+//            til_password.isErrorEnabled = false
+//            til_password.error = null
+//            val username = et_username.text //aaaaaa004  Bbbbbb001
+//            val password = et_password.text
+//            if (username.isNullOrEmpty()) {
+//                til_username.error = getString(R.string.err_not_empty)
+//                til_username.requestFocus()
+//                return@setOnClickListener
+//            }
+//            if (password.isNullOrEmpty()) {
+//                til_password.error = getString(R.string.err_not_empty)
+//                til_password.requestFocus()
+//                return@setOnClickListener
+//            }
+//            loginViewModel.login(username.toString(), password.toString())
+
+            val intent = Intent(this, MainActivity::class.java)
+            startActivity(intent)
+            finishAffinity()
         }
 
         btn_signup.setOnClickListener {

+ 17 - 3
app/src/main/java/com/sambath/sbc/screen/news/NewsFragment.kt

@@ -31,12 +31,17 @@ class NewsFragment : Fragment() {
     }
 
     override fun onCreateView(
-        inflater: LayoutInflater, container: ViewGroup?,
-        savedInstanceState: Bundle?
+        inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
     ): View? {
         // Inflate the layout for this fragment
         _root = inflater.inflate(R.layout.fragment_news, container, false)
 
+        setTab()
+
+        return binding
+    }
+
+    private fun setTab() {
         val tabTitles = listOf("TOP NEWS", "POPULAR", "LAST", "HIGHLIGHT")
 
         // Populate TabLayout with dynamic tabs
@@ -86,7 +91,8 @@ class NewsFragment : Fragment() {
             }
         })
 
-        return binding
+        setNewsHeaderFeed()
+        setNewsFeed()
     }
 
     private fun setNewsHeaderFeed() {
@@ -136,4 +142,12 @@ class NewsFragment : Fragment() {
             // Add more card items as needed
         )
     }
+
+    interface TabSelectionListener {
+        fun onTabSelected(tabIndex: Int)
+    }
+
+    fun selectTab(tabIndex: Int) {
+        binding.tabLayout.getTabAt(tabIndex)?.select()
+    }
 }

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

@@ -58,13 +58,13 @@ class SplashScreenActivity : BaseActivity() {
                     val intent = Intent(this@SplashScreenActivity, MainActivity::class.java)
                     startActivity(intent)
 
-//                    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)
-//                    }
+                    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()
 

+ 7 - 3
app/src/main/res/layout/fragment_news.xml

@@ -4,6 +4,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
+    android:background="@color/color_black"
     android:orientation="vertical"
     tools:context=".screen.news.NewsFragment">
 
@@ -11,8 +12,10 @@
         android:id="@+id/tabLayout"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        app:tabGravity="fill"
-        app:tabMode="scrollable" />
+        android:background="@color/color_black"
+        app:tabGravity="center"
+        app:tabMode="scrollable"
+        app:tabTextColor="@color/color_white" />
 
     <TextView
         android:id="@+id/selectedTabTextView"
@@ -21,7 +24,8 @@
         android:layout_gravity="center_horizontal"
         android:padding="16dp"
         android:text="Selected Tab: "
-        android:textSize="18sp" />
+        android:textSize="18sp"
+        android:visibility="gone" />
 
     <androidx.recyclerview.widget.RecyclerView
         android:id="@+id/recyclerViewNewsHeader"