Browse Source
Interchange UserService and UserRepository names. Check description.
Interchange UserService and UserRepository names. Check description.
As per the sample provided at https://github.com/android/architecture-components-samples/tree/main/GithubBrowserSample, the Retrofit interfaces should be named Services and the classes using the services are Repositories. Once all are properly named, we can move the db repositories inside the repositories package.renovate/org.robolectric-robolectric-4.x
Ammar Githam
4 years ago
7 changed files with 28 additions and 28 deletions
-
6app/src/main/java/awais/instagrabber/dialogs/ProfilePicDialogFragment.java
-
10app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java
-
6app/src/main/java/awais/instagrabber/fragments/settings/MorePreferencesFragment.java
-
2app/src/main/java/awais/instagrabber/repositories/UserService.kt
-
10app/src/main/java/awais/instagrabber/viewmodels/AppStateViewModel.java
-
8app/src/main/java/awais/instagrabber/viewmodels/UserSearchViewModel.java
-
14app/src/main/java/awais/instagrabber/webservices/UserRepository.kt
@ -1,29 +1,29 @@ |
|||||
package awais.instagrabber.webservices |
package awais.instagrabber.webservices |
||||
|
|
||||
import awais.instagrabber.repositories.UserRepository |
|
||||
|
import awais.instagrabber.repositories.UserService |
||||
import awais.instagrabber.repositories.responses.FriendshipStatus |
import awais.instagrabber.repositories.responses.FriendshipStatus |
||||
import awais.instagrabber.repositories.responses.User |
import awais.instagrabber.repositories.responses.User |
||||
import awais.instagrabber.repositories.responses.UserSearchResponse |
import awais.instagrabber.repositories.responses.UserSearchResponse |
||||
import awais.instagrabber.webservices.RetrofitFactory.retrofit |
import awais.instagrabber.webservices.RetrofitFactory.retrofit |
||||
import java.util.* |
import java.util.* |
||||
|
|
||||
object UserService : BaseService() { |
|
||||
private val repository: UserRepository = retrofit.create(UserRepository::class.java) |
|
||||
|
object UserRepository : BaseService() { |
||||
|
private val service: UserService = retrofit.create(UserService::class.java) |
||||
|
|
||||
suspend fun getUserInfo(uid: Long): User { |
suspend fun getUserInfo(uid: Long): User { |
||||
val response = repository.getUserInfo(uid) |
|
||||
|
val response = service.getUserInfo(uid) |
||||
return response.user |
return response.user |
||||
} |
} |
||||
|
|
||||
suspend fun getUsernameInfo(username: String): User { |
suspend fun getUsernameInfo(username: String): User { |
||||
val response = repository.getUsernameInfo(username) |
|
||||
|
val response = service.getUsernameInfo(username) |
||||
return response.user |
return response.user |
||||
} |
} |
||||
|
|
||||
suspend fun getUserFriendship(uid: Long): FriendshipStatus = repository.getUserFriendship(uid) |
|
||||
|
suspend fun getUserFriendship(uid: Long): FriendshipStatus = service.getUserFriendship(uid) |
||||
|
|
||||
suspend fun search(query: String): UserSearchResponse { |
suspend fun search(query: String): UserSearchResponse { |
||||
val timezoneOffset = TimeZone.getDefault().rawOffset.toFloat() / 1000 |
val timezoneOffset = TimeZone.getDefault().rawOffset.toFloat() / 1000 |
||||
return repository.search(timezoneOffset, query) |
|
||||
|
return service.search(timezoneOffset, query) |
||||
} |
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue