Remove prefs var in GPSExtractor

This commit is contained in:
misaochan 2018-06-23 20:04:47 +10:00
parent fe3dda18ce
commit be5c05435e
3 changed files with 9 additions and 12 deletions

View file

@ -106,12 +106,12 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse {
ParcelFileDescriptor descriptor = contentResolver.openFileDescriptor(mediaUri, "r");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (descriptor != null) {
imageObj = new GPSExtractor(descriptor.getFileDescriptor(), prefs);
imageObj = new GPSExtractor(descriptor.getFileDescriptor());
}
} else {
String filePath = getPathOfMediaOrCopy();
if (filePath != null) {
imageObj = new GPSExtractor(filePath, prefs);
imageObj = new GPSExtractor(filePath);
}
}
@ -161,11 +161,11 @@ public class FileProcessor implements SimilarImageDialogFragment.onResponse {
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (descriptor != null) {
tempImageObj = new GPSExtractor(descriptor.getFileDescriptor(), prefs);
tempImageObj = new GPSExtractor(descriptor.getFileDescriptor());
}
} else {
if (filePath != null) {
tempImageObj = new GPSExtractor(file.getAbsolutePath(), prefs);
tempImageObj = new GPSExtractor(file.getAbsolutePath());
}
}

View file

@ -16,8 +16,7 @@ import timber.log.Timber;
* is uploaded, extract latitude and longitude from EXIF data of image.
*/
public class GPSExtractor {
private SharedPreferences prefs;
private ExifInterface exif;
private double decLatitude;
private double decLongitude;
@ -28,8 +27,7 @@ public class GPSExtractor {
* @param fileDescriptor the file descriptor of the image
*/
@RequiresApi(24)
public GPSExtractor(@NonNull FileDescriptor fileDescriptor, SharedPreferences prefs) {
this.prefs = prefs;
public GPSExtractor(@NonNull FileDescriptor fileDescriptor) {
try {
exif = new ExifInterface(fileDescriptor);
} catch (IOException | IllegalArgumentException e) {
@ -42,8 +40,7 @@ public class GPSExtractor {
* @param path file path of the image
*
*/
public GPSExtractor(@NonNull String path, SharedPreferences prefs) {
this.prefs = prefs;
public GPSExtractor(@NonNull String path) {
try {
exif = new ExifInterface(path);
} catch (IOException | IllegalArgumentException e) {

View file

@ -329,12 +329,12 @@ public class MultipleShareActivity extends AuthenticatedActivity
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
ParcelFileDescriptor fd = getContentResolver().openFileDescriptor(imageUri,"r");
if (fd != null) {
gpsExtractor = new GPSExtractor(fd.getFileDescriptor(), prefs);
gpsExtractor = new GPSExtractor(fd.getFileDescriptor());
}
} else {
String filePath = FileUtils.getPath(this,imageUri);
if (filePath != null) {
gpsExtractor = new GPSExtractor(filePath, prefs);
gpsExtractor = new GPSExtractor(filePath);
}
}