Fix Codacy issues

This commit is contained in:
Neslihan 2017-05-13 15:07:30 +03:00
parent fc2557d47f
commit 2dafd88a6c
6 changed files with 31 additions and 18 deletions

View file

@ -10,24 +10,24 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import butterknife.BindView;
import butterknife.ButterKnife;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; 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.LatLng;
import fr.free.nrw.commons.location.LocationServiceManager; import fr.free.nrw.commons.location.LocationServiceManager;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.theme.BaseActivity; import fr.free.nrw.commons.theme.BaseActivity;
import fr.free.nrw.commons.utils.UriSerializer; import fr.free.nrw.commons.utils.UriSerializer;
import java.util.List;
public class NearbyActivity extends BaseActivity { public class NearbyActivity extends BaseActivity {
@BindView(R.id.progressBar) @BindView(R.id.progressBar)
ProgressBar progressBar; ProgressBar progressBar;
private boolean isMapViewActive = false; private boolean isMapViewActive = false;
//public List<Place> placeList;
private LocationServiceManager locationManager; private LocationServiceManager locationManager;
private LatLng curLatLang; private LatLng curLatLang;
@ -153,6 +153,9 @@ public class NearbyActivity extends BaseActivity {
} }
} }
/**
* Calls fragment for map view
*/
public void setMapFragment() { public void setMapFragment() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
NearbyMapFragment fragment = new NearbyMapFragment(); NearbyMapFragment fragment = new NearbyMapFragment();
@ -161,6 +164,9 @@ public class NearbyActivity extends BaseActivity {
ft.commit(); ft.commit();
} }
/**
* Calls fragment for list view
*/
public void setListFragment() { public void setListFragment() {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
NearbyListFragment fragment = new NearbyListFragment(); NearbyListFragment fragment = new NearbyListFragment();

View file

@ -26,6 +26,12 @@ import timber.log.Timber;
public class NearbyController { public class NearbyController {
private static final int MAX_RESULTS = 1000; private static final int MAX_RESULTS = 1000;
/**
* Prepares Place list to make their distance information update later.
* @param curLatLng current location for user
* @param context context
* @return Place list without distance information
*/
public static List<Place> loadAttractionsFromLocation(LatLng curLatLng, Context context) { public static List<Place> loadAttractionsFromLocation(LatLng curLatLng, Context context) {
Timber.d("Loading attractions near %s", curLatLng); Timber.d("Loading attractions near %s", curLatLng);
if (curLatLng == null) { if (curLatLng == null) {
@ -62,7 +68,6 @@ public class NearbyController {
* @param placeList list of nearby places in Place data type * @param placeList list of nearby places in Place data type
* @return Place list that holds nearby places * @return Place list that holds nearby places
*/ */
public static List<Place> loadAttractionsFromLocationToPlaces( public static List<Place> loadAttractionsFromLocationToPlaces(
LatLng curLatLng, LatLng curLatLng,
List<Place> placeList) { List<Place> placeList) {
@ -80,7 +85,7 @@ public class NearbyController {
* @param placeList list of nearby places in Place data type * @param placeList list of nearby places in Place data type
* @return BaseMarkerOprions list that holds nearby places * @return BaseMarkerOprions list that holds nearby places
*/ */
public static List<BaseMarkerOptions> loadAttractionsFromLocationToBaseMarkerOptions ( public static List<BaseMarkerOptions> loadAttractionsFromLocationToBaseMarkerOptions(
LatLng curLatLng, LatLng curLatLng,
List<Place> placeList) { List<Place> placeList) {
List<BaseMarkerOptions> baseMarkerOptionses = new ArrayList<>(); List<BaseMarkerOptions> baseMarkerOptionses = new ArrayList<>();

View file

@ -9,19 +9,22 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ListView; import android.widget.ListView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnItemClick;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
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.R;
import fr.free.nrw.commons.location.LatLng; import fr.free.nrw.commons.location.LatLng;
import fr.free.nrw.commons.utils.UriDeserializer; import fr.free.nrw.commons.utils.UriDeserializer;
import java.lang.reflect.Type;
import java.util.List;
import timber.log.Timber; import timber.log.Timber;
public class NearbyListFragment extends ListFragment { public class NearbyListFragment extends ListFragment {
@ -66,7 +69,7 @@ public class NearbyListFragment extends ListFragment {
gson = new GsonBuilder() 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();

View file

@ -46,7 +46,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
gson = new GsonBuilder() 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();

View file

@ -5,7 +5,7 @@ import android.net.Uri;
import fr.free.nrw.commons.location.LatLng; import fr.free.nrw.commons.location.LatLng;
public class Place{ public class Place {
public final String name; public final String name;
public final String description; public final String description;

View file

@ -1,6 +1,5 @@
package fr.free.nrw.commons.utils; package fr.free.nrw.commons.utils;
import android.net.Uri; import android.net.Uri;
import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializationContext;