/** 图片循环 */
 private void initViewPager() {
   ViewGroup.LayoutParams mViewPagerlayoutParams = mViewPager.getLayoutParams();
   if (mViewPagerlayoutParams != null) {
     mViewPagerlayoutParams.width = Misc.getScreenDisplay(this)[0];
     mViewPagerlayoutParams.height = (int) (mViewPagerlayoutParams.width);
     mViewPager.setLayoutParams(mViewPagerlayoutParams);
   }
   mViewPager.setAdapter(new ProductDetailPicAdapter2(this, product.getImgList()));
   mViewPager.setOnPageChangeListener(this);
   // 设置布局参数
   LinearLayout.LayoutParams params =
       new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   int marginParam = Misc.dip2px(this, 10) / 2;
   llytPagerPoiner.removeAllViewsInLayout();
   for (int i = 0; i < product.getImgList().size(); i++) {
     // 设置按钮属性
     View item = new ImageView(this);
     item.setBackgroundResource(R.drawable.recommend_gallery);
     item.setTag(String.valueOf(i));
     // item.setOnClickListener(parentActivity);
     params.setMargins(marginParam, 0, marginParam, 0);
     params.weight = 1;
     llytPagerPoiner.addView(item, params);
   }
   llytPagerPoiner.getChildAt(0).setBackgroundResource(R.drawable.recommend_gallery_select);
 }
Ejemplo n.º 2
0
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private void init(Context context) {
    // Disable clipping of children so non-selected pages are visible
    setClipChildren(false);

    // Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
    // You need to set this value here if using hardware acceleration in an
    // application targeted at these releases.
    if (Build.VERSION.SDK_INT >= 11) {
      setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }

    // 添加ViewPager
    mPager = new ViewPager(context);
    mPager.setId(R.id.pager);
    // If hardware acceleration is enabled, you should also remove
    // clipping on the pager for its children.
    mPager.setClipChildren(false);
    mPager.setPageMargin(pageMargin);
    mPager.setOnPageChangeListener(this);
    // Necessary or the pager will only have one extra page to show
    // make this at least however many pages you can see
    mPager.setOffscreenPageLimit(calcOffscreenPageLimit());
    mPager.setLayoutParams(
        new FrameLayout.LayoutParams(pageWidth, pageHeight, Gravity.CENTER_HORIZONTAL));
    this.addView(mPager);
  }
Ejemplo n.º 3
0
  private void initEmotion() {
    // 获取屏幕宽度
    int gvWidth = DisplayUtils.getScreenWidthPixels(this);
    // 表情边距
    int spacing = DisplayUtils.dp2px(this, 8);
    // GridView中item的宽度
    int itemWidth = (gvWidth - spacing * 8) / 7;
    int gvHeight = itemWidth * 3 + spacing * 4;

    List<GridView> gvs = new ArrayList<GridView>();
    List<String> emotionNames = new ArrayList<String>();
    // 遍历所有的表情名字
    for (String emojiName : EmotionUtils.emojiMap.keySet()) {
      emotionNames.add(emojiName);
      // 每20个表情作为一组,同时添加到ViewPager对应的view集合中
      if (emotionNames.size() == 20) {
        GridView gv = createEmotionGridView(emotionNames, gvWidth, spacing, itemWidth, gvHeight);
        gvs.add(gv);
        // 添加完一组表情,重新创建一个表情名字集合
        emotionNames = new ArrayList<String>();
      }
    }

    // 检查最后是否有不足20个表情的剩余情况
    if (emotionNames.size() > 0) {
      GridView gv = createEmotionGridView(emotionNames, gvWidth, spacing, itemWidth, gvHeight);
      gvs.add(gv);
    }

    // 将多个GridView添加显示到ViewPager中
    emotionPagerGvAdapter = new EmotionPagerAdapter(gvs);
    vp_emotion_dashboard.setAdapter(emotionPagerGvAdapter);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(gvWidth, gvHeight);
    vp_emotion_dashboard.setLayoutParams(params);
  }
 /**
  * create ViewPager view</br>
  *
  * @return
  */
 private ViewPager createVIewpager() {
   ViewPager viewPager = new ViewPager(getContext());
   ViewPager.LayoutParams params = new ViewPager.LayoutParams();
   params.width = android.support.v4.view.ViewPager.LayoutParams.MATCH_PARENT;
   params.height = BOARD_HEIGHT;
   viewPager.setLayoutParams(params);
   viewPager.setPadding(0, 15, 0, 0);
   return viewPager;
 }
