package com.ikea.kompis.shopping;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ExpandableListView;
import android.widget.TextView;
import com.handmark.pulltorefresh.library.ILoadingLayout;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnPullEventListener;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener;
import com.handmark.pulltorefresh.library.PullToRefreshBase.State;
import com.handmark.pulltorefresh.library.PullToRefreshExpandableListView;
import com.ikea.kompis.ShoppingCartActivity;
import com.ikea.kompis.TypeFaceProvider;
import com.ikea.kompis.browse.event.ProductDetailsCloseFromSL;
import com.ikea.kompis.extendedcontent.ECIkeaFamilyActivity;
import com.ikea.kompis.fragments.BaseFragment;
import com.ikea.kompis.setting.event.LocaleChangeEvent;
import com.ikea.kompis.shopping.event.MotherSPRSelectedEvent;
import com.ikea.kompis.shopping.event.SLItemStateChangeEvent;
import com.ikea.kompis.user.event.AccountUpdatedEvent;
import com.ikea.kompis.user.event.LogoutDoneEvent;
import com.ikea.kompis.util.KillSwitchUtil;
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.cart.ShoppingCart;
import com.ikea.shared.cart.ShoppingCartModel;
import com.ikea.shared.config.model.Currency;
import com.ikea.shared.config.model.KillSwitchConfig;
import com.ikea.shared.event.KillSwitchEvent;
import com.ikea.shared.products.model.RetailItemCommChild;
import com.ikea.shared.products.model.RetailItemCommChildList;
import com.ikea.shared.products.model.RetailItemCommunication;
import com.ikea.shared.shopping.event.SLChangedEvent;
import com.ikea.shared.shopping.event.ShoppingListRefreshEvent;
import com.ikea.shared.shopping.event.StartSyncEvent;
import com.ikea.shared.shopping.model.Receipt;
import com.ikea.shared.shopping.service.ShoppingCartService;
import com.ikea.shared.stores.model.StoreRef;
import com.ikea.shared.user.model.User;
import com.ikea.shared.user.service.UserService;
import com.ikea.shared.util.Constant;
import com.ikea.shared.util.L;
import com.ikea.shared.util.NetworkUtil;
import com.ikea.shared.util.ServiceCallback;
import com.squareup.otto.Bus;
import com.squareup.otto.Subscribe;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.UnknownFormatConversionException;

public class ShoppingListFragment extends BaseFragment
{
  private static final String KEY_FIRST_VISIBLE_ITEM_INDEX = "KEY_FIRST_VISIBLE_ITEM_INDEX";
  private static final String KEY_ITEM_SCROLL_POSITION = "KEY_ITEM_SCROLL_POSITION";
  private static final String KEY_SHOPPING_CART_LIST_STATE = "KEY_SHOPPING_CART_LIST_STATE";
  private static final String KEY_SHOPPING_CART_QUICK_MENU_STATE = "KEY_SHOPPING_CART_QUICK_MENU_STATE";
  private final Runnable fitsOnScreen = new Runnable()
  {
    public void run()
    {
      try
      {
        if ((ShoppingListFragment.this.mShoppingListView == null) || (ShoppingListFragment.this.mShoppingListView.getRefreshableView() == null))
          return;
        int i = ((ExpandableListView)ShoppingListFragment.this.mShoppingListView.getRefreshableView()).getLastVisiblePosition();
        if ((i == -1 + ((ExpandableListView)ShoppingListFragment.this.mShoppingListView.getRefreshableView()).getCount()) && (((ExpandableListView)ShoppingListFragment.this.mShoppingListView.getRefreshableView()).getChildAt(i) != null) && (-100 + ((ExpandableListView)ShoppingListFragment.this.mShoppingListView.getRefreshableView()).getChildAt(i).getBottom() < ((ExpandableListView)ShoppingListFragment.this.mShoppingListView.getRefreshableView()).getHeight()))
        {
          L.I("It fits!");
          ShoppingListFragment.this.mIkeaBottomIcon.setVisibility(8);
          return;
        }
        L.I("It fits! NOT");
        if (ShoppingCart.i(ShoppingListFragment.this.getActivity()).isEmpty())
        {
          ShoppingListFragment.this.mIkeaBottomIcon.setVisibility(8);
          return;
        }
      }
      catch (Exception localException)
      {
        localException.printStackTrace();
        return;
      }
      ShoppingListFragment.this.mIkeaBottomIcon.setVisibility(0);
    }
  };
  private boolean hasFamilyNumber;
  private long mCartLastUpdatedTime;
  private View mIkeaBottomIcon;
  private TextView mIkeaFamilyMessage;
  private View mIkeaFamilyMessageView;
  private TextView mIkeaFamilyPrice;
  private TextView mIkeaFamilyTitle;
  private View mIkeaSavingView;
  private int mItemPosition = 0;
  private int mListPosition = 0;
  private Parcelable mListState;
  private HashMap<String, Integer> mSLItemStateNew = new HashMap();
  private final ServiceCallback<ShoppingCartModel> mServiceCallBack = new ServiceCallback()
  {
    public void done(ShoppingCartModel paramAnonymousShoppingCartModel, AppError paramAnonymousAppError, Exception paramAnonymousException)
    {
      L.I("ShoppingListFragment mServiceCallBack  result: " + paramAnonymousShoppingCartModel);
      if (paramAnonymousShoppingCartModel != null)
      {
        ShoppingListFragment.this.updateSLItemState(paramAnonymousShoppingCartModel.getProductList());
        ShoppingListFragment.this.refreshListView(paramAnonymousShoppingCartModel);
      }
    }
  };
  private ShoppingCartModel mShoppingCartModel;
  private ShoppingListAdapter mShoppingListAdapter;
  private PullToRefreshExpandableListView mShoppingListView;
  private View mSummaryHeader;
  private View mSummaryView;
  private TextView mTotalPrice;
  private TextView mTotalTitle;
  private StoreRef mfavStore;

