Codacy fixes

This commit is contained in:
maskara 2017-04-02 22:34:42 +05:30
parent 2e063a3dcf
commit c14e2566f5
7 changed files with 58 additions and 27 deletions

View file

@ -12,12 +12,20 @@ import java.util.List;
import fr.free.nrw.commons.R;
public class NearbyAdapter extends ArrayAdapter<Place> {
public List<Place> placesList;
private Context mContext;
private List<Place> placesList;
private Context context;
public List<Place> getPlacesList() {
return placesList;
}
/** Accepts activity context and list of places
* @param context
* @param places
*/
public NearbyAdapter(Context context, List<Place> places) {
super(context, R.layout.item_place, places);
this.mContext = context;
this.context = context;
placesList = places;
}
@ -29,11 +37,12 @@ public class NearbyAdapter extends ArrayAdapter<Place> {
// Check if an existing view is being reused, otherwise inflate the view
if (convertView == null) {
convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_place, parent, false);
convertView = LayoutInflater.from(getContext())
.inflate(R.layout.item_place, parent, false);
}
NearbyViewHolder viewHolder = new NearbyViewHolder(convertView);
viewHolder.bindModel(mContext, place);
viewHolder.bindModel(context, place);
// Return the completed view to render on screen
return convertView;
}

View file

@ -12,10 +12,6 @@ import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.ProgressBar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;
@ -26,6 +22,10 @@ import fr.free.nrw.commons.location.LocationServiceManager;
import static fr.free.nrw.commons.utils.LengthUtils.computeDistanceBetween;
import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class NearbyListFragment extends ListFragment implements TaskListener {
private NearbyAsyncTask nearbyAsyncTask;
@ -166,14 +166,18 @@ public class NearbyListFragment extends ListFragment implements TaskListener {
}
}
@OnItemClick(R.id.listview) void onItemClicked(int position) {
@OnItemClick(R.id.listview)
void onItemClicked(int position) {
Place place = places.get(position);
LatLng placeLatLng = place.location;
double latitude = placeLatLng.latitude;
double longitude = placeLatLng.longitude;
Log.d(TAG, "Item at position " + position + " has coords: Lat: " + latitude + " Long: " + longitude);
Log.d(TAG, "Item at position "
+ position + " has coords: Lat: "
+ latitude + " Long: "
+ longitude);
//Open map app at given position
Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + latitude + "," + longitude);

View file

@ -3,6 +3,8 @@ package fr.free.nrw.commons.nearby;
import android.os.StrictMode;
import android.util.Log;
import fr.free.nrw.commons.location.LatLng;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -10,7 +12,6 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import fr.free.nrw.commons.location.LatLng;
public class NearbyPlaces {