diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java index 8dbe728..9e5ffb2 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java @@ -36,6 +36,7 @@ public class MainActivity extends ActionBarActivity { private static final Logger lg = LoggerFactory.getLogger(MainActivity.class); public static DisplayImageOptions options; + public static DisplayImageOptions rectOptions; private GestureDetectorCompat gestureDetector; private MainActivityState currFrag = MainActivityState.PANORAMIO; private StandardLocationListener locationCallback; @@ -101,11 +102,12 @@ public class MainActivity extends ActionBarActivity { currFrag = fragId == null ? MainActivityState.PANORAMIO : fragId; lg.trace("Set final frag id: {}", fragId); photoInfo = savedInstanceState != null ? (PanoramioImageInfo) savedInstanceState.getSerializable(AppConstants.PHOTO_INFO) : null; - savedConfiguration = savedInstanceState != null && savedInstanceState.getBoolean(AppConstants.SAVED_CONFIG_KEY); + boolean copySavedConfiguration = savedConfiguration = + savedInstanceState != null && savedInstanceState.getBoolean(AppConstants.SAVED_CONFIG_KEY); switchFragment(); updateSwipeHandler(); - if (HelperUtils.checkForLocalicatonEnabled(this)) return; + if (!copySavedConfiguration && HelperUtils.checkForLocalicatonEnabled(this)) return; } @Override @@ -291,7 +293,10 @@ public class MainActivity extends ActionBarActivity { lg.trace("onResume"); String locationProvider = LocationUtils.getDefaultLocation(this); + lg.debug("Selected location provider {} is available", locationProvider); + if (locationProvider != null) { + lg.debug("Requesting location updates"); LocationManager locationService = (LocationManager)getSystemService(LOCATION_SERVICE); locationService.requestLocationUpdates(locationProvider, HelperUtils.fetchGpsUpdateFreq(this), diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/adapters/WikiLocationsAdapter.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/adapters/WikiLocationsAdapter.java index f609f0d..8991490 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/adapters/WikiLocationsAdapter.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/adapters/WikiLocationsAdapter.java @@ -43,7 +43,7 @@ public class WikiLocationsAdapter extends ArrayAdapter { String url = wikiPage.getThumbnail() != null ? wikiPage.getThumbnail() : null; TextView locDistanceInfo = (TextView) itemView.findViewById(R.id.wiki_locs_item_distance); - locDistanceInfo.setText("" + wikiPage.getDistance() / 1000.0 + " km"); + locDistanceInfo.setText(String.format("%.2f km", wikiPage.getDistance() / 1000.0)); imgPreview.setImageBitmap(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.noimage)); if (url != null) { diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java index 425fcee..76a19a9 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java @@ -53,7 +53,7 @@ public class PanoramioShowerFragment extends Fragment { ImageLoader.getInstance().displayImage( imageInfo.getPhotoFileUrl(), (ImageView) inflatedView.findViewById(R.id.photo_container), - MainActivity.options); + MainActivity.rectOptions); photoTitle = (TextView)inflatedView.findViewById(R.id.photo_title); photoTitle.setText(imageInfo.getPhotoTitle()); diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/WikiLocationsFragment.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/WikiLocationsFragment.java index 907411c..59b13a2 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/WikiLocationsFragment.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/WikiLocationsFragment.java @@ -237,6 +237,12 @@ public class WikiLocationsFragment extends Fragment implements Refreshable { } Location location = LocationUtils.getLastKnownLocation(getActivity()); + + if (location == null) { + lg.debug("Location is still not available"); + return; + } + LocationUtils.getGeoCodedLocation(getActivity(), location.getLatitude(), location.getLongitude(), new LocationGeoCoderCallback() { @Override public void callback(int code, String message, String googleStatus, String geocodedLocation) { diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/HelperUtils.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/HelperUtils.java index d6332cd..9603527 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/HelperUtils.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/HelperUtils.java @@ -59,7 +59,8 @@ public class HelperUtils { } public static void initUniversalDownloader(Context ctx) { - MainActivity.options = ImageLoaderUtils.createDefaultOptions(); + MainActivity.options = ImageLoaderUtils.createRoundedOptions(); + MainActivity.rectOptions = ImageLoaderUtils.createRectangularOptions(); initUniversalDownloader(ctx, MainActivity.options); } diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/ImageLoaderUtils.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/ImageLoaderUtils.java index f823bc0..d26a1eb 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/ImageLoaderUtils.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/utils/ImageLoaderUtils.java @@ -2,16 +2,25 @@ package pl.tpolgrabia.urbanexplorer.utils; import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.assist.ImageScaleType; +import com.nostra13.universalimageloader.core.display.CircleBitmapDisplayer; import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; /** * Created by tpolgrabia on 28.08.16. */ public class ImageLoaderUtils { - public static DisplayImageOptions createDefaultOptions() { + public static DisplayImageOptions createRoundedOptions() { return new DisplayImageOptions.Builder() .cacheOnDisc(true).cacheInMemory(true) .imageScaleType(ImageScaleType.EXACTLY) - .displayer(new FadeInBitmapDisplayer(300)).build(); + .displayer(new CircleBitmapDisplayer()).build(); + } + + public static DisplayImageOptions createRectangularOptions() { + return new DisplayImageOptions.Builder() + .cacheOnDisc(true).cacheInMemory(true) + .imageScaleType(ImageScaleType.EXACTLY) + .displayer(new FadeInBitmapDisplayer(300)).build(); + } } diff --git a/app/src/main/res/layout/location_item.xml b/app/src/main/res/layout/location_item.xml index 492b619..ab61f64 100644 --- a/app/src/main/res/layout/location_item.xml +++ b/app/src/main/res/layout/location_item.xml @@ -1,19 +1,28 @@ - - + - + - \ No newline at end of file + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/wiki_locations_item.xml b/app/src/main/res/layout/wiki_locations_item.xml index 71e132f..f51895a 100644 --- a/app/src/main/res/layout/wiki_locations_item.xml +++ b/app/src/main/res/layout/wiki_locations_item.xml @@ -1,31 +1,42 @@ - - + - + - + - + + + + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index dabd1bc..51a9363 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -45,7 +45,7 @@ Ograniczenie promienia Y wyszukiwania w panoramio Ograniczenie promienia Y wyszukiwania w panoramio Ustawienia wyszukiwania w panoramio - Link do serwisu panoramio + Link panoramio Liczba zdjęć panoramio pobierana w czasie zapytania Paczka transferowa zdjęć panoramio Użytkownik