コード例 #1
0
 private void initDots() {
   // TODO Auto-generated method stub
   dotList.clear();
   advll_dot.removeAllViews();
   dotPosition = -1;
   LinearLayout.LayoutParams lp =
       new LinearLayout.LayoutParams(
           ContextUtil.dip2px(PreMainActivity.this, 8),
           ContextUtil.dip2px(PreMainActivity.this, 8));
   lp.setMargins(
       ContextUtil.dip2px(PreMainActivity.this, 1.5f),
       0,
       ContextUtil.dip2px(PreMainActivity.this, 1.5f),
       0);
   int count = companies.size();
   int size = 0;
   if (count % 6 == 0) {
     size = count / 6;
   } else {
     size = count / 6 + 1;
   }
   for (int i = 0; i < size; i++) {
     ImageView iv_dot = new ImageView(PreMainActivity.this);
     iv_dot.setLayoutParams(lp);
     iv_dot.setBackgroundResource(R.drawable.app_dot_normal);
     if (i == 0) {
       iv_dot.setBackgroundResource(R.drawable.app_dot_focused);
     }
     advll_dot.addView(iv_dot);
     dotList.add(iv_dot);
   }
 }
コード例 #2
0
 private void initData() {
   // TODO Auto-generated method stub
   uid = SharepreferenceUtil.readString(PreMainActivity.this, SharepreferenceUtil.fileName, "uid");
   finalBitmap = FinalBitmap.create(PreMainActivity.this);
   if (ContextUtil.getHeith(PreMainActivity.this) <= 480) {
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 60);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "l";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 800) {
     // if(ContextUtil.getWidth(this)<=480)
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 140);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "l";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 860) {
     // if(ContextUtil.getWidth(this)<=480)
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 150);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "l";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 960) {
     // if(ContextUtil.getWidth(this)<=480)
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 180);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "m";
   } else if (ContextUtil.getHeith(PreMainActivity.this) <= 1280) {
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 200);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "m";
   } else {
     //			RelativeLayout.LayoutParams linearParams = (RelativeLayout.LayoutParams) fl_ad
     //					.getLayoutParams();
     //			linearParams.height = ContextUtil.dip2px(PreMainActivity.this, 210);
     //			fl_ad.setLayoutParams(linearParams);
     dpitype = "h";
   }
   RelativeLayout.LayoutParams linearParams =
       (RelativeLayout.LayoutParams) fl_ad.getLayoutParams();
   linearParams.width = ContextUtil.getWidth(PreMainActivity.this);
   linearParams.height = linearParams.width / 2;
   fl_ad.setLayoutParams(linearParams);
   BitMapUtil.getImgOpt(PreMainActivity.this, finalBitmap, mJazzy, R.drawable.os_login_topicon);
 }
コード例 #3
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // TODO Auto-generated method stub
    final int selectId = position;
    ViewHolder viewHolder = null;
    if (convertView == null) {
      convertView = inflater.inflate(R.layout.os_dhb_syzx_yyy_list_item, null);
      viewHolder = new ViewHolder();
      viewHolder.iv_thumbnail = (ImageView) convertView.findViewById(R.id.iv_thumbnail);
      viewHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
      viewHolder.tv_describe = (MarqueeText) convertView.findViewById(R.id.tv_describe);
      viewHolder.tv_time = (TextView) convertView.findViewById(R.id.tv_time);
      viewHolder.btn_yyy = (FButton) convertView.findViewById(R.id.btn_yyy);
      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }

    if (infos.get(position).getSmallpic() != null
        && (infos.get(position).getSmallpic().contains(".jpg")
            || infos.get(position).getSmallpic().contains(".png"))) {
      finalBitmap.display(
          viewHolder.iv_thumbnail,
          infos.get(position).getSmallpic(),
          loadingBitmap,
          loadingBitmap,
          false);
    }
    viewHolder.tv_name.setText(infos.get(position).getTitle());
    viewHolder.tv_describe.setText(infos.get(position).getInfo());
    viewHolder.tv_time.setText(ContextUtil.formateTime(infos.get(position).getBegintime()));
    viewHolder.btn_yyy.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View v) {
            // TODO Auto-generated method stub
            // 旧流程,先跳转至摇一摇广告页,浏览完广告图后才可进入摇一摇界面
            //				((DhbSyzxShakeListActivity) mContext).getNextAd(
            //						infos.get(selectId).getGgid(), infos.get(selectId)
            //						.getLargepic());

            // 新流程,直接跳转至摇一摇界面
            Intent intent = new Intent(mContext, DhbSyzxShakeActivity.class);
            intent.putExtra("currentGgid", infos.get(selectId).getGgid());
            intent.putExtra("largepic", infos.get(selectId).getLargepic());
            mContext.startActivity(intent);

            //				SimpleDateFormat simpledate = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            //				try {
            //					Date date1 = simpledate.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm").format(new
            // Date()));
            //					Date date2 =
            // simpledate.parse(ContextUtil.formateTime(infos.get(selectId).getBegintime()));
            //					Date date3 =
            // simpledate.parse(ContextUtil.formateTime(infos.get(selectId).getEndtime()));
            //					if(date1.getTime()<date2.getTime()){
            //						Toast.makeText(mContext,
            // "活动时间还没到,"+ContextUtil.formateTime(infos.get(selectId).getBegintime())+"开始~",
            // Toast.LENGTH_SHORT).show();
            //					}else if(date1.getTime()>date3.getTime()){
            //						Toast.makeText(mContext, "活动已结束~", Toast.LENGTH_SHORT).show();
            //					}else{
            //						((DhbSyzxShakeListActivity) mContext).getNextAd(
            //								infos.get(selectId).getGgid(), infos.get(selectId)
            //								.getLargepic());
            //					}
            //				} catch (ParseException e) {
            //					// TODO Auto-generated catch block
            //					e.printStackTrace();
            //				}
          }
        });
    return convertView;
  }
