-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from imprakharshukla/dev
Dev
- Loading branch information
Showing
31 changed files
with
284 additions
and
50 deletions.
There are no files selected for viewing
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
5 changes: 3 additions & 2 deletions
5
app/src/main/java/com/techriz/andronix/donation/di/MiscModule.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
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
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
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/techriz/andronix/donation/ui/fragments/SplashActivity.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,60 @@ | ||
package com.techriz.andronix.donation.ui.fragments | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.os.PersistableBundle | ||
import android.widget.Toast | ||
import androidx.activity.viewModels | ||
import com.google.android.material.snackbar.Snackbar | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.lifecycle.lifecycleScope | ||
import androidx.navigation.findNavController | ||
import androidx.navigation.ui.AppBarConfiguration | ||
import androidx.navigation.ui.navigateUp | ||
import androidx.navigation.ui.setupActionBarWithNavController | ||
import com.github.florent37.viewanimator.ViewAnimator | ||
import com.techriz.andronix.donation.MainActivity | ||
import com.techriz.andronix.donation.R | ||
import com.techriz.andronix.donation.databinding.ActivitySplashBinding | ||
import dagger.hilt.android.AndroidEntryPoint | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import kotlinx.coroutines.withContext | ||
|
||
@AndroidEntryPoint | ||
class SplashActivity : AppCompatActivity() { | ||
lateinit var binding: ActivitySplashBinding | ||
|
||
val viewModel: SplashViewModel by viewModels() | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivitySplashBinding.inflate(layoutInflater) | ||
setContentView(binding.root) | ||
println("Executed!") | ||
lifecycleScope.launch(Dispatchers.Main) { | ||
viewModel.applyTheme() | ||
animateLogo() | ||
} | ||
} | ||
|
||
private fun animateLogo() { | ||
ViewAnimator | ||
.animate(binding.logo) | ||
.pulse() | ||
.duration(350) | ||
.repeatCount(1) | ||
.onStop { | ||
lifecycleScope.launch { | ||
this@SplashActivity.startActivity( | ||
Intent( | ||
this@SplashActivity, | ||
MainActivity::class.java | ||
) | ||
) | ||
finish() | ||
} | ||
} | ||
.start() | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/techriz/andronix/donation/ui/fragments/SplashViewModel.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,30 @@ | ||
package com.techriz.andronix.donation.ui.fragments; | ||
|
||
import androidx.appcompat.app.AppCompatDelegate | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.techriz.andronix.donation.repository.SettingsRepository | ||
import com.techriz.andronix.donation.utils.Constants.DARK_MODE | ||
import com.techriz.andronix.donation.utils.Constants.DEVICE_MODE | ||
import com.techriz.andronix.donation.utils.Constants.LIGHT_MODE | ||
|
||
import javax.inject.Inject | ||
|
||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
|
||
@ExperimentalCoroutinesApi | ||
@HiltViewModel | ||
class SplashViewModel @Inject | ||
constructor(val settingsRepository: SettingsRepository) : ViewModel() { | ||
|
||
suspend fun applyTheme() { | ||
when (settingsRepository.getTheme()) { | ||
LIGHT_MODE -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) | ||
DARK_MODE -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) | ||
DEVICE_MODE -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) | ||
} | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.