// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.oliodevices.assist.app.fragments; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import butterknife.ButterKnife; import com.google.android.gms.common.api.PendingResult; import com.google.android.gms.common.api.Result; import com.google.android.gms.common.api.ResultCallback; import com.google.android.gms.common.api.Status; import com.google.android.gms.location.places.GeoDataApi; import com.google.android.gms.location.places.Place; import com.google.android.gms.location.places.PlaceBuffer; import com.google.android.gms.location.places.Places; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.UiSettings; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; import com.olio.data.object.user.Location; import com.olio.data.object.user.Locations; import com.oliodevices.assist.app.activities.MainActivity; import com.oliodevices.assist.app.core.Utils; import com.oliodevices.assist.app.events.LocationsUpdatedEvent; import com.oliodevices.assist.app.views.SetupInputView; import com.squareup.otto.Bus; import java.util.Objects; // Referenced classes of package com.oliodevices.assist.app.fragments: // BaseFragment, TitleChanger public class ConfirmLocationFragment extends BaseFragment implements TitleChanger { private static final String ARG_LOCATION = "location"; private static final String STATE_LOCATION_CONFIRMED = "location_confirmed"; View mConfirmLocationView; private boolean mIsLocationConfirmed; private Location mLocation; SetupInputView mLocationNameView; MapView mMapView; View mNameLocationView; public ConfirmLocationFragment() { } private void initializeView() { String s = mLocation.getDisplayName(); if (s != null) { mLocationNameView.setText(s); } } private void loadMapView(final LatLng latLng) { mMapView.getMapAsync(new OnMapReadyCallback() { final ConfirmLocationFragment this$0; final LatLng val$latLng; public void onMapReady(GoogleMap googlemap) { googlemap.getUiSettings().setMyLocationButtonEnabled(false); googlemap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 13F)); googlemap.addMarker((new MarkerOptions()).position(latLng)); mMapView.setVisibility(0); } { this$0 = ConfirmLocationFragment.this; latLng = latlng; super(); } }); } public static ConfirmLocationFragment newInstance(Location location) { ConfirmLocationFragment confirmlocationfragment = new ConfirmLocationFragment(); Bundle bundle = new Bundle(); bundle.putParcelable("location", location); confirmlocationfragment.setArguments(bundle); return confirmlocationfragment; } private void setVisibilities() { if (mIsLocationConfirmed) { mConfirmLocationView.setVisibility(8); mNameLocationView.setVisibility(0); } } public void onActivityCreated(Bundle bundle) { super.onActivityCreated(bundle); mMapView.onCreate(bundle); com.google.android.gms.common.api.GoogleApiClient googleapiclient = ((MainActivity)getActivity()).getGoogleApiClient(); Places.GeoDataApi.getPlaceById(googleapiclient, new String[] { mLocation.getGooglePlaceId() }).setResultCallback(new ResultCallback() { final ConfirmLocationFragment this$0; public volatile void onResult(Result result) { onResult((PlaceBuffer)result); } public void onResult(PlaceBuffer placebuffer) { if (isAdded() && placebuffer.getStatus().isSuccess() && placebuffer.getCount() > 0) { loadMapView(placebuffer.get(0).getLatLng()); } placebuffer.release(); } { this$0 = ConfirmLocationFragment.this; super(); } }); boolean flag; if (bundle != null && bundle.getBoolean("location_confirmed")) { flag = true; } else { flag = false; } mIsLocationConfirmed = flag; setVisibilities(); } public void onCreate(Bundle bundle) { super.onCreate(bundle); bundle = getArguments(); if (bundle != null) { mLocation = (Location)bundle.getParcelable("location"); } } public View onCreateView(LayoutInflater layoutinflater, ViewGroup viewgroup, Bundle bundle) { layoutinflater = layoutinflater.inflate(0x7f03003c, viewgroup, false); ButterKnife.inject(this, layoutinflater); initializeView(); return layoutinflater; } public void onDestroy() { super.onDestroy(); mMapView.onDestroy(); } public void onDone() { String s = mLocationNameView.getText().toString(); if (s.isEmpty()) { mLocationNameView.setErrorState(true); Utils.showToastMessage(getActivity(), getString(0x7f0600e3)); return; } Utils.hideKeyboard(getActivity()); android.content.ContentResolver contentresolver = getActivity().getContentResolver(); Locations locations = Locations.get(contentresolver); if (mLocation.getDisplayName() != null) { locations.removeLocation(mLocation); } mLocation.setDisplayName(s); if (Objects.equals(s, "work")) { mLocation.setLocationType(com.olio.data.object.user.Location.LocationType.WORK); } else if (Objects.equals(s, "home")) { mLocation.setLocationType(com.olio.data.object.user.Location.LocationType.HOME); } else { mLocation.setLocationType(com.olio.data.object.user.Location.LocationType.OTHER); } locations.addLocation(mLocation); locations.save(contentresolver); mBus.post(new LocationsUpdatedEvent(locations)); } public void onLowMemory() { super.onLowMemory(); mMapView.onLowMemory(); } public void onNoButton() { getActivity().onBackPressed(); } public void onPause() { super.onPause(); mMapView.onPause(); } public void onResume() { super.onResume(); mMapView.onResume(); } public void onSaveInstanceState(Bundle bundle) { mMapView.onSaveInstanceState(bundle); super.onSaveInstanceState(bundle); bundle.putBoolean("location_confirmed", mIsLocationConfirmed); } public void onYesButton() { mIsLocationConfirmed = true; if (Utils.isItemProtected(getActivity(), mLocation)) { onDone(); return; } else { setVisibilities(); Utils.showKeyboardDelayed(getActivity(), mLocationNameView.findViewById(0x7f0d01a8)); return; } } public void setActivityTitle(Activity activity) { activity.setTitle(0x7f0600ff); } }