Ejemplo n.º 1
0
  // if platform selected form platform gridview is SinaWeibo,
  // TencentWeibo, Facebook, or Twitter, there will be a button
  // in the left-bottom of the page, which provides At-friends function
  private LinearLayout getAtLine(String platform) {
    if (!isShowAtUserLayout(platform)) {
      return null;
    }
    LinearLayout llAt = new LinearLayout(getContext());
    LayoutParams lpAt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpAt.rightMargin = dipToPx(getContext(), 4);
    lpAt.gravity = Gravity.LEFT | Gravity.BOTTOM;
    lpAt.weight = 1;
    llAt.setLayoutParams(lpAt);
    llAt.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (platforms != null && platforms.size() > 0) {
              FollowListPage subPage = new FollowListPage();
              subPage.setPlatform(platforms.get(0));
              subPage.showForResult(activity, null, EditPage.this);
            } else {
              int resId = getStringRes(activity, "ssdk_oks_select_one_plat_at_least");
              if (resId > 0) {
                Toast.makeText(getContext(), resId, Toast.LENGTH_SHORT).show();
              }
            }
          }
        });

    TextView tvAt = new TextView(getContext());
    int resId = getBitmapRes(activity, "ssdk_oks_btn_back_nor");
    if (resId > 0) {
      tvAt.setBackgroundResource(resId);
    }
    int dp_32 = dipToPx(getContext(), 32);
    tvAt.setLayoutParams(new LayoutParams(dp_32, dp_32));
    tvAt.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    tvAt.setText(getAtUserButtonText(platform));
    int dp_2 = dipToPx(getContext(), 2);
    tvAt.setPadding(0, 0, 0, dp_2);
    tvAt.setTypeface(Typeface.DEFAULT_BOLD);
    tvAt.setTextColor(0xff000000);
    tvAt.setGravity(Gravity.CENTER);
    llAt.addView(tvAt);

    TextView tvName = new TextView(getContext());
    tvName.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    tvName.setTextColor(0xff000000);
    resId = getStringRes(activity, "ssdk_oks_list_friends");
    String text = getContext().getString(resId, getName(platform));
    tvName.setText(text);
    LayoutParams lpName = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpName.gravity = Gravity.CENTER_VERTICAL;
    tvName.setLayoutParams(lpName);
    llAt.addView(tvName);

    return llAt;
  }
