package com.ikea.kompis.fte;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewPropertyAnimator;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.ikea.kompis.IkeaApplication;
import com.ikea.kompis.TypeFaceProvider;
import com.ikea.kompis.extendedcontent.ECCountryUtils;
import com.ikea.kompis.extendedcontent.ECQRFirstTimeEvent;
import com.ikea.kompis.fte.event.CountryUpdateEvent;
import com.ikea.kompis.fte.event.RegistrationFirstTimeEvent;
import com.ikea.kompis.network.event.NetworkStatusEvent;
import com.ikea.kompis.setting.CountryFragment;
import com.ikea.kompis.setting.event.ConfigSelectionDoneEvent;
import com.ikea.kompis.stores.event.LocationUpdateEvent;
import com.ikea.kompis.user.event.ChooseNearestStore;
import com.ikea.kompis.util.CustomPicker;
import com.ikea.kompis.util.CustomPicker.PickerModeEnum;
import com.ikea.kompis.util.CustomPicker.SelectionListener;
import com.ikea.kompis.util.CustomPopUp;
import com.ikea.kompis.util.CustomPopUp.CustomPopupClickListener;
import com.ikea.kompis.util.ReverseGeocoderHelper;
import com.ikea.kompis.util.UiUtil;
import com.ikea.kompis.view.NetworkDialogFragment;
import com.ikea.shared.AppConfigData;
import com.ikea.shared.AppConfigManager;
import com.ikea.shared.AppError;
import com.ikea.shared.analytics.UsageTracker;
import com.ikea.shared.config.model.Config;
import com.ikea.shared.config.model.Country;
import com.ikea.shared.config.model.KillSwitchConfig;
import com.ikea.shared.config.model.Language;
import com.ikea.shared.config.model.Languages;
import com.ikea.shared.config.model.Region;
import com.ikea.shared.config.model.RegionList;
import com.ikea.shared.config.service.ConfigService;
import com.ikea.shared.geofence.GeofenceService;
import com.ikea.shared.store.service.StoreCache;
import com.ikea.shared.store.service.StoreService;
import com.ikea.shared.stores.model.StoreList;
import com.ikea.shared.stores.model.StoreLocation;
import com.ikea.shared.stores.model.StoreRef;
import com.ikea.shared.stores.model.StoreRefList;
import com.ikea.shared.util.L;
import com.ikea.shared.util.LocationUtil;
import com.ikea.shared.util.ServiceCallback;
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

public class NearestStoreFragment extends Fragment
{
  private static final String GETTING_KILLED_BY_SYSTEM = "GETTING_KILLED_BY_SYSTEM";
  private static final String KEY_ASYNC_TASK_RUNNING = "KEY_ASYNC_TASK_RUNNING";
  private static final String KEY_COUNTRY_PICKER_VISIBLE = "KEY_COUNTRY_PICKER_VISIBLE";
  private static final String KEY_LANGUAGE_PICKER_VISIBLE = "KEY_LANGUAGE_PICKER_VISIBLE";
  private static final String KEY_LBS_POPUP_VISIBLE = "KEY_LBS_POPUP_VISIBLE";
  private static final String KEY_NO_NETWORK_POPUP_VISIBLE = "KEY_NO_NETWORK_POPUP_VISIBLE";
  private static final String KEY_PICKER_INDEX = "KEY_PICKER_INDEX";
  private static final String KEY_PROGRESS_BAR_VISIBLE = "KEY_PROGRESS_BAR_VISIBLE";
  private static final String KEY_REGION_PICKER_VISIBLE = "KEY_REGION_PICKER_VISIBLE";
  private static final String KEY_SELECT_STORE_BTN_CLICK = "KEY_SELECT_STORE_BTN_CLICK";
  private static final float VIEW_FADED = 0.7F;
  private TextView firstHeader;
  private final Handler handler = new Handler();
  private boolean isAsycnTaskRunning = false;
  private boolean isCountryListOpen;
  boolean isGPSLocationEnabled = false;
  private boolean isLandscape;
  private boolean isNetworkLocationEnabled = false;
  private boolean isTablet;
  protected final Bus mBus = IkeaApplication.mBus;
  private TextView mChooseOtherStore;
  private Config mConfig;
  private View mCounrtyListLayout;
  private String[] mCountryCodeList;
  private CountryFragment mCountryFragment;
  private List<Country> mCountryList;
  private String[] mCountryNameList;
  private Location mCurrentLocation;
  private float mDeviceWidth;
  private View mFadeView;
  private View mGPSOFFLayout;
  private TextView mGPSOffExplainText;
  private View mGPSOnLayout;
  private final ReverseGeocoderHelper mGeocoderHelper = new ReverseGeocoderHelper();
  private final ServiceCallback<KillSwitchConfig> mKLServiceCallback = new ServiceCallback()
  {
    public void done(KillSwitchConfig paramAnonymousKillSwitchConfig, AppError paramAnonymousAppError, Exception paramAnonymousException)
    {
      NearestStoreFragment.this.showProgressBar(false);
      if ((paramAnonymousKillSwitchConfig != null) && (paramAnonymousKillSwitchConfig.isSuccessful()))
      {
        NearestStoreFragment.this.sendRequestForStore();
        return;
      }
      UiUtil.showNetworkToast(NearestStoreFragment.this.getActivity(), false);
    }
  };
  private CustomPopUp mLBSOffPopUp;
  private boolean mLBSPopUpVisible = false;
  private CustomPicker mLanguagePicker;
  private boolean mLanguagePickerVisible = false;
  private Uri mLaunchedFromCatalogueURI;
  private String mMyCurrentCountryCode;
  private String mMyCurrentCountryName;
  private StoreRef mNearestStore;
  private TextView mNearestStoreName;
  private boolean mNeedToFetchKillSwitch = false;
  private final NetworkDialogFragment mNetworkDialog = NetworkDialogFragment.newInstance();
  private CustomPopUp mNoNetworkPopUp;
  private boolean mNoNetworkPopUpVisible = false;
  private final View.OnClickListener mOnClickListener = new View.OnClickListener()
  {
    public void onClick(View paramAnonymousView)
    {
      switch (paramAnonymousView.getId())
      {
      case 2131624127:
      case 2131624128:
      case 2131624129:
      default:
        return;
      case 2131624125:
        NearestStoreFragment.this.saveCurrentStore();
        NearestStoreFragment.this.openNextFTEFragment();
        return;
      case 2131624126:
        NearestStoreFragment.access$102(NearestStoreFragment.this, true);
        NearestStoreFragment.this.selectOtherStore();
        return;
      case 2131624130:
        try
        {
          AppConfigManager.i(NearestStoreFragment.this.getActivity()).saveFavStore(null);
          if (AppConfigManager.i(NearestStoreFragment.this.getActivity()).getAppConfigData() != null)
            AppConfigManager.i(NearestStoreFragment.this.getActivity()).getAppConfigData().setFavStore(null);
          NearestStoreFragment.access$102(NearestStoreFragment.this, true);
          NearestStoreFragment.this.selectOtherStore();
          return;
        }
        catch (IOException localIOException)
        {
          while (true)
            localIOException.printStackTrace();
        }
      case 2131624131:
      }
      NearestStoreFragment.this.hideCountryList();
    }
  };
  private int mPickerIndex;
  private View mProgressBar;
  private View mProgressBarGPSOff;
  private CustomPicker mRegionPicker;
  private boolean mRegionPickerVisible;
  private Button mSelectAStore;
  private boolean mSelectStoreBtnClick = false;
  private Button mSelectThisStore;
  private String mSelectedCountry;
  private String mSelectedLanguage;
  private final ServiceCallback<Config> mServiceCallBackConfig = new ServiceCallback()
  {
    public void done(Config paramAnonymousConfig, AppError paramAnonymousAppError, Exception paramAnonymousException)
    {
      NearestStoreFragment.this.showProgressBar(false);
      if (paramAnonymousConfig != null)
      {
        NearestStoreFragment.access$1402(NearestStoreFragment.this, ConfigService.i(NearestStoreFragment.this.getActivity()).getCachedConfig());
        if (NearestStoreFragment.this.mCountryFragment != null)
          NearestStoreFragment.this.mCountryFragment.getCountryAndRefreshCountryList(NearestStoreFragment.this.mConfig.getCountry());
        NearestStoreFragment.this.startStoreSelection(false);
        return;
      }
      NearestStoreFragment.this.toggleButtonStatus(false);
      UiUtil.showNetworkToast(NearestStoreFragment.this.getActivity(), false);
      if (paramAnonymousAppError != null)
      {
        UsageTracker.i().formError(NearestStoreFragment.this.getActivity(), "getconfiguration", paramAnonymousAppError.getMessage());
        return;
      }
      UsageTracker.i().formError(NearestStoreFragment.this.getActivity(), "getconfiguration", NearestStoreFragment.this.getString(2131165474));
    }
  };
  private final ServiceCallback<StoreList> mServiceCallback = new ServiceCallback()
  {
    public void done(final StoreList paramAnonymousStoreList, final AppError paramAnonymousAppError, final Exception paramAnonymousException)
    {
      L.I("callback done  :: " + paramAnonymousStoreList);
      if ((paramAnonymousStoreList != null) && (paramAnonymousStoreList.isSuccessful()) && (paramAnonymousStoreList.getErrorCode() == 200) && (paramAnonymousStoreList.getStoreRefList() != null))
      {
        if (StoreCache.i(NearestStoreFragment.this.getActivity()).getCachedStoreList() != null)
        {
          NearestStoreFragment.access$602(NearestStoreFragment.this, StoreCache.i(NearestStoreFragment.this.getActivity()).getCachedStoreList().getStoreRefList());
          GeofenceService.i(NearestStoreFragment.this.getActivity()).registerAllStore();
          if ((NearestStoreFragment.this.mStoreRef.getStoreRef() == null) || (NearestStoreFragment.this.mStoreRef.getStoreRef().size() <= 0))
            break label329;
          NearestStoreFragment.access$702(NearestStoreFragment.this, StoreService.i(NearestStoreFragment.this.getActivity()).getNearestStore(NearestStoreFragment.this.mStoreRef, NearestStoreFragment.this.mCurrentLocation, false));
          if (NearestStoreFragment.this.mNearestStore != null)
          {
            L.I("mNearestStore mNearestStore.getStoreLocation().getLat() " + NearestStoreFragment.this.mNearestStore.getStoreLocation().getLat());
            L.I("mNearestStore mNearestStore.getStoreLocation().getLong() " + NearestStoreFragment.this.mNearestStore.getStoreLocation().getLong());
          }
          if ((!NearestStoreFragment.this.isCurrentSupportedCountry()) || (NearestStoreFragment.this.mSelectStoreBtnClick))
          {
            NearestStoreFragment.this.mBus.post(new ChooseNearestStore());
            NearestStoreFragment.access$102(NearestStoreFragment.this, false);
          }
        }
        else
        {
          NearestStoreFragment.access$602(NearestStoreFragment.this, null);
          return;
        }
        NearestStoreFragment.this.updateNearestStoreInfo();
        NearestStoreFragment.this.showProgressBar(false);
        NearestStoreFragment.this.toggleButtonStatus(true);
        return;
        label329: NearestStoreFragment.this.showProgressBar(false);
        NearestStoreFragment.this.toggleButtonStatus(true);
        return;
      }
      NearestStoreFragment.this.showProgressBar(false);
      NearestStoreFragment.this.handler.postDelayed(new Runnable()
      {
        public void run()
        {
          if (paramAnonymousAppError != null)
            UsageTracker.i().formError(NearestStoreFragment.this.getActivity(), "getstores", paramAnonymousAppError.getMessage());
          if ((paramAnonymousStoreList != null) && (paramAnonymousStoreList.getErrorCode() == 500))
          {
            String str = NearestStoreFragment.this.getString(2131165646) + NearestStoreFragment.this.getString(2131165714);
            NearestStoreFragment.this.showErrorMessage(str, paramAnonymousAppError, paramAnonymousException);
            return;
          }
          UiUtil.showNetworkToast(NearestStoreFragment.this.getActivity(), false);
        }
      }
      , 100L);
    }
  };
  private boolean mShowLoadingVisible = false;
  private StoreRefList mStoreRef;
  private boolean mWasIRestoredAfterBeingKilledBySystem = false;
  private TextView nearStoreTextView;
  private TextView secondHeader;

