mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Fixed images cannot be saved. Fixed crashes when downloading videos
This commit is contained in:
parent
f5f2acfab1
commit
f109d28c9d
@ -426,22 +426,6 @@ public class ViewImageActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
try {
|
||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
|
||||
File directory = new File(path + "/Infinity/");
|
||||
if(!directory.exists()) {
|
||||
if(!directory.mkdir()) {
|
||||
saveSuccess = false;
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if(directory.isFile()) {
|
||||
if(!directory.delete() && !directory.mkdir()) {
|
||||
saveSuccess = false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Android Q support
|
||||
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
ContentValues values = new ContentValues();
|
||||
@ -478,6 +462,22 @@ public class ViewImageActivity extends AppCompatActivity {
|
||||
values.put(MediaStore.Images.Media.IS_PENDING, 0);
|
||||
resolver.update(item, values, null, null);
|
||||
} else {
|
||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
|
||||
File directory = new File(path + "/Infinity/");
|
||||
if(!directory.exists()) {
|
||||
if(!directory.mkdir()) {
|
||||
saveSuccess = false;
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if(directory.isFile()) {
|
||||
if(!directory.delete() && !directory.mkdir()) {
|
||||
saveSuccess = false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File file = new File(path + "/Infinity/", mImageFileName + ".jpg");
|
||||
int postfix = 1;
|
||||
while(file.exists()) {
|
||||
|
@ -51,6 +51,8 @@ import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
|
||||
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
|
||||
import com.google.android.exoplayer2.util.Util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
|
||||
@ -395,6 +397,20 @@ public class ViewVideoActivity extends AppCompatActivity {
|
||||
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mGifOrVideoFileName);
|
||||
} else {
|
||||
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
|
||||
File directory = new File(path + "/Infinity/");
|
||||
if(!directory.exists()) {
|
||||
if(!directory.mkdir()) {
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mGifOrVideoFileName);
|
||||
}
|
||||
} else {
|
||||
if(directory.isFile()) {
|
||||
if(!directory.delete() && !directory.mkdir()) {
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mGifOrVideoFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES + "/Infinity/", mGifOrVideoFileName);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user