mirror of
https://github.com/shaulascr/ecommerce_serang.git
synced 2025-12-15 07:31:02 +00:00
add splash screen
This commit is contained in:
@ -173,7 +173,8 @@
|
||||
<activity
|
||||
android:name=".ui.auth.RegisterActivity"
|
||||
android:exported="true"
|
||||
android:windowSoftInputMode="adjustResize">
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/Theme.App.SplashScreen">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import android.util.Log
|
||||
import androidx.activity.enableEdgeToEdge
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
@ -39,6 +40,8 @@ class RegisterActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Thread.sleep(3000)
|
||||
installSplashScreen()
|
||||
binding = ActivityRegisterBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
sessionManager = SessionManager(this)
|
||||
|
||||
@ -69,12 +69,10 @@ class HomeFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
|
||||
initUi()
|
||||
setupRecyclerView()
|
||||
observeData()
|
||||
setupSearchView()
|
||||
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
@ -145,15 +143,14 @@ class HomeFragment : Fragment() {
|
||||
binding.loadingAll.root.visibility = View.VISIBLE
|
||||
binding.error.root.isVisible = false
|
||||
binding.home.isVisible = false
|
||||
delay(5000)
|
||||
}
|
||||
is HomeUiState.Success -> {
|
||||
val products = state.products
|
||||
viewModel.loadStoresForProducts(products)
|
||||
delay(2000)
|
||||
binding.loadingAll.root.visibility = View.GONE
|
||||
binding.error.root.isVisible = false
|
||||
binding.home.isVisible = true
|
||||
val products = state.products
|
||||
viewModel.loadStoresForProducts(products) // << add this here
|
||||
|
||||
productAdapter?.updateLimitedProducts(products)
|
||||
}
|
||||
is HomeUiState.Error -> {
|
||||
@ -171,7 +168,6 @@ class HomeFragment : Fragment() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
|
||||
@ -151,7 +151,7 @@ class StoreDetailActivity : AppCompatActivity() {
|
||||
.into(binding.ivStoreImage)
|
||||
|
||||
val ratingStr = it.storeRating
|
||||
val ratingValue = ratingStr.toFloatOrNull()
|
||||
val ratingValue = ratingStr?.toFloatOrNull() ?: 0f
|
||||
|
||||
if (ratingValue != null && ratingValue > 0f) {
|
||||
binding.tvStoreRating.text = String.format("%.1f", ratingValue)
|
||||
|
||||
@ -45,11 +45,11 @@ class StoreDetailViewModel (private val repository: ProductRepository
|
||||
} // Filter by storeId and exclude current product
|
||||
_otherProducts.value = filteredProducts // Update LiveData
|
||||
} else if (result is Result.Error) {
|
||||
Log.e("ProductViewModel", "Error loading other products: ${result.exception.message}")
|
||||
Log.e("StoreDetailViewModel", "Error loading other products: ${result.exception.message}")
|
||||
_otherProducts.value = emptyList() // Set empty list on failure
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("ProductViewModel", "Exception loading other products: ${e.message}")
|
||||
Log.e("StoreDetailViewModel", "Exception loading other products: ${e.message}")
|
||||
_otherProducts.value = emptyList()
|
||||
}
|
||||
}
|
||||
@ -67,7 +67,7 @@ class StoreDetailViewModel (private val repository: ProductRepository
|
||||
loadStoreDetail(storeId)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("ProductViewModel", "Error loading product details: ${e.message}")
|
||||
Log.e("StoreDetailViewModel", "Error loading product details: ${e.message}")
|
||||
_error.value = "Failed to load product details: ${e.message}"
|
||||
} finally {
|
||||
_isLoading.value = false
|
||||
@ -82,7 +82,7 @@ class StoreDetailViewModel (private val repository: ProductRepository
|
||||
val result = repository.fetchStoreDetail(storeId)
|
||||
_storeDetail.value = result
|
||||
} catch (e: Exception) {
|
||||
Log.e("ProductViewModel", "Error loading store details: ${e.message}")
|
||||
Log.e("StoreDetailViewModel", "Error loading store details: ${e.message}")
|
||||
_storeDetail.value = Result.Error(e)
|
||||
}
|
||||
}
|
||||
@ -99,10 +99,10 @@ class StoreDetailViewModel (private val repository: ProductRepository
|
||||
if (result is Result.Success) {
|
||||
map[storeId] = result.data
|
||||
} else if (result is Result.Error) {
|
||||
Log.e("ProductViewModel", "Failed to load storeId $storeId", result.exception)
|
||||
Log.e("StoreDetailViewModel", "Failed to load storeId $storeId", result.exception)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("ProductViewModel", "Exception fetching storeId $storeId", e)
|
||||
Log.e("StoreDetailViewModel", "Exception fetching storeId $storeId", e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -330,4 +330,10 @@
|
||||
<item name="cornerSize">5dp</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
<style name="Theme.App.SplashScreen" parent="Theme.SplashScreen">
|
||||
<item name="windowSplashScreenBackground">@color/blue_50</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@drawable/outline_shopping_cart_24</item>
|
||||
<item name="postSplashScreenTheme">@style/Theme.Ecommerce_serang</item>
|
||||
</style>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user