Browse Source
comments viewer improvement
comments viewer improvement
1. Viewing parent comments is now paginated, no more long waits
2. Liking a comment will no longer refresh the entire comment list
3. The pink tint on liked comments from v18 is restored
also removed FeedStoriesFetcher which was deprecated by c24fd01
renovate/org.robolectric-robolectric-4.x
Austin Huang
4 years ago
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
8 changed files with 106 additions and 142 deletions
-
16app/src/main/java/awais/instagrabber/adapters/CommentsAdapter.java
-
3app/src/main/java/awais/instagrabber/adapters/viewholder/comments/ChildCommentViewHolder.java
-
3app/src/main/java/awais/instagrabber/adapters/viewholder/comments/ParentCommentViewHolder.java
-
32app/src/main/java/awais/instagrabber/asyncs/CommentsFetcher.java
-
93app/src/main/java/awais/instagrabber/asyncs/FeedStoriesFetcher.java
-
70app/src/main/java/awais/instagrabber/fragments/CommentsViewerFragment.java
-
10app/src/main/java/awais/instagrabber/models/CommentModel.java
-
1app/src/main/res/values/color.xml
@ -1,93 +0,0 @@ |
|||||
package awais.instagrabber.asyncs; |
|
||||
|
|
||||
import android.os.AsyncTask; |
|
||||
import android.util.Log; |
|
||||
|
|
||||
import org.json.JSONArray; |
|
||||
import org.json.JSONObject; |
|
||||
|
|
||||
import java.net.HttpURLConnection; |
|
||||
import java.net.URL; |
|
||||
|
|
||||
import awais.instagrabber.BuildConfig; |
|
||||
import awais.instagrabber.interfaces.FetchListener; |
|
||||
import awais.instagrabber.models.FeedStoryModel; |
|
||||
import awais.instagrabber.models.ProfileModel; |
|
||||
import awais.instagrabber.utils.Constants; |
|
||||
import awais.instagrabber.utils.NetworkUtils; |
|
||||
import awaisomereport.LogCollector.LogFile; |
|
||||
|
|
||||
import static awais.instagrabber.utils.Utils.logCollector; |
|
||||
|
|
||||
public final class FeedStoriesFetcher extends AsyncTask<Void, Void, FeedStoryModel[]> { |
|
||||
private final FetchListener<FeedStoryModel[]> fetchListener; |
|
||||
|
|
||||
public FeedStoriesFetcher(final FetchListener<FeedStoryModel[]> fetchListener) { |
|
||||
this.fetchListener = fetchListener; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected FeedStoryModel[] doInBackground(final Void... voids) { |
|
||||
FeedStoryModel[] result = null; |
|
||||
String url = "https://www.instagram.com/graphql/query/?query_hash=b7b84d884400bc5aa7cfe12ae843a091&variables=" + |
|
||||
"{\"only_stories\":true,\"stories_prefetch\":false,\"stories_video_dash_manifest\":false}"; |
|
||||
|
|
||||
try { |
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); |
|
||||
conn.setInstanceFollowRedirects(false); |
|
||||
conn.setUseCaches(false); |
|
||||
conn.connect(); |
|
||||
|
|
||||
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { |
|
||||
final JSONArray feedStoriesReel = new JSONObject(NetworkUtils.readFromConnection(conn)) |
|
||||
.getJSONObject("data") |
|
||||
.getJSONObject(Constants.EXTRAS_USER) |
|
||||
.getJSONObject("feed_reels_tray") |
|
||||
.getJSONObject("edge_reels_tray_to_reel") |
|
||||
.getJSONArray("edges"); |
|
||||
|
|
||||
conn.disconnect(); |
|
||||
|
|
||||
final int storiesLen = feedStoriesReel.length(); |
|
||||
final FeedStoryModel[] feedStoryModels = new FeedStoryModel[storiesLen]; |
|
||||
final String[] feedStoryIDs = new String[storiesLen]; |
|
||||
|
|
||||
for (int i = 0; i < storiesLen; ++i) { |
|
||||
final JSONObject node = feedStoriesReel.getJSONObject(i).getJSONObject("node"); |
|
||||
|
|
||||
final JSONObject user = node.getJSONObject(node.has("user") ? "user" : "owner"); |
|
||||
final ProfileModel profileModel = new ProfileModel(false, false, false, |
|
||||
user.getString("id"), |
|
||||
user.getString("username"), |
|
||||
null, null, null, |
|
||||
user.getString("profile_pic_url"), |
|
||||
null, 0, 0, 0, false, false, false, false); |
|
||||
|
|
||||
final String id = node.getString("id"); |
|
||||
final boolean fullyRead = !node.isNull("seen") && node.getLong("seen") == node.getLong("latest_reel_media"); |
|
||||
feedStoryIDs[i] = id; |
|
||||
feedStoryModels[i] = new FeedStoryModel(id, profileModel, fullyRead); |
|
||||
} |
|
||||
result = feedStoryModels; |
|
||||
} |
|
||||
|
|
||||
conn.disconnect(); |
|
||||
} catch (final Exception e) { |
|
||||
if (logCollector != null) |
|
||||
logCollector.appendException(e, LogFile.ASYNC_FEED_STORY_FETCHER, "doInBackground"); |
|
||||
if (BuildConfig.DEBUG) Log.e("AWAISKING_APP", "", e); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected void onPreExecute() { |
|
||||
if (fetchListener != null) fetchListener.doBefore(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
protected void onPostExecute(final FeedStoryModel[] result) { |
|
||||
if (fetchListener != null) fetchListener.onResult(result); |
|
||||
} |
|
||||
} |
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue