mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-12 17:57:29 +00:00
Interchange StoriesService and StoriesRepository names.
This commit is contained in:
parent
8bb0fba4cb
commit
1191b416ce
@ -69,7 +69,7 @@ import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import awais.instagrabber.webservices.TagsService;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
@ -93,7 +93,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private String hashtag;
|
||||
private Hashtag hashtagModel = null;
|
||||
private ActionMode actionMode;
|
||||
private StoriesService storiesService;
|
||||
private StoriesRepository storiesRepository;
|
||||
private boolean isLoggedIn;
|
||||
private TagsService tagsService;
|
||||
private GraphQLService graphQLService;
|
||||
@ -298,7 +298,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
final String cookie = settingsHelper.getString(Constants.COOKIE);
|
||||
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0;
|
||||
tagsService = isLoggedIn ? TagsService.getInstance() : null;
|
||||
storiesService = isLoggedIn ? StoriesService.INSTANCE : null;
|
||||
storiesRepository = isLoggedIn ? StoriesRepository.INSTANCE : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@ -585,7 +585,7 @@ public class HashTagFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private void fetchStories() {
|
||||
if (!isLoggedIn) return;
|
||||
storiesFetching = true;
|
||||
storiesService.getUserStory(
|
||||
storiesRepository.getUserStory(
|
||||
StoryViewerOptions.forHashtag(hashtagModel.getName()),
|
||||
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
|
@ -66,7 +66,7 @@ import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.LocationService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
@ -87,7 +87,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
private long locationId;
|
||||
private Location locationModel;
|
||||
private ActionMode actionMode;
|
||||
private StoriesService storiesService;
|
||||
private StoriesRepository storiesRepository;
|
||||
private GraphQLService graphQLService;
|
||||
private LocationService locationService;
|
||||
private boolean isLoggedIn;
|
||||
@ -291,7 +291,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
final String cookie = settingsHelper.getString(Constants.COOKIE);
|
||||
isLoggedIn = !TextUtils.isEmpty(cookie) && CookieUtils.getUserIdFromCookie(cookie) > 0;
|
||||
locationService = isLoggedIn ? LocationService.getInstance() : null;
|
||||
storiesService = StoriesService.INSTANCE;
|
||||
storiesRepository = StoriesRepository.INSTANCE;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
@ -589,7 +589,7 @@ public class LocationFragment extends Fragment implements SwipeRefreshLayout.OnR
|
||||
private void fetchStories() {
|
||||
if (isLoggedIn) {
|
||||
storiesFetching = true;
|
||||
storiesService.getUserStory(
|
||||
storiesRepository.getUserStory(
|
||||
StoryViewerOptions.forLocation(locationId, locationModel.getName()),
|
||||
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
|
@ -47,8 +47,8 @@ import awais.instagrabber.utils.TextUtils;
|
||||
import awais.instagrabber.viewmodels.ArchivesViewModel;
|
||||
import awais.instagrabber.viewmodels.FeedStoriesViewModel;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awais.instagrabber.webservices.StoriesService.ArchiveFetchResponse;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import awais.instagrabber.webservices.StoriesRepository.ArchiveFetchResponse;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
public final class StoryListViewerFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
|
||||
@ -61,7 +61,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
|
||||
private boolean firstRefresh = true;
|
||||
private FeedStoriesViewModel feedStoriesViewModel;
|
||||
private ArchivesViewModel archivesViewModel;
|
||||
private StoriesService storiesService;
|
||||
private StoriesRepository storiesRepository;
|
||||
private Context context;
|
||||
private String type;
|
||||
private String endCursor = null;
|
||||
@ -136,7 +136,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
|
||||
context = getContext();
|
||||
if (context == null) return;
|
||||
setHasOptionsMenu(true);
|
||||
storiesService = StoriesService.INSTANCE;
|
||||
storiesRepository = StoriesRepository.INSTANCE;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@ -242,7 +242,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
|
||||
}
|
||||
firstRefresh = false;
|
||||
} else if (type.equals("feed")) {
|
||||
storiesService.getFeedStories(
|
||||
storiesRepository.getFeedStories(
|
||||
CoroutineUtilsKt.getContinuation((feedStoryModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
Log.e(TAG, "failed", throwable);
|
||||
@ -257,7 +257,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
|
||||
}), Dispatchers.getIO())
|
||||
);
|
||||
} else if (type.equals("archive")) {
|
||||
storiesService.fetchArchive(
|
||||
storiesRepository.fetchArchive(
|
||||
endCursor,
|
||||
CoroutineUtilsKt.getContinuation((archiveFetchResponse, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
|
@ -101,7 +101,7 @@ import awais.instagrabber.viewmodels.StoriesViewModel;
|
||||
import awais.instagrabber.webservices.DirectMessagesService;
|
||||
import awais.instagrabber.webservices.MediaService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static awais.instagrabber.customviews.helpers.SwipeGestureListener.SWIPE_THRESHOLD;
|
||||
@ -122,7 +122,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
private StoriesAdapter storiesAdapter;
|
||||
private SwipeEvent swipeEvent;
|
||||
private GestureDetectorCompat gestureDetector;
|
||||
private StoriesService storiesService;
|
||||
private StoriesRepository storiesRepository;
|
||||
private MediaService mediaService;
|
||||
private StoryModel currentStory;
|
||||
private int slidePos;
|
||||
@ -162,7 +162,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
userId = CookieUtils.getUserIdFromCookie(cookie);
|
||||
deviceId = settingsHelper.getString(Constants.DEVICE_UUID);
|
||||
fragmentActivity = (AppCompatActivity) requireActivity();
|
||||
storiesService = StoriesService.INSTANCE;
|
||||
storiesRepository = StoriesRepository.INSTANCE;
|
||||
mediaService = MediaService.INSTANCE;
|
||||
directMessagesService = DirectMessagesService.INSTANCE;
|
||||
setHasOptionsMenu(true);
|
||||
@ -521,7 +521,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
poll.getRightChoice() + " (" + poll.getRightCount() + ")"
|
||||
}), (d, w) -> {
|
||||
sticking = true;
|
||||
storiesService.respondToPoll(
|
||||
storiesRepository.respondToPoll(
|
||||
csrfToken,
|
||||
userId,
|
||||
deviceId,
|
||||
@ -560,7 +560,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
.setView(input)
|
||||
.setPositiveButton(R.string.confirm, (d, w) -> {
|
||||
sticking = true;
|
||||
storiesService.respondToQuestion(
|
||||
storiesRepository.respondToQuestion(
|
||||
csrfToken,
|
||||
userId,
|
||||
deviceId,
|
||||
@ -618,7 +618,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
.setAdapter(new ArrayAdapter<>(context, android.R.layout.simple_list_item_1, choices), (d, w) -> {
|
||||
if (quiz.getMyChoice() == -1) {
|
||||
sticking = true;
|
||||
storiesService.respondToQuiz(
|
||||
storiesRepository.respondToQuiz(
|
||||
csrfToken,
|
||||
userId,
|
||||
deviceId,
|
||||
@ -689,7 +689,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
.setView(sliderView)
|
||||
.setPositiveButton(R.string.confirm, (d, w) -> {
|
||||
sticking = true;
|
||||
storiesService.respondToSlider(
|
||||
storiesRepository.respondToSlider(
|
||||
csrfToken,
|
||||
userId,
|
||||
deviceId,
|
||||
@ -805,7 +805,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
setTitle(type);
|
||||
storiesViewModel.getList().setValue(Collections.emptyList());
|
||||
if (type == Type.STORY) {
|
||||
storiesService.fetch(
|
||||
storiesRepository.fetch(
|
||||
options.getId(),
|
||||
CoroutineUtilsKt.getContinuation((storyModel, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
@ -858,7 +858,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
storyCallback.onSuccess(Collections.singletonList(live));
|
||||
return;
|
||||
}
|
||||
storiesService.getUserStory(
|
||||
storiesRepository.getUserStory(
|
||||
fetchOptions,
|
||||
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
@ -972,7 +972,7 @@ public class StoryViewerFragment extends Fragment {
|
||||
}
|
||||
|
||||
if (settingsHelper.getBoolean(MARK_AS_SEEN))
|
||||
storiesService.seen(
|
||||
storiesRepository.seen(
|
||||
csrfToken,
|
||||
userId,
|
||||
deviceId,
|
||||
|
@ -54,7 +54,7 @@ import awais.instagrabber.utils.CoroutineUtilsKt;
|
||||
import awais.instagrabber.utils.DownloadUtils;
|
||||
import awais.instagrabber.utils.Utils;
|
||||
import awais.instagrabber.viewmodels.FeedStoriesViewModel;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
import static androidx.core.content.PermissionChecker.checkSelfPermission;
|
||||
@ -68,7 +68,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
||||
private MainActivity fragmentActivity;
|
||||
private MotionLayout root;
|
||||
private FragmentFeedBinding binding;
|
||||
private StoriesService storiesService;
|
||||
private StoriesRepository storiesRepository;
|
||||
private boolean shouldRefresh = true;
|
||||
private final boolean isRotate = false;
|
||||
private FeedStoriesViewModel feedStoriesViewModel;
|
||||
@ -276,7 +276,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
storiesService = StoriesService.INSTANCE;
|
||||
storiesRepository = StoriesRepository.INSTANCE;
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
|
||||
// final String cookie = settingsHelper.getString(Constants.COOKIE);
|
||||
storiesFetching = true;
|
||||
updateSwipeRefreshState();
|
||||
storiesService.getFeedStories(
|
||||
storiesRepository.getFeedStories(
|
||||
CoroutineUtilsKt.getContinuation((feedStoryModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
Log.e(TAG, "failed", throwable);
|
||||
|
@ -96,7 +96,7 @@ import awais.instagrabber.webservices.FriendshipRepository;
|
||||
import awais.instagrabber.webservices.GraphQLService;
|
||||
import awais.instagrabber.webservices.MediaService;
|
||||
import awais.instagrabber.webservices.ServiceCallback;
|
||||
import awais.instagrabber.webservices.StoriesService;
|
||||
import awais.instagrabber.webservices.StoriesRepository;
|
||||
import awais.instagrabber.webservices.UserRepository;
|
||||
import kotlinx.coroutines.Dispatchers;
|
||||
|
||||
@ -119,7 +119,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
private ActionMode actionMode;
|
||||
private Handler usernameSettingHandler;
|
||||
private FriendshipRepository friendshipRepository;
|
||||
private StoriesService storiesService;
|
||||
private StoriesRepository storiesRepository;
|
||||
private MediaService mediaService;
|
||||
private UserRepository userRepository;
|
||||
private GraphQLService graphQLService;
|
||||
@ -335,7 +335,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
friendshipRepository = isLoggedIn ? FriendshipRepository.Companion.getInstance() : null;
|
||||
directMessagesService = isLoggedIn ? DirectMessagesService.INSTANCE : null;
|
||||
storiesService = isLoggedIn ? StoriesService.INSTANCE : null;
|
||||
storiesRepository = isLoggedIn ? StoriesRepository.INSTANCE : null;
|
||||
mediaService = isLoggedIn ? MediaService.INSTANCE : null;
|
||||
userRepository = isLoggedIn ? UserRepository.Companion.getInstance() : null;
|
||||
graphQLService = isLoggedIn ? null : GraphQLService.INSTANCE;
|
||||
@ -1046,7 +1046,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
}
|
||||
|
||||
private void fetchStoryAndHighlights(final long profileId) {
|
||||
storiesService.getUserStory(
|
||||
storiesRepository.getUserStory(
|
||||
StoryViewerOptions.forUser(profileId, profileModel.getFullName()),
|
||||
CoroutineUtilsKt.getContinuation((storyModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
@ -1059,7 +1059,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
|
||||
}
|
||||
}), Dispatchers.getIO())
|
||||
);
|
||||
storiesService.fetchHighlights(
|
||||
storiesRepository.fetchHighlights(
|
||||
profileId,
|
||||
CoroutineUtilsKt.getContinuation((highlightModels, throwable) -> AppExecutors.INSTANCE.getMainThread().execute(() -> {
|
||||
if (throwable != null) {
|
||||
|
@ -3,7 +3,7 @@ package awais.instagrabber.repositories
|
||||
import awais.instagrabber.repositories.responses.StoryStickerResponse
|
||||
import retrofit2.http.*
|
||||
|
||||
interface StoriesRepository {
|
||||
interface StoriesService {
|
||||
// this one is the same as MediaRepository.fetch BUT you need to make sure it's a story
|
||||
@GET("/api/v1/media/{mediaId}/info/")
|
||||
suspend fun fetch(@Path("mediaId") mediaId: Long): String
|
@ -5,7 +5,7 @@ import awais.instagrabber.fragments.settings.PreferenceKeys
|
||||
import awais.instagrabber.models.FeedStoryModel
|
||||
import awais.instagrabber.models.HighlightModel
|
||||
import awais.instagrabber.models.StoryModel
|
||||
import awais.instagrabber.repositories.StoriesRepository
|
||||
import awais.instagrabber.repositories.StoriesService
|
||||
import awais.instagrabber.repositories.requests.StoryViewerOptions
|
||||
import awais.instagrabber.repositories.responses.StoryStickerResponse
|
||||
import awais.instagrabber.repositories.responses.User
|
||||
@ -19,17 +19,17 @@ import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
|
||||
object StoriesService {
|
||||
private val repository: StoriesRepository = retrofit.create(StoriesRepository::class.java)
|
||||
object StoriesRepository {
|
||||
private val service: StoriesService = retrofit.create(StoriesService::class.java)
|
||||
|
||||
suspend fun fetch(mediaId: Long): StoryModel {
|
||||
val response = repository.fetch(mediaId)
|
||||
val response = service.fetch(mediaId)
|
||||
val itemJson = JSONObject(response).getJSONArray("items").getJSONObject(0)
|
||||
return ResponseBodyUtils.parseStoryItem(itemJson, false, null)
|
||||
}
|
||||
|
||||
suspend fun getFeedStories(): List<FeedStoryModel> {
|
||||
val response = repository.getFeedStories()
|
||||
val response = service.getFeedStories()
|
||||
return parseStoriesBody(response)
|
||||
}
|
||||
|
||||
@ -94,7 +94,7 @@ object StoriesService {
|
||||
}
|
||||
|
||||
suspend fun fetchHighlights(profileId: Long): List<HighlightModel> {
|
||||
val response = repository.fetchHighlights(profileId)
|
||||
val response = service.fetchHighlights(profileId)
|
||||
val highlightsReel = JSONObject(response).getJSONArray("tray")
|
||||
val length = highlightsReel.length()
|
||||
val highlightModels: MutableList<HighlightModel> = ArrayList()
|
||||
@ -122,7 +122,7 @@ object StoriesService {
|
||||
if (!isEmpty(maxId)) {
|
||||
form["max_id"] = maxId // NOT TESTED
|
||||
}
|
||||
val response = repository.fetchArchive(form)
|
||||
val response = service.fetchArchive(form)
|
||||
val data = JSONObject(response)
|
||||
val highlightsReel = data.getJSONArray("items")
|
||||
val length = highlightsReel.length()
|
||||
@ -142,7 +142,7 @@ object StoriesService {
|
||||
|
||||
suspend fun getUserStory(options: StoryViewerOptions): List<StoryModel> {
|
||||
val url = buildUrl(options) ?: return emptyList()
|
||||
val response = repository.getUserStory(url)
|
||||
val response = service.getUserStory(url)
|
||||
val isLocOrHashtag = options.type == StoryViewerOptions.Type.LOCATION || options.type == StoryViewerOptions.Type.HASHTAG
|
||||
val isHighlight = options.type == StoryViewerOptions.Type.HIGHLIGHT || options.type == StoryViewerOptions.Type.STORY_ARCHIVE
|
||||
var data: JSONObject? = JSONObject(response)
|
||||
@ -187,7 +187,7 @@ object StoriesService {
|
||||
arg1 to arg2,
|
||||
)
|
||||
val signedForm = Utils.sign(form)
|
||||
return repository.respondToSticker(storyId, stickerId, action, signedForm)
|
||||
return service.respondToSticker(storyId, stickerId, action, signedForm)
|
||||
}
|
||||
|
||||
suspend fun respondToQuestion(
|
||||
@ -249,7 +249,7 @@ object StoriesService {
|
||||
"reel" to "1",
|
||||
"live_vod" to "0",
|
||||
)
|
||||
return repository.seen(queryMap, signedForm)
|
||||
return service.seen(queryMap, signedForm)
|
||||
}
|
||||
|
||||
private fun buildUrl(options: StoryViewerOptions): String? {
|
Loading…
Reference in New Issue
Block a user