diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java
index cb14140..a72565f 100644
--- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java
+++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java
@@ -1,25 +1,25 @@
package pl.tpolgrabia.urbanexplorer;
-import android.content.Intent;
-import android.location.LocationManager;
import android.os.Bundle;
-import android.provider.Settings;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.ActionBarActivity;
-import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
-import android.widget.Toast;
import com.nostra13.universalimageloader.cache.memory.impl.WeakMemoryCache;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
import com.nostra13.universalimageloader.core.assist.ImageScaleType;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;
+import pl.tpolgrabia.urbanexplorer.dto.PanoramioImageInfo;
import pl.tpolgrabia.urbanexplorer.fragments.HomeFragment;
+import pl.tpolgrabia.urbanexplorer.fragments.PanoramioShowerFragment;
public class MainActivity extends ActionBarActivity {
private static final int LOCATION_SETTINGS_REQUEST_ID = 1;
private static final String CLASS_TAG = MainActivity.class.getSimpleName();
+ private static final String PHOTO_BACKSTACK = "PHOTO_BACKSTACK";
public static DisplayImageOptions options;
@Override
@@ -45,6 +45,11 @@ public class MainActivity extends ActionBarActivity {
ImageLoader.getInstance().init(config);
+ getSupportFragmentManager()
+ .beginTransaction()
+ .add(R.id.fragments, new HomeFragment())
+ .commit();
+
}
@Override
@@ -57,4 +62,25 @@ public class MainActivity extends ActionBarActivity {
return super.onOptionsItemSelected(item);
}
}
+
+ public void switchToPhoto(PanoramioImageInfo photoInfo) {
+ FragmentManager fragmentManager = getSupportFragmentManager();
+ //HomeFragment homeFragment = (HomeFragment) fragmentManager.findFragmentById(R.id.home_frag);
+ FragmentTransaction ctx = fragmentManager.beginTransaction();
+// ctx.remove(homeFragment);
+
+ // TODO add inserting photo showing fragment
+
+ PanoramioShowerFragment panoramioShower = new PanoramioShowerFragment();
+ Bundle arguments = new Bundle();
+ arguments.putSerializable(PanoramioShowerFragment.PANORAMIO_PHOTO_ARG_KEY, photoInfo);
+ panoramioShower.setArguments(arguments);
+
+ // ctx.add(R.id.fragments, panoramioShower);
+ ctx.replace(R.id.fragments, panoramioShower);
+ ctx.addToBackStack(PHOTO_BACKSTACK);
+
+ ctx.commit();
+
+ }
}
diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/PanoramioImageInfo.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/PanoramioImageInfo.java
index 2e08775..19dc586 100644
--- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/PanoramioImageInfo.java
+++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/PanoramioImageInfo.java
@@ -1,11 +1,13 @@
package pl.tpolgrabia.urbanexplorer.dto;
+import java.io.Serializable;
import java.util.Date;
/**
* Created by tpolgrabia on 27.08.16.
*/
-public class PanoramioImageInfo {
+public class PanoramioImageInfo implements Serializable{
+ private static final long serialVersionUID = -3749926831546160047L;
private Double height;
private String ownerName;
private Long ownerId;
diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java
index 2e88db1..268e67e 100644
--- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java
+++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java
@@ -20,6 +20,7 @@ import com.androidquery.callback.AjaxCallback;
import com.androidquery.callback.AjaxStatus;
import org.json.JSONException;
import org.json.JSONObject;
+import pl.tpolgrabia.urbanexplorer.MainActivity;
import pl.tpolgrabia.urbanexplorer.R;
import pl.tpolgrabia.urbanexplorer.dto.PanoramioImageInfo;
import pl.tpolgrabia.urbanexplorer.utils.NumberUtils;
@@ -192,7 +193,7 @@ public class HomeFragment extends Fragment implements LocationListener {
private void fetchPanoramioLocations() {
- Location location = locationService.getLastKnownLocation(locationProvider);
+ final Location location = locationService.getLastKnownLocation(locationProvider);
Double radiusX = fetchRadiusX();
Double radiusY = fetchRadiusY();
final String aqQuery = "http://www.panoramio.com/map/get_panoramas.php?" +
@@ -232,6 +233,18 @@ public class HomeFragment extends Fragment implements LocationListener {
R.layout.location_item,
photosInfos);
locations.setAdapter(adapter);
+
+ locations.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+ @Override
+ public boolean onItemLongClick(AdapterView> adapterView, View view, int pos, long rowId) {
+ PanoramioAdapter panAdapter = (PanoramioAdapter) locations.getAdapter();
+ PanoramioImageInfo photoInfo = panAdapter.getItem(pos);
+ MainActivity activity = (MainActivity) getActivity();
+ activity.switchToPhoto(photoInfo);
+ return false;
+ }
+ });
+
} catch (JSONException e) {
Log.w(CLASS_TAG, "Json not supported format", e);
}
diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java
new file mode 100644
index 0000000..5978895
--- /dev/null
+++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/PanoramioShowerFragment.java
@@ -0,0 +1,57 @@
+package pl.tpolgrabia.urbanexplorer.fragments;
+
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import android.widget.ImageView;
+import android.widget.TextView;
+import com.nostra13.universalimageloader.core.ImageLoader;
+import pl.tpolgrabia.urbanexplorer.MainActivity;
+import pl.tpolgrabia.urbanexplorer.R;
+import pl.tpolgrabia.urbanexplorer.dto.PanoramioImageInfo;
+
+/**
+ * A simple {@link Fragment} subclass.
+ */
+public class PanoramioShowerFragment extends Fragment {
+
+
+ public static final String PANORAMIO_PHOTO_ARG_KEY = "PANORAMIO_PHOTO_ARG_KEY";
+ private TextView photoTitle;
+
+ public PanoramioShowerFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ Bundle arguments = getArguments();
+ final View inflatedView = inflater.inflate(R.layout.fragment_panoramio_shower, container, false);
+
+ if (arguments == null) {
+ return inflatedView;
+ }
+
+ PanoramioImageInfo imageInfo = (PanoramioImageInfo) arguments.getSerializable(PANORAMIO_PHOTO_ARG_KEY);
+
+ if (imageInfo != null) {
+ ImageLoader.getInstance().displayImage(
+ imageInfo.getPhotoFileUrl(),
+ (ImageView) inflatedView.findViewById(R.id.photo_container),
+ MainActivity.options);
+
+ photoTitle = (TextView)inflatedView.findViewById(R.id.phot_title);
+ photoTitle.setText(imageInfo.getPhotoTitle());
+ }
+
+ return inflatedView;
+ }
+
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 0f7d333..b4b5f7c 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -1,5 +1,6 @@
+ tools:context="pl.tpolgrabia.urbanexplorer.MainActivity" android:orientation="horizontal">
@@ -16,11 +17,11 @@
-
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/fragment_panoramio_shower.xml b/app/src/main/res/layout/fragment_panoramio_shower.xml
new file mode 100644
index 0000000..190b934
--- /dev/null
+++ b/app/src/main/res/layout/fragment_panoramio_shower.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+