// 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.location.Location; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AutoCompleteTextView; import android.widget.ImageView; import android.widget.ListView; 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.Result; import com.google.android.gms.common.api.ResultCallback; 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.Places; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLngBounds; import com.olio.data.object.user.LocationBuilder; import com.oliodevices.assist.app.activities.AssistantActivityCallbacks; import com.oliodevices.assist.app.adapters.LocationListAdapter; import com.oliodevices.assist.app.core.Constants; import com.oliodevices.assist.app.core.Utils; import java.util.ArrayList; import java.util.Iterator; // Referenced classes of package com.oliodevices.assist.app.fragments: // AssistantBaseFragment public class AssistantUserLocationFragment extends AssistantBaseFragment { private static final String ARG_LOCATION_NAME = "location_name"; private static final String ARG_LOCATION_TYPE = "location_type"; ImageView mClearInput; private LocationListAdapter mListAdapter; AutoCompleteTextView mLocationAutoComplete; private String mLocationName; private com.olio.data.object.user.Location.LocationType mLocationType; TextView mTitleView; public AssistantUserLocationFragment() { } private void doSearch(String s) { GoogleApiClient googleapiclient = mCallbacks.getGoogleApiClient(); if (!googleapiclient.isConnected()) { Utils.showToastMessage(getActivity(), getString(0x7f0601b1)); return; } Location location = LocationServices.FusedLocationApi.getLastLocation(googleapiclient); Object obj = Constants.GLOBAL_BOUNDS; if (location != null) { obj = new LatLng(location.getLatitude(), location.getLongitude()); obj = LatLngBounds.builder().include(((LatLng) (obj))).build(); } Places.GeoDataApi.getAutocompletePredictions(googleapiclient, s, ((LatLngBounds) (obj)), null).setResultCallback(new ResultCallback() { final AssistantUserLocationFragment this$0; public volatile void onResult(Result result) { onResult((AutocompletePredictionBuffer)result); } public void onResult(AutocompletePredictionBuffer autocompletepredictionbuffer) { if (!autocompletepredictionbuffer.getStatus().isSuccess()) { Utils.showToastMessage(getActivity(), getString(0x7f0601b1)); autocompletepredictionbuffer.release(); return; } ArrayList arraylist = new ArrayList(); AutocompletePrediction autocompleteprediction; for (Iterator iterator = autocompletepredictionbuffer.iterator(); iterator.hasNext(); arraylist.add(LocationBuilder.aLocation().setGooglePlaceId(autocompleteprediction.getPlaceId()).setDisplayAddress(autocompleteprediction.getDescription()).setLocationType(mLocationType).build())) { autocompleteprediction = (AutocompletePrediction)iterator.next(); } autocompletepredictionbuffer.release(); mListAdapter.clear(); mListAdapter.addAll(arraylist); } { this$0 = AssistantUserLocationFragment.this; super(); } }); } private void initializeView(View view) { static class _cls4 { 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; } } } _cls4..SwitchMap.com.olio.data.object.user.Location.LocationType[mLocationType.ordinal()]; JVM INSTR tableswitch 1 2: default 32 // 1 122 // 2 128; goto _L1 _L2 _L3 _L1: int i = 0x7f060124; _L5: mTitleView.setText(i); mListAdapter = new LocationListAdapter(getActivity(), new ArrayList()); view = (ListView)ButterKnife.findById(view, 0x7f0d0109); view.setAdapter(mListAdapter); view.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { final AssistantUserLocationFragment this$0; public void onItemClick(AdapterView adapterview, View view1, int j, long l) { if (isAdded()) { hideKeyboard(getActivity()); mCallbacks.confirmLocation(mLocationType, (com.olio.data.object.user.Location)mListAdapter.getItem(j)); } } { this$0 = AssistantUserLocationFragment.this; super(); } }); mLocationAutoComplete.addTextChangedListener(new TextWatcher() { final AssistantUserLocationFragment this$0; public void afterTextChanged(Editable editable) { } public void beforeTextChanged(CharSequence charsequence, int j, int k, int l) { } public void onTextChanged(CharSequence charsequence, int j, int k, int l) { ImageView imageview; if (charsequence.toString().length() > 2) { doSearch(charsequence.toString()); } else { mListAdapter.clear(); } imageview = mClearInput; if (charsequence.toString().length() > 0) { j = 0; } else { j = 4; } imageview.setVisibility(j); } { this$0 = AssistantUserLocationFragment.this; super(); } }); mLocationAutoComplete.setText(mLocationName); return; _L2: i = 0x7f0600c2; continue; /* Loop/switch isn't completed */ _L3: i = 0x7f0601d9; if (true) goto _L5; else goto _L4 _L4: } public static AssistantUserLocationFragment newInstance(com.olio.data.object.user.Location.LocationType locationtype) { AssistantUserLocationFragment assistantuserlocationfragment = new AssistantUserLocationFragment(); Bundle bundle = new Bundle(); bundle.putSerializable("location_type", locationtype); assistantuserlocationfragment.setArguments(bundle); return assistantuserlocationfragment; } public static AssistantUserLocationFragment newInstance(com.olio.data.object.user.Location.LocationType locationtype, String s) { AssistantUserLocationFragment assistantuserlocationfragment = new AssistantUserLocationFragment(); Bundle bundle = new Bundle(); bundle.putSerializable("location_type", locationtype); bundle.putString("location_name", s); assistantuserlocationfragment.setArguments(bundle); return assistantuserlocationfragment; } public int getStage() { return 5; } public boolean isSkipVisible() { return true; } public void onCancelSkip() { } public void onClearInput() { mLocationAutoComplete.setText(""); } 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 onCreate(Bundle bundle) { super.onCreate(bundle); bundle = getArguments(); if (bundle != null) { mLocationType = (com.olio.data.object.user.Location.LocationType)bundle.getSerializable("location_type"); mLocationName = bundle.getString("location_name"); } } public View onCreateView(LayoutInflater layoutinflater, ViewGroup viewgroup, Bundle bundle) { layoutinflater = layoutinflater.inflate(0x7f030036, viewgroup, false); ButterKnife.inject(this, layoutinflater); initializeView(layoutinflater); return layoutinflater; } public void onResume() { super.onResume(); if (mLocationName == null) { Utils.showKeyboardDelayed(getActivity(), mLocationAutoComplete); } } public void onShowSkipConfirmation() { } }