Инициализация модулей для даггера
This commit is contained in:
@@ -69,4 +69,7 @@ dependencies {
|
||||
implementation "androidx.room:room-ktx:2.2.6"
|
||||
|
||||
implementation "androidx.navigation:navigation-compose:2.5.3"
|
||||
|
||||
implementation 'com.google.dagger:dagger:2.38.1'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.34'
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package ru.megboyzz.studentq
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import com.vk.api.sdk.VK
|
||||
import com.vk.api.sdk.VKApiCallback
|
||||
import com.vk.api.sdk.VKApiConfig
|
||||
import com.vk.api.sdk.auth.VKAuthenticationResult
|
||||
import com.vk.sdk.api.users.UsersService
|
||||
import com.vk.sdk.api.users.dto.UsersUserFull
|
||||
import ru.megboyzz.studentq.data.Profile
|
||||
|
||||
class AppViewModel(activity: ComponentActivity) : AndroidViewModel(activity.application) {
|
||||
|
||||
val authLauncher = VK.login(activity) { result: VKAuthenticationResult ->
|
||||
|
||||
when (result) {
|
||||
is VKAuthenticationResult.Success -> {
|
||||
Toast.makeText(activity.applicationContext, "Успешный успех", Toast.LENGTH_LONG).show()
|
||||
val userId = VK.getUserId()
|
||||
val value = object : VKApiCallback<List<UsersUserFull>> {
|
||||
|
||||
override fun fail(error: Exception) {
|
||||
error.message?.let { Log.e("VK::getUser", it) }
|
||||
}
|
||||
|
||||
override fun success(result: List<UsersUserFull>) {
|
||||
|
||||
val name = result[0].firstName
|
||||
val surname = result[0].lastName
|
||||
val id = userId.value
|
||||
|
||||
if(name != null && surname != null) {
|
||||
val profile = Profile(name = name, surname = surname, vkID = id, isHeadman = false)
|
||||
dao?.setProfile(profile)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Создает кофиг
|
||||
val config = VKApiConfig(
|
||||
context = activity.applicationContext,
|
||||
langProvider = {"ru"}
|
||||
)
|
||||
VK.setConfig(config)
|
||||
|
||||
VK.execute(
|
||||
UsersService().usersGet(listOf(userId), listOf()),
|
||||
value
|
||||
)
|
||||
|
||||
}
|
||||
is VKAuthenticationResult.Failed -> {
|
||||
Toast.makeText(this, "Не успех", Toast.LENGTH_LONG).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,13 +30,13 @@ fun SplashScreen(navHostController: NavHostController){
|
||||
val alphaAnim = animateFloatAsState(
|
||||
targetValue = if (startAnimation) 1f else 0f,
|
||||
animationSpec = tween(
|
||||
durationMillis = 1000
|
||||
durationMillis = 500
|
||||
)
|
||||
)
|
||||
|
||||
LaunchedEffect(key1 = true) {
|
||||
startAnimation = true
|
||||
delay(1000)
|
||||
delay(500)
|
||||
navHostController.popBackStack()
|
||||
navHostController.navigate(AppNavRoute.Auth.route)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Studentq" parent="android:Theme.Material.Light.NoActionBar">
|
||||
<item name="android:statusBarColor">#CCE6195E</item>
|
||||
<item name="android:statusBarColor">#CCD81858</item>
|
||||
<item name="android:colorBackground">#FF1E1E1E</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
Reference in New Issue
Block a user