From 880f5d316e6570e71182b121ee319c97925d90dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20P=C3=B3=C5=82grabia?= Date: Wed, 28 Sep 2016 21:23:39 +0200 Subject: [PATCH] You can switch now to blank google places fragment. --- .../urbanexplorer/MainActivity.java | 11 ++++----- .../urbanexplorer/PlacesFragment.java | 2 ++ .../urbanexplorer/dto/MainActivityState.java | 3 +-- .../urbanexplorer/fragments/HomeFragment.java | 1 - .../handlers/GooglePlacesSwitchHandler.java | 24 +++++++++++++++++++ 5 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/pl/tpolgrabia/urbanexplorer/handlers/GooglePlacesSwitchHandler.java diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java index fdbe284..2d34c4b 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/MainActivity.java @@ -19,16 +19,13 @@ import pl.tpolgrabia.urbanexplorer.activities.SettingsActivity; import pl.tpolgrabia.urbanexplorer.callbacks.StandardLocationListener; import pl.tpolgrabia.urbanexplorer.dto.MainActivityState; import pl.tpolgrabia.panoramiobindings.dto.PanoramioImageInfo; +import pl.tpolgrabia.urbanexplorer.handlers.*; import pl.tpolgrabia.urbanexplorerutils.events.DataLoadingFinishEvent; import pl.tpolgrabia.urbanexplorerutils.events.DataLoadingStartEvent; import pl.tpolgrabia.urbanexplorer.fragments.HomeFragment; import pl.tpolgrabia.urbanexplorer.fragments.PanoramioShowerFragment; import pl.tpolgrabia.urbanexplorer.fragments.Refreshable; import pl.tpolgrabia.urbanexplorer.fragments.WikiLocationsFragment; -import pl.tpolgrabia.urbanexplorer.handlers.PanoramioShowerSwitchHandler; -import pl.tpolgrabia.urbanexplorer.handlers.PanoramioSwitchHandler; -import pl.tpolgrabia.urbanexplorer.handlers.SwipeHandler; -import pl.tpolgrabia.urbanexplorer.handlers.WikiSwitchHandler; import pl.tpolgrabia.urbanexplorer.utils.HelperUtils; import pl.tpolgrabia.urbanexplorer.views.CustomInterceptor; import pl.tpolgrabia.urbanexplorer.views.SwipeFrameLayout; @@ -59,14 +56,16 @@ public class MainActivity extends ActionBarActivity { private static final Map fragTags = new HashMap<>(); static { - fragTags.put(AppConstants.HOME_FRAGMENT_ID, HomeFragment.TAG); - fragTags.put(AppConstants.WIKI_FRAGMENT_ID, WikiLocationsFragment.TAG); + fragTags.put(MainActivityState.PANORAMIO.getOrder(), HomeFragment.TAG); + fragTags.put(MainActivityState.WIKI.getOrder(), WikiLocationsFragment.TAG); + fragTags.put(MainActivityState.GOOGLE_PLACES.getOrder(), PlacesFragment.TAG); } public MainActivity() { switchFragmentActions.put(MainActivityState.PANORAMIO_SHOWER, new PanoramioShowerSwitchHandler(this)); switchFragmentActions.put(MainActivityState.PANORAMIO, new PanoramioSwitchHandler(this)); switchFragmentActions.put(MainActivityState.WIKI, new WikiSwitchHandler(this)); + switchFragmentActions.put(MainActivityState.GOOGLE_PLACES, new GooglePlacesSwitchHandler(this)); } private List photos; diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/PlacesFragment.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/PlacesFragment.java index d7c3ebb..42dfe98 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/PlacesFragment.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/PlacesFragment.java @@ -14,6 +14,8 @@ import android.view.ViewGroup; public class PlacesFragment extends Fragment { + public static final String TAG = PlacesFragment.class.getSimpleName(); + public PlacesFragment() { // Required empty public constructor } diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/MainActivityState.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/MainActivityState.java index 2092fc1..36a0835 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/MainActivityState.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/dto/MainActivityState.java @@ -1,13 +1,12 @@ package pl.tpolgrabia.urbanexplorer.dto; -import pl.tpolgrabia.urbanexplorer.MainActivity; - /** * Created by tpolgrabia on 19.09.16. */ public enum MainActivityState { PANORAMIO(0), WIKI(1), + GOOGLE_PLACES(2), PANORAMIO_SHOWER(-1); private final Integer order; 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 1887577..61dad11 100644 --- a/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/fragments/HomeFragment.java @@ -15,7 +15,6 @@ import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -// import pl.tpolgrabia.googleutils.utils.GeocoderUtils; import pl.tpolgrabia.googleutils.utils.GeocoderUtils; import pl.tpolgrabia.panoramiobindings.utils.PanoramioUtils; import pl.tpolgrabia.urbanexplorer.AppConstants; diff --git a/app/src/main/java/pl/tpolgrabia/urbanexplorer/handlers/GooglePlacesSwitchHandler.java b/app/src/main/java/pl/tpolgrabia/urbanexplorer/handlers/GooglePlacesSwitchHandler.java new file mode 100644 index 0000000..5807967 --- /dev/null +++ b/app/src/main/java/pl/tpolgrabia/urbanexplorer/handlers/GooglePlacesSwitchHandler.java @@ -0,0 +1,24 @@ +package pl.tpolgrabia.urbanexplorer.handlers; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import pl.tpolgrabia.urbanexplorer.MainActivity; +import pl.tpolgrabia.urbanexplorer.PlacesFragment; + +/** + * Created by tpolgrabia on 28.09.16. + */ +public class GooglePlacesSwitchHandler implements Runnable { + private static final Logger lg = LoggerFactory.getLogger(GooglePlacesSwitchHandler.class); + private final MainActivity mainActivity; + + public GooglePlacesSwitchHandler(MainActivity mainActivity) { + this.mainActivity = mainActivity; + } + + @Override + public void run() { + lg.debug("Switching to google places fragment"); + mainActivity.switchFragment(new PlacesFragment(), PlacesFragment.TAG); + } +}