onResume() method for calling registerLocationManager

This commit is contained in:
misaochan 2016-02-08 15:39:42 +13:00
parent e5b746e411
commit 0d188d630c
2 changed files with 13 additions and 10 deletions

View file

@ -38,7 +38,7 @@ public class GPSExtractor {
return gpsPref; return gpsPref;
} }
private void registerLocationManager() { protected void registerLocationManager() {
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
criteria = new Criteria(); criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, true); provider = locationManager.getBestProvider(criteria, true);

View file

@ -34,6 +34,8 @@ public class ShareActivity
implements SingleUploadFragment.OnUploadActionInitiated, implements SingleUploadFragment.OnUploadActionInitiated,
CategorizationFragment.OnCategoriesSaveHandler { CategorizationFragment.OnCategoriesSaveHandler {
private static final String TAG = ShareActivity.class.getName();
private SingleUploadFragment shareView; private SingleUploadFragment shareView;
private CategorizationFragment categorizationFragment; private CategorizationFragment categorizationFragment;
@ -44,17 +46,14 @@ public class ShareActivity
private String mediaUriString; private String mediaUriString;
private Uri mediaUri; private Uri mediaUri;
private Contribution contribution; private Contribution contribution;
private ImageView backgroundImageView; private ImageView backgroundImageView;
private UploadController uploadController; private UploadController uploadController;
private CommonsApplication cacheObj; private CommonsApplication cacheObj;
private boolean cacheFound; private boolean cacheFound;
private static final String TAG = ShareActivity.class.getName(); private GPSExtractor imageObj;
public ShareActivity() { public ShareActivity() {
super(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE); super(WikiAccountAuthenticator.COMMONS_ACCOUNT_TYPE);
@ -197,11 +196,10 @@ public class ShareActivity
String filePath = FileUtils.getPath(this, mediaUri); String filePath = FileUtils.getPath(this, mediaUri);
Log.d(TAG, "Filepath: " + filePath); Log.d(TAG, "Filepath: " + filePath);
if (filePath != null && !filePath.equals("")) { Log.d(TAG, "Calling GPSExtractor");
//extract the coordinates of image in decimal degrees imageObj = new GPSExtractor(filePath, this);
Log.d(TAG, "Calling GPSExtractor");
GPSExtractor imageObj = new GPSExtractor(filePath, this);
if (filePath != null && !filePath.equals("")) {
//Gets image coords if exist, otherwise gets last known coords //Gets image coords if exist, otherwise gets last known coords
String decimalCoords = imageObj.getCoords(); String decimalCoords = imageObj.getCoords();
@ -240,6 +238,11 @@ public class ShareActivity
requestAuthToken(); requestAuthToken();
} }
@Override
public void onResume() {
super.onResume();
imageObj.registerLocationManager();
}
@Override @Override
protected void onDestroy() { protected void onDestroy() {