Ejemplo n.º 5
0
 private void initView() {
   mViewPager = new ViewPager(mContext);
   LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
   mViewPager.setLayoutParams(params);
   mViewPager.setBackgroundColor(0xFF000000);
   setContentView(mViewPager);
   setParams();
   initViewPager();
 }
Ejemplo n.º 6
0
  /** 初始化宫格列表ui */
  public void afterPlatformListGot() {
    Context context = getContext();

    // 为了更好的ui效果,开启子线程获取平台列表
    int pageSize = platformList.length > PAGE_SIZE ? PAGE_SIZE : platformList.length;
    int lines = pageSize / 3;
    if (pageSize % 3 > 0) {
      lines++;
    }
    ViewGroup.LayoutParams lp = pager.getLayoutParams();
    int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(context, 10);
    int scrW = getResources().getDisplayMetrics().widthPixels;
    lp.height = (scrW - dp_10 * 2) * lines / 3;
    pager.setLayoutParams(lp);
    PlatformAdapter adapter = new PlatformAdapter(platformList, this);
    pager.setAdapter(adapter);
    int pageCount = 0;
    if (platformList != null) {
      int size = platformList.length;
      pageCount = size / PAGE_SIZE;
      if (size % PAGE_SIZE > 0) {
        pageCount++;
      }
    }
    points = new ImageView[pageCount];
    if (points.length <= 0) {
      return;
    }

    LinearLayout llPoints = new LinearLayout(context);
    // 如果页面总是超过1,则设置页面指示器
    llPoints.setVisibility(pageCount > 1 ? View.VISIBLE : View.GONE);
    LayoutParams lpLl = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpLl.gravity = Gravity.CENTER_HORIZONTAL;
    llPoints.setLayoutParams(lpLl);
    addView(llPoints);

    int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
    grayPoint = BitmapFactory.decodeResource(getResources(), R.drawable.gray_point);
    whitePoint = BitmapFactory.decodeResource(getResources(), R.drawable.white_point);
    for (int i = 0; i < pageCount; i++) {
      points[i] = new ImageView(context);
      points[i].setScaleType(ScaleType.CENTER_INSIDE);
      points[i].setImageBitmap(grayPoint);
      LayoutParams lpIv = new LayoutParams(dp_5, dp_5);
      lpIv.setMargins(dp_5, dp_5, dp_5, 0);
      points[i].setLayoutParams(lpIv);
      llPoints.addView(points[i]);
    }
    int curPage = pager.getCurrentItem();
    points[curPage].setImageBitmap(whitePoint);
  }