Ejemplo n.º 2
0
  /** 初始化可左右滑动的图片Adapter */
  private void initPicAdapter(String imgs[]) {
    for (int i = 0; i < imgs.length; i++) {
      ImageView iv = new ImageView(getBaseContext());
      LayoutParams lp = (LayoutParams) iv.getLayoutParams();
      if (null == lp) {
        lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      }
      iv.setImageResource(R.drawable.dot_grey2x);
      lp.rightMargin = 5;
      iv.setLayoutParams(lp);
      frame_dian.addView(iv);
      imgViews.add(iv);
    }

    for (int h = 0; h < imgs.length; h++) {
      ImageView imageView_pic = new ImageView(this);
      String url = imgs[h];
      bitmapUtilsPic.display(imageView_pic, url);
      viewlist.add(imageView_pic);
    }

    if (null == picAdapter) {
      picAdapter = new GroupBuyImageAdapter(PindanDetailActivity.this, imgs);
      gallery.setAdapter(picAdapter);
      gallery.setSelection(0);
      gallery.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
              // 不显示大图片
              if (null == pagerAdapter) {
                pagerAdapter = new BigPicAdapter(viewlist, handler);
                pagerImage.setAdapter(pagerAdapter);
              }
              pagerImage.setCurrentItem(position);
              content_all.setVisibility(View.INVISIBLE);
              pagerLayout.setVisibility(View.VISIBLE);
              pagerLayout.startAnimation(animationsmall_big);
            }
          });
      gallery.setOnItemSelectedListener(
          new OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {

              for (int i = 0; i < imgViews.size(); i++) {
                if (i == position) {
                  ((ImageView) frame_dian.getChildAt(i)).setImageResource(R.drawable.dot_yellow2x);
                } else {
                  ((ImageView) frame_dian.getChildAt(i)).setImageResource(R.drawable.dot_grey2x);
                }
              }
            }

            @Override
            public void onNothingSelected(AdapterView<?> arg0) {}
          });
    } else {
      picAdapter.notifyDataSetChanged();
    }
  }
    @SuppressWarnings("deprecation")
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      Message message1 = (Message) this.getItem(position);

      ViewHolder holder;
      if (convertView == null) {
        holder = new ViewHolder();
        convertView = LayoutInflater.from(mContext).inflate(R.layout.sms_row, parent, false);
        holder.message = (EmojiconTextView) convertView.findViewById(R.id.message_text);
        holder.thumb = (FetchableImageView) convertView.findViewById(R.id.thumb);
        holder.message.setPadding(10, 10, 10, 10);
        convertView.setTag(holder);
      } else holder = (ViewHolder) convertView.getTag();
      if (message1.getMsgtype().equalsIgnoreCase("text")) {
        holder.message.setVisibility(View.VISIBLE);
        holder.thumb.setVisibility(View.GONE);

        holder.message.setText(message1.getMessage());
        LayoutParams lp = (LayoutParams) holder.message.getLayoutParams();
        if (message1.getIsmine().equals("yes")) {
          holder.message.setBackgroundResource(R.drawable.message_you);
          holder.message.setPadding(15, 15, 15, 15);
          lp.gravity = Gravity.RIGHT;
          lp.leftMargin = 50;
          lp.rightMargin = 20;
        }
        // If not mine then it is from sender to show orange background and
        // align to left
        else {
          holder.message.setBackgroundResource(R.drawable.message_from);
          holder.message.setPadding(15, 15, 15, 15);
          lp.gravity = Gravity.LEFT;
          lp.rightMargin = 50;
          lp.leftMargin = 20;
        }
        holder.message.setLayoutParams(lp);
        holder.message.setTextColor(mContext.getResources().getColor(R.color.Black));
      } else {
        LayoutParams lp1 = (LayoutParams) holder.thumb.getLayoutParams();
        holder.message.setVisibility(View.GONE);
        holder.thumb.setVisibility(View.VISIBLE);
        holder.thumb.setPadding(15, 15, 15, 15);
        if (message1.getMsgtype().equals("video")) {

          holder.thumb.setImage(message1.getMessage(), R.drawable.placeholder_video);
          final String url = DataManager.FILE_PATH + message1.getMessage().toString();
          holder.thumb.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent intent = new Intent(Intent.ACTION_VIEW);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  intent.setDataAndType(Uri.parse(url), "video/*");
                  mContext.startActivity(intent);
                }
              });
        } else if (message1.getMsgtype().equals("audio")) {
          holder.thumb.setImage(message1.getMessage(), R.drawable.placeholder_audio);
          final String url = DataManager.FILE_PATH + message1.getMessage();
          holder.thumb.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Uri myUri = Uri.parse(url);
                  Intent intent = new Intent(Intent.ACTION_VIEW);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  intent.setDataAndType(myUri, "audio/*");
                  mContext.startActivity(intent);
                }
              });
        } else if (message1.getMsgtype().equals("photo")) {
          holder.thumb.setImage(
              DataManager.FILE_PATH + message1.getMessage(), R.drawable.placeholder_image);
          final String url = DataManager.FILE_PATH + message1.getMessage();
          holder.thumb.setOnClickListener(
              new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent intent = new Intent(Intent.ACTION_VIEW);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                  intent.setDataAndType(Uri.parse(url), "image/*");
                  mContext.startActivity(intent);
                }
              });
        }
        if (message1.getIsmine().equals("yes")) {
          holder.thumb.setBackgroundResource(R.drawable.message_you);
          holder.thumb.setPadding(15, 15, 15, 15);
          lp1.gravity = Gravity.RIGHT;
          lp1.topMargin = 10;
          lp1.bottomMargin = 10;
          lp1.leftMargin = 50;
          lp1.rightMargin = 20;
        }
        // If not mine then it is from sender to show orange background and
        // align to left
        else {
          holder.thumb.setBackgroundResource(R.drawable.message_from);
          holder.thumb.setPadding(15, 15, 15, 15);
          lp1.gravity = Gravity.LEFT;
          lp1.topMargin = 10;
          lp1.bottomMargin = 10;
          lp1.rightMargin = 50;
          lp1.leftMargin = 20;
        }
        holder.thumb.setLayoutParams(lp1);
      }
      return convertView;
    }
  /** 设置button的 宽度 以及监听 */
  private void setButton() {
    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    int width0 = 2; // 边框宽度
    int width1 = 10; // 外部边框距左右边界距离
    int hight0 = 70; // 外部边框高度
    LinearLayout a_layout = (LinearLayout) findViewById(R.id.a_layout);
    LayoutParams param = (LayoutParams) a_layout.getLayoutParams();
    param.topMargin = 10;
    param.bottomMargin = 10;
    param.leftMargin = width1;
    param.rightMargin = width1;
    if (height == 1280 && width == 720) {
      hight0 = 70;
      width = width + 4;
      param.leftMargin = width1;
      param.rightMargin = width1 + 1;
    } else if (height == 854 && width == 480) {
      hight0 = 45;
      width1 = 18;
      width0 = 2;
      param.leftMargin = width1;
      param.rightMargin = width1 - 1;
    } else if (height == 800 && width == 480) {
      hight0 = 45;
      width1 = 18;
      width0 = 2;
      param.leftMargin = width1;
      param.rightMargin = width1 - 1;
    } else if (height >= 1750 && height <= 1920 && width == 1080) {
      width1 = 40; // 外部边框距左右边界距离
      hight0 = 100;
      param.leftMargin = width1;
      param.rightMargin = width1;
    }
    int hight1 = hight0 - width0 * 2; // button高度
    param.height = hight0;
    // view1 = (Button) findViewById(R.id.view_1);
    // view2 = (Button) findViewById(R.id.view_2);
    // view3 = (Button) findViewById(R.id.view_3);
    // view1.setWidth(width0);
    // view2.setWidth(width0);
    // view3.setWidth(width0);
    // view1.setHeight(hight1);
    // view2.setHeight(hight1);
    // view3.setHeight(hight1);

    int button_width = (width - width1 * 2 - 7 * width0) / 4;
    button_1 = (Button) findViewById(R.id.button_1);
    button_2 = (Button) findViewById(R.id.button_2);
    button_3 = (Button) findViewById(R.id.button_3);
    button_4 = (Button) findViewById(R.id.button_4);
    button_1.setOnClickListener(this);
    button_2.setOnClickListener(this);
    button_3.setOnClickListener(this);
    button_4.setOnClickListener(this);
    btnList.add(button_1);
    btnList.add(button_2);
    btnList.add(button_3);
    btnList.add(button_4);

    for (int i = 0; i < btnList.size(); i++) {
      btnList.get(i).setWidth(button_width);
      btnList.get(i).setHeight(hight1);
    }

    if (version < 4) {
      button_1.setBackgroundResource(R.drawable.left_shape_red2);
      button_4.setBackgroundResource(R.drawable.right_shape_white2);
    }
  }