// 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.content.ContentResolver; import android.database.Cursor; import android.location.Address; import android.location.Geocoder; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; import butterknife.ButterKnife; import com.google.android.gms.common.api.GoogleApiClient; import com.google.android.gms.common.api.PendingResult; import com.google.android.gms.common.api.Status; import com.google.android.gms.location.FusedLocationProviderApi; import com.google.android.gms.location.LocationServices; import com.google.android.gms.location.places.AutocompletePrediction; import com.google.android.gms.location.places.AutocompletePredictionBuffer; 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.model.LatLng; import com.olio.data.object.user.Location; import com.olio.data.object.user.LocationBuilder; import com.olio.data.object.user.Locations; import com.oliodevices.assist.app.activities.AssistantActivityCallbacks; import com.oliodevices.assist.app.core.Constants; import com.oliodevices.assist.app.core.Utils; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; import java.util.concurrent.TimeUnit; // Referenced classes of package com.oliodevices.assist.app.fragments: // AssistantBaseFragment public class AssistantLocationFragment extends AssistantBaseFragment { private static final String ARG_LOCATION_TYPE = "location_type"; private static final String STATE_PROFILE_LOCATION = "profile_location"; private static final int TIME_TO_WAIT_FOR_RESPONSE_MILLIS = 5000; View mContactLocationView; private AsyncTask mGetAddressTask; private AsyncTask mGetLocationTask; private com.olio.data.object.user.Location.LocationType mLocationType; View mMainView; TextView mProfileAddressView; private Location mProfileLocation; View mProfileLocationView; View mProgressView; TextView mTitleView; public AssistantLocationFragment() { } private void getDeviceLocation() { if (!mCallbacks.getGoogleApiClient().isConnected()) { Utils.showToastMessage(getActivity(), getString(0x7f0601b0)); return; } else { mGetLocationTask = (new AsyncTask() { final AssistantLocationFragment this$0; protected volatile Object doInBackground(Object aobj[]) { return doInBackground((Void[])aobj); } protected transient String doInBackground(Void avoid[]) { if (isCancelled()) { return null; } if (!isResumed()) { return null; } avoid = getActivity(); Object obj = LocationServices.FusedLocationApi.getLastLocation(mCallbacks.getGoogleApiClient()); if (obj == null) { avoid.runOnUiThread(avoid. new Runnable() { final _cls1 this$1; final Activity val$activity; public void run() { Utils.showToastMessage(activity, getString(0x7f0601b0)); } { this$1 = final__pcls1; activity = Activity.this; super(); } }); return null; } Geocoder geocoder = new Geocoder(avoid, Locale.getDefault()); try { obj = geocoder.getFromLocation(((android.location.Location) (obj)).getLatitude(), ((android.location.Location) (obj)).getLongitude(), 1); } // Misplaced declaration of an exception variable catch (Object obj) { avoid.runOnUiThread(avoid. new Runnable() { final _cls1 this$1; final Activity val$activity; public void run() { Utils.showToastMessage(activity, getString(0x7f0601b0)); } { this$1 = final__pcls1; activity = Activity.this; super(); } }); return null; } if (obj == null || ((List) (obj)).isEmpty()) { avoid.runOnUiThread(avoid. new Runnable() { final _cls1 this$1; final Activity val$activity; public void run() { Utils.showToastMessage(activity, getString(0x7f0601b0)); } { this$1 = final__pcls1; activity = Activity.this; super(); } }); return null; } avoid = (Address)((List) (obj)).get(0); int j = avoid.getMaxAddressLineIndex(); obj = new ArrayList(j); for (int i = 0; i < j; i++) { ((ArrayList) (obj)).add(avoid.getAddressLine(i)); } return TextUtils.join(", ", ((Iterable) (obj))); } protected volatile void onPostExecute(Object obj) { onPostExecute((String)obj); } protected void onPostExecute(String s) { if (s == null) { return; } else { mCallbacks.confirmCurrentLocation(mLocationType, s); return; } } { this$0 = AssistantLocationFragment.this; super(); } }).execute(new Void[0]); return; } } public static AssistantLocationFragment newInstance(com.olio.data.object.user.Location.LocationType locationtype) { AssistantLocationFragment assistantlocationfragment = new AssistantLocationFragment(); Bundle bundle = new Bundle(); bundle.putSerializable("location_type", locationtype); assistantlocationfragment.setArguments(bundle); return assistantlocationfragment; } private void retrieveProfileAddress() { mGetAddressTask = (new AsyncTask() { final AssistantLocationFragment this$0; final GoogleApiClient val$apiClient; protected transient Location doInBackground(Void avoid[]) { if (!isCancelled()) { avoid = Uri.withAppendedPath(android.provider.ContactsContract.Profile.CONTENT_URI, "data"); Object obj; Object obj1; Object obj2; int i; if (mLocationType == com.olio.data.object.user.Location.LocationType.HOME) { i = 1; } else { i = 2; } obj1 = null; obj2 = null; obj = null; if (getActivity() != null) { Cursor cursor = getActivity().getContentResolver().query(avoid, new String[] { "data2", "data1" }, "data2 = ?", new String[] { String.valueOf(i) }, null); if (cursor != null) { avoid = obj2; if (cursor.moveToNext()) { String s = cursor.getString(cursor.getColumnIndex("data1")); avoid = obj2; if (s != null) { AutocompletePredictionBuffer autocompletepredictionbuffer = (AutocompletePredictionBuffer)Places.GeoDataApi.getAutocompletePredictions(apiClient, s, Constants.GLOBAL_BOUNDS, null).await(5000L, TimeUnit.MILLISECONDS); avoid = obj1; if (autocompletepredictionbuffer.getStatus().isSuccess()) { avoid = obj1; if (autocompletepredictionbuffer.getCount() > 0) { avoid = autocompletepredictionbuffer.get(0).getPlaceId(); PlaceBuffer placebuffer = (PlaceBuffer)Places.GeoDataApi.getPlaceById(apiClient, new String[] { avoid }).await(5000L, TimeUnit.MILLISECONDS); avoid = obj; if (placebuffer.getStatus().isSuccess()) { avoid = obj; if (placebuffer.getCount() > 0) { avoid = placebuffer.get(0); LatLng latlng = avoid.getLatLng(); avoid = LocationBuilder.aLocation().setDisplayName(avoid.getAddress().toString()).setGooglePlaceId(avoid.getId()).setLatitude(latlng.latitude).setLongitude(latlng.longitude).setLocationType(mLocationType).setDisplayAddress(avoid.getAddress().toString()).build(); } } placebuffer.release(); } } autocompletepredictionbuffer.release(); } } cursor.close(); return avoid; } } } return null; } protected volatile Object doInBackground(Object aobj[]) { return doInBackground((Void[])aobj); } protected void onPostExecute(Location location) { if (isAdded()) { setProfileLocation(location); } } protected volatile void onPostExecute(Object obj) { onPostExecute((Location)obj); } { this$0 = AssistantLocationFragment.this; apiClient = googleapiclient; super(); } }).execute(new Void[0]); } private void setProfileLocation(Location location) { mProfileLocation = location; mProgressView.setVisibility(8); mMainView.setVisibility(0); if (mProfileLocation == null) { mProfileLocationView.setVisibility(8); return; } else { mProfileAddressView.setText(mProfileLocation.getDisplayAddress()); return; } } public int getStage() { return 5; } public boolean isSkipVisible() { return true; } public void onActivityCreated(Bundle bundle) { int i; super.onActivityCreated(bundle); static class _cls3 { static final int $SwitchMap$com$olio$data$object$user$Location$LocationType[]; static { $SwitchMap$com$olio$data$object$user$Location$LocationType = new int[com.olio.data.object.user.Location.LocationType.values().length]; try { $SwitchMap$com$olio$data$object$user$Location$LocationType[com.olio.data.object.user.Location.LocationType.HOME.ordinal()] = 1; } catch (NoSuchFieldError nosuchfielderror2) { } try { $SwitchMap$com$olio$data$object$user$Location$LocationType[com.olio.data.object.user.Location.LocationType.WORK.ordinal()] = 2; } catch (NoSuchFieldError nosuchfielderror1) { } try { $SwitchMap$com$olio$data$object$user$Location$LocationType[com.olio.data.object.user.Location.LocationType.OTHER.ordinal()] = 3; } catch (NoSuchFieldError nosuchfielderror) { return; } } } if (bundle == null) { if (mLocationType == com.olio.data.object.user.Location.LocationType.OTHER) { mProgressView.setVisibility(8); mProfileLocationView.setVisibility(8); mContactLocationView.setVisibility(0); mMainView.setVisibility(0); } else { retrieveProfileAddress(); } } else { setProfileLocation((Location)bundle.getParcelable("profile_location")); } _cls3..SwitchMap.com.olio.data.object.user.Location.LocationType[mLocationType.ordinal()]; JVM INSTR tableswitch 1 2: default 88 // 1 123 // 2 129; goto _L1 _L2 _L3 _L1: i = 0x7f060124; _L5: mTitleView.setText(i); return; _L2: i = 0x7f0600c2; continue; /* Loop/switch isn't completed */ _L3: i = 0x7f0601d9; if (true) goto _L5; else goto _L4 _L4: } public void onAnotherAddress() { mCallbacks.getUserLocation(mLocationType); } public void onCancelSkip() { } public void onConfirmSkip() { if (mLocationType == com.olio.data.object.user.Location.LocationType.HOME) { mCallbacks.finishLocation(); return; } if (mLocationType == com.olio.data.object.user.Location.LocationType.OTHER) { mCallbacks.finishLocation(); return; } else { mCallbacks.nextLocation(mLocationType); return; } } public void onContactLocation() { mCallbacks.getContactLocation(); } public void onCreate(Bundle bundle) { super.onCreate(bundle); bundle = getArguments(); if (bundle != null) { mLocationType = (com.olio.data.object.user.Location.LocationType)bundle.getSerializable("location_type"); } } public View onCreateView(LayoutInflater layoutinflater, ViewGroup viewgroup, Bundle bundle) { layoutinflater = layoutinflater.inflate(0x7f030031, viewgroup, false); ButterKnife.inject(this, layoutinflater); return layoutinflater; } public void onCurrentLocation() { getDeviceLocation(); } public void onDetach() { if (mGetLocationTask != null) { mGetLocationTask.cancel(true); } if (mGetAddressTask != null) { mGetAddressTask.cancel(true); } super.onDetach(); } public void onProfileLocation() { if (mLocationType != com.olio.data.object.user.Location.LocationType.HOME) goto _L2; else goto _L1 _L1: mProfileLocation.setDisplayName(getString(0x7f0600c1)); _L4: ContentResolver contentresolver = getActivity().getContentResolver(); Locations locations = Locations.get(contentresolver); locations.addLocation(mProfileLocation); locations.save(contentresolver); mCallbacks.nextLocation(mLocationType); return; _L2: if (mLocationType == com.olio.data.object.user.Location.LocationType.WORK) { mProfileLocation.setDisplayName(getString(0x7f0601d8)); } if (true) goto _L4; else goto _L3 _L3: } public void onSaveInstanceState(Bundle bundle) { super.onSaveInstanceState(bundle); bundle.putParcelable("profile_location", mProfileLocation); } public void onShowSkipConfirmation() { } }