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 w w . j ava 2 s . 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.PlaceDetailResponse; public class PlaceDetailResponseHandlerFragment extends Fragment implements PlacesResponseHandler<PlaceDetailResponse> { private static final String TAG = PlaceDetailResponseHandlerFragment.class.getSimpleName(); private PlaceDetailResponseHandler responseHandler; private PlaceDetailResponse unhandledResponse; public interface PlaceDetailResponseHandler { void handleResponse(PlaceDetailResponse response); } @Override public void onAttach(Activity activity) { super.onAttach(activity); if (activity instanceof PlaceDetailResponseHandler) { responseHandler = (PlaceDetailResponseHandler) activity; if (unhandledResponse != null) { responseHandler.handleResponse(unhandledResponse); unhandledResponse = null; } } else { Log.e(TAG, "Hosting activity must implement PlaceDetailResponseHandler"); } } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); } @Override public void onDetach() { super.onDetach(); responseHandler = null; } @Override public void handleResponse(PlaceDetailResponse response) { if (responseHandler != null) { responseHandler.handleResponse(response); unhandledResponse = null; } else { unhandledResponse = response; } } }