[Lint] Remove class variables to local

This commit is contained in:
Dinu Kumarasiri 2017-05-20 11:37:04 +02:00
parent 8f5be5a434
commit 83957bae06
10 changed files with 23 additions and 35 deletions

View file

@ -1,7 +1,5 @@
package fr.free.nrw.commons; package fr.free.nrw.commons;
import fr.free.nrw.commons.location.LatLng;
import org.mediawiki.api.ApiResult; import org.mediawiki.api.ApiResult;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
@ -22,6 +20,7 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import fr.free.nrw.commons.location.LatLng;
import timber.log.Timber; import timber.log.Timber;
/** /**
@ -32,12 +31,10 @@ import timber.log.Timber;
*/ */
public class MediaDataExtractor { public class MediaDataExtractor {
private boolean fetched; private boolean fetched;
private boolean processed;
private String filename; private String filename;
private ArrayList<String> categories; private ArrayList<String> categories;
private Map<String, String> descriptions; private Map<String, String> descriptions;
private String author;
private Date date; private Date date;
private String license; private String license;
private String coordinates; private String coordinates;
@ -51,7 +48,7 @@ public class MediaDataExtractor {
categories = new ArrayList<>(); categories = new ArrayList<>();
descriptions = new HashMap<>(); descriptions = new HashMap<>();
fetched = false; fetched = false;
processed = false; boolean processed = false;
this.licenseList = licenseList; this.licenseList = licenseList;
} }
@ -122,7 +119,7 @@ public class MediaDataExtractor {
descriptions = getMultilingualText(descriptionNode); descriptions = getMultilingualText(descriptionNode);
Node authorNode = findTemplateParameter(templateNode, "author"); Node authorNode = findTemplateParameter(templateNode, "author");
author = getFlatText(authorNode); String author = getFlatText(authorNode);
} }
Node coordinateTemplateNode = findTemplate(doc.getDocumentElement(), "location"); Node coordinateTemplateNode = findTemplate(doc.getDocumentElement(), "location");

View file

