Back to project page AndroidPlaces.
The source code is released under:
Apache License
If you think the Android project AndroidPlaces listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2014 Brian Lee//from w ww . j a v a 2s . c om * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.tigerpenguin.places.responsehandler; import android.app.Activity; import android.app.Fragment; import android.os.Bundle; import android.util.Log; import com.tigerpenguin.places.response.NearbySearchResponse; public class NearbySearchHandlerFragment extends Fragment implements PlacesResponseHandler<NearbySearchResponse> { private static final String TAG = NearbySearchHandlerFragment.class.getSimpleName(); private NearbySearchResponseHandler responseHandler; private NearbySearchResponse unhandledResponse; public interface NearbySearchResponseHandler { void handleResponse(NearbySearchResponse response); } @Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof NearbySearchResponseHandler) { responseHandler = (NearbySearchResponseHandler) activity; if (unhandledResponse != null) { responseHandler.handleResponse(unhandledResponse); unhandledResponse = null; } } else { Log.e(TAG, "Hosting activity must implement NearbySearchResponseHandler"); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } @Override public void onDetach() { super.onDetach(); responseHandler = null; } @Override public void handleResponse(NearbySearchResponse response) { if (responseHandler != null) { responseHandler.handleResponse(response); unhandledResponse = null; } else { unhandledResponse = response; } } }