  private boolean hasFamilyNumber()
  {
    User localUser = UserService.i(this.mParent).getUser();
    return (localUser != null) && (localUser.isLoggedIn()) && (!TextUtils.isEmpty(localUser.getIkeaFamilyNumber()));
  }

  private void refreshListView(ShoppingCartModel paramShoppingCartModel)
  {
    if ((paramShoppingCartModel != null) && (getActivity() != null))
    {
      if (this.mShoppingListAdapter != null)
      {
        this.mShoppingListAdapter.notifyDataSetChanged();
        if (this.mSLItemStateNew != null)
          this.mShoppingListAdapter.setSLItemsStateList(this.mSLItemStateNew);
        if (!paramShoppingCartModel.getProductList().isEmpty())
          break label262;
        showSummaryView(false);
        User localUser = UserService.i(this.mParent).getUser();
        if ((localUser == null) || (!localUser.isLoggedIn()))
          break label249;
        this.mShoppingListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
      }
      while (true)
      {
        refreshPrice(paramShoppingCartModel);
        ((ExpandableListView)this.mShoppingListView.getRefreshableView()).setGroupIndicator(null);
        if (this.mListState == null)
          this.mListState = ((ExpandableListView)this.mShoppingListView.getRefreshableView()).onSaveInstanceState();
        if (this.mListState != null)
        {
          this.mShoppingListView.requestFocus();
          ((ExpandableListView)this.mShoppingListView.getRefreshableView()).onRestoreInstanceState(this.mListState);
          this.mListState = null;
        }
        for (int i = 0; i < this.mShoppingListAdapter.getGroupCount(); i++)
          ((ExpandableListView)this.mShoppingListView.getRefreshableView()).expandGroup(i);
        this.mShoppingListAdapter = new ShoppingListAdapter(this.mParent, this, this.mHandler);
        ((ExpandableListView)this.mShoppingListView.getRefreshableView()).setAdapter(this.mShoppingListAdapter);
        break;
        label249: this.mShoppingListView.setMode(PullToRefreshBase.Mode.DISABLED);
        continue;
        label262: this.mShoppingListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
        showSummaryView(true);
      }
      ((ExpandableListView)this.mShoppingListView.getRefreshableView()).setSelectionFromTop(this.mListPosition, this.mItemPosition);
    }
    ((ExpandableListView)this.mShoppingListView.getRefreshableView()).post(this.fitsOnScreen);
  }