@ -10,7 +10,6 @@ import butterknife.ButterKnife;
import fr.free.nrw.commons.theme.BaseActivity; import fr.free.nrw.commons.theme.BaseActivity;
public class WelcomeActivity extends BaseActivity { public class WelcomeActivity extends BaseActivity {
private WelcomePagerAdapter adapter;
@BindView(R.id.welcomePager) ViewPager pager; @BindView(R.id.welcomePager) ViewPager pager;
@BindView(R.id.welcomePagerIndicator) CirclePageIndicator indicator; @BindView(R.id.welcomePagerIndicator) CirclePageIndicator indicator;
@ -29,7 +28,7 @@ public class WelcomeActivity extends BaseActivity {
} }
private void setUpAdapter() { private void setUpAdapter() {
adapter = new WelcomePagerAdapter(this); WelcomePagerAdapter adapter = new WelcomePagerAdapter(this);
pager.setAdapter(adapter); pager.setAdapter(adapter);
indicator.setViewPager(pager); indicator.setViewPager(pager);
} }

View file

@ -14,7 +14,6 @@ public class CacheController {
private double x, y; private double x, y;
private QuadTree<List<String>> quadTree; private QuadTree<List<String>> quadTree;
private Point<List<String>>[] pointsFound;
private double xMinus, xPlus, yMinus, yPlus; private double xMinus, xPlus, yMinus, yPlus;
private static final int EARTH_RADIUS = 6378137; private static final int EARTH_RADIUS = 6378137;
@ -42,6 +41,7 @@ public class CacheController {
} }
public List<String> findCategory() { public List<String> findCategory() {
Point<List<String>>[] pointsFound;
//Convert decLatitude and decLongitude to a coordinate offset range //Convert decLatitude and decLongitude to a coordinate offset range
convertCoordRange(); convertCoordRange();
pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus); pointsFound = quadTree.searchWithin(xMinus, yMinus, xPlus, yPlus);

View file

@ -14,13 +14,13 @@ import fr.free.nrw.commons.R;
public class CategoriesAdapter extends BaseAdapter { public class CategoriesAdapter extends BaseAdapter {
private Context context;
private LayoutInflater mInflater; private LayoutInflater mInflater;
private ArrayList<CategorizationFragment.CategoryItem> items; private ArrayList<CategorizationFragment.CategoryItem> items;
public CategoriesAdapter(Context context, ArrayList<CategorizationFragment.CategoryItem> items) { public CategoriesAdapter(Context context, ArrayList<CategorizationFragment.CategoryItem> items) {
this.context = context; Context localcontext;
localcontext = context;
this.items = items; this.items = items;
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
} }

View file

@ -32,16 +32,15 @@ import fr.free.nrw.commons.theme.NavigationBaseActivity;
import fr.free.nrw.commons.utils.UriSerializer; import fr.free.nrw.commons.utils.UriSerializer;
import timber.log.Timber; import timber.log.Timber;
public class NearbyActivity extends NavigationBaseActivity { public class NearbyActivity extends NavigationBaseActivity {
@BindView(R.id.progressBar) @BindView(R.id.progressBar)
ProgressBar progressBar; ProgressBar progressBar;
private boolean isMapViewActive = false; private boolean isMapViewActive = false;
private LocationServiceManager locationManager; private LocationServiceManager locationManager;
private LatLng curLatLang; private LatLng curLatLang;
private Gson gson;
private String gsonPlaceList;
private String gsonCurLatLng;
private Bundle bundle; private Bundle bundle;
private NearbyAsyncTask nearbyAsyncTask; private NearbyAsyncTask nearbyAsyncTask;
@ -203,11 +202,11 @@ public class NearbyActivity extends NavigationBaseActivity {
return; return;
} }
gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(Uri.class, new UriSerializer()) .registerTypeAdapter(Uri.class, new UriSerializer())
.create(); .create();
gsonPlaceList = gson.toJson(placeList); String gsonPlaceList = gson.toJson(placeList);
gsonCurLatLng = gson.toJson(curLatLang); String gsonCurLatLng = gson.toJson(curLatLang);
if (placeList.size() == 0) { if (placeList.size() == 0) {
int duration = Toast.LENGTH_SHORT; int duration = Toast.LENGTH_SHORT;

View file

@ -24,9 +24,7 @@ import fr.free.nrw.commons.utils.UriDeserializer;
import timber.log.Timber; import timber.log.Timber;
public class NearbyListFragment extends ListFragment { public class NearbyListFragment extends ListFragment {
private Gson gson;
private List<Place> placeList; private List<Place> placeList;
private LatLng curLatLng;
@BindView(R.id.listView) ListView listview; @BindView(R.id.listView) ListView listview;
@ -60,7 +58,7 @@ public class NearbyListFragment extends ListFragment {
// Check that this is the first time view is created, // Check that this is the first time view is created,
// to avoid double list when screen orientation changed // to avoid double list when screen orientation changed
Bundle bundle = this.getArguments(); Bundle bundle = this.getArguments();
gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(Uri.class, new UriDeserializer()) .registerTypeAdapter(Uri.class, new UriDeserializer())
.create(); .create();
if (bundle != null) { if (bundle != null) {
@ -69,7 +67,7 @@ public class NearbyListFragment extends ListFragment {
Type listType = new TypeToken<List<Place>>() {}.getType(); Type listType = new TypeToken<List<Place>>() {}.getType();
placeList = gson.fromJson(gsonPlaceList, listType); placeList = gson.fromJson(gsonPlaceList, listType);
Type curLatLngType = new TypeToken<LatLng>() {}.getType(); Type curLatLngType = new TypeToken<LatLng>() {}.getType();
curLatLng = gson.fromJson(gsonLatLng, curLatLngType); LatLng curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
placeList = NearbyController.loadAttractionsFromLocationToPlaces(curLatLng, placeList); placeList = NearbyController.loadAttractionsFromLocationToPlaces(curLatLng, placeList);
} }
if (savedInstanceState == null) { if (savedInstanceState == null) {

View file

@ -31,8 +31,6 @@ import fr.free.nrw.commons.utils.UriDeserializer;
public class NearbyMapFragment extends android.support.v4.app.Fragment { public class NearbyMapFragment extends android.support.v4.app.Fragment {
private MapView mapView; private MapView mapView;
private Gson gson;
private List<Place> placeList;
private List<NearbyBaseMarker> baseMarkerOptionses; private List<NearbyBaseMarker> baseMarkerOptionses;
private fr.free.nrw.commons.location.LatLng curLatLng; private fr.free.nrw.commons.location.LatLng curLatLng;
@ -44,14 +42,14 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Bundle bundle = this.getArguments(); Bundle bundle = this.getArguments();
gson = new GsonBuilder() Gson gson = new GsonBuilder()
.registerTypeAdapter(Uri.class, new UriDeserializer()) .registerTypeAdapter(Uri.class, new UriDeserializer())
.create(); .create();
if (bundle != null) { if (bundle != null) {
String gsonPlaceList = bundle.getString("PlaceList"); String gsonPlaceList = bundle.getString("PlaceList");
String gsonLatLng = bundle.getString("CurLatLng"); String gsonLatLng = bundle.getString("CurLatLng");
Type listType = new TypeToken<List<Place>>() {}.getType(); Type listType = new TypeToken<List<Place>>() {}.getType();
placeList = gson.fromJson(gsonPlaceList, listType); List<Place> placeList = gson.fromJson(gsonPlaceList, listType);
Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {}.getType(); Type curLatLngType = new TypeToken<fr.free.nrw.commons.location.LatLng>() {}.getType();
curLatLng = gson.fromJson(gsonLatLng, curLatLngType); curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
baseMarkerOptionses = NearbyController baseMarkerOptionses = NearbyController

View file

@ -30,8 +30,7 @@ public class GPSExtractor {
public boolean imageCoordsExists; public boolean imageCoordsExists;
private MyLocationListener myLocationListener; private MyLocationListener myLocationListener;
private LocationManager locationManager; private LocationManager locationManager;
private String provider;
private Criteria criteria;
public GPSExtractor(String filePath, Context context){ public GPSExtractor(String filePath, Context context){
this.filePath = filePath; this.filePath = filePath;
@ -54,8 +53,8 @@ public class GPSExtractor {
*/ */
protected void registerLocationManager() { protected void registerLocationManager() {
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
criteria = new Criteria(); Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, true); String provider = locationManager.getBestProvider(criteria, true);
myLocationListener = new MyLocationListener(); myLocationListener = new MyLocationListener();
try { try {

View file

@ -33,7 +33,6 @@ public class MwVolleyApi {
private static RequestQueue REQUEST_QUEUE; private static RequestQueue REQUEST_QUEUE;
private static final Gson GSON = new GsonBuilder().create(); private static final Gson GSON = new GsonBuilder().create();
private Context context; private Context context;
private String coordsLog;
protected static Set<String> categorySet; protected static Set<String> categorySet;
private static List<String> categoryList; private static List<String> categoryList;
@ -56,7 +55,7 @@ public class MwVolleyApi {
} }
public void request(String coords) { public void request(String coords) {
coordsLog = coords; String coordsLog = coords;
String apiUrl = buildUrl(coords); String apiUrl = buildUrl(coords);
Timber.d("URL: %s", apiUrl); Timber.d("URL: %s", apiUrl);

View file

@ -47,7 +47,6 @@ public class ShareActivity
implements SingleUploadFragment.OnUploadActionInitiated, implements SingleUploadFragment.OnUploadActionInitiated,
CategorizationFragment.OnCategoriesSaveHandler { CategorizationFragment.OnCategoriesSaveHandler {
private SingleUploadFragment shareView;
private CategorizationFragment categorizationFragment; private CategorizationFragment categorizationFragment;
private CommonsApplication app; private CommonsApplication app;
@ -59,13 +58,13 @@ public class ShareActivity
private Uri mediaUri; private Uri mediaUri;
private Contribution contribution; private Contribution contribution;
private SimpleDraweeView backgroundImageView; private SimpleDraweeView backgroundImageView;
private UploadController uploadController; private UploadController uploadController;
private CommonsApplication cacheObj; private CommonsApplication cacheObj;
private boolean cacheFound; private boolean cacheFound;
private GPSExtractor imageObj; private GPSExtractor imageObj;
private String filePath;
private String decimalCoords; private String decimalCoords;
private boolean useNewPermissions = false; private boolean useNewPermissions = false;
@ -194,7 +193,7 @@ public class ShareActivity
protected void onAuthCookieAcquired(String authCookie) { protected void onAuthCookieAcquired(String authCookie) {
app.getMWApi().setAuthCookie(authCookie); app.getMWApi().setAuthCookie(authCookie);
shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView"); SingleUploadFragment shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView");
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization"); categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
if(shareView == null && categorizationFragment == null) { if(shareView == null && categorizationFragment == null) {
shareView = new SingleUploadFragment(); shareView = new SingleUploadFragment();
@ -375,7 +374,7 @@ public class ShareActivity
* @param gpsEnabled * @param gpsEnabled
*/ */
public void getFileMetadata(boolean gpsEnabled) { public void getFileMetadata(boolean gpsEnabled) {
filePath = FileUtils.getPath(this, mediaUri); String filePath = FileUtils.getPath(this, mediaUri);
Timber.d("Filepath: %s", filePath); Timber.d("Filepath: %s", filePath);
Timber.d("Calling GPSExtractor"); Timber.d("Calling GPSExtractor");
if(imageObj == null) { if(imageObj == null) {