  public static int calculateInSampleSize(BitmapFactory.Options paramOptions, int paramInt1, int paramInt2)
  {
    int i = paramOptions.outHeight;
    int j = paramOptions.outWidth;
    int k = 1;
    int n;
    if ((i > paramInt2) || (j > paramInt1))
    {
      int m = Math.round(i / paramInt2);
      n = Math.round(j / paramInt1);
      if (m < n)
        k = m;
    }
    else
    {
      return k;
    }
    return n;
  }

  public static Bitmap decodeBitmap(Resources paramResources, int paramInt1, int paramInt2, int paramInt3)
  {
    BitmapFactory.Options localOptions = new BitmapFactory.Options();
    localOptions.inJustDecodeBounds = true;
    BitmapFactory.decodeResource(paramResources, paramInt1, localOptions);
    localOptions.inSampleSize = calculateInSampleSize(localOptions, paramInt2, paramInt3);
    localOptions.inJustDecodeBounds = false;
    return BitmapFactory.decodeResource(paramResources, paramInt1, localOptions);
  }

  private List<Language> getLanguagesListForSelectedRegion()
  {
    AppConfigData localAppConfigData = AppConfigManager.i(getActivity()).getAppConfigData();
    List localList1 = null;
    if (localAppConfigData != null)
    {
      if ((AppConfigManager.i(getActivity()).getAppConfigData().getRegion() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getRegion().getLanguages() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getRegion().getLanguages().getLanguage() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getRegion().getLanguages().getLanguage().isEmpty()))
        break label123;
      localList1 = AppConfigManager.i(getActivity()).getAppConfigData().getRegion().getLanguages().getLanguage();
    }
    label123: boolean bool;
    do
    {
      List localList2;
      do
      {
        Languages localLanguages;
        do
        {
          Country localCountry;
          do
          {
            return localList1;
            localCountry = AppConfigManager.i(getActivity()).getAppConfigData().getConfig();
            localList1 = null;
          }
          while (localCountry == null);
          localLanguages = AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getLanguages();
          localList1 = null;
        }
        while (localLanguages == null);
        localList2 = AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getLanguages().getLanguage();
        localList1 = null;
      }
      while (localList2 == null);
      bool = AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getLanguages().getLanguage().isEmpty();
      localList1 = null;
    }
    while (bool);
    return AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getLanguages().getLanguage();
  }

