mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 06:37:30 +00:00
Add MediaRepository to ProfileFragmentViewModel constructor
This commit is contained in:
parent
58e0863de5
commit
2a0295e325
@ -348,6 +348,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
|||||||
UserRepository.Companion.getInstance(),
|
UserRepository.Companion.getInstance(),
|
||||||
FriendshipRepository.Companion.getInstance(),
|
FriendshipRepository.Companion.getInstance(),
|
||||||
StoriesRepository.Companion.getInstance(),
|
StoriesRepository.Companion.getInstance(),
|
||||||
|
MediaRepository.Companion.getInstance(),
|
||||||
this,
|
this,
|
||||||
getArguments()
|
getArguments()
|
||||||
)).get(ProfileFragmentViewModel.class);
|
)).get(ProfileFragmentViewModel.class);
|
||||||
|
@ -7,6 +7,7 @@ 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.FriendshipRepository
|
||||||
|
import awais.instagrabber.webservices.MediaRepository
|
||||||
import awais.instagrabber.webservices.StoriesRepository
|
import awais.instagrabber.webservices.StoriesRepository
|
||||||
import awais.instagrabber.webservices.UserRepository
|
import awais.instagrabber.webservices.UserRepository
|
||||||
|
|
||||||
@ -15,6 +16,7 @@ class ProfileFragmentViewModel(
|
|||||||
userRepository: UserRepository,
|
userRepository: UserRepository,
|
||||||
friendshipRepository: FriendshipRepository,
|
friendshipRepository: FriendshipRepository,
|
||||||
storiesRepository: StoriesRepository,
|
storiesRepository: StoriesRepository,
|
||||||
|
mediaRepository: MediaRepository,
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
private val _profile = MutableLiveData<User?>()
|
private val _profile = MutableLiveData<User?>()
|
||||||
val profile: LiveData<User?> = _profile
|
val profile: LiveData<User?> = _profile
|
||||||
@ -26,7 +28,7 @@ class ProfileFragmentViewModel(
|
|||||||
private set
|
private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Log.d(TAG, "${state.keys()} $userRepository $friendshipRepository $storiesRepository")
|
Log.d(TAG, "${state.keys()} $userRepository $friendshipRepository $storiesRepository $mediaRepository")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,6 +37,7 @@ class ProfileFragmentViewModelFactory(
|
|||||||
private val userRepository: UserRepository,
|
private val userRepository: UserRepository,
|
||||||
private val friendshipRepository: FriendshipRepository,
|
private val friendshipRepository: FriendshipRepository,
|
||||||
private val storiesRepository: StoriesRepository,
|
private val storiesRepository: StoriesRepository,
|
||||||
|
private val mediaRepository: MediaRepository,
|
||||||
owner: SavedStateRegistryOwner,
|
owner: SavedStateRegistryOwner,
|
||||||
defaultArgs: Bundle? = null,
|
defaultArgs: Bundle? = null,
|
||||||
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
|
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
|
||||||
@ -47,7 +50,8 @@ class ProfileFragmentViewModelFactory(
|
|||||||
handle,
|
handle,
|
||||||
userRepository,
|
userRepository,
|
||||||
friendshipRepository,
|
friendshipRepository,
|
||||||
storiesRepository
|
storiesRepository,
|
||||||
|
mediaRepository,
|
||||||
) as T
|
) as T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@ 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.FriendshipService
|
||||||
|
import awais.instagrabber.repositories.MediaService
|
||||||
import awais.instagrabber.repositories.StoriesService
|
import awais.instagrabber.repositories.StoriesService
|
||||||
import awais.instagrabber.repositories.UserService
|
import awais.instagrabber.repositories.UserService
|
||||||
import awais.instagrabber.repositories.responses.*
|
import awais.instagrabber.repositories.responses.*
|
||||||
import awais.instagrabber.webservices.FriendshipRepository
|
import awais.instagrabber.webservices.FriendshipRepository
|
||||||
|
import awais.instagrabber.webservices.MediaRepository
|
||||||
import awais.instagrabber.webservices.StoriesRepository
|
import awais.instagrabber.webservices.StoriesRepository
|
||||||
import awais.instagrabber.webservices.UserRepository
|
import awais.instagrabber.webservices.UserRepository
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
@ -50,7 +52,7 @@ internal class ProfileFragmentViewModelTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val storiesService = object: StoriesService {
|
private val storiesService = object : StoriesService {
|
||||||
override suspend fun fetch(mediaId: Long): String {
|
override suspend fun fetch(mediaId: Long): String {
|
||||||
TODO("Not yet implemented")
|
TODO("Not yet implemented")
|
||||||
}
|
}
|
||||||
@ -80,6 +82,40 @@ internal class ProfileFragmentViewModelTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val mediaService = object : MediaService {
|
||||||
|
override suspend fun fetch(mediaId: Long): MediaInfoResponse {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun fetchLikes(mediaId: String, action: String): LikersResponse {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun action(action: String, mediaId: String, signedForm: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun editCaption(mediaId: String, signedForm: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun translate(form: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun uploadFinish(retryContext: String, queryParams: Map<String, String>, signedForm: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun delete(mediaId: String, mediaType: String, signedForm: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun archive(mediaId: String, signedForm: Map<String, String>): String {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testNoUsernameNoCurrentUser() {
|
fun testNoUsernameNoCurrentUser() {
|
||||||
val state = SavedStateHandle(
|
val state = SavedStateHandle(
|
||||||
@ -90,6 +126,13 @@ internal class ProfileFragmentViewModelTest {
|
|||||||
val userRepository = UserRepository(userService)
|
val userRepository = UserRepository(userService)
|
||||||
val friendshipRepository = FriendshipRepository(friendshipService)
|
val friendshipRepository = FriendshipRepository(friendshipService)
|
||||||
val storiesRepository = StoriesRepository(storiesService)
|
val storiesRepository = StoriesRepository(storiesService)
|
||||||
val viewModel = ProfileFragmentViewModel(state, userRepository, friendshipRepository, storiesRepository)
|
val mediaRepository = MediaRepository(mediaService)
|
||||||
|
val viewModel = ProfileFragmentViewModel(
|
||||||
|
state,
|
||||||
|
userRepository,
|
||||||
|
friendshipRepository,
|
||||||
|
storiesRepository,
|
||||||
|
mediaRepository
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user