示例#1
0
  protected void buildMultiPic(final GridLayout gridLayout) {
    gridLayout.setVisibility(View.VISIBLE);
    // 获取当前屏幕尺寸
    DisplayMetrics metrics = new DisplayMetrics();
    WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    windowManager.getDefaultDisplay().getMetrics(metrics);
    // 设置图片的宽度和高度
    int picWidth = metrics.widthPixels / 3 - 48;

    for (int i = 0; i < 9; i++) {
      // 获取View
      SimpleDraweeView simpleDraweeView = (SimpleDraweeView) gridLayout.getChildAt(i);
      // 设置布局参数
      GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
      layoutParams.width = picWidth;
      layoutParams.height = picWidth;
      layoutParams.setMargins(8, 8, 8, 8);
      simpleDraweeView.setLayoutParams(layoutParams);
      // 设置图片数据源
      simpleDraweeView.setImageURI(Uri.parse(Image.imageThumbUrls[i]));
      // 准备传递数据
      final ImageViewPageMessage imageViewPageMessage =
          new ImageViewPageMessage(Image.imageThumbUrls, i);
      simpleDraweeView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              EventBus.getDefault().postSticky(imageViewPageMessage);
              Intent intent = new Intent(mContext, ImageViewPagerActivity.class);
              mContext.startActivity(intent);
            }
          });
    }
  }
示例#2
0
  public void onFragmentBack(final AcContentInfo.DataEntity.FullContentEntity fullContentEntity) {
    // 加载标题图片并点击播放默认第一个视频
    mTitleImg.setImageURI(Uri.parse(fullContentEntity.getCover()));
    mTitleImg.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            AcContentInfo.DataEntity.FullContentEntity.VideosEntity videosEntity =
                fullContentEntity.getVideos().get(0);

            VideoPlayActivity.startActivity(
                AcContentActivity.this,
                String.valueOf(videosEntity.getVideoId()),
                String.valueOf(videosEntity.getDanmakuId()),
                videosEntity.getSourceId(),
                videosEntity.getType());
          }
        });
    //        mCollapsingToolbarLayout.setTitle("AC" + fullContentEntity.getContentId());
  }
示例#3
0
 @Override
 public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
   if (holder instanceof ItemViewHolder) {
     ItemViewHolder item = (ItemViewHolder) holder;
     Post post = mPostList.get(position);
     item.avatar.setImageURI(Uri.parse(StrUtils.thumForID(post.userId)));
     item.avatar.setTag(post.userId);
     item.avatar.setOnClickListener(mListener);
     item.userName.setText(post.name);
     item.university.setText(post.school);
     item.time.setText(StrUtils.timeTransfer(post.timestamp));
     item.title.setText(post.title);
     item.content.setText(post.body);
     item.like_number.setText(post.likenumber);
     item.comment_number.setText(post.commentnumber);
     item.grid.removeAllViews();
     for (int i = 0; i < post.thumbnailUrl.size() && i < 4; i++) {
       String url = post.thumbnailUrl.get(i);
       SimpleDraweeView image = new SimpleDraweeView(mContext);
       item.grid.addView(image);
       image.setImageURI(Uri.parse(url));
       image.setId(imageID);
       image.setOnClickListener(mListener);
       try {
         JSONObject j = new JSONObject();
         JSONArray array = new JSONArray(post.imageUrl);
         j.put(AtyImage.KEY_ARRAY, array);
         j.put(AtyImage.KEY_INDEX, i);
         image.setTag(j.toString());
       } catch (JSONException e) {
         // ignore
       }
     }
     item.itemView.setTag(post);
     item.itemView.setOnClickListener(mListener);
   } else if (holder instanceof ProgressViewHolder) {
     ProgressViewHolder progress = (ProgressViewHolder) holder;
     progress.progressBar.setIndeterminate(true);
   }
 }
  // 实现setContentView方法
  @Override
  public void setContentView(View contentView, int position, HorizontalScrollView parent) {
    SimpleDraweeView userimg =
        (SimpleDraweeView) contentView.findViewById(R.id.petdiartycomment_userimg);
    TextView timeTv = (TextView) contentView.findViewById(R.id.petdiartycomment_time);
    TextView contentTv = (TextView) contentView.findViewById(R.id.petdiartycomment_content);
    TextView voicenameTv = (TextView) contentView.findViewById(R.id.petdiartycomment_voice_name);
    PercentRelativeLayout voiceRL =
        (PercentRelativeLayout) contentView.findViewById(R.id.petdiartycomment_voice);
    ImageView voiceImg = (ImageView) contentView.findViewById(R.id.petdiartycomment_voiceimg);
    TextView voiceText = (TextView) contentView.findViewById(R.id.petdiartycomment_voicetext);
    CommontObject commentObj = (CommontObject) getItem(position);
    if (commentObj != null) {
      AccountObject account = commentObj.getAccount();
      String name = "";
      if (account != null) {
        if (!CommonTextUtils.isEmpty(account.getIcoUrl())) {
          FrescoHelper.displayImageview(
              userimg,
              account.getIcoUrl() + CommonUtils.getAvatarSize(mContext),
              R.drawable.avatar_default_image,
              mContext.getResources(),
              true);
        } else {
          Uri uri = Uri.parse("res://mobi.jzcx.android.chongmi/" + R.drawable.avatar_default_image);
          userimg.setImageURI(uri);
        }
        name = account.getNickName();
      }
      if (!CommonTextUtils.isEmpty(commentObj.getTimeStamp())) {
        timeTv.setText(commentObj.getTimeStamp());
      } else {
        timeTv.setText("");
      }
      if (!CommonTextUtils.isEmpty(commentObj.getText())) {
        contentTv.setText(commentObj.getText());
      } else {
        contentTv.setText("");
      }
      // if (!CommonTextUtils.isEmpty(commentObj.getVoiceUrl())) {
      // voiceRL.setVisibility(View.VISIBLE);
      // contentTv.setVisibility(View.GONE);
      // } else {
      //
      // }
      voiceRL.setVisibility(View.GONE);
      contentTv.setVisibility(View.VISIBLE);
      if (!CommonTextUtils.isEmpty(name)) {
        voicenameTv.setText(name);
      } else {
        voicenameTv.setText("");
      }
      userimg.setOnClickListener(new userImgClick(account));

      // String localPath = FileUtils.VOICE +
      // DemoUtils.md5(commentObj.getVoiceUrl()) + ".amr";
      //
      // if (FileUtils.exists(localPath)) {
      // try {
      // long duration = CommonUtils.getAmrDuration(new File(localPath));
      // NumberFormat nf = NumberFormat.getNumberInstance();
      // nf.setMaximumFractionDigits(2);
      // voiceText.setText(nf.format(Double.valueOf(duration / 1000)));
      // } catch (IOException e) {
      // e.printStackTrace();
      // }
      // voiceRL.setOnClickListener(new VoicePlayClickListener(localPath,
      // voiceImg, this, mContext));
      // } else {
      // voiceText.setText("");
      // }
    }
  }