コード例 #4
0
  /** 初始化JazzViewPager开源库 */
  private void initJazzViewPager() {
    LinearLayout.LayoutParams ll =
        new LinearLayout.LayoutParams(
            ContextUtil.dip2px(PreMainActivity.this, 8),
            ContextUtil.dip2px(PreMainActivity.this, 8));
    ll.setMargins(
        ContextUtil.dip2px(PreMainActivity.this, 1.5f),
        0,
        ContextUtil.dip2px(PreMainActivity.this, 1.5f),
        0);
    dots = new ArrayList<View>();
    mJazzy.setTransitionEffect(TransitionEffect.Standard);
    view_img = new ArrayList<View>();
    if (advs.size() > 0) {
      for (int i = 0; i < advs.size(); i++) {
        View view =
            PreMainActivity.this.getLayoutInflater().inflate(R.layout.os_main_ad_item, null);
        ImageView img = (ImageView) view.findViewById(R.id.img);
        img.setAdjustViewBounds(true);
        img.setScaleType(ScaleType.FIT_XY);
        finalBitmap.display(img, advs.get(i).getMeitiurl());
        final int tempPos = i;
        img.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                if (!TextUtils.isEmpty(advs.get(tempPos).getLinkurl())) {
                  Intent intent = new Intent(PreMainActivity.this, WebViewActivity.class);
                  intent.putExtra("url", advs.get(tempPos).getLinkurl());
                  startActivity(intent);
                }
              }
            });
        view_img.add(view);
        if (i == 0) {
          ImageView dot = new ImageView(PreMainActivity.this);
          dot.setLayoutParams(ll);
          dot.setBackgroundResource(R.drawable.app_dot_focused);
          dot.setPadding(
              ContextUtil.dip2px(PreMainActivity.this, 1.5f), 0,
              ContextUtil.dip2px(PreMainActivity.this, 1.5f), 0);
          dots_ll.addView(dot);
          dots.add(dot);
        } else {
          ImageView dot = new ImageView(PreMainActivity.this);
          dot.setLayoutParams(ll);
          dot.setPadding(
              ContextUtil.dip2px(PreMainActivity.this, 1.5f), 0,
              ContextUtil.dip2px(PreMainActivity.this, 1.5f), 0);
          dot.setBackgroundResource(R.drawable.app_dot_normal);
          dots_ll.addView(dot);
          dots.add(dot);
        }
      }
    }
    if (view_img.size() > 0) {
      mJazzy.setAdapter(new MyJazzyPagerAdapter(view_img, mJazzy));
      mJazzy.setCurrentItem(0);
    }
    mJazzy.setOnPageChangeListener(new MyJazzyViewPager());
    // mJazzy.setPageMargin(30);
    // 创建定时器
    scheduledExecutor = Executors.newSingleThreadScheduledExecutor();
    // 首次启动时3秒后开始执行,接下来3秒执行一次
    scheduledExecutor.scheduleAtFixedRate(new ViewpagerTask(), 3, 5, TimeUnit.SECONDS);
  }