Exemplo n.º 1
0
  /** 加载页面 */
  private void initView() {
    /*头部标题*/
    myCommonTitle = (MyCommonTitle) findViewById(R.id.aci_mytitle);
    myCommonTitle.setTitle("喜刷刷");
    myCommonTitle.setBackBtnVisible(false);
    myCommonTitle.setLisener(null, this);

    container = (ScrollView) findViewById(R.id.container);

    viewPager = (AutoScrollViewPager) findViewById(R.id.index_slider); // 轮播图
    tv_news_more = (LinearLayout) findViewById(R.id.tv_index_gift); // 新闻更多
    index_list = (AutoListView) findViewById(R.id.index_list); // 新闻资讯
    index_list.setOnItemClickListener(this);
    index_gift = (LinearLayout) findViewById(R.id.index_gift); // 中间三大模块(即时,永久,兴趣)

    index_image1 = (ImageView) findViewById(R.id.index_image1); // 即时红包
    index_image2 = (ImageView) findViewById(R.id.index_image2); // 永久红包
    index_image3 = (ImageView) findViewById(R.id.index_image3); // 兴趣标签

    LayoutParams pageParms = viewPager.getLayoutParams();
    pageParms.width = Tools.M_SCREEN_WIDTH;
    pageParms.height = Tools.M_SCREEN_WIDTH * 2 / 5;

    LayoutParams imagelayout = index_gift.getLayoutParams();
    imagelayout.width = Tools.M_SCREEN_WIDTH;
    imagelayout.height = Tools.M_SCREEN_WIDTH * 11 / 30;
    badgeView1 = new BadgeView(IndexActivity.this, index_image1);
    badgeView1.setText("0");
    // badgeView1.hide();
    badgeView2 = new BadgeView(IndexActivity.this, index_image2);
    badgeView2.setText("0");
    // badgeView2.hide();

    viewPager.setInterval(2000);
    viewPager.startAutoScroll();

    viewPager.setOnPageChangeListener(
        new OnPageChangeListener() {
          public void onPageSelected(int position) {
            // 回调view
            uihandler.obtainMessage(0, position).sendToTarget();
          }

          public void onPageScrolled(int position, float positionOffset, int positionOffsetPx) {}

          public void onPageScrollStateChanged(int position) {}
        });

    setListener(index_image1, index_image2, index_image3, tv_news_more);
  }
  public void onPause() {
    super.onPause();

    if (null != viewPager) {
      viewPager.stopAutoScroll();
    }
  }
Exemplo n.º 3
0
 @Override
 protected void onPause() {
   super.onPause();
   if (viewPager != null) {
     viewPager.stopAutoScroll();
   }
 }