  private List<Region> getRegionForCountry()
  {
    if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions().getRegions() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions().getRegions().isEmpty()))
      return AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions().getRegions();
    return null;
  }

  private String getSelectedUserCountry()
  {
    return AppConfigManager.i(getActivity()).getAppConfigData().getCountryName();
  }

  private String getSelectedUserLanguages()
  {
    return AppConfigManager.i(getActivity()).getAppConfigData().getLanguageName();
  }

  private void handleCountrySelection(int paramInt)
  {
    int i;
    if (getActivity() != null)
    {
      this.isCountryListOpen = false;
      i = 1;
      try
      {
        String str2 = LocationUtil.getRetailCode(getActivity());
        String str3 = ((Country)this.mConfig.getCountry().get(paramInt)).getCountrycode();
        if ((str2 != null) && (str3 != null))
        {
          boolean bool = str3.equals(str2);
          if (bool)
            i = 0;
        }
      }
      catch (Exception localException2)
      {
        try
        {
          if ((this.mConfig.getCountry() != null) && (this.mConfig.getCountry().get(paramInt) != null))
            AppConfigManager.i(getActivity()).updateSelcetedCountry(((Country)this.mConfig.getCountry().get(paramInt)).getCountryName(), ((Country)this.mConfig.getCountry().get(paramInt)).getCountrycode(), (Country)this.mConfig.getCountry().get(paramInt));
          if ((this.mSelectedCountry == null) || ((this.mSelectedCountry != null) && (this.mConfig.getCountry() != null) && (this.mConfig.getCountry().get(paramInt) != null) && (((Country)this.mConfig.getCountry().get(paramInt)).getCountryName() != null) && (!((Country)this.mConfig.getCountry().get(paramInt)).getCountryName().equalsIgnoreCase(this.mSelectedCountry))))
          {
            this.mNearestStore = null;
            this.mNearestStoreName.setText("");
            this.mNearestStoreName.setVisibility(4);
            if (this.mChooseOtherStore != null)
            {
              if ((AppConfigManager.i(getActivity()).getAppConfigData() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() == null) || (!AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
                break label588;
              this.mChooseOtherStore.setText(getResources().getString(2131165612));
              this.mChooseOtherStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
            }
            if (this.mSelectThisStore != null)
            {
              this.mSelectThisStore.setEnabled(false);
              this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
            }
          }
        }
        catch (Exception localException2)
        {
          try
          {
            AppConfigManager.i(getActivity()).saveFavStore(null);
            while (true)
            {
              localList = getRegionForCountry();
              if ((localList == null) || (localList.isEmpty()))
                break label630;
              if (i != 0)
                UsageTracker.i().countryChanged(getActivity());
              AppConfigManager localAppConfigManager = AppConfigManager.i(getActivity());
              j = 0;
              if (localAppConfigManager == null)
                break label621;
              AppConfigData localAppConfigData = AppConfigManager.i(getActivity()).getAppConfigData();
              j = 0;
              if (localAppConfigData == null)
                break label621;
              String str1 = AppConfigManager.i(getActivity()).getAppConfigData().getRegionCode();
              j = 0;
              if (str1 == null)
                break label621;
              for (int k = 0; k < localList.size(); k++)
                if (AppConfigManager.i(getActivity()).getAppConfigData().getRegionCode().equalsIgnoreCase(((Region)localList.get(k)).getValue()))
                  j = k;
              i = 1;
              this.mNeedToFetchKillSwitch = true;
              break;
              localException1 = localException1;
              localException1.printStackTrace();
              break;
              localException2 = localException2;
              localException2.printStackTrace();
            }
            label588: this.mChooseOtherStore.setText(getResources().getString(2131165611));
          }
          catch (IOException localIOException2)
          {
            List localList;
            int j;
            while (true)
              L.E(localIOException2.getMessage());
            label621: showRegionPicker(localList, j);
          }
        }
      }
    }
    while (true)
    {
      return;
      try
      {
        label630: AppConfigManager.i(getActivity()).updateSelcetedRegion(null, null, null);
        if (isDeviceLocaleSupported())
        {
          setDeviceLocaleAsLanguages();
          if (i == 0)
            continue;
          UsageTracker.i().countryChanged(getActivity());
        }
      }
      catch (IOException localIOException1)
      {
        while (true)
          localIOException1.printStackTrace();
        if (i != 0)
          UsageTracker.i().countryChanged(getActivity());
        showLanguagePicker(((Country)this.mCountryList.get(paramInt)).getLanguages().getLanguage(), 0);
      }
    }
  }

  private void handleTimeOutForCurrentLocation()
  {
    this.handler.postDelayed(new Runnable()
    {
      public void run()
      {
        if ((NearestStoreFragment.this.mCurrentLocation == null) && (NearestStoreFragment.this.getActivity() != null))
        {
          NearestStoreFragment.this.showProgressBar(false);
          NearestStoreFragment.this.showCountryAndLanguagePicker();
        }
      }
    }
    , 30000L);
  }

  private void hideCountryList()
  {
    this.isCountryListOpen = false;
    this.mCounrtyListLayout.animate().translationX(this.mDeviceWidth);
    this.mFadeView.setVisibility(8);
    this.mFadeView.animate().alpha(0.0F);
  }

  private void initCountryList()
  {
    this.mCountryList = ConfigService.i(getActivity()).getCachedConfig().getCountry();
    this.mCountryNameList = new String[this.mCountryList.size()];
    this.mCountryCodeList = new String[this.mCountryList.size()];
    for (int i = 0; i < this.mCountryList.size(); i++)
    {
      this.mCountryNameList[i] = ((Country)this.mCountryList.get(i)).getCountryName();
      this.mCountryCodeList[i] = ((Country)this.mCountryList.get(i)).getCountrycode();
    }
  }

  private void initGPSStatus()
  {
    LocationManager localLocationManager = (LocationManager)getActivity().getSystemService("location");
    this.isGPSLocationEnabled = localLocationManager.isProviderEnabled("gps");
    this.isNetworkLocationEnabled = localLocationManager.isProviderEnabled("network");
  }

  private boolean isCurrentSupportedCountry()
  {
    if ((this.mMyCurrentCountryName != null) && (this.mCountryNameList != null) && (this.mCountryCodeList != null))
      for (int i = 0; i < this.mCountryNameList.length; i++)
        if (((this.mCountryNameList[i] != null) && (this.mCountryNameList[i].toLowerCase(Locale.US).equalsIgnoreCase(this.mMyCurrentCountryName))) || ((this.mCountryCodeList[i] != null) && (this.mCountryCodeList[i].toLowerCase(Locale.US).equalsIgnoreCase(this.mMyCurrentCountryCode))))
          return true;
    return false;
  }

  private boolean isDeviceLocaleSupported()
  {
    if (getActivity() != null)
    {
      Locale localLocale = Resources.getSystem().getConfiguration().locale;
      L.I("Device locale is " + localLocale.getLanguage());
      Country localCountry = AppConfigManager.i(getActivity()).getAppConfigData().getConfig();
      Languages localLanguages = localCountry.getLanguages();
      List localList = null;
      if (localLanguages != null)
        localList = localCountry.getLanguages().getLanguage();
      if ((localList != null) && (!localList.isEmpty()))
        for (int i = 0; i < localList.size(); i++)
          if (((Language)localList.get(i)).getValue().equalsIgnoreCase(localLocale.getLanguage()))
            return true;
    }
    return false;
  }

  private boolean isLBSOff()
  {
    return (!this.isGPSLocationEnabled) && (!this.isNetworkLocationEnabled);
  }

  private void saveCurrentStore()
  {
    try
    {
      AppConfigManager.i(getActivity()).saveFavStore(this.mNearestStore);
      UsageTracker.i().currentStoreChanged(getActivity(), this.mNearestStore);
      return;
    }
    catch (IOException localIOException)
    {
      L.E("saving fav store error  :: " + localIOException.getMessage());
    }
  }

  private void selectOtherStore()
  {
    Country localCountry = AppConfigManager.i(getActivity()).getAppConfigData().getConfig();
    if (localCountry != null);
    int i;
    for (String str = localCountry.getCountrycode(); ; str = Locale.getDefault().getCountry().toLowerCase(Locale.US))
    {
      i = 0;
      if (str == null)
        break;
      boolean bool = str.isEmpty();
      i = 0;
      if (bool)
        break;
      List localList = this.mCountryList;
      i = 0;
      if (localList == null)
        break;
      for (int j = 0; j < this.mCountryList.size(); j++)
        if (((Country)this.mCountryList.get(j)).getCountrycode().toLowerCase(Locale.US).equalsIgnoreCase(str))
          i = j;
    }
    showCountryList(i);
  }

  private void sendRequestForStore()
  {
    boolean bool = AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo();
    updateUiForStoreServiceDisable(bool);
    if (!bool)
      this.handler.postDelayed(new Runnable()
      {
        public void run()
        {
          NearestStoreFragment.this.mBus.post(new ChooseNearestStore());
        }
      }
      , 300L);
    do
    {
      return;
      if (StoreCache.i(getActivity()).getCachedStoreList() != null);
      for (this.mStoreRef = StoreCache.i(getActivity()).getCachedStoreList().getStoreRefList(); ; this.mStoreRef = null)
      {
        this.mNearestStore = AppConfigManager.i(getActivity()).getAppConfigData().getFavStore();
        if ((this.mStoreRef != null) && (this.mStoreRef.getStoreRef().size() != 0))
          break;
        showProgressBar(true);
        StoreService.i(getActivity()).getStoresAsync(this.mServiceCallback);
        return;
      }
      if (this.mNearestStore == null)
        this.mNearestStore = StoreService.i(getActivity()).getNearestStore(this.mStoreRef, this.mCurrentLocation, false);
      showProgressBar(false);
      updateNearestStoreInfo();
    }
    while ((this.mCountryFragment == null) || (this.isCountryListOpen) || (!this.mSelectStoreBtnClick));
    this.handler.postDelayed(new Runnable()
    {
      public void run()
      {
        NearestStoreFragment.this.mBus.post(new ChooseNearestStore());
        NearestStoreFragment.access$102(NearestStoreFragment.this, false);
      }
    }
    , 300L);
  }

  private void sendRequestForStoreAndKL()
  {
    KillSwitchConfig localKillSwitchConfig = AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig();
    if (((localKillSwitchConfig != null) && (System.currentTimeMillis() - localKillSwitchConfig.getLastUpdatedTime() > 7200000L)) || (this.mNeedToFetchKillSwitch))
    {
      this.mNeedToFetchKillSwitch = false;
      showProgressBar(true);
      ConfigService.i(getActivity()).getConfigurationKSAsync(this.mKLServiceCallback, null, null);
      return;
    }
    sendRequestForStore();
  }

  private void setCurrentCountryAsCountry()
  {
    Country localCountry = null;
    String str1 = "";
    int i = 0;
    while (true)
      try
      {
        if (i < this.mCountryList.size())
        {
          if ((((Country)this.mCountryList.get(i)).getCountryName().equalsIgnoreCase(this.mMyCurrentCountryName)) || (this.mCountryCodeList[i].toLowerCase(Locale.US).equalsIgnoreCase(this.mMyCurrentCountryCode)))
          {
            str1 = ((Country)this.mCountryList.get(i)).getCountrycode();
            localCountry = (Country)this.mCountryList.get(i);
          }
        }
        else
        {
          L.I("country code :: " + str1);
          AppConfigManager.i(getActivity()).updateSelcetedCountry(this.mMyCurrentCountryName, str1, localCountry);
          if ((localCountry != null) && (localCountry.getRegions() != null) && (localCountry.getRegions().getRegions() != null) && (!localCountry.getRegions().getRegions().isEmpty()))
          {
            showRegionPicker(localCountry.getRegions().getRegions(), 0);
            return;
          }
        }
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
        continue;
        if (isDeviceLocaleSupported())
        {
          setDeviceLocaleAsLanguages();
          return;
        }
        String str2 = AppConfigManager.i(getActivity()).getAppConfigData().getCountryCode();
        int j = 0;
        if (j < this.mCountryList.size())
        {
          if (((Country)this.mCountryList.get(j)).getCountrycode().equalsIgnoreCase(str2))
            showLanguagePicker(((Country)this.mCountryList.get(j)).getLanguages().getLanguage(), this.mPickerIndex);
          j++;
          continue;
          i++;
        }
      }
  }

  private void setDeviceLocaleAsLanguages()
  {
    String str1 = "";
    try
    {
      String str2 = Resources.getSystem().getConfiguration().locale.getLanguage();
      List localList = AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getLanguages().getLanguage();
      for (int i = 0; ; i++)
        if (i < localList.size())
        {
          if (str2.equalsIgnoreCase(((Language)localList.get(i)).getmValue()))
            str1 = ((Language)localList.get(i)).getName();
        }
        else
        {
          AppConfigManager.i(getActivity()).updateSelcetedLanguage(str1.toLowerCase(Locale.US), str2.toLowerCase(Locale.US));
          sendRequestForStoreAndKL();
          return;
        }
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
  }

  private void showCountryAndLanguagePicker()
  {
    if ((!this.mWasIRestoredAfterBeingKilledBySystem) || (this.mShowLoadingVisible))
    {
      if ((this.mSelectedCountry != null) && (!this.mSelectedCountry.isEmpty()))
        break label48;
      if (!isCurrentSupportedCountry())
        break label43;
      setCurrentCountryAsCountry();
    }
    while (true)
    {
      return;
      label43: selectOtherStore();
      return;
      label48: if ((this.mSelectedLanguage == null) || (this.mSelectedLanguage.isEmpty()))
      {
        if (isDeviceLocaleSupported())
        {
          setDeviceLocaleAsLanguages();
          return;
        }
        String str = AppConfigManager.i(getActivity()).getAppConfigData().getCountryName();
        for (int i = 0; i < this.mCountryList.size(); i++)
          if (((Country)this.mCountryList.get(i)).getCountryName().equalsIgnoreCase(str))
            showLanguagePicker(((Country)this.mCountryList.get(i)).getLanguages().getLanguage(), this.mPickerIndex);
      }
    }
  }

  private void showCountryList(int paramInt)
  {
    if (this.mCounrtyListLayout != null)
    {
      this.isCountryListOpen = true;
      if (this.mCountryFragment != null)
        this.mCountryFragment.setSelectedCountry(paramInt);
      if (!this.isTablet)
        break label112;
      if (!this.isLandscape)
        break label87;
      this.mCounrtyListLayout.animate().translationX(this.mDeviceWidth - this.mDeviceWidth / 3.0F);
    }
    while (true)
    {
      this.mFadeView.setVisibility(0);
      this.mFadeView.animate().alpha(0.7F);
      return;
      label87: this.mCounrtyListLayout.animate().translationX(this.mDeviceWidth - this.mDeviceWidth / 2.0F);
      continue;
      label112: this.mCounrtyListLayout.animate().translationX(this.mDeviceWidth - this.mDeviceWidth);
    }
  }

  private void showErrorMessage(String paramString, AppError paramAppError, Exception paramException)
  {
    toggleButtonStatus(false);
    if (!this.mNoNetworkPopUpVisible)
    {
      showNoNetowrkPopUp(paramString);
      if ((paramException == null) || (paramException.getMessage() == null))
        break label44;
      L.E(paramException.getMessage());
    }
    label44: 
    while (paramAppError == null)
    {
      return;
      this.mNoNetworkPopUpVisible = false;
      break;
    }
    L.I(paramAppError.toString());
  }

  private void showLanguagePicker(final List<Language> paramList, int paramInt)
  {
    if (getActivity() == null);
    while ((!this.mWasIRestoredAfterBeingKilledBySystem) && (this.mLanguagePickerVisible))
      return;
    if (paramList.size() == 1)
      try
      {
        AppConfigManager.i(getActivity()).updateSelcetedLanguage(((Language)paramList.get(0)).getName(), ((Language)paramList.get(0)).getValue());
        sendRequestForStoreAndKL();
        return;
      }
      catch (IOException localIOException)
      {
        while (true)
          localIOException.printStackTrace();
      }
    String[] arrayOfString = new String[paramList.size()];
    for (int i = 0; i < paramList.size(); i++)
      arrayOfString[i] = ((Language)paramList.get(i)).getName();
    this.mLanguagePicker = new CustomPicker(getActivity(), CustomPicker.PickerModeEnum.NORMAL, false);
    this.mLanguagePicker.setDisplayValue(arrayOfString);
    this.mLanguagePicker.setTitle(getResources().getString(2131165637));
    this.mLanguagePicker.setEnableCrossIcon(true);
    this.mLanguagePickerVisible = true;
    this.mLanguagePicker.showPicker(paramInt, new CustomPicker.SelectionListener()
    {
      public void onCancel()
      {
        NearestStoreFragment.access$2702(NearestStoreFragment.this, false);
        NearestStoreFragment.this.showProgressBar(false);
      }

      public void onSelection(int paramAnonymousInt)
      {
        UsageTracker.i().languageChanged(NearestStoreFragment.this.getActivity());
        NearestStoreFragment.access$2502(NearestStoreFragment.this, false);
        try
        {
          AppConfigManager.i(NearestStoreFragment.this.getActivity()).updateSelcetedLanguage(((Language)paramList.get(paramAnonymousInt)).getName(), ((Language)paramList.get(paramAnonymousInt)).getValue());
          NearestStoreFragment.this.sendRequestForStoreAndKL();
          return;
        }
        catch (IOException localIOException)
        {
          while (true)
            localIOException.printStackTrace();
        }
      }
    });
  }

  private void showNoNetowrkPopUp(String paramString)
  {
    this.mNoNetworkPopUp = new CustomPopUp(getActivity(), getString(2131165517), paramString);
    this.mNoNetworkPopUpVisible = true;
    this.mNoNetworkPopUp.show(new CustomPopUp.CustomPopupClickListener()
    {
      public boolean onBackKeyPressed()
      {
        NearestStoreFragment.access$2802(NearestStoreFragment.this, false);
        NearestStoreFragment.this.mChooseOtherStore.setEnabled(true);
        return false;
      }

      public void onCancel()
      {
        NearestStoreFragment.access$3002(NearestStoreFragment.this, null);
        NearestStoreFragment.access$2802(NearestStoreFragment.this, false);
        NearestStoreFragment.this.mChooseOtherStore.setEnabled(true);
      }

      public void onLinkClick()
      {
      }

      public void onPrimaryBtnClick()
      {
        NearestStoreFragment.access$2802(NearestStoreFragment.this, false);
        NearestStoreFragment.this.mChooseOtherStore.setEnabled(true);
      }

      public void onSecondaryBtnClick()
      {
      }
    });
  }

  private void showPopUpToTurnONLBS()
  {
    if (((!this.mWasIRestoredAfterBeingKilledBySystem) && (this.mLBSPopUpVisible)) || (this.isCountryListOpen) || (this.mLanguagePickerVisible))
      return;
    this.mLBSOffPopUp = new CustomPopUp(getActivity(), getResources().getString(2131165743), getResources().getString(2131165489), getResources().getString(2131165431), "", "");
    this.mLBSOffPopUp.setCancelable(false);
    this.mLBSPopUpVisible = true;
    this.mLBSOffPopUp.show(new CustomPopUp.CustomPopupClickListener()
    {
      public boolean onBackKeyPressed()
      {
        NearestStoreFragment.access$1802(NearestStoreFragment.this, false);
        return true;
      }

      public void onCancel()
      {
        NearestStoreFragment.this.mLBSOffPopUp.dismiss();
        NearestStoreFragment.access$1802(NearestStoreFragment.this, false);
      }

      public void onLinkClick()
      {
      }

      public void onPrimaryBtnClick()
      {
        try
        {
          Intent localIntent = new Intent("android.settings.LOCATION_SOURCE_SETTINGS");
          List localList = NearestStoreFragment.this.getActivity().getPackageManager().queryIntentActivities(localIntent, 0);
          if ((localList != null) && (!localList.isEmpty()))
          {
            NearestStoreFragment.this.startActivity(localIntent);
            NearestStoreFragment.this.getActivity().overridePendingTransition(2130968587, 2130968584);
            NearestStoreFragment.access$1802(NearestStoreFragment.this, false);
            return;
          }
          Toast.makeText(NearestStoreFragment.this.getActivity(), NearestStoreFragment.this.getResources().getString(2131165328), 1).show();
          return;
        }
        catch (Exception localException)
        {
          localException.printStackTrace();
        }
      }

      public void onSecondaryBtnClick()
      {
        NearestStoreFragment.this.mLBSOffPopUp.dismiss();
        NearestStoreFragment.access$1802(NearestStoreFragment.this, false);
      }
    });
  }

  private void showProgressBar(boolean paramBoolean)
  {
    if (this.mProgressBar != null)
    {
      if (!paramBoolean)
        break label107;
      this.mChooseOtherStore.setEnabled(false);
      this.mProgressBar.setVisibility(0);
      if (this.mProgressBarGPSOff != null)
        this.mProgressBarGPSOff.setVisibility(0);
      if (this.mSelectThisStore != null)
      {
        this.mSelectThisStore.setEnabled(false);
        this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
      }
      if (this.mSelectAStore != null)
      {
        this.mSelectAStore.setEnabled(false);
        this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
      }
    }
    label107: 
    do
    {
      return;
      this.mChooseOtherStore.setEnabled(true);
      this.mProgressBar.setVisibility(4);
      if (this.mProgressBarGPSOff != null)
        this.mProgressBarGPSOff.setVisibility(4);
      if ((this.mSelectThisStore != null) && (this.mNearestStore != null))
      {
        this.mSelectThisStore.setEnabled(true);
        this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
      }
    }
    while (this.mSelectAStore == null);
    this.mSelectAStore.setEnabled(true);
    this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
  }

  private void showRegionPicker(List<Region> paramList, int paramInt)
  {
    if (getActivity() == null);
    final ArrayList localArrayList;
    String[] arrayOfString;
    List localList;
    do
    {
      do
        return;
      while ((!this.mWasIRestoredAfterBeingKilledBySystem) && (this.mRegionPickerVisible));
      localArrayList = new ArrayList();
      for (int i = 0; i < paramList.size(); i++)
        if (((Region)paramList.get(i)).isEnabled())
          localArrayList.add(paramList.get(i));
      arrayOfString = new String[paramList.size()];
      for (int j = 0; j < localArrayList.size(); j++)
        arrayOfString[j] = ((Region)localArrayList.get(j)).getName();
      if (localArrayList.size() != 1)
        break;
      try
      {
        AppConfigManager.i(getActivity()).updateSelcetedRegion(((Region)localArrayList.get(0)).getName(), ((Region)localArrayList.get(0)).getValue(), (Region)localArrayList.get(0));
        if (isDeviceLocaleSupported())
        {
          setDeviceLocaleAsLanguages();
          return;
        }
      }
      catch (IOException localIOException)
      {
        while (true)
          localIOException.printStackTrace();
        localList = getLanguagesListForSelectedRegion();
      }
    }
    while (localList == null);
    showLanguagePicker(localList, 0);
    return;
    this.mRegionPicker = new CustomPicker(getActivity(), CustomPicker.PickerModeEnum.NORMAL, false);
    this.mRegionPicker.setDisplayValue(arrayOfString);
    this.mRegionPicker.setTitle(getResources().getString(2131165642));
    this.mRegionPicker.setSubTitle(getResources().getString(2131165546));
    this.mRegionPicker.setEnableCrossIcon(true);
    this.mRegionPickerVisible = true;
    this.mRegionPicker.showPicker(paramInt, new CustomPicker.SelectionListener()
    {
      public void onCancel()
      {
        NearestStoreFragment.access$2002(NearestStoreFragment.this, false);
        NearestStoreFragment.this.showProgressBar(false);
      }

      public void onSelection(int paramAnonymousInt)
      {
        NearestStoreFragment.access$2002(NearestStoreFragment.this, false);
        try
        {
          AppConfigManager.i(NearestStoreFragment.this.getActivity()).updateSelcetedRegion(((Region)localArrayList.get(paramAnonymousInt)).getName(), ((Region)localArrayList.get(paramAnonymousInt)).getValue(), (Region)localArrayList.get(paramAnonymousInt));
          L.I("Selected region is :: " + ((Region)localArrayList.get(paramAnonymousInt)).getName());
          if (NearestStoreFragment.this.isDeviceLocaleSupported())
          {
            NearestStoreFragment.this.setDeviceLocaleAsLanguages();
            return;
          }
        }
        catch (IOException localIOException)
        {
          while (true)
            localIOException.printStackTrace();
          List localList = NearestStoreFragment.this.getLanguagesListForSelectedRegion();
          NearestStoreFragment.this.showLanguagePicker(localList, 0);
        }
      }
    });
  }

  private void startStoreSelection(boolean paramBoolean)
  {
    initCountryList();
    this.mSelectedCountry = getSelectedUserCountry();
    this.mSelectedLanguage = getSelectedUserLanguages();
    if ((this.mSelectedCountry != null) && (!this.mSelectedCountry.isEmpty()) && (this.mSelectedLanguage != null) && (!this.mSelectedLanguage.isEmpty()))
      if (isLBSOff())
      {
        this.mSelectAStore.setEnabled(true);
        this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
      }
    do
    {
      do
      {
        return;
        sendRequestForStoreAndKL();
        return;
        if ((paramBoolean) || ((this.mCurrentLocation != null) && (this.mMyCurrentCountryName != null) && (!this.mMyCurrentCountryName.isEmpty())))
        {
          showCountryAndLanguagePicker();
          return;
        }
      }
      while ((this.mWasIRestoredAfterBeingKilledBySystem) && (!this.mShowLoadingVisible));
      if (isLBSOff())
      {
        showPopUpToTurnONLBS();
        return;
      }
    }
    while ((this.mCurrentLocation == null) || (this.isCountryListOpen));
    showProgressBar(true);
    handleTimeOutForCurrentLocation();
    this.mGeocoderHelper.fetchCountryName(getActivity(), this.mCurrentLocation, this.mProgressBar, this.mBus, this.isAsycnTaskRunning);
  }

  private void toggleButtonStatus(boolean paramBoolean)
  {
    if (!paramBoolean)
    {
      if (this.mSelectThisStore != null)
      {
        this.mSelectThisStore.setEnabled(false);
        this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
      }
      if (this.mSelectAStore != null)
      {
        this.mSelectAStore.setEnabled(false);
        this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
      }
    }
    while (true)
    {
      this.mChooseOtherStore.setEnabled(paramBoolean);
      return;
      this.mProgressBar.setVisibility(4);
      if (this.mProgressBarGPSOff != null)
        this.mProgressBarGPSOff.setVisibility(4);
      if ((this.mSelectThisStore != null) && (this.mNearestStore != null))
      {
        this.mSelectThisStore.setEnabled(true);
        this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
      }
      if (this.mSelectAStore != null)
      {
        this.mSelectAStore.setEnabled(true);
        this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
      }
    }
  }

  private void updateAccount(String paramString1, String paramString2, String paramString3)
  {
    Country localCountry;
    Language localLanguage;
    if (getActivity() != null)
    {
      Iterator localIterator1 = ConfigService.i(getActivity()).getCachedConfig().getCountry().iterator();
      while (localIterator1.hasNext())
      {
        localCountry = (Country)localIterator1.next();
        if (localCountry.getCountrycode().equalsIgnoreCase(paramString2))
        {
          Iterator localIterator2 = localCountry.getLanguages().getLanguage().iterator();
          do
          {
            if (!localIterator2.hasNext())
              break;
            localLanguage = (Language)localIterator2.next();
          }
          while (!localLanguage.getValue().equalsIgnoreCase(paramString3));
        }
      }
    }
    try
    {
      AppConfigManager.i(getActivity()).updateSelcetedLanguage(localLanguage.getName(), paramString3);
      AppConfigManager.i(getActivity()).updateSelcetedCountry(localCountry.getCountryName(), paramString2, localCountry);
      return;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
    }
  }

  private void updateNearestStoreInfo()
  {
    if (!isAdded())
      return;
    if (this.mNearestStore != null)
    {
      this.mNearestStoreName.setText(getResources().getString(2131165243) + " " + UiUtil.getFormatedStoreName(getActivity(), this.mNearestStore.getStoreName()));
      this.mNearestStoreName.setVisibility(0);
      if (this.mChooseOtherStore != null)
      {
        if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
        {
          this.mChooseOtherStore.setText(getResources().getString(2131165613));
          this.mChooseOtherStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
        }
      }
      else
      {
        if (this.mSelectThisStore != null)
        {
          this.mSelectThisStore.setEnabled(true);
          if ((AppConfigManager.i(getActivity()).getAppConfigData() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() == null) || (!AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
            break label462;
          this.mSelectThisStore.setText(getResources().getString(2131165608));
          label245: this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
        }
        if (this.mSelectAStore != null)
        {
          if ((AppConfigManager.i(getActivity()).getAppConfigData() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() == null) || (!AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
            break label482;
          this.mSelectAStore.setText(getResources().getString(2131165610));
          label334: this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
        }
      }
    }
    while (true)
      if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
      {
        this.firstHeader.setText(getString(2131165616));
        this.secondHeader.setText(getString(2131165618));
        this.nearStoreTextView.setText(getString(2131165614));
        return;
        this.mChooseOtherStore.setText(getResources().getString(2131165612));
        break;
        label462: this.mSelectThisStore.setText(getResources().getString(2131165609));
        break label245;
        label482: this.mSelectAStore.setText(getResources().getString(2131165634));
        break label334;
        if ((this.mStoreRef != null) && (this.mStoreRef.getStoreRef() != null) && (this.mStoreRef.getStoreRef().size() > 0))
        {
          this.mNearestStoreName.setText(getResources().getString(2131165243) + " " + UiUtil.getFormatedStoreName(getActivity(), ((StoreRef)this.mStoreRef.getStoreRef().get(0)).getStoreName()));
          this.mNearestStoreName.setVisibility(0);
          if (this.mChooseOtherStore != null)
          {
            if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
            {
              this.mChooseOtherStore.setText(getResources().getString(2131165613));
              label679: this.mChooseOtherStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
            }
          }
          else
          {
            if (this.mSelectThisStore != null)
            {
              this.mSelectThisStore.setEnabled(true);
              if ((AppConfigManager.i(getActivity()).getAppConfigData() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() == null) || (!AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
                break label913;
              this.mSelectThisStore.setText(getResources().getString(2131165608));
              label776: this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
            }
            if (this.mSelectAStore == null)
              continue;
            this.mSelectAStore.setEnabled(true);
            if ((AppConfigManager.i(getActivity()).getAppConfigData() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() == null) || (!AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
              break label933;
            this.mSelectAStore.setText(getResources().getString(2131165610));
          }
          while (true)
          {
            this.mSelectAStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana_bold"));
            break;
            this.mChooseOtherStore.setText(getResources().getString(2131165612));
            break label679;
            label913: this.mSelectThisStore.setText(getResources().getString(2131165609));
            break label776;
            label933: this.mSelectAStore.setText(getResources().getString(2131165634));
          }
        }
      }
    this.firstHeader.setText(getString(2131165617));
    this.secondHeader.setText(getString(2131165619));
    this.nearStoreTextView.setText(getString(2131165615));
    this.mNearestStoreName.setText(AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getCountryName());
    this.mNearestStoreName.setVisibility(0);
  }

  private void updateUiForStoreServiceDisable(boolean paramBoolean)
  {
    if (paramBoolean)
    {
      this.secondHeader.setText(getString(2131165618));
      this.nearStoreTextView.setText(getString(2131165614));
      this.mChooseOtherStore.setText(getResources().getString(2131165613));
      this.mSelectAStore.setText(getResources().getString(2131165610));
      return;
    }
    this.secondHeader.setText(getString(2131165619));
    this.nearStoreTextView.setText(getString(2131165615));
    this.mNearestStoreName.setText(AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getCountryName());
    this.mNearestStoreName.setVisibility(0);
    this.mChooseOtherStore.setText(getResources().getString(2131165612));
    this.mSelectAStore.setText(getResources().getString(2131165634));
  }

  private void updateVisibility()
  {
    if (isLBSOff())
    {
      this.mGPSOnLayout.setVisibility(8);
      this.mGPSOFFLayout.setVisibility(0);
      return;
    }
    this.mGPSOnLayout.setVisibility(0);
    this.mGPSOFFLayout.setVisibility(8);
  }

  public void closeCountryListOverlay()
  {
    hideCountryList();
  }

  @Subscribe
  public void handleCountrySelection(ConfigSelectionDoneEvent paramConfigSelectionDoneEvent)
  {
    hideCountryList();
    handleCountrySelection(paramConfigSelectionDoneEvent.mSelectedCountryIndex);
  }

  @Subscribe
  public void handleCurrentCountry(CountryUpdateEvent paramCountryUpdateEvent)
  {
    this.mMyCurrentCountryName = paramCountryUpdateEvent.countryName;
    this.mMyCurrentCountryCode = paramCountryUpdateEvent.countryCode;
    if (ConfigService.i(getActivity()).getCachedConfig() != null)
    {
      showProgressBar(false);
      startStoreSelection(true);
    }
  }

  @Subscribe
  public void handleCurrentLocation(LocationUpdateEvent paramLocationUpdateEvent)
  {
    this.mCurrentLocation = paramLocationUpdateEvent.currentLocation;
    L.I("Current location :: " + this.mCurrentLocation);
    if ((this.mCurrentLocation != null) && (!this.isCountryListOpen))
      this.mGeocoderHelper.fetchCountryName(getActivity(), this.mCurrentLocation, this.mProgressBar, this.mBus, this.isAsycnTaskRunning);
  }

  @Subscribe
  public void handleNetworkStatusChange(NetworkStatusEvent paramNetworkStatusEvent)
  {
    if (paramNetworkStatusEvent.mConnected)
    {
      if ((this.mNetworkDialog != null) && (this.mNetworkDialog.isVisible()) && (isAdded()))
        this.mNetworkDialog.dismiss();
      if (ConfigService.i(getActivity()).getCachedConfig() == null)
      {
        showProgressBar(true);
        ConfigService.i(getActivity()).loadConfigureAsyc(this.mServiceCallBackConfig);
      }
    }
  }

  public boolean isCountrtListOpen()
  {
    return this.isCountryListOpen;
  }

  public void onActivityCreated(Bundle paramBundle)
  {
    super.onActivityCreated(paramBundle);
    if (paramBundle != null)
    {
      if (paramBundle.containsKey("KEY_LBS_POPUP_VISIBLE"))
        this.mLBSPopUpVisible = paramBundle.getBoolean("KEY_LBS_POPUP_VISIBLE");
      if (paramBundle.containsKey("KEY_PICKER_INDEX"))
        this.mPickerIndex = paramBundle.getInt("KEY_PICKER_INDEX");
      if (paramBundle.containsKey("KEY_COUNTRY_PICKER_VISIBLE"))
        this.isCountryListOpen = paramBundle.getBoolean("KEY_COUNTRY_PICKER_VISIBLE");
      if (paramBundle.containsKey("KEY_LANGUAGE_PICKER_VISIBLE"))
        this.mLanguagePickerVisible = paramBundle.getBoolean("KEY_LANGUAGE_PICKER_VISIBLE");
      if (paramBundle.containsKey("KEY_REGION_PICKER_VISIBLE"))
        this.mRegionPickerVisible = paramBundle.getBoolean("KEY_REGION_PICKER_VISIBLE");
      if (paramBundle.containsKey("KEY_SELECT_STORE_BTN_CLICK"))
        this.mSelectStoreBtnClick = paramBundle.getBoolean("KEY_SELECT_STORE_BTN_CLICK");
      if (!this.mLBSPopUpVisible)
        break label173;
      showPopUpToTurnONLBS();
    }
    while (true)
    {
      if (paramBundle.containsKey("KEY_PROGRESS_BAR_VISIBLE"))
        this.mShowLoadingVisible = paramBundle.getBoolean("KEY_PROGRESS_BAR_VISIBLE");
      if (paramBundle.containsKey("KEY_ASYNC_TASK_RUNNING"))
        this.isAsycnTaskRunning = paramBundle.getBoolean("KEY_ASYNC_TASK_RUNNING");
      return;
      label173: if (this.isCountryListOpen)
      {
        if ((this.mConfig != null) && (this.mConfig.getCountry() != null))
          initCountryList();
        showCountryList(this.mPickerIndex);
      }
      else if (this.mRegionPickerVisible)
      {
        if ((AppConfigManager.i(getActivity()).getAppConfigData() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions() != null) && (AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions().getRegions() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions().getRegions().isEmpty()))
          showRegionPicker(AppConfigManager.i(getActivity()).getAppConfigData().getConfig().getRegions().getRegions(), this.mPickerIndex);
      }
      else if (this.mLanguagePickerVisible)
      {
        String str = AppConfigManager.i(getActivity()).getAppConfigData().getCountryCode();
        if ((this.mConfig != null) && (this.mConfig.getCountry() != null))
          initCountryList();
        for (int i = 0; i < this.mCountryList.size(); i++)
          if ((((Country)this.mCountryList.get(i)).getCountrycode().equals(str)) && (((Country)this.mCountryList.get(i)).getLanguages() != null))
            showLanguagePicker(((Country)this.mCountryList.get(i)).getLanguages().getLanguage(), this.mPickerIndex);
      }
    }
  }

  public void onAttach(Activity paramActivity)
  {
    super.onAttach(paramActivity);
    Bundle localBundle = getArguments();
    if ((localBundle != null) && (localBundle.containsKey("LaunchedFromCatalogue")))
    {
      this.mLaunchedFromCatalogueURI = ((Uri)localBundle.getParcelable("LaunchedFromCatalogue"));
      if (this.mLaunchedFromCatalogueURI != null)
      {
        String str = this.mLaunchedFromCatalogueURI.getAuthority();
        List localList = this.mLaunchedFromCatalogueURI.getPathSegments();
        if ((localList != null) && (localList.size() == 3))
          updateAccount(str, (String)localList.get(0), (String)localList.get(1));
      }
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.mConfig = ConfigService.i(getActivity()).getCachedConfig();
    if (paramBundle != null)
      this.mWasIRestoredAfterBeingKilledBySystem = paramBundle.getBoolean("GETTING_KILLED_BY_SYSTEM", false);
    this.isTablet = UiUtil.isTablet(getActivity());
    this.isLandscape = UiUtil.isLandscape(getActivity());
    this.mDeviceWidth = UiUtil.screenWidth(getActivity());
    if ((paramBundle != null) && (paramBundle.containsKey("KEY_NO_NETWORK_POPUP_VISIBLE")))
    {
      this.mNoNetworkPopUpVisible = paramBundle.getBoolean("KEY_NO_NETWORK_POPUP_VISIBLE");
      boolean bool1 = this.mNoNetworkPopUpVisible;
      boolean bool2 = false;
      if (!bool1)
        bool2 = true;
      this.mNoNetworkPopUpVisible = bool2;
    }
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    View localView = paramLayoutInflater.inflate(2130903087, paramViewGroup, false);
    if (UiUtil.isTablet(getActivity()))
    {
      int i = UiUtil.screenHeight(getActivity());
      int j = (int)UiUtil.screenWidth(getActivity());
      ((ImageView)localView.findViewById(2131624133)).setImageBitmap(decodeBitmap(getResources(), 2130837789, j, i));
    }
    this.mSelectThisStore = ((Button)localView.findViewById(2131624125));
    this.mSelectThisStore.setEnabled(false);
    this.mSelectThisStore.setTypeface(TypeFaceProvider.getTypeFace(getActivity(), "verdana"));
    this.mChooseOtherStore = ((TextView)localView.findViewById(2131624126));
    this.mChooseOtherStore.setEnabled(true);
    this.mNearestStoreName = ((TextView)localView.findViewById(2131624190));
    this.mProgressBar = localView.findViewById(2131624189);
    this.mProgressBar.setVisibility(4);
    this.mProgressBarGPSOff = localView.findViewById(2131624129);
    this.mProgressBarGPSOff.setVisibility(4);
    this.mSelectAStore = ((Button)localView.findViewById(2131624130));
    this.nearStoreTextView = ((TextView)localView.findViewById(2131624188));
    ImageView localImageView = (ImageView)localView.findViewById(2131624107);
    label409: label488: ViewGroup.LayoutParams localLayoutParams;
    if (UiUtil.isTablet(getActivity()))
      if ((UiUtil.isTablet7(getActivity())) && (!UiUtil.isMdpiDevice(getActivity())))
      {
        localImageView.setImageResource(2130837788);
        this.firstHeader = ((TextView)localView.findViewById(2131624105));
        this.secondHeader = ((TextView)localView.findViewById(2131624106));
        this.mGPSOffExplainText = ((TextView)localView.findViewById(2131624128));
        if ((AppConfigManager.i(getActivity()).getAppConfigData() == null) || (AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig() == null) || (!AppConfigManager.i(getActivity()).getAppConfigData().getKillSwitchConfig().isShowStoreInfo()))
          break label685;
        this.firstHeader.setText(getString(2131165616));
        this.secondHeader.setText(getString(2131165618));
        if (this.mGPSOffExplainText != null)
          this.mGPSOffExplainText.setText(getString(2131165246));
        localView.findViewById(2131624108).setVisibility(0);
        localView.findViewById(2131624109).setVisibility(0);
        this.mGPSOnLayout = localView.findViewById(2131624124);
        this.mGPSOFFLayout = localView.findViewById(2131624127);
        if ((!this.isGPSLocationEnabled) && (!this.isNetworkLocationEnabled))
          break label730;
        this.mGPSOnLayout.setVisibility(0);
        this.mGPSOFFLayout.setVisibility(8);
        this.mSelectThisStore.setOnClickListener(this.mOnClickListener);
        this.mChooseOtherStore.setOnClickListener(this.mOnClickListener);
        this.mSelectAStore.setOnClickListener(this.mOnClickListener);
        this.mCounrtyListLayout = localView.findViewById(2131624132);
        this.mFadeView = localView.findViewById(2131624131);
        this.mFadeView.setOnClickListener(this.mOnClickListener);
        this.mCounrtyListLayout.setTranslationX(this.mDeviceWidth);
        localLayoutParams = this.mCounrtyListLayout.getLayoutParams();
        if (!this.isTablet)
          break label765;
        if (!this.isLandscape)
          break label750;
        localLayoutParams.width = ((int)(this.mDeviceWidth / 3.0F));
      }
    while (true)
    {
      this.mCounrtyListLayout.setLayoutParams(localLayoutParams);
      if (paramBundle != null)
        break label778;
      FragmentTransaction localFragmentTransaction = getChildFragmentManager().beginTransaction();
      this.mCountryFragment = CountryFragment.getNewInstance(true);
      localFragmentTransaction.replace(this.mCounrtyListLayout.getId(), this.mCountryFragment, "COUNTRY_LIST_FRAGMENT");
      localFragmentTransaction.commit();
      return localView;
      localImageView.setImageResource(2130837787);
      break;
      localImageView.setImageResource(2130837786);
      break;
      label685: this.firstHeader.setText(getString(2131165617));
      this.secondHeader.setText(getString(2131165619));
      this.mGPSOffExplainText.setText(getString(2131165247));
      break label409;
      label730: this.mGPSOnLayout.setVisibility(8);
      this.mGPSOFFLayout.setVisibility(0);
      break label488;
      label750: localLayoutParams.width = ((int)(this.mDeviceWidth / 2.0F));
      continue;
      label765: localLayoutParams.width = ((int)this.mDeviceWidth);
    }
    label778: this.mCountryFragment = ((CountryFragment)getChildFragmentManager().findFragmentByTag("COUNTRY_LIST_FRAGMENT"));
    return localView;
  }

  public void onPause()
  {
    super.onPause();
    this.mServiceCallBackConfig.markInvalid();
    this.mServiceCallback.markInvalid();
    this.mKLServiceCallback.markInvalid();
    try
    {
      this.mBus.unregister(this);
      return;
    }
    catch (Exception localException)
    {
      L.W("No event handler to unregister");
    }
  }

  public void onResume()
  {
    super.onResume();
    this.mServiceCallBackConfig.markValid();
    this.mServiceCallback.markValid();
    this.mKLServiceCallback.markValid();
    this.mBus.register(this);
    initGPSStatus();
    updateVisibility();
    this.mCurrentLocation = ((FirstUserExperienceActivity)getActivity()).getCurrentLocation();
    this.mMyCurrentCountryName = ((FirstUserExperienceActivity)getActivity()).getCurrentCountry();
    if (this.mProgressBarGPSOff != null)
      this.mProgressBarGPSOff.setVisibility(4);
    if (ConfigService.i(getActivity()).getCachedConfig() == null)
    {
      showProgressBar(true);
      ConfigService.i(getActivity()).loadConfigureAsyc(this.mServiceCallBackConfig);
      return;
    }
    startStoreSelection(false);
  }

  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    paramBundle.putBoolean("KEY_LBS_POPUP_VISIBLE", this.mLBSPopUpVisible);
    if (this.mNoNetworkPopUp != null)
    {
      paramBundle.putBoolean("KEY_NO_NETWORK_POPUP_VISIBLE", this.mNoNetworkPopUpVisible);
      this.mNoNetworkPopUp.dismiss();
    }
    paramBundle.putBoolean("KEY_COUNTRY_PICKER_VISIBLE", this.isCountryListOpen);
    if (this.mLanguagePicker != null)
    {
      paramBundle.putBoolean("KEY_LANGUAGE_PICKER_VISIBLE", this.mLanguagePicker.isPickerVisible());
      if (this.mLanguagePicker.isPickerVisible())
        paramBundle.putInt("KEY_PICKER_INDEX", this.mLanguagePicker.getCurrentSelectedValue());
    }
    if (this.mRegionPicker != null)
    {
      paramBundle.putBoolean("KEY_REGION_PICKER_VISIBLE", this.mRegionPicker.isPickerVisible());
      if (this.mRegionPicker.isPickerVisible())
        paramBundle.putInt("KEY_PICKER_INDEX", this.mRegionPicker.getCurrentSelectedValue());
    }
    paramBundle.putBoolean("GETTING_KILLED_BY_SYSTEM", true);
    paramBundle.putBoolean("KEY_SELECT_STORE_BTN_CLICK", this.mSelectStoreBtnClick);
    if (this.mProgressBar != null)
      paramBundle.putBoolean("KEY_PROGRESS_BAR_VISIBLE", this.mProgressBar.isShown());
    if (this.mGeocoderHelper != null)
    {
      Log.e("aaz", "" + this.mGeocoderHelper.running);
      paramBundle.putBoolean("KEY_ASYNC_TASK_RUNNING", this.mGeocoderHelper.running);
    }
  }

  protected void openNextFTEFragment()
  {
    if (new ECCountryUtils().isECEnabledInCurrentStore(getActivity()))
    {
      this.mBus.post(new ECQRFirstTimeEvent());
      return;
    }
    this.mBus.post(new RegistrationFirstTimeEvent());
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.fte.NearestStoreFragment
 * JD-Core Version:    0.6.2
 */