  private void refreshPrice(ShoppingCartModel paramShoppingCartModel)
  {
    this.mShoppingCartModel = paramShoppingCartModel;
    Receipt localReceipt = paramShoppingCartModel.getReceipt();
    String str1 = "%s %n";
    if ((AppConfigManager.i(this.mParent).getAppConfigData().getCurrencyForLanguages() != null) && (AppConfigManager.i(this.mParent).getAppConfigData().getCurrencyForLanguages().getPositiveFormat() != null))
      str1 = AppConfigManager.i(this.mParent).getAppConfigData().getCurrencyForLanguages().getPositiveFormat();
    String str2 = com.ikea.kompis.util.UiUtil.getCurrencySymbol(this.mParent);
    float f;
    String str5;
    if (localReceipt != null)
    {
      if (this.mTotalPrice != null)
      {
        String str6 = str1.replace("%s", str2).replace("%n", com.ikea.shared.util.UiUtil.getFormatedPrice(this.mParent, localReceipt.getTotal(), true));
        this.mTotalPrice.setText(str6);
      }
      if (this.mIkeaFamilyPrice != null)
      {
        User localUser = UserService.i(this.mParent).getUser();
        f = localReceipt.getIkeaFamilySaving();
        if ((!TextUtils.isEmpty(localUser.getIkeaFamilyNumber())) || (!TextUtils.isEmpty(localUser.getLocalIkeaFamilyNumber())))
          break label512;
        if (!AppConfigManager.i(this.mParent).getAppConfigData().isMemberLight())
          break label354;
        this.mIkeaFamilyMessageView.setVisibility(0);
        this.mIkeaSavingView.setVisibility(8);
        if (f <= 0.0F)
          break label334;
        str5 = str1.replace("%s", str2).replace("%n", com.ikea.shared.util.UiUtil.getFormatedPrice(this.mParent, f, true));
      }
    }
    label512: 
    while (true)
    {
      try
      {
        this.mIkeaFamilyMessage.setText(getResources().getString(2131165368, new Object[] { str5 }));
        if ((AppConfigManager.i(getActivity()) != null) && (AppConfigManager.i(getActivity()).getAppConfigData() != null) && (!AppConfigManager.i(getActivity()).getAppConfigData().isIRWSupported()))
          this.mIkeaFamilyMessageView.setVisibility(8);
        return;
      }
      catch (UnknownFormatConversionException localUnknownFormatConversionException2)
      {
        localUnknownFormatConversionException2.printStackTrace();
        continue;
      }
      catch (Exception localException2)
      {
        localException2.printStackTrace();
        continue;
      }
      label334: this.mIkeaFamilyMessage.setText(getResources().getString(2131165369));
      continue;
      label354: if (AppConfigManager.i(this.mParent).getAppConfigData().isMemberFull())
      {
        this.mIkeaFamilyMessageView.setVisibility(0);
        this.mIkeaSavingView.setVisibility(8);
        if (f > 0.0F)
        {
          String str4 = str1.replace("%s", str2).replace("%n", com.ikea.shared.util.UiUtil.getFormatedPrice(this.mParent, f, true));
          try
          {
            this.mIkeaFamilyMessage.setText(getResources().getString(2131165659, new Object[] { str4 }));
          }
          catch (UnknownFormatConversionException localUnknownFormatConversionException1)
          {
            localUnknownFormatConversionException1.printStackTrace();
          }
          catch (Exception localException1)
          {
            localException1.printStackTrace();
          }
        }
        else
        {
          this.mIkeaFamilyMessage.setText(getResources().getString(2131165655));
        }
      }
      else
      {
        this.mIkeaFamilyMessageView.setVisibility(8);
        this.mIkeaSavingView.setVisibility(8);
        continue;
        if (f > 0.0F)
        {
          this.mIkeaFamilyMessageView.setVisibility(8);
          this.mIkeaSavingView.setVisibility(0);
          String str3 = str1.replace("%s", str2).replace("%n", com.ikea.shared.util.UiUtil.getFormatedPrice(this.mParent, f, true));
          this.mIkeaFamilyPrice.setText("-" + str3);
        }
        else
        {
          this.mIkeaFamilyMessageView.setVisibility(8);
          this.mIkeaSavingView.setVisibility(8);
        }
      }
    }
  }