Exemplo n.º 4
0
 @Override
 protected void onResume() {
   super.onResume();
   if (viewPager != null) {
     viewPager.startAutoScroll();
   }
   if (container != null) {
     container.smoothScrollTo(0, 0);
   }
   HttpUtils.getpertemcount(
       new HttpErrorHandler() {
         @Override
         public void onRecevieSuccess(JSONObject json) {
           String jishi = json.getJSONObject(UrlContants.jsonData).getString("jishi");
           String yongjiu = json.getJSONObject(UrlContants.jsonData).getString("yongjiu");
           if (CommonUtils.CheckLogin() && Integer.valueOf(StringUtil.toString(jishi, "0")) > 0) {
             badgeView1.show();
             badgeView1.setText(jishi);
           } else {
             badgeView1.hide();
           }
           if (CommonUtils.CheckLogin()
               && Integer.valueOf(StringUtil.toString(yongjiu, "0")) > 0) {
             badgeView2.show();
             badgeView2.setText(yongjiu);
           } else {
             badgeView2.hide();
           }
         }
       });
 }
    @Override
    public void handleMessage(Message msg) {
      super.handleMessage(msg);

      switch (msg.what) {
        case SCROLL_WHAT:
          AutoScrollViewPager pager = this.autoScrollViewPager.get();
          if (pager != null) {
            pager.scroller.setScrollDurationFactor(pager.autoScrollFactor);
            pager.scrollOnce();
            pager.scroller.setScrollDurationFactor(pager.swipeScrollFactor);
            pager.sendScrollMessage(pager.interval + pager.scroller.getDuration());
          }
        default:
          break;
      }
    }
  @Override
  protected void onResume() {
    super.onResume();

    if (null != viewPager) {
      viewPager.startAutoScroll();
    }
  }
  private void responseHouseInfo() {
    if (!appDto.getTags().isEmpty()) {
      flowlayout.setVisibility(View.VISIBLE);

      flowlayout.setAdapter(
          new TagAdapter<String>(appDto.getTags()) {
            @Override
            public View getView(FlowLayout parent, int position, String s) {
              TextView tv =
                  (TextView)
                      LayoutInflater.from(KeeperHouseInfoPublishActivity.this)
                          .inflate(R.layout.tag_layout, parent, false);
              tv.setText(s);
              return tv;
            }
          });
    }

    imageURLList = appDto.getTopImages();
    initViewPager();
    viewPagerAdapter.notifyDataSetChanged();

    viewPager.setFocusable(true);
    viewPager.setFocusableInTouchMode(true);
    viewPager.requestFocus();

    this.communityTextView.setText(appDto.getCommunity() + "   " + appDto.getHouseType());
    this.areaTextView.setText(appDto.getAreaStr());
    this.moneyTextView.setText(appDto.getMonthMoney());
    this.monthTextView.setText("元/月");

    this.leaseTypeTextView.setText(
        Html.fromHtml(
            "<font color=#999999>类型:</font><font color=#222222>"
                + appDto.getLeaseType()
                + "</font>"));
    this.decorateTextView.setText(
        Html.fromHtml(
            "<font color=#999999>装修:</font><font color=#222222>"
                + appDto.getDecorate()
                + "</font>"));
    this.areaSizeTextView.setText(
        Html.fromHtml(
            "<font color=#999999>面积:</font><font color=#222222>" + appDto.getSize() + "</font>"));
    this.orientationTextView.setText(
        Html.fromHtml(
            "<font color=#999999>朝向:</font><font color=#222222>"
                + appDto.getOrientation()
                + "</font>"));
    this.floorTextView.setText(
        Html.fromHtml(
            "<font color=#999999>楼层:</font><font color=#222222>" + appDto.getFloor() + "</font>"));
    this.leaseTimeTextView.setText(appDto.getLeaseTimeStr());

    this.adapter.setData(appDto.getEquipments(), false);

    this.heatingFeesTextView.setText(appDto.isHeatingFees() ? "租户交" : "房东交");

    this.busTextView.setText(
        Html.fromHtml(
            "<font color=#999999>公交:</font><font color=#222222>" + appDto.getBus() + "</font>"));
    this.subwayTextView.setText(
        Html.fromHtml(
            "<font color=#999999>地铁:</font><font color=#222222>" + appDto.getSubway() + "</font>"));

    this.applyLookTextView.setEnabled(appDto.isAdd());

    if (appDto.getReserveCount() == 0) {
      lookCountBadgeView.hide();

    } else {
      lookCountBadgeView.setText(appDto.getReserveCount() + "");
      lookCountBadgeView.show(true);
    }
  }
  private void initViewPager() {
    // indicator
    indicatorLayout = (LinearLayout) this.findViewById(R.id.indicatorLayout);
    indicatorLayout.removeAllViews();

    indicatorImageViews = new ImageView[imageURLList.size()];
    for (int i = 0; i < imageURLList.size(); i++) {
      ImageView imageView = new ImageView(this);
      imageView.setLayoutParams(new LinearLayout.LayoutParams(10, 10));
      if (i == 0) {
        imageView.setBackgroundResource(R.drawable.page_indicator_focused);
      } else {
        imageView.setBackgroundResource(R.drawable.page_indicator_unfocused);
      }

      indicatorImageViews[i] = imageView;

      LinearLayout.LayoutParams layoutParams =
          new LinearLayout.LayoutParams(
              new ViewGroup.LayoutParams(
                  LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
      layoutParams.leftMargin = 10;
      layoutParams.rightMargin = 10;
      indicatorLayout.addView(indicatorImageViews[i], layoutParams);
    }

    // http://www.trinea.cn/android/auto-scroll-view-pager/
    // ViewPager
    viewPager = (AutoScrollViewPager) this.findViewById(R.id.viewPager);
    viewPager.setInterval(3000);
    viewPager.setCycle(true);
    viewPager.setAutoScrollDurationFactor(7.0);
    viewPager.setSlideBorderMode(AutoScrollViewPager.SLIDE_BORDER_MODE_CYCLE);
    viewPager.setStopScrollWhenTouch(false);
    viewPagerAdapter = new ImagePagerAdapter(this, imageURLList);

    viewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          @Override
          public void onPageScrollStateChanged(int arg0) {}

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {}

          @Override
          public void onPageSelected(int index) {
            int position = index % imageURLList.size();
            for (int i = 0; i < imageURLList.size(); i++) {
              if (i == position) {
                indicatorImageViews[i].setBackgroundResource(R.drawable.page_indicator_focused);
              } else {
                indicatorImageViews[i].setBackgroundResource(R.drawable.page_indicator_unfocused);
              }
            }
          }
        });
    // viewPagerAdapter.setInfiniteLoop(true);
    viewPager.setAdapter(viewPagerAdapter);
    viewPager.startAutoScroll();

    final GestureDetector tapGestureDetector = new GestureDetector(this, new TapGestureListener());
    viewPager.setOnTouchListener(
        new View.OnTouchListener() {
          public boolean onTouch(View v, MotionEvent event) {
            tapGestureDetector.onTouchEvent(event);
            return false;
          }
        });
  }