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(),
|
||||
FriendshipRepository.Companion.getInstance(),
|
||||
StoriesRepository.Companion.getInstance(),
|
||||
MediaRepository.Companion.getInstance(),
|
||||
this,
|
||||
getArguments()
|
||||
)).get(ProfileFragmentViewModel.class);
|
||||
|
@ -7,6 +7,7 @@ import androidx.savedstate.SavedStateRegistryOwner
|
||||
import awais.instagrabber.repositories.responses.User
|
||||
import awais.instagrabber.utils.extensions.TAG
|
||||
import awais.instagrabber.webservices.FriendshipRepository
|
||||
import awais.instagrabber.webservices.MediaRepository
|
||||
import awais.instagrabber.webservices.StoriesRepository
|
||||
import awais.instagrabber.webservices.UserRepository
|
||||
|
||||
@ -15,6 +16,7 @@ class ProfileFragmentViewModel(
|
||||
userRepository: UserRepository,
|
||||
friendshipRepository: FriendshipRepository,
|
||||
storiesRepository: StoriesRepository,
|
||||
mediaRepository: MediaRepository,
|
||||
) : ViewModel() {
|
||||
private val _profile = MutableLiveData<User?>()
|
||||
val profile: LiveData<User?> = _profile
|
||||
@ -26,7 +28,7 @@ class ProfileFragmentViewModel(
|
||||
private set
|
||||
|
||||
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 friendshipRepository: FriendshipRepository,
|
||||
private val storiesRepository: StoriesRepository,
|
||||
private val mediaRepository: MediaRepository,
|
||||
owner: SavedStateRegistryOwner,
|
||||
defaultArgs: Bundle? = null,
|
||||
) : AbstractSavedStateViewModelFactory(owner, defaultArgs) {
|
||||
@ -47,7 +50,8 @@ class ProfileFragmentViewModelFactory(
|
||||
handle,
|
||||
userRepository,
|
||||
friendshipRepository,
|
||||
storiesRepository
|
||||
storiesRepository,
|
||||
mediaRepository,
|
||||
) as T
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,12 @@ package awais.instagrabber.viewmodels
|
||||
import androidx.lifecycle.SavedStateHandle
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import awais.instagrabber.repositories.FriendshipService
|
||||
import awais.instagrabber.repositories.MediaService
|
||||
import awais.instagrabber.repositories.StoriesService
|
||||
import awais.instagrabber.repositories.UserService
|
||||
import awais.instagrabber.repositories.responses.*
|
||||
import awais.instagrabber.webservices.FriendshipRepository
|
||||
import awais.instagrabber.webservices.MediaRepository
|
||||
import awais.instagrabber.webservices.StoriesRepository
|
||||
import awais.instagrabber.webservices.UserRepository
|
||||
import org.junit.Test
|
||||
@ -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
|
||||
fun testNoUsernameNoCurrentUser() {
|
||||
val state = SavedStateHandle(
|
||||
@ -90,6 +126,13 @@ internal class ProfileFragmentViewModelTest {
|
||||
val userRepository = UserRepository(userService)
|
||||
val friendshipRepository = FriendshipRepository(friendshipService)
|
||||
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