  private void saveListState()
  {
    this.mListState = ((ExpandableListView)this.mShoppingListView.getRefreshableView()).onSaveInstanceState();
    this.mListPosition = ((ExpandableListView)this.mShoppingListView.getRefreshableView()).getFirstVisiblePosition();
    View localView = ((ExpandableListView)this.mShoppingListView.getRefreshableView()).getChildAt(0);
    if (localView == null);
    for (int i = 0; ; i = localView.getTop())
    {
      this.mItemPosition = i;
      return;
    }
  }

  private void setSyncValue()
  {
    if (this.mShoppingListView != null);
    try
    {
      this.mShoppingListView.getLoadingLayoutProxy().setPullLabel(getString(2131165575));
      this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(getString(2131165448));
      this.mShoppingListView.getLoadingLayoutProxy().setReleaseLabel(getString(2131165582));
      this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(this.mParent, this.mShoppingListView, ShoppingCart.i(this.mParent).getLastStockSyncedTime()));
      return;
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }

  private void showSummaryView(boolean paramBoolean)
  {
    View localView1 = this.mSummaryView;
    int i;
    View localView2;
    int j;
    if (paramBoolean)
    {
      i = 0;
      localView1.setVisibility(i);
      localView2 = this.mSummaryHeader;
      j = 0;
      if (!paramBoolean)
        break label43;
    }
    while (true)
    {
      localView2.setVisibility(j);
      return;
      i = 8;
      break;
      label43: j = 8;
    }
  }

  private void startSync()
  {
    if ((this.mShoppingListView != null) && (isAdded()))
    {
      this.mShoppingListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
      this.mHandler.postDelayed(new Runnable()
      {
        public void run()
        {
          if (ShoppingListFragment.this.isAdded())
          {
            ShoppingListFragment.this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(ShoppingListFragment.this.getString(2131165686));
            ShoppingListFragment.this.mShoppingListView.setRefreshing(true);
          }
        }
      }
      , 500L);
    }
  }

  private void updateSLItemState(Collection<RetailItemCommunication> paramCollection)
  {
    if (((paramCollection == null) || (paramCollection.isEmpty())) && (this.mSLItemStateNew != null))
      this.mSLItemStateNew.clear();
    Iterator localIterator1;
    do
    {
      return;
      HashMap localHashMap = this.mSLItemStateNew;
      localIterator1 = null;
      if (localHashMap != null)
      {
        Set localSet = this.mSLItemStateNew.entrySet();
        localIterator1 = null;
        if (localSet != null)
          localIterator1 = this.mSLItemStateNew.entrySet().iterator();
      }
    }
    while (localIterator1 == null);
    label72: Map.Entry localEntry;
    int i;
    Iterator localIterator2;
    label102: if (localIterator1.hasNext())
    {
      localEntry = (Map.Entry)localIterator1.next();
      i = 0;
      localIterator2 = paramCollection.iterator();
    }
    while (true)
    {
      RetailItemCommunication localRetailItemCommunication;
      if (localIterator2.hasNext())
      {
        localRetailItemCommunication = (RetailItemCommunication)localIterator2.next();
        if (localRetailItemCommunication.getItemNo().equals(localEntry.getKey()))
          i = 1;
      }
      else
      {
        if (i != 0)
          break label72;
        localIterator1.remove();
        break label72;
        break;
      }
      if ((localRetailItemCommunication.getRetailItemCommChildList() != null) && (localRetailItemCommunication.getRetailItemCommChildList().getRetailItemCommChild() != null) && (!localRetailItemCommunication.getRetailItemCommChildList().getRetailItemCommChild().isEmpty()))
      {
        Iterator localIterator3 = localRetailItemCommunication.getRetailItemCommChildList().getRetailItemCommChild().iterator();
        if (localIterator3.hasNext())
        {
          RetailItemCommChild localRetailItemCommChild = (RetailItemCommChild)localIterator3.next();
          if ((localRetailItemCommChild.isCollected()) || (!localRetailItemCommChild.getItemNo().equals(localEntry.getKey())))
            break label102;
          i = 1;
        }
      }
    }
  }

