mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-15 19:27:31 +00:00
Add GraphQLRepository to ProfileFragmentViewModel constructor
This commit is contained in:
parent
205e21b07c
commit
dad2260ea2
@ -349,6 +349,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
FriendshipRepository.Companion.getInstance(),
|
FriendshipRepository.Companion.getInstance(),
|
||||||
StoriesRepository.Companion.getInstance(),
|
StoriesRepository.Companion.getInstance(),
|
||||||
MediaRepository.Companion.getInstance(),
|
MediaRepository.Companion.getInstance(),
|
||||||
|
GraphQLRepository.Companion.getInstance(),
|
||||||
this,
|
this,
|
||||||
getArguments()
|
getArguments()
|
||||||
)).get(ProfileFragmentViewModel.class);
|
)).get(ProfileFragmentViewModel.class);
|
||||||
|
@ -6,10 +6,7 @@ import androidx.lifecycle.*
|
|||||||
import androidx.savedstate.SavedStateRegistryOwner
|
import androidx.savedstate.SavedStateRegistryOwner
|
||||||
import awais.instagrabber.repositories.responses.User
|
import awais.instagrabber.repositories.responses.User
|
||||||
import awais.instagrabber.utils.extensions.TAG
|
import awais.instagrabber.utils.extensions.TAG
|
||||||
import awais.instagrabber.webservices.FriendshipRepository
|
import awais.instagrabber.webservices.*
|
||||||
import awais.instagrabber.webservices.MediaRepository
|
|
||||||
import awais.instagrabber.webservices.StoriesRepository
|
|
||||||
import awais.instagrabber.webservices.UserRepository
|
|
||||||
|
|
||||||
class ProfileFragmentViewModel(
|
class ProfileFragmentViewModel(
|
||||||
state: SavedStateHandle,
|
state: SavedStateHandle,
|
||||||
@ -17,6 +14,7 @@ class ProfileFragmentViewModel(
|
|||||||
friendshipRepository: FriendshipRepository,
|
friendshipRepository: FriendshipRepository,
|
||||||
storiesRepository: StoriesRepository,
|
storiesRepository: StoriesRepository,
|
||||||
mediaRepository: MediaRepository,
|
mediaRepository: MediaRepository,
|
||||||
|
graphQLRepository: GraphQLRepository,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private val _profile = MutableLiveData<User?>()
|
private val _profile = MutableLiveData<User?>()
|
||||||
val profile: LiveData<User?> = _profile
|
val profile: LiveData<User?> = _profile
|
||||||
@ -38,6 +36,7 @@ class ProfileFragmentViewModelFactory(
|
|||||||
private val friendshipRepository: FriendshipRepository,
|
private val friendshipRepository: FriendshipRepository,
|
||||||
private val storiesRepository: StoriesRepository,
|
private val storiesRepository: StoriesRepository,
|
||||||
private val mediaRepository: MediaRepository,
|
private val mediaRepository: MediaRepository,
|
||||||
|
private val graphQLRepository: GraphQLRepository,
|
||||||
owner: SavedStateRegistryOwner,
|
owner: SavedStateRegistryOwner,
|
||||||
defaultArgs: Bundle? = null,
|
defaultArgs: Bundle? = null,
|
||||||
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
|
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
|
||||||
@ -52,6 +51,7 @@ class ProfileFragmentViewModelFactory(
|
|||||||
friendshipRepository,
|
friendshipRepository,
|
||||||
storiesRepository,
|
storiesRepository,
|
||||||
mediaRepository,
|
mediaRepository,
|
||||||
|
graphQLRepository,
|
||||||
) as T
|
) as T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,9 @@ package awais.instagrabber.viewmodels
|
|||||||
|
|
||||||
import androidx.lifecycle.SavedStateHandle
|
import androidx.lifecycle.SavedStateHandle
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
import awais.instagrabber.repositories.FriendshipService
|
import awais.instagrabber.repositories.*
|
||||||
import awais.instagrabber.repositories.MediaService
|
|
||||||
import awais.instagrabber.repositories.StoriesService
|
|
||||||
import awais.instagrabber.repositories.UserService
|
|
||||||
import awais.instagrabber.repositories.responses.*
|
import awais.instagrabber.repositories.responses.*
|
||||||
import awais.instagrabber.webservices.FriendshipRepository
|
import awais.instagrabber.webservices.*
|
||||||
import awais.instagrabber.webservices.MediaRepository
|
|
||||||
import awais.instagrabber.webservices.StoriesRepository
|
|
||||||
import awais.instagrabber.webservices.UserRepository
|
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
@ -116,6 +110,28 @@ internal class ProfileFragmentViewModelTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val graphQLService = object : GraphQLService {
|
||||||
|
override suspend fun fetch(queryParams: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getUser(username: String): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getPost(shortcode: String): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getTag(tag: String): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun getLocation(locationId: Long): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNoUsernameNoCurrentUser() {
|
fun testNoUsernameNoCurrentUser() {
|
||||||
val state = SavedStateHandle(
|
val state = SavedStateHandle(
|
||||||
@ -127,12 +143,14 @@ internal class ProfileFragmentViewModelTest {
|
|||||||
val friendshipRepository = FriendshipRepository(friendshipService)
|
val friendshipRepository = FriendshipRepository(friendshipService)
|
||||||
val storiesRepository = StoriesRepository(storiesService)
|
val storiesRepository = StoriesRepository(storiesService)
|
||||||
val mediaRepository = MediaRepository(mediaService)
|
val mediaRepository = MediaRepository(mediaService)
|
||||||
|
val graphQLRepository = GraphQLRepository(graphQLService)
|
||||||
val viewModel = ProfileFragmentViewModel(
|
val viewModel = ProfileFragmentViewModel(
|
||||||
state,
|
state,
|
||||||
userRepository,
|
userRepository,
|
||||||
friendshipRepository,
|
friendshipRepository,
|
||||||
storiesRepository,
|
storiesRepository,
|
||||||
mediaRepository
|
mediaRepository,
|
||||||
|
graphQLRepository,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user