Minor gui enhancements + minor bug fixes.

master
Tomasz Półgrabia 2016-09-20 22:54:43 +02:00
parent 2a89cb9af4
commit f484a6474a
9 changed files with 81 additions and 40 deletions

View File

@ -36,6 +36,7 @@ public class MainActivity extends ActionBarActivity {
private static final Logger lg = LoggerFactory.getLogger(MainActivity.class); private static final Logger lg = LoggerFactory.getLogger(MainActivity.class);
public static DisplayImageOptions options; public static DisplayImageOptions options;
public static DisplayImageOptions rectOptions;
private GestureDetectorCompat gestureDetector; private GestureDetectorCompat gestureDetector;
private MainActivityState currFrag = MainActivityState.PANORAMIO; private MainActivityState currFrag = MainActivityState.PANORAMIO;
private StandardLocationListener locationCallback; private StandardLocationListener locationCallback;
@ -101,11 +102,12 @@ public class MainActivity extends ActionBarActivity {
currFrag = fragId == null ? MainActivityState.PANORAMIO : fragId; currFrag = fragId == null ? MainActivityState.PANORAMIO : fragId;
lg.trace("Set final frag id: {}", fragId); lg.trace("Set final frag id: {}", fragId);
photoInfo = savedInstanceState != null ? (PanoramioImageInfo) savedInstanceState.getSerializable(AppConstants.PHOTO_INFO) : null; 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(); switchFragment();
updateSwipeHandler(); updateSwipeHandler();
if (HelperUtils.checkForLocalicatonEnabled(this)) return; if (!copySavedConfiguration && HelperUtils.checkForLocalicatonEnabled(this)) return;
} }
@Override @Override
@ -291,7 +293,10 @@ public class MainActivity extends ActionBarActivity {
lg.trace("onResume"); lg.trace("onResume");
String locationProvider = LocationUtils.getDefaultLocation(this); String locationProvider = LocationUtils.getDefaultLocation(this);
lg.debug("Selected location provider {} is available", locationProvider);
if (locationProvider != null) { if (locationProvider != null) {
lg.debug("Requesting location updates");
LocationManager locationService = (LocationManager)getSystemService(LOCATION_SERVICE); LocationManager locationService = (LocationManager)getSystemService(LOCATION_SERVICE);
locationService.requestLocationUpdates(locationProvider, locationService.requestLocationUpdates(locationProvider,
HelperUtils.fetchGpsUpdateFreq(this), HelperUtils.fetchGpsUpdateFreq(this),

View File

@ -43,7 +43,7 @@ public class WikiLocationsAdapter extends ArrayAdapter<WikiAppObject> {
String url = wikiPage.getThumbnail() != null ? wikiPage.getThumbnail() : null; String url = wikiPage.getThumbnail() != null ? wikiPage.getThumbnail() : null;
TextView locDistanceInfo = (TextView) itemView.findViewById(R.id.wiki_locs_item_distance); 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)); imgPreview.setImageBitmap(BitmapFactory.decodeResource(getContext().getResources(), R.drawable.noimage));
if (url != null) { if (url != null) {

View File

@ -53,7 +53,7 @@ public class PanoramioShowerFragment extends Fragment {
ImageLoader.getInstance().displayImage( ImageLoader.getInstance().displayImage(
imageInfo.getPhotoFileUrl(), imageInfo.getPhotoFileUrl(),
(ImageView) inflatedView.findViewById(R.id.photo_container), (ImageView) inflatedView.findViewById(R.id.photo_container),
MainActivity.options); MainActivity.rectOptions);
photoTitle = (TextView)inflatedView.findViewById(R.id.photo_title); photoTitle = (TextView)inflatedView.findViewById(R.id.photo_title);
photoTitle.setText(imageInfo.getPhotoTitle()); photoTitle.setText(imageInfo.getPhotoTitle());

View File

@ -237,6 +237,12 @@ public class WikiLocationsFragment extends Fragment implements Refreshable {
} }
Location location = LocationUtils.getLastKnownLocation(getActivity()); 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() { LocationUtils.getGeoCodedLocation(getActivity(), location.getLatitude(), location.getLongitude(), new LocationGeoCoderCallback() {
@Override @Override
public void callback(int code, String message, String googleStatus, String geocodedLocation) { public void callback(int code, String message, String googleStatus, String geocodedLocation) {

View File

@ -59,7 +59,8 @@ public class HelperUtils {
} }
public static void initUniversalDownloader(Context ctx) { public static void initUniversalDownloader(Context ctx) {
MainActivity.options = ImageLoaderUtils.createDefaultOptions(); MainActivity.options = ImageLoaderUtils.createRoundedOptions();
MainActivity.rectOptions = ImageLoaderUtils.createRectangularOptions();
initUniversalDownloader(ctx, MainActivity.options); initUniversalDownloader(ctx, MainActivity.options);
} }

View File

@ -2,16 +2,25 @@ package pl.tpolgrabia.urbanexplorer.utils;
import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.assist.ImageScaleType; import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.CircleBitmapDisplayer;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer; import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
/** /**
* Created by tpolgrabia on 28.08.16. * Created by tpolgrabia on 28.08.16.
*/ */
public class ImageLoaderUtils { public class ImageLoaderUtils {
public static DisplayImageOptions createDefaultOptions() { public static DisplayImageOptions createRoundedOptions() {
return new DisplayImageOptions.Builder() return new DisplayImageOptions.Builder()
.cacheOnDisc(true).cacheInMemory(true) .cacheOnDisc(true).cacheInMemory(true)
.imageScaleType(ImageScaleType.EXACTLY) .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();
} }
} }

View File

@ -1,19 +1,28 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<ImageView <LinearLayout android:layout_width="match_parent"
android:id="@+id/photo_img" android:layout_height="wrap_content"
android:layout_width="80dp" android:layout_marginLeft="8dp"
android:layout_height="80dp" android:layout_marginTop="8dp"
android:layout_marginRight="10dp"/> android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<TextView <ImageView
android:id="@+id/location_description" android:id="@+id/photo_img"
android:layout_width="wrap_content" android:layout_width="80dp"
android:layout_height="wrap_content" android:layout_height="80dp"
android:text="@string/test_string"/> android:layout_marginRight="10dp"/>
</LinearLayout> <TextView
android:id="@+id/location_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_string"/>
</LinearLayout>
</FrameLayout>

View File

@ -1,31 +1,42 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ImageView android:id="@+id/wiki_locs_item_img_preview" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp" android:orientation="horizontal"
android:layout_height="120dp" android:layout_width="match_parent"
android:layout_marginRight="10dp"/> android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp">
<LinearLayout android:id="@+id/wiki_locs_item_desc_container" <ImageView android:id="@+id/wiki_locs_item_img_preview"
android:layout_width="0dp" android:layout_width="120dp"
android:layout_height="wrap_content" android:layout_height="120dp"
android:layout_weight="1" android:layout_marginRight="10dp"/>
android:orientation="vertical">
<TextView android:id="@+id/wiki_locs_item_title" <LinearLayout android:id="@+id/wiki_locs_item_desc_container"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/wiki_location_fill_title" /> android:layout_weight="1"
android:orientation="vertical">
<TextView android:id="@+id/wiki_locs_item_distance" <TextView android:id="@+id/wiki_locs_item_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/wiki_location_fill_distance" /> android:text="@string/wiki_location_fill_title"/>
<TextView android:id="@+id/wiki_locs_item_distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wiki_location_fill_distance"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </FrameLayout>

View File

@ -45,7 +45,7 @@
<string name="panoramio_radiusy_summary">Ograniczenie promienia Y wyszukiwania w panoramio</string> <string name="panoramio_radiusy_summary">Ograniczenie promienia Y wyszukiwania w panoramio</string>
<string name="panoramio_radiusy_title">Ograniczenie promienia Y wyszukiwania w panoramio</string> <string name="panoramio_radiusy_title">Ograniczenie promienia Y wyszukiwania w panoramio</string>
<string name="panoramio_search_settings">Ustawienia wyszukiwania w panoramio</string> <string name="panoramio_search_settings">Ustawienia wyszukiwania w panoramio</string>
<string name="panoramio_url">Link do serwisu panoramio</string> <string name="panoramio_url">Link panoramio</string>
<string name="panoramio_bulk_size_summary">Liczba zdjęć panoramio pobierana w czasie zapytania</string> <string name="panoramio_bulk_size_summary">Liczba zdjęć panoramio pobierana w czasie zapytania</string>
<string name="panoramio_bulk_size_title">Paczka transferowa zdjęć panoramio</string> <string name="panoramio_bulk_size_title">Paczka transferowa zdjęć panoramio</string>
<string name="login">Użytkownik</string> <string name="login">Użytkownik</string>