[Lint] Remove class variables to local

This commit is contained in:
Dinu Kumarasiri 2017-05-20 11:37:04 +02:00
parent 6b51df51f8
commit 7ad1cf294f
10 changed files with 32 additions and 56 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -2,11 +2,9 @@ package fr.free.nrw.commons.nearby;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.location.LocationManager;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
@ -20,22 +18,20 @@ import android.view.View;
import android.widget.ProgressBar;
import android.widget.Toast;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.UriSerializer;
import fr.free.nrw.commons.R;
import timber.log.Timber;
import java.util.List;
public class NearbyActivity extends BaseActivity {
@BindView(R.id.progressBar)
ProgressBar progressBar;
@ -43,9 +39,6 @@ public class NearbyActivity extends BaseActivity {
private LocationServiceManager locationManager;
private LatLng curLatLang;
private Gson gson;
private String gsonPlaceList;
private String gsonCurLatLng;
private Bundle bundle;
private NearbyAsyncTask nearbyAsyncTask;
@ -201,11 +194,11 @@ public class NearbyActivity extends BaseActivity {
return;
}
gson = new GsonBuilder()
Gson gson = new GsonBuilder()
.registerTypeAdapter(Uri.class, new UriSerializer())
.create();
gsonPlaceList = gson.toJson(placeList);
gsonCurLatLng = gson.toJson(curLatLang);
String gsonPlaceList = gson.toJson(placeList);
String gsonCurLatLng = gson.toJson(curLatLang);
if (placeList.size() == 0) {
int duration = Toast.LENGTH_SHORT;

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.nearby;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
@ -9,28 +8,23 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UriDeserializer;
import java.lang.reflect.Type;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UriDeserializer;
import timber.log.Timber;
public class NearbyListFragment extends ListFragment {
private Gson gson;
private List<Place> placeList;
private LatLng curLatLng;
@BindView(R.id.listView) ListView listview;
@ -64,7 +58,7 @@ public class NearbyListFragment extends ListFragment {
// Check that this is the first time view is created,
// to avoid double list when screen orientation changed
Bundle bundle = this.getArguments();
gson = new GsonBuilder()
Gson gson = new GsonBuilder()
.registerTypeAdapter(Uri.class, new UriDeserializer())
.create();
if (bundle != null) {
@ -73,7 +67,7 @@ public class NearbyListFragment extends ListFragment {
Type listType = new TypeToken<List<Place>>() {}.getType();
placeList = gson.fromJson(gsonPlaceList, listType);
Type curLatLngType = new TypeToken<LatLng>() {}.getType();
curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
LatLng curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
placeList = NearbyController.loadAttractionsFromLocationToPlaces(curLatLng, placeList);
}
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 {
private MapView mapView;
private Gson gson;
private List<Place> placeList;
private List<NearbyBaseMarker> baseMarkerOptionses;
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) {
super.onCreate(savedInstanceState);
Bundle bundle = this.getArguments();
gson = new GsonBuilder()
Gson gson = new GsonBuilder()
.registerTypeAdapter(Uri.class, new UriDeserializer())
.create();
if (bundle != null) {
String gsonPlaceList = bundle.getString("PlaceList");
String gsonLatLng = bundle.getString("CurLatLng");
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();
curLatLng = gson.fromJson(gsonLatLng, curLatLngType);
baseMarkerOptionses = NearbyController

View file

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

View file

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

View file

@ -47,7 +47,6 @@ public class ShareActivity
implements SingleUploadFragment.OnUploadActionInitiated,
CategorizationFragment.OnCategoriesSaveHandler {
private SingleUploadFragment shareView;
private CategorizationFragment categorizationFragment;
private CommonsApplication app;
@ -58,14 +57,12 @@ public class ShareActivity
private Uri mediaUri;
private Contribution contribution;
private ImageView backgroundImageView;
private UploadController uploadController;
private CommonsApplication cacheObj;
private boolean cacheFound;
private GPSExtractor imageObj;
private String filePath;
private String decimalCoords;
private boolean useNewPermissions = false;
@ -190,7 +187,7 @@ public class ShareActivity
protected void onAuthCookieAcquired(String authCookie) {
app.getApi().setAuthCookie(authCookie);
shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView");
SingleUploadFragment shareView = (SingleUploadFragment) getSupportFragmentManager().findFragmentByTag("shareView");
categorizationFragment = (CategorizationFragment) getSupportFragmentManager().findFragmentByTag("categorization");
if(shareView == null && categorizationFragment == null) {
shareView = new SingleUploadFragment();
@ -216,7 +213,7 @@ public class ShareActivity
setContentView(R.layout.activity_share);
app = (CommonsApplication)this.getApplicationContext();
backgroundImageView = (ImageView)findViewById(R.id.backgroundImage);
ImageView backgroundImageView = (ImageView)findViewById(R.id.backgroundImage);
//Receive intent from ContributionController.java when user selects picture to upload
Intent intent = getIntent();
@ -370,7 +367,7 @@ public class ShareActivity
* @param gpsEnabled
*/
public void getFileMetadata(boolean gpsEnabled) {
filePath = FileUtils.getPath(this, mediaUri);
String filePath = FileUtils.getPath(this, mediaUri);
Timber.d("Filepath: %s", filePath);
Timber.d("Calling GPSExtractor");
if(imageObj == null) {