コード例 #1
0
 private void showInformationDialog(TwitchChannel twitchChannel) {
   AlertDialog.Builder builder = new AlertDialog.Builder(ctx, R.style.SNAlertDialogStyle);
   builder.setTitle(twitchChannel.getName());
   builder.setMessage(
       twitchChannel.getDescription() == null
           ? ctx.getString(R.string.no_description)
           : twitchChannel.getDescription());
   builder.setNegativeButton(R.string.close, null);
   builder.show();
 }
コード例 #2
0
  // Replace the contents of a view (invoked by the layout manager)
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
    final TwitchChannel twitchChannel = twitchChannelList.get(position);

    holder.mFeaturedView.setText(getStatusString(twitchChannel.getStatus()));
    holder.mTitleText.setText(twitchChannel.getName());
    Picasso.with(ctx)
        .load(twitchChannel.getImage().getSize600())
        .error(R.drawable.feed_default)
        .into(holder.mMainImage);

    holder.mMainImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            ctx.startActivity(Utils.openURLIntent(twitchChannel.getLink()));
          }
        });

    holder.mInformationLayout.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            showInformationDialog(twitchChannel);
          }
        });

    holder.mCommentText.setText(
        MessageFormat.format(
            ctx.getString(R.string.follower_count), twitchChannel.getFollowersCount()));

    holder.mCreatedDate.setText(
        MessageFormat.format(
            ctx.getString(R.string.live_viewers), twitchChannel.getCurrentViewers()));

    if (twitchChannel.isLive()) {

      holder.mTimeImage.setVisibility(View.VISIBLE);
      holder.mCreatedDate.setVisibility(View.VISIBLE);

      holder.mFeaturedBoxView.setBackgroundColor(
          ctx.getResources().getColor(R.color.twitch_purple));
      holder.shimmerFrameLayout.setBaseAlpha(0.8f);
      holder.shimmerFrameLayout.startShimmerAnimation();

      if (!twitchChannel.getMetaGame().isEmpty()) {
        holder.mTitleSubText.setVisibility(View.VISIBLE);
        holder.mTitleSubText.setText(
            String.format(ctx.getString(R.string.playing), twitchChannel.getMetaGame()));
      }

      // SHOW FIRE IF VIEWERS OVER 100? or 10% of followers?
      if (twitchChannel.getCurrentViewers() != 0
          && twitchChannel.getCurrentViewers()
              >= Math.round(0.1 * twitchChannel.getFollowersCount())) {
        holder.mTimeImage.setImageResource(R.drawable.trending);
      }
    } else {
      holder.mTimeImage.setVisibility(View.INVISIBLE);
      holder.mCreatedDate.setVisibility(View.INVISIBLE);
      holder.mTitleSubText.setVisibility(View.GONE);
      holder.mFeaturedBoxView.setBackgroundColor(ctx.getResources().getColor(R.color.sn_green));
      holder.shimmerFrameLayout.stopShimmerAnimation();
    }
  }