Ejemplo n.º 7
0
  public void updateView() {
    Event[] hotEvents = DataEngine.getInstance().getHotEventList();
    int maxHeight = 0;
    Resources res = mContext.getResources();
    int eventIconSize = res.getDimensionPixelSize(R.dimen.event_img_size);
    LayoutInflater inflater = LayoutInflater.from(mContext);
    for (int i = 0; i < hotEvents.length; ++i) {
      View v = inflater.inflate(R.layout.view_event_list_cell, null);
      UrlImageView img = (UrlImageView) v.findViewById(R.id.event_img);
      img.setImageHeight(eventIconSize);
      img.setImageWidth(eventIconSize);
      img.setDefaultBitmap(BitmapFactory.decodeResource(res, R.drawable.ic_launcher));
      img.setImageFromUrl(hotEvents[i].getImg());

      TextView title = (TextView) v.findViewById(R.id.event_title);
      title.setText(hotEvents[i].getTitle());

      TextView author = (TextView) v.findViewById(R.id.event_author);
      author.setText(res.getString(R.string.tip_event_author, hotEvents[i].getAuthor()));

      TextView address = (TextView) v.findViewById(R.id.event_address);
      address.setText(res.getString(R.string.tip_event_address, hotEvents[i].getAddress()));

      TextView time = (TextView) v.findViewById(R.id.event_time);
      time.setText(res.getString(R.string.tip_event_time, hotEvents[i].getEventTime()));
      v.setTag(hotEvents[i].getEventId());
      v.setOnClickListener(mPageOnClickListener);
      mViews.add(v);
      measureView(v);
      maxHeight = maxHeight < v.getMeasuredHeight() ? v.getMeasuredHeight() : maxHeight;

      ImageView circle = new ImageView(mContext);
      if (0 == i) {
        circle.setImageResource(R.drawable.dot_selected);
      } else {
        circle.setImageResource(R.drawable.dot_none);
      }
      circle.setPadding(5, 0, 5, 0);
      mCircleContainer.addView(circle);
    }
    ViewGroup.LayoutParams lp = mViewPager.getLayoutParams();
    lp.height = maxHeight;
    mViewPager.setLayoutParams(lp);
    mViewPager.setAdapter(new HotPageAdapter());
    mViewPager.setOnPageChangeListener(mPageChangeListener);

    mCategoryGrid.setNumColumns(3);
    mCategoryGrid.setAdapter(new CategoryGridAdapter());
    mCategoryGrid.setVerticalSpacing(
        mContext.getResources().getDimensionPixelSize(R.dimen.category_vertical_padding));
  }
  private void getDataView() {
    float imgWidths = DPIUtil.screen_width;
    float imgHeight = imgWidths * 284 / 716;
    ViewGroup.LayoutParams params = viewPager.getLayoutParams();
    params.height = Math.round(imgHeight);
    params.width = Math.round(imgWidths);
    viewPager.setLayoutParams(params);
    custemViewPagerAdapter = new CustemViewPagerAdapter(mViewList);
    viewPager.setAdapter(custemViewPagerAdapter);

    mRecyclerView.addHeaderView(headView);
    adapter = new GridViewAdapter(getActivity(), mList, imgWidth);
    mRecyclerView.setAdapter(adapter);
    setListener();
    initPopupWindow();
    getHomeData();
  }
Ejemplo n.º 9
0
  /**
   * 获取TabHost
   *
   * @param mContext
   * @param gravity tabs的位置,上面TOP 下面BOTTOM,目前只支持两个
   * @return
   */
  public static TabHost getTabHostAndPagerView(Context mContext, int tabGravity) {
    // init TabHost
    TabHost tabhost = new TabHost(mContext);
    tabhost.setId(android.R.id.tabhost);
    tabhost.setLayoutParams(
        new FragmentTabHost.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    LinearLayout mLinearLayout = new LinearLayout(mContext);
    mLinearLayout.setOrientation(LinearLayout.VERTICAL);
    mLinearLayout.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // init TabWidget
    TabWidget tabs = new TabWidget(mContext);
    tabs.setId(android.R.id.tabs);
    tabs.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 0));
    tabs.setOrientation(LinearLayout.HORIZONTAL);

    FrameLayout tabcontent = new FrameLayout(mContext);
    tabcontent.setId(android.R.id.tabcontent);
    tabcontent.setLayoutParams(new LinearLayout.LayoutParams(0, 0, 0f));

    ViewPager viewPager = new ViewPager(mContext);
    viewPager.setId(EasyR.id.pager);
    viewPager.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, 0, 1f));

    tabhost.addView(mLinearLayout);
    switch (tabGravity) {
      case TabGravity.BOTTOM:
        mLinearLayout.addView(viewPager);

        mLinearLayout.addView(tabs); // wiget在下面
        mLinearLayout.addView(tabcontent);
        break;
      case TabGravity.TOP:
      default:
        mLinearLayout.addView(tabs); // wiget在上面
        mLinearLayout.addView(tabcontent);

        mLinearLayout.addView(viewPager);
        break;
    }
    return tabhost;
  }
