コード例 #1
0
  @Override
  public void onResume() {
    super.onResume();

    LoginModel loginModel = new LoginModel(getActivity());

    ConfigModel configModel = new ConfigModel(getActivity());
    configModel.getConfig();
  }
コード例 #2
0
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View mainView = inflater.inflate(R.layout.home_fragment, null);

    back = (ImageView) mainView.findViewById(R.id.top_view_back);
    back.setVisibility(View.GONE);
    title = (TextView) mainView.findViewById(R.id.top_view_text);
    Resources resource = this.getResources();
    String ecmobileStr = resource.getString(R.string.ecmobile);
    title.setText(ecmobileStr);

    title_right_button = (LinearLayout) mainView.findViewById(R.id.top_right_button);
    title_right_button.setVisibility(View.VISIBLE);
    title_right_button.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            msgModel.unreadCount = 0;
            headUnreadTextView.setVisibility(View.GONE);
            Intent intent = new Intent(getActivity(), ShopNotifyActivity.class);
            startActivity(intent);
            getActivity().overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
          }
        });

    headUnreadTextView = (TextView) mainView.findViewById(R.id.head_unread_num);

    if (null == dataModel) {
      dataModel = new HomeModel(getActivity());
      dataModel.fetchHotSelling();
      dataModel.fetchCategoryGoods();
    }

    if (null == MsgModel.getInstance()) {
      msgModel = new MsgModel(getActivity());
    } else {
      msgModel = MsgModel.getInstance();
    }

    msgModel.addResponseListener(this);
    msgModel.getUnreadMessageCount();

    if (null == ConfigModel.getInstance()) {
      ConfigModel configModel = new ConfigModel(getActivity());
      configModel.getConfig();
    }

    dataModel.addResponseListener(this);

    bannerView =
        (FrameLayout) LayoutInflater.from(getActivity()).inflate(R.layout.banner_scroll_view, null);

    bannerViewPager = (ViewPager) bannerView.findViewById(R.id.banner_viewpager);

    LayoutParams params1 = bannerViewPager.getLayoutParams();
    params1.width = getDisplayMetricsWidth();
    params1.height = (int) (params1.width * 1.0 / 484 * 200);

    bannerViewPager.setLayoutParams(params1);

    bannerListView = new ArrayList<View>();

    bannerPageAdapter = new Bee_PageAdapter(bannerListView);

    bannerViewPager.setAdapter(bannerPageAdapter);
    bannerViewPager.setCurrentItem(0);

    bannerViewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          private int mPreviousState = ViewPager.SCROLL_STATE_IDLE;

          @Override
          public void onPageScrolled(int i, float v, int i2) {}

          @Override
          public void onPageSelected(int i) {}

          @Override
          public void onPageScrollStateChanged(int state) {
            // All of this is to inhibit any scrollable container from consuming our touch events as
            // the user is changing pages
            if (mPreviousState == ViewPager.SCROLL_STATE_IDLE) {
              if (state == ViewPager.SCROLL_STATE_DRAGGING) {
                mTouchTarget = bannerViewPager;
              }
            } else {
              if (state == ViewPager.SCROLL_STATE_IDLE
                  || state == ViewPager.SCROLL_STATE_SETTLING) {
                mTouchTarget = null;
              }
            }

            mPreviousState = state;
          }
        });

    mIndicator = (PageIndicator) bannerView.findViewById(R.id.indicator);
    mIndicator.setViewPager(bannerViewPager);

    mListView = (MyListView) mainView.findViewById(R.id.home_listview);
    mListView.addHeaderView(bannerView);
    mListView.bannerView = bannerView;

    mListView.setPullLoadEnable(false);
    mListView.setPullRefreshEnable(true);
    mListView.setXListViewListener(this, 0);
    mListView.setRefreshTime();

    homeSetAdapter();

    ShoppingCartModel shoppingCartModel = new ShoppingCartModel(getActivity());
    shoppingCartModel.addResponseListener(this);
    shoppingCartModel.homeCartList();

    return mainView;
  }