Skip to content

Commit 3bbafc6

Browse files
committed
Fix some story and mediaretriever bug
1 parent 63dc69e commit 3bbafc6

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

app/src/main/java/awais/instagrabber/utils/ResponseBodyUtils.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.net.Uri;
44
import android.util.Log;
5-
import android.util.Pair;
65

76
import androidx.annotation.Nullable;
87

@@ -1042,7 +1041,7 @@ else if (backupSwipeUpUrl != null && backupSwipeUpUrl.startsWith("http"))
10421041
tappableObject.getString("question"),
10431042
tappableObject.getString("emoji"),
10441043
tappableObject.getBoolean("viewer_can_vote"),
1045-
tappableObject.getDouble("slider_vote_average"),
1044+
tappableObject.optDouble("slider_vote_average"),
10461045
tappableObject.getInt("slider_vote_count"),
10471046
tappableObject.optDouble("viewer_vote")
10481047
));

app/src/main/java/awais/instagrabber/webservices/StoriesService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ private void parseStoriesBody(final String body, final ServiceCallback<List<Feed
193193
node.getInt("media_count"),
194194
false,
195195
node.optBoolean("has_besties_media")));
196-
}
197-
catch (Exception e) {} // to cover promotional reels with non-long user pk's
196+
} catch (Exception e) {} // to cover promotional reels with non-long user pk's
198197
}
199198
final JSONArray broadcasts = new JSONObject(body).getJSONArray("broadcasts");
200199
for (int i = 0; i < broadcasts.length(); ++i) {
@@ -371,7 +370,8 @@ public void getUserStory(final StoryViewerOptions options,
371370
final String url = buildUrl(options);
372371
final Call<String> userStoryCall = repository.getUserStory(url);
373372
final boolean isLocOrHashtag = options.getType() == StoryViewerOptions.Type.LOCATION || options.getType() == StoryViewerOptions.Type.HASHTAG;
374-
final boolean isHighlight = options.getType() == StoryViewerOptions.Type.HIGHLIGHT || options.getType() == StoryViewerOptions.Type.STORY_ARCHIVE;
373+
final boolean isHighlight = options.getType() == StoryViewerOptions.Type.HIGHLIGHT || options
374+
.getType() == StoryViewerOptions.Type.STORY_ARCHIVE;
375375
userStoryCall.enqueue(new Callback<String>() {
376376
@Override
377377
public void onResponse(@NonNull final Call<String> call, @NonNull final Response<String> response) {
@@ -412,7 +412,7 @@ public void onResponse(@NonNull final Call<String> call, @NonNull final Response
412412
callback.onSuccess(null);
413413
}
414414
} catch (JSONException e) {
415-
Log.e(TAG, "Error parsing string");
415+
Log.e(TAG, "Error parsing string", e);
416416
}
417417
}
418418

app/src/main/java/awais/instagrabber/workers/DownloadWorker.java

+14-8
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757
import static awais.instagrabber.utils.Constants.DOWNLOAD_CHANNEL_ID;
5858
import static awais.instagrabber.utils.Constants.NOTIF_GROUP_NAME;
5959

60-
//import awaisomereport.LogCollector;
61-
//import static awais.instagrabber.utils.Utils.logCollector;
62-
6360
public class DownloadWorker extends Worker {
6461
private static final String TAG = "DownloadWorker";
6562
private static final String DOWNLOAD_GROUP = "DOWNLOAD_GROUP";
@@ -340,13 +337,22 @@ private Bitmap getThumbnail(final Context context,
340337
return bitmap;
341338
}
342339
if (mimeType.startsWith("video")) {
343-
try (MediaMetadataRetriever retriever = new MediaMetadataRetriever()) {
340+
try {
341+
MediaMetadataRetriever retriever = new MediaMetadataRetriever();
344342
try {
345-
retriever.setDataSource(context, uri);
346-
} catch (final Exception e) {
347-
retriever.setDataSource(file.getAbsolutePath());
343+
try {
344+
retriever.setDataSource(context, uri);
345+
} catch (final Exception e) {
346+
retriever.setDataSource(file.getAbsolutePath());
347+
}
348+
bitmap = retriever.getFrameAtTime();
349+
} finally {
350+
try {
351+
retriever.release();
352+
} catch (Exception e) {
353+
Log.e(TAG, "getThumbnail: ", e);
354+
}
348355
}
349-
bitmap = retriever.getFrameAtTime();
350356
} catch (final Exception e) {
351357
Log.e(TAG, "", e);
352358
}

0 commit comments

Comments
 (0)