mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-22 14:47:29 +00:00
v16.6-a8: INFINITE STORY SCROLL
This commit is contained in:
parent
be45f52f7e
commit
eb387d9c81
@ -10,7 +10,7 @@ android {
|
||||
targetSdkVersion 29
|
||||
|
||||
versionCode 27
|
||||
versionName '16.6-a7'
|
||||
versionName '16.6-a8'
|
||||
|
||||
multiDexEnabled true
|
||||
|
||||
|
@ -88,6 +88,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
private static AsyncTask<?, ?, ?> currentlyExecuting;
|
||||
private AsyncTask<Void, Void, FeedStoryModel[]> prevStoriesFetcher;
|
||||
private final boolean autoloadPosts;
|
||||
private FeedStoryModel[] stories;
|
||||
private boolean hasNextPage = false, feedHasNextPage = false, discoverHasMore = false;
|
||||
private String endCursor = null, feedEndCursor = null, discoverEndMaxId = null;
|
||||
private final FetchListener<PostModel[]> postsFetchListener = new FetchListener<PostModel[]>() {
|
||||
@ -206,6 +207,7 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
feedStoriesAdapter.setData(result);
|
||||
if (result != null && result.length > 0)
|
||||
main.mainBinding.feedStories.setVisibility(View.VISIBLE);
|
||||
stories = result;
|
||||
}
|
||||
};
|
||||
private final MentionClickListener mentionClickListener = new MentionClickListener() {
|
||||
@ -224,10 +226,13 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
if (tag instanceof FeedStoryModel) {
|
||||
final FeedStoryModel feedStoryModel = (FeedStoryModel) tag;
|
||||
final StoryModel[] storyModels = feedStoryModel.getStoryModels();
|
||||
final int index = indexOfIntArray(stories, feedStoryModel);
|
||||
|
||||
main.startActivity(new Intent(main, StoryViewer.class)
|
||||
.putExtra(Constants.EXTRAS_STORIES, storyModels)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
|
||||
.putExtra(Constants.FEED, stories)
|
||||
.putExtra(Constants.FEED_ORDER, index)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -861,4 +866,15 @@ public final class MainHelper implements SwipeRefreshLayout.OnRefreshListener {
|
||||
currentFeedPlayer.getPlaybackState();
|
||||
}
|
||||
}
|
||||
|
||||
public static int indexOfIntArray(Object[] array, Object key) {
|
||||
int returnvalue = -1;
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
if (key == array[i]) {
|
||||
returnvalue = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnvalue;
|
||||
}
|
||||
}
|
@ -215,7 +215,7 @@ public final class Main extends BaseLanguageActivity {
|
||||
|
||||
final boolean isQueryNull = userQuery == null;
|
||||
if (isQueryNull) allItems.clear();
|
||||
if (BuildConfig.DEBUG && isQueryNull) userQuery = "the.badak"; // todo
|
||||
if (BuildConfig.DEBUG && isQueryNull) userQuery = "austinhuang.me";
|
||||
if (!mainBinding.swipeRefreshLayout.isRefreshing() && userQuery != null) mainHelper.onRefresh();
|
||||
|
||||
mainHelper.onIntent(getIntent());
|
||||
|
@ -46,6 +46,7 @@ import awais.instagrabber.asyncs.DownloadAsync;
|
||||
import awais.instagrabber.customviews.helpers.SwipeGestureListener;
|
||||
import awais.instagrabber.databinding.ActivityStoryViewerBinding;
|
||||
import awais.instagrabber.interfaces.SwipeEvent;
|
||||
import awais.instagrabber.models.FeedStoryModel;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
import awais.instagrabber.models.enums.MediaItemType;
|
||||
@ -121,13 +122,34 @@ public final class StoryViewer extends BaseLanguageActivity {
|
||||
@Override
|
||||
public void onSwipe(final boolean isRightSwipe) {
|
||||
if (storyModels != null && storiesLen > 0) {
|
||||
if (isRightSwipe) {
|
||||
if (--slidePos <= 0) slidePos = 0;
|
||||
} else if (++slidePos >= storiesLen) slidePos = storiesLen - 1;
|
||||
if (((slidePos == storiesLen - 1 && isRightSwipe == false) || (slidePos == 0 && isRightSwipe == true))
|
||||
&& intent.hasExtra(Constants.FEED)) {
|
||||
final FeedStoryModel[] storyFeed = (FeedStoryModel[]) intent.getSerializableExtra(Constants.FEED);
|
||||
final int index = intent.getIntExtra(Constants.FEED_ORDER, 1738);
|
||||
final FeedStoryModel feedStoryModel = isRightSwipe ?
|
||||
(storyFeed.length == 0 ? null : storyFeed[index-1]) :
|
||||
(storyFeed.length == index+1 ? null : storyFeed[index+1]);
|
||||
final StoryModel[] nextStoryModels = feedStoryModel.getStoryModels();
|
||||
|
||||
currentStory = storyModels[slidePos];
|
||||
slidePos = currentStory.getPosition();
|
||||
refreshStory();
|
||||
if (feedStoryModel != null) {
|
||||
final Intent newIntent = new Intent(getApplicationContext(), StoryViewer.class)
|
||||
.putExtra(Constants.EXTRAS_STORIES, nextStoryModels)
|
||||
.putExtra(Constants.EXTRAS_USERNAME, feedStoryModel.getProfileModel().getUsername())
|
||||
.putExtra(Constants.FEED, storyFeed)
|
||||
.putExtra(Constants.FEED_ORDER, isRightSwipe ? (index-1) : (index+1));
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(newIntent);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isRightSwipe) {
|
||||
if (--slidePos <= 0) slidePos = 0;
|
||||
} else if (++slidePos >= storiesLen) slidePos = storiesLen - 1;
|
||||
|
||||
currentStory = storyModels[slidePos];
|
||||
slidePos = currentStory.getPosition();
|
||||
refreshStory();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -364,4 +386,15 @@ public final class StoryViewer extends BaseLanguageActivity {
|
||||
player = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static int indexOfIntArray(Object[] array, Object key) {
|
||||
int returnvalue = -1;
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
if (key == array[i]) {
|
||||
returnvalue = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnvalue;
|
||||
}
|
||||
}
|
@ -38,6 +38,8 @@ public final class Constants {
|
||||
public static final String EXTRAS_FOLLOWERS = "followers";
|
||||
public static final String EXTRAS_SHORTCODE = "shortcode";
|
||||
public static final String EXTRAS_END_CURSOR = "endCursor";
|
||||
public static final String FEED = "feed";
|
||||
public static final String FEED_ORDER = "feedOrder";
|
||||
//////////////////////// EXTRAS ////////////////////////
|
||||
public static final String USER_AGENT = "Mozilla/5.0 (Linux; Android 8.1.0; motorola one Build/OPKS28.63-18-3; wv) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/70.0.3538.80 Mobile Safari/537.36 " +
|
||||
|
Loading…
Reference in New Issue
Block a user