// 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.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.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.google.android.gms.maps.model.LatLngBounds; import com.olio.data.object.user.LocationBuilder; import com.oliodevices.assist.app.activities.MainActivity; 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: // BaseFragment, TitleChanger, ConfirmLocationFragment public class UpdateLocationFragment extends BaseFragment implements TitleChanger { static final boolean $assertionsDisabled; private static final String ARG_LOCATION = "location"; AutoCompleteTextView mAutoCompleteTextView; ImageView mClearInput; private boolean mIsEditMode; private LocationListAdapter mListAdapter; private com.olio.data.object.user.Location mLocation; TextView mTitleView; public UpdateLocationFragment() { } private void doSearch(String s) { GoogleApiClient googleapiclient = ((MainActivity)getActivity()).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 UpdateLocationFragment this$0; public volatile void onResult(Result result) { onResult((AutocompletePredictionBuffer)result); } public void onResult(AutocompletePredictionBuffer autocompletepredictionbuffer) { if (!autocompletepredictionbuffer.getStatus().isSuccess()) { if (isAdded()) { 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()).build())) { autocompleteprediction = (AutocompletePrediction)iterator.next(); } autocompletepredictionbuffer.release(); mListAdapter.clear(); mListAdapter.addAll(arraylist); } { this$0 = UpdateLocationFragment.this; super(); } }); } private void initializeView(View view) { mListAdapter = new LocationListAdapter(getActivity(), new ArrayList()); view = (ListView)ButterKnife.findById(view, 0x7f0d0109); view.setAdapter(mListAdapter); view.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { final UpdateLocationFragment this$0; public void onItemClick(AdapterView adapterview, View view1, int i, long l) { if (isAdded()) { hideKeyboard(getActivity()); if (!mIsEditMode) { mLocation = new com.olio.data.object.user.Location(); } adapterview = (com.olio.data.object.user.Location)mListAdapter.getItem(i); view1 = ((MainActivity)getActivity()).getGoogleApiClient(); Places.GeoDataApi.getPlaceById(view1, new String[] { adapterview.getGooglePlaceId() }).setResultCallback(adapterview. new ResultCallback() { final _cls2 this$1; final com.olio.data.object.user.Location val$item; public volatile void onResult(Result result) { onResult((PlaceBuffer)result); } public void onResult(PlaceBuffer placebuffer) { if (placebuffer.getStatus().isSuccess()) { LatLng latlng = placebuffer.get(0).getLatLng(); mLocation.setGooglePlaceId(item.getGooglePlaceId()); mLocation.setDisplayAddress(item.getDisplayAddress()); mLocation.setLatitude(latlng.latitude); mLocation.setLongitude(latlng.longitude); startFragment(ConfirmLocationFragment.newInstance(mLocation)); } else { Utils.showToastMessage(getActivity(), "Error trying to fetch selected location data"); } placebuffer.release(); } { this$1 = final__pcls2; item = com.olio.data.object.user.Location.this; super(); } }); } } { this$0 = UpdateLocationFragment.this; super(); } }); mAutoCompleteTextView.addTextChangedListener(new TextWatcher() { final UpdateLocationFragment this$0; public void afterTextChanged(Editable editable) { } public void beforeTextChanged(CharSequence charsequence, int i, int j, int k) { } public void onTextChanged(CharSequence charsequence, int i, int j, int k) { ImageView imageview; if (charsequence.toString().length() > 2) { doSearch(charsequence.toString()); } else { mListAdapter.clear(); } imageview = mClearInput; if (charsequence.toString().length() > 0) { i = 0; } else { i = 4; } imageview.setVisibility(i); } { this$0 = UpdateLocationFragment.this; super(); } }); if (getArguments() != null) { mIsEditMode = true; mTitleView.setText(0x7f0600ab); mLocation = (com.olio.data.object.user.Location)getArguments().getParcelable("location"); if (!$assertionsDisabled && mLocation == null) { throw new AssertionError(); } view = mLocation.getDisplayAddress(); if (view != null) { mAutoCompleteTextView.setText(view); mAutoCompleteTextView.setSelection(view.length()); } return; } else { mIsEditMode = false; mTitleView.setText(0x7f060037); return; } } public static UpdateLocationFragment newInstance(com.olio.data.object.user.Location location) { UpdateLocationFragment updatelocationfragment = new UpdateLocationFragment(); Bundle bundle = new Bundle(); bundle.putParcelable("location", location); updatelocationfragment.setArguments(bundle); return updatelocationfragment; } public void onClearInput() { mAutoCompleteTextView.setText(""); } public View onCreateView(LayoutInflater layoutinflater, ViewGroup viewgroup, Bundle bundle) { layoutinflater = layoutinflater.inflate(0x7f03004f, viewgroup, false); ButterKnife.inject(this, layoutinflater); initializeView(layoutinflater); return layoutinflater; } public void onResume() { super.onResume(); Utils.showKeyboardDelayed(getActivity(), mAutoCompleteTextView); } public void setActivityTitle(Activity activity) { activity.setTitle(0x7f0600ff); } static { boolean flag; if (!com/oliodevices/assist/app/fragments/UpdateLocationFragment.desiredAssertionStatus()) { flag = true; } else { flag = false; } $assertionsDisabled = flag; } /* static com.olio.data.object.user.Location access$202(UpdateLocationFragment updatelocationfragment, com.olio.data.object.user.Location location) { updatelocationfragment.mLocation = location; return location; } */ }