Ejemplo n.º 10
0
  private void init(final Context context) {
    setOrientation(VERTICAL);
    int dp_10 = cn.sharesdk.framework.utils.R.dipToPx(context, 10);
    setPadding(dp_10, dp_10, dp_10, dp_10);

    pager = new ViewPager(context);
    pager.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, 1));
    pager.setOnPageChangeListener(this);
    addView(pager);

    // 为了更好的ui效果,开启子线程获取平台列表
    new Thread() {
      public void run() {
        platformList = ShareSDK.getPlatformList(context);
        UIHandler.sendEmptyMessage(MSG_PLATFORM_LIST_GOT, PlatformGridView.this);
      }
    }.start();
  }
Ejemplo n.º 11
0
  /**
   * 读取提示形式 和 提示位置 和 播放延迟
   *
   * @param attrs
   */
  private void initView(AttributeSet attrs) {
    if (mViewPager != null) {
      removeView(mViewPager);
    }

    TypedArray type = getContext().obtainStyledAttributes(attrs, R.styleable.RollViewPager);
    gravity = type.getInteger(R.styleable.RollViewPager_rollviewpager_hint_gravity, 1);
    int mode = type.getInteger(R.styleable.RollViewPager_rollviewpager_hint_mode, -1);
    delay = type.getInt(R.styleable.RollViewPager_rollviewpager_play_delay, 0);
    color = type.getColor(R.styleable.RollViewPager_rollviewpager_hint_color, Color.BLACK);
    alpha = type.getInt(R.styleable.RollViewPager_rollviewpager_hint_alpha, 0);
    mViewPager = new ViewPager(getContext());
    mViewPager.setId(R.id.viewpager_inner);
    mViewPager.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    addView(mViewPager);
    type.recycle();

    initHint(mode);
  }
Ejemplo n.º 12
0
  private void setUpViewPager(View convertView, ViewPager viewPager, LayoutInflater inflater) {
    viewPager = (ViewPager) convertView.findViewById(R.id.vp_issue);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, GlobalData.getScreenHeight(activity) / 4);
    viewPager.setLayoutParams(lp);
    viewPager.setOnPageChangeListener(
        new ViewPager.OnPageChangeListener() {

          // 配合Adapter的currentItem字段进行设置。
          @Override
          public void onPageSelected(int arg0) {
            handler.sendMessage(Message.obtain(handler, ImageHandler.MSG_PAGE_CHANGED, arg0, 0));
          }

          // 覆写该方法实现轮播效果的暂停和恢复
          @Override
          public void onPageScrollStateChanged(int arg0) {
            switch (arg0) {
              case ViewPager.SCROLL_STATE_DRAGGING:
                handler.sendEmptyMessage(ImageHandler.MSG_KEEP_SILENT);
                break;
              case ViewPager.SCROLL_STATE_IDLE:
                handler.sendEmptyMessageDelayed(
                    ImageHandler.MSG_UPDATE_IMAGE, ImageHandler.MSG_DELAY);
                break;
              default:
                break;
            }
          }

          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub

          }
        });
    asyncViewPagerLoader = new AsyncViewPagerLoader(viewPager);
    asyncViewPagerLoader.execute();
  }
Ejemplo n.º 13
0
 public void setPagerProperties(final ViewPager vp) {
   final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) vp.getLayoutParams();
   lp.height = mEmojiKeyboardHeight;
   lp.bottomMargin = mEmojiPagerBottomMargin;
   vp.setLayoutParams(lp);
 }
Ejemplo n.º 14
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;
  }