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);
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),

View File

@ -43,7 +43,7 @@ public class WikiLocationsAdapter extends ArrayAdapter<WikiAppObject> {
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) {

View File

@ -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());

View File

@ -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) {

View File

@ -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);
}

View File

@ -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 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,9 +1,17 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/photo_img"
android:layout_width="80dp"
@ -15,5 +23,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_string"/>
</LinearLayout>
</FrameLayout>

View File

@ -1,8 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:layout_marginLeft="8dp"
android:layout_marginTop="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp">
<ImageView android:id="@+id/wiki_locs_item_img_preview"
android:layout_width="120dp"
@ -29,3 +38,5 @@
</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_title">Ograniczenie promienia Y 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_title">Paczka transferowa zdjęć panoramio</string>
<string name="login">Użytkownik</string>