mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +00:00
Null check. Fixes https://github.com/austinhuang0131/barinsta/issues/862
This commit is contained in:
parent
8f72796891
commit
a60e934162
@ -1,10 +1,8 @@
|
||||
package awais.instagrabber.utils;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.webkit.MimeTypeMap;
|
||||
@ -13,8 +11,6 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.work.Constraints;
|
||||
import androidx.work.Data;
|
||||
import androidx.work.NetworkType;
|
||||
@ -294,7 +290,8 @@ public final class DownloadUtils {
|
||||
final int childPositionIfSingle) {
|
||||
final Map<String, String> map = new HashMap<>();
|
||||
for (final Media media : feedModels) {
|
||||
final File downloadDir = getDownloadDir(context, "@" + media.getUser().getUsername());
|
||||
final User mediaUser = media.getUser();
|
||||
final File downloadDir = getDownloadDir(context, mediaUser == null ? "" : "@" + mediaUser.getUsername());
|
||||
if (downloadDir == null) return;
|
||||
switch (media.getMediaType()) {
|
||||
case MEDIA_TYPE_IMAGE:
|
||||
@ -307,9 +304,8 @@ public final class DownloadUtils {
|
||||
case MEDIA_TYPE_VOICE: {
|
||||
final String url = getUrlOfType(media);
|
||||
String fileName = media.getId();
|
||||
final User user = media.getUser();
|
||||
if (user != null) {
|
||||
fileName = user.getUsername() + "_" + fileName;
|
||||
if (mediaUser != null) {
|
||||
fileName = mediaUser.getUsername() + "_" + fileName;
|
||||
}
|
||||
final File file = getDownloadSaveFile(downloadDir, fileName, url);
|
||||
map.put(url, file.getAbsolutePath());
|
||||
|
Loading…
Reference in New Issue
Block a user