Skip to content

Commit

Permalink
update(Twitter - Custom Downloader): The numbers from filename now fo…
Browse files Browse the repository at this point in the history
…llows media index from the post.
  • Loading branch information
crimera committed Jul 18, 2024
1 parent 2c8b1bb commit b3ab727
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Build;
import android.widget.LinearLayout;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -276,14 +277,23 @@ public void onClick(DialogInterface dialogInterface, int which) {
ArrayList<HashMap> mData = new ArrayList<HashMap>();
HashMap<String,String> media = mediaData.get(which);
mData.add(media);
downloadMedia(filename,mData);
downloadMedia(filename+"_"+(which+1),mData);
dialogInterface.dismiss();
}
});
builder.setNegativeButton(strRes("piko_pref_native_downloader_download_all"),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialogInterface, int index) {
downloadMedia(filename,mediaData);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
int i = 0;
for (HashMap ignored : mediaData) {
ArrayList<HashMap> mData = new ArrayList<>();
HashMap media = mediaData.get(i);
mData.add(media);
downloadMedia(filename+"_"+(++i),mData);
}

}
dialogInterface.dismiss();
}
});
Expand All @@ -302,7 +312,7 @@ private static void downloadMedia(String filename,ArrayList<HashMap> mediaData){
String mediaUrl = (String)media.get("url");
String ext = (String)media.get("ext");

String updFileName = filename+"_"+String.valueOf(i+1)+"."+ext;
String updFileName = filename+"."+ext;

Utils.downloadFile(mediaUrl,updFileName);
}
Expand Down

0 comments on commit b3ab727

Please sign in to comment.