mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 20:37:12 +01:00
Fix IllegalArgumentException when downloading media.
This commit is contained in:
parent
bedcf6d0b6
commit
eabbabb2b2
@ -14,6 +14,8 @@ import androidx.browser.customtabs.CustomTabColorSchemeParams;
|
||||
import androidx.browser.customtabs.CustomTabsIntent;
|
||||
import androidx.browser.customtabs.CustomTabsService;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -88,7 +90,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
if (path.endsWith("jpg") || path.endsWith("png")) {
|
||||
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
|
||||
String url = uri.toString();
|
||||
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||
String fileName = FilenameUtils.getName(path);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, url);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, fileName);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, fileName);
|
||||
@ -96,7 +98,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
} else if (path.endsWith("gif")) {
|
||||
Intent intent = new Intent(this, ViewImageOrGifActivity.class);
|
||||
String url = uri.toString();
|
||||
String fileName = url.substring(url.lastIndexOf('/') + 1);
|
||||
String fileName = FilenameUtils.getName(path);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_GIF_URL_KEY, url);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, fileName);
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_POST_TITLE_KEY, fileName);
|
||||
|
@ -48,6 +48,8 @@ import com.google.android.material.snackbar.Snackbar;
|
||||
import com.thefuntasty.hauler.DragDirection;
|
||||
import com.thefuntasty.hauler.HaulerView;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -289,7 +291,7 @@ public class ViewVideoActivity extends AppCompatActivity {
|
||||
}
|
||||
} else if (videoType == VIDEO_TYPE_DIRECT) {
|
||||
videoDownloadUrl = mVideoUri.toString();
|
||||
videoFileName = videoDownloadUrl.substring(videoDownloadUrl.lastIndexOf('/') + 1);
|
||||
videoFileName = FilenameUtils.getName(videoDownloadUrl);
|
||||
// Produces DataSource instances through which media data is loaded.
|
||||
dataSourceFactory = new DefaultHttpDataSourceFactory(Util.getUserAgent(this, "Infinity"));
|
||||
// Prepare the player with the source.
|
||||
|
Loading…
Reference in New Issue
Block a user