  @Subscribe
  public void RSt(SLItemStateChangeEvent paramSLItemStateChangeEvent)
  {
    if (this.mShoppingListAdapter != null)
      this.mShoppingListAdapter.updateItemState(paramSLItemStateChangeEvent);
    if ((this.mShoppingListView != null) && (paramSLItemStateChangeEvent.state == 1) && (ShoppingCart.i(getActivity()).getProductList().size() == 1))
      this.mShoppingListView.setMode(PullToRefreshBase.Mode.DISABLED);
    while ((this.mShoppingListView == null) || (!this.mShoppingListView.getMode().equals(PullToRefreshBase.Mode.DISABLED)))
      return;
    this.mShoppingListView.setMode(PullToRefreshBase.Mode.PULL_FROM_START);
  }

  @Subscribe
  public void addItemToShoppingList(SLChangedEvent paramSLChangedEvent)
  {
    if ((getActivity() != null) && (this.mShoppingListView != null) && (this.mShoppingListView.isRefreshing()) && (!ShoppingCartService.i(getActivity()).getSLSyncInProcess()))
    {
      this.mShoppingListView.onRefreshComplete();
      this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(this.mParent, this.mShoppingListView, ShoppingCart.i(this.mParent).getLastStockSyncedTime()));
      this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(getString(2131165448));
    }
    Constant.i().setUpdateSlAfterItemDeleted(false);
    Constant.i().setProductModified(false);
    this.mCartLastUpdatedTime = ShoppingCart.i(getActivity()).getCartLastUdpatedTime();
    refreshListView(paramSLChangedEvent.shoppingCart);
  }

  @Subscribe
  public void handleAccountUpdated(AccountUpdatedEvent paramAccountUpdatedEvent)
  {
    this.mServiceCallBack.markValid();
    ShoppingCart.i(getActivity()).fetchShoppingCart(this.mServiceCallBack);
    Constant.i().setProductModified(false);
    this.mCartLastUpdatedTime = ShoppingCart.i(getActivity()).getCartLastUdpatedTime();
    Constant.i().setUpdateSlAfterItemDeleted(false);
  }

  @Subscribe
  public void handleKillSwitchEvent(KillSwitchEvent paramKillSwitchEvent)
  {
    if ((!KillSwitchUtil.isPrimaryServiceSameAsPrevious(paramKillSwitchEvent.oldKillSwitchConfig, paramKillSwitchEvent.newKillSwitchConfig)) && (this.mShoppingListAdapter != null))
      this.mShoppingListAdapter.notifyDataSetChanged();
  }

  @Subscribe
  public void handleLocaleChange(LocaleChangeEvent paramLocaleChangeEvent)
  {
    L.I("SL handleLocaleChange");
    setSyncValue();
    if (this.mTotalTitle != null)
      this.mTotalTitle.setText(2131165712);
    if (this.mIkeaFamilyTitle != null)
      this.mIkeaFamilyTitle.setText(2131165244);
    if (this.mShoppingListAdapter != null)
    {
      this.mShoppingListAdapter.upadteEmptyView();
      this.mShoppingListAdapter.notifyDataSetChanged();
    }
  }

  @Subscribe
  public void handleLogout(LogoutDoneEvent paramLogoutDoneEvent)
  {
    if (this.mShoppingListAdapter != null)
    {
      this.mServiceCallBack.markValid();
      ShoppingCart.i(getActivity()).fetchShoppingCart(this.mServiceCallBack);
      Constant.i().setProductModified(false);
      this.mCartLastUpdatedTime = ShoppingCart.i(getActivity()).getCartLastUdpatedTime();
    }
    if ((this.mShoppingListView != null) && (this.mShoppingListView.isRefreshing()))
    {
      this.mShoppingListView.onRefreshComplete();
      this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(this.mParent, this.mShoppingListView, ShoppingCart.i(this.mParent).getLastStockSyncedTime()));
      this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(getString(2131165448));
    }
  }

  @Subscribe
  public void handleRefresh(ShoppingListRefreshEvent paramShoppingListRefreshEvent)
  {
    if ((this.mShoppingListView != null) && (this.mShoppingListView.isRefreshing()))
    {
      this.mShoppingListView.onRefreshComplete();
      this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(this.mParent, this.mShoppingListView, ShoppingCart.i(this.mParent).getLastStockSyncedTime()));
      this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(getString(2131165448));
    }
  }

  @Subscribe
  public void handleStartSyncSLEvent(StartSyncEvent paramStartSyncEvent)
  {
    startSync();
  }

  @Subscribe
  public void motherSPRSelected(MotherSPRSelectedEvent paramMotherSPRSelectedEvent)
  {
    int i = this.mShoppingListAdapter.getItemIndex(paramMotherSPRSelectedEvent.retailItemCommunication);
    if (i >= 0)
    {
      ((ExpandableListView)this.mShoppingListView.getRefreshableView()).smoothScrollToPosition(i);
      ((ExpandableListView)this.mShoppingListView.getRefreshableView()).setSelection(i);
    }
  }

  public void onActivityCreated(Bundle paramBundle)
  {
    super.onActivityCreated(paramBundle);
    if (paramBundle != null)
    {
      if (paramBundle.containsKey("KEY_SHOPPING_CART_LIST_STATE"))
      {
        this.mListState = paramBundle.getParcelable("KEY_SHOPPING_CART_LIST_STATE");
        this.mSLItemStateNew = ((HashMap)paramBundle.getSerializable("KEY_SHOPPING_CART_QUICK_MENU_STATE"));
      }
      if (paramBundle.containsKey("KEY_FIRST_VISIBLE_ITEM_INDEX"))
        this.mListPosition = paramBundle.getInt("KEY_FIRST_VISIBLE_ITEM_INDEX");
      if (paramBundle.containsKey("KEY_ITEM_SCROLL_POSITION"))
        this.mItemPosition = paramBundle.getInt("KEY_ITEM_SCROLL_POSITION");
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.hasFamilyNumber = hasFamilyNumber();
    L.I("hasFamilyNumber onCreate : " + this.hasFamilyNumber);
  }

  public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
  {
    View localView = paramLayoutInflater.inflate(2130903145, paramViewGroup, false);
    this.mShoppingListView = ((PullToRefreshExpandableListView)localView.findViewById(2131624403));
    this.mShoppingListView.getLoadingLayoutProxy().setTextTypeface(TypeFaceProvider.getTypeFace(localView.getContext(), "verdana_bold"));
    this.mShoppingListView.setOnPullEventListener(new PullToRefreshBase.OnPullEventListener()
    {
      public void onPullEvent(PullToRefreshBase<ExpandableListView> paramAnonymousPullToRefreshBase, PullToRefreshBase.State paramAnonymousState, PullToRefreshBase.Mode paramAnonymousMode)
      {
        if (ShoppingListFragment.this.getActivity() != null)
        {
          ShoppingListFragment.this.mShoppingListView.getLoadingLayoutProxy().setPullLabel(ShoppingListFragment.this.getString(2131165575));
          ShoppingListFragment.this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(ShoppingListFragment.this.getString(2131165448));
          ShoppingListFragment.this.mShoppingListView.getLoadingLayoutProxy().setReleaseLabel(ShoppingListFragment.this.getString(2131165582));
          ShoppingListFragment.this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(ShoppingListFragment.this.mParent, ShoppingListFragment.this.mShoppingListView, ShoppingCart.i(ShoppingListFragment.this.getActivity()).getLastStockSyncedTime()));
        }
      }
    });
    this.mShoppingListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener()
    {
      public void onRefresh(PullToRefreshBase<ExpandableListView> paramAnonymousPullToRefreshBase)
      {
        if ((AppConfigManager.i(ShoppingListFragment.this.getActivity()) != null) && (AppConfigManager.i(ShoppingListFragment.this.getActivity()).getAppConfigData() != null) && (AppConfigManager.i(ShoppingListFragment.this.getActivity()).getAppConfigData().getKillSwitchConfig() != null) && (!AppConfigManager.i(ShoppingListFragment.this.getActivity()).getAppConfigData().getKillSwitchConfig().isSyncShoppingBag()))
        {
          ShoppingListFragment.this.mShoppingListView.onRefreshComplete();
          com.ikea.kompis.util.UiUtil.showCustomToast(ShoppingListFragment.this.getString(2131165684), ShoppingListFragment.this.getActivity());
        }
        do
        {
          return;
          if ((AppConfigManager.i(ShoppingListFragment.this.getActivity()) != null) && (AppConfigManager.i(ShoppingListFragment.this.getActivity()).getAppConfigData() != null) && (AppConfigManager.i(ShoppingListFragment.this.getActivity()).getAppConfigData().getKillSwitchConfig() != null) && (!AppConfigManager.i(ShoppingListFragment.this.getActivity()).getAppConfigData().getKillSwitchConfig().isPerformStockCheck()))
          {
            ShoppingListFragment.this.mShoppingListView.onRefreshComplete();
            com.ikea.kompis.util.UiUtil.showCustomToast(ShoppingListFragment.this.getString(2131165671), ShoppingListFragment.this.getActivity());
            return;
          }
        }
        while ((ShoppingCartService.i(ShoppingListFragment.this.mParent).getLoginSyncInProcess()) || (ShoppingCartService.i(ShoppingListFragment.this.mParent).getSyncInProcess()));
        if (NetworkUtil.isConnectionAvailable(ShoppingListFragment.this.getActivity()))
        {
          ShoppingCartService.i(ShoppingListFragment.this.mParent).refreshSL();
          return;
        }
        ShoppingListFragment.this.mShoppingListView.onRefreshComplete();
        com.ikea.kompis.util.UiUtil.showNetworkToast(ShoppingListFragment.this.getActivity(), false);
      }
    });
    this.mShoppingListView.setOnScrollListener(new AbsListView.OnScrollListener()
    {
      public void onScroll(AbsListView paramAnonymousAbsListView, int paramAnonymousInt1, int paramAnonymousInt2, int paramAnonymousInt3)
      {
      }

      public void onScrollStateChanged(AbsListView paramAnonymousAbsListView, int paramAnonymousInt)
      {
        if (paramAnonymousInt == 0)
          ShoppingListFragment.this.saveListState();
      }
    });
    this.mIkeaBottomIcon = localView.findViewById(2131624402);
    this.mIkeaBottomIcon.setOnClickListener(null);
    this.mSummaryView = localView.findViewById(2131624404);
    this.mSummaryView.setOnClickListener(null);
    this.mSummaryHeader = localView.findViewById(2131624413);
    this.mTotalPrice = ((TextView)localView.findViewById(2131624410));
    this.mTotalTitle = ((TextView)localView.findViewById(2131624409));
    this.mIkeaSavingView = localView.findViewById(2131624405);
    this.mIkeaFamilyTitle = ((TextView)localView.findViewById(2131624406));
    this.mIkeaFamilyTitle.setText(getResources().getString(2131165244));
    this.mIkeaFamilyPrice = ((TextView)localView.findViewById(2131624407));
    this.mIkeaFamilyMessageView = localView.findViewById(2131624411);
    this.mIkeaFamilyMessage = ((TextView)localView.findViewById(2131624412));
    this.mIkeaFamilyMessageView.setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View paramAnonymousView)
      {
        ShoppingListFragment.this.startActivity(new Intent(ShoppingListFragment.this.mParent, ECIkeaFamilyActivity.class));
        ShoppingListFragment.this.mIkeaFamilyMessageView.setEnabled(false);
        ShoppingListFragment.this.mParent.overridePendingTransition(2130968587, 2130968584);
      }
    });
    return localView;
  }

  public void onPause()
  {
    super.onPause();
    if ((this.mShoppingListView != null) && (this.mShoppingListView.getRefreshableView() != null))
      saveListState();
    this.mServiceCallBack.markInvalid();
    try
    {
      this.mBus.unregister(this);
      return;
    }
    catch (Exception localException)
    {
      L.W("No event handler to unregister");
    }
  }

  public void onResume()
  {
    super.onResume();
    this.mBus.register(this);
    L.I("hasFamilyNumber onResume : " + this.hasFamilyNumber);
    long l = ShoppingCart.i(getActivity()).getCartLastUdpatedTime();
    StoreRef localStoreRef = AppConfigManager.i(getActivity()).getAppConfigData().getFavStore();
    if ((localStoreRef != null) && (this.mfavStore != null) && (!this.mfavStore.getStoreNo().equals(localStoreRef.getStoreNo())))
    {
      Constant.i().setProductModified(true);
      setSyncValue();
    }
    this.mfavStore = localStoreRef;
    if (this.mShoppingListAdapter == null)
    {
      this.mServiceCallBack.markValid();
      ShoppingCart.i(getActivity()).fetchShoppingCart(this.mServiceCallBack);
    }
    label501: 
    while (true)
    {
      if (this.mIkeaFamilyMessageView != null)
        this.mIkeaFamilyMessageView.setEnabled(true);
      if (this.mShoppingCartModel != null)
        refreshPrice(this.mShoppingCartModel);
      this.mCartLastUpdatedTime = l;
      return;
      if ((this.hasFamilyNumber != hasFamilyNumber()) || (Constant.i().isFamilyNumberChanged()) || (Constant.i().isProductModified()) || (Constant.i().isUpdateSlAfterItemDeleted()) || (l != this.mCartLastUpdatedTime))
      {
        this.mServiceCallBack.markValid();
        ShoppingCart.i(getActivity()).fetchShoppingCart(this.mServiceCallBack);
        Constant.i().setProductModified(false);
        Constant.i().setUpdateSlAfterItemDeleted(false);
        Constant.i().setFamilyNumberChanged(false);
        if ((this.mShoppingListView != null) && (this.mShoppingListView.isRefreshing()))
        {
          this.mShoppingListView.onRefreshComplete();
          this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(getString(2131165448));
          this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(this.mParent, this.mShoppingListView, ShoppingCart.i(this.mParent).getLastStockSyncedTime()));
        }
      }
      while (true)
      {
        if (this.mShoppingListView == null)
          break label501;
        ((ExpandableListView)this.mShoppingListView.getRefreshableView()).post(this.fitsOnScreen);
        break;
        if ((this.mShoppingListView != null) && (this.mShoppingListView.isRefreshing()) && (!ShoppingCartService.i(this.mParent).getSyncInProcess()))
        {
          this.mShoppingListView.onRefreshComplete();
          this.mShoppingListView.getLoadingLayoutProxy().setRefreshingLabel(getString(2131165448));
          this.mShoppingListView.getLoadingLayoutProxy().setLastUpdatedLabel(com.ikea.kompis.util.UiUtil.getLastUpdatedLabel(this.mParent, this.mShoppingListView, ShoppingCart.i(this.mParent).getLastStockSyncedTime()));
        }
        if (ShoppingCartService.i(this.mParent).getLoginSyncInProcess())
          startSync();
        if ((UsageTracker.i().isBackPressed()) && (this.mParent.isShoppingListMaximize()))
          UsageTracker.i().viewSL(getActivity(), null);
      }
    }
  }

  public void onSaveInstanceState(Bundle paramBundle)
  {
    super.onSaveInstanceState(paramBundle);
    if ((this.mShoppingListView != null) && (this.mShoppingListView.getRefreshableView() != null))
      saveListState();
    paramBundle.putParcelable("KEY_SHOPPING_CART_LIST_STATE", this.mListState);
    paramBundle.putInt("KEY_FIRST_VISIBLE_ITEM_INDEX", this.mListPosition);
    paramBundle.putInt("KEY_ITEM_SCROLL_POSITION", this.mItemPosition);
    if (this.mShoppingListAdapter != null)
      paramBundle.putSerializable("KEY_SHOPPING_CART_QUICK_MENU_STATE", this.mShoppingListAdapter.getSLItemsStateList());
  }

  @Subscribe
  public void refreshListView(ProductDetailsCloseFromSL paramProductDetailsCloseFromSL)
  {
    if ((this.mShoppingListAdapter != null) && (this.mShoppingListAdapter.getGroupCount() > 0))
    {
      this.mShoppingListAdapter.notifyDataSetChanged();
      ((ExpandableListView)this.mShoppingListView.getRefreshableView()).post(this.fitsOnScreen);
    }
  }
}

/* Location:           C:\Documents and Settings\Cesar Cabello Cea\Mis documentos\Downloads\apk-downloader\com.ikea.kompis-6_dex2jar.jar
 * Qualified Name:     com.ikea.kompis.shopping.ShoppingListFragment
 * JD-Core Version:    0.6.2
 */