@Override
    public void onBindViewHolder(final ViewHolder holder, int position) {
      HHFriendshipUser friendship = user.getFriendships().get(position);
      holder.position = position;
      holder.btnFollowOnClickListener.setFriendship(friendship);
      holder.btnUnfollowOnClickListener.setFriendship(friendship);
      holder.txtUserName.setText(friendship.getUser().getName());
      holder.onClickUserListener.setUser(friendship.getUser());

      boolean friendIsFollowed = HHUser.userIsFollowed(user, friendship.getUser());
      boolean friendFollowsMe = HHUser.userFollowsMe(user, friendship.getUser());
      boolean friendIsRequested = HHUser.userIsRequested(user, friendship.getUser());
      // boolean userRequestedMe = HHUser.userRequestedMe(user, friendship.getUser());

      if (friendIsFollowed) {
        holder.btnFollow.setVisibility(View.GONE);
        holder.btnUnfollow.setVisibility(View.VISIBLE);
      } else {
        holder.btnFollow.setVisibility(View.VISIBLE);
        holder.btnFollow.setEnabled(true);
        holder.btnFollow.clearColorFilter();
        holder.btnUnfollow.setVisibility(View.GONE);
      }

      if (friendIsRequested) {
        holder.btnFollow.setColorFilter(
            ZZZUtility.screen(ContextCompat.getColor(context, R.color.adam_theme_darkest)));
        holder.btnFollow.setEnabled(false);
      }

      if (friendIsFollowed && friendFollowsMe) {
        holder.imgFollowStatus.setImageResource(R.drawable.follow_in_out);
      } else if (friendIsFollowed) {
        holder.imgFollowStatus.setImageResource(R.drawable.follow_out);
      } else if (friendFollowsMe) {
        holder.imgFollowStatus.setImageResource(R.drawable.follow_in);
      } else {
        holder.imgFollowStatus.setImageResource(R.drawable.follow_none);
      }

      // get User Image
      WebHelper.getFacebookProfilePicture(
          friendship.getUser().getFBUserID(),
          new WebHelper.GetFacebookProfilePictureCallback() {
            @Override
            public void returnFacebookProfilePicture(Bitmap bitmap) {
              holder.imgProfile.setImageBitmap(bitmap);
            }
          });
    }
Пример #2
0
    public View getView(int position, View convertView, ViewGroup parent) {
      if (convertView == null) {
        convertView = createView(parent);
      }
      ViewHolder holder = (ViewHolder) convertView.getTag();

      // index is reverse since most recent appears at the bottom...
      final int index = position;

      final TaskDescription td = mRecentTaskDescriptions.get(index);

      // holder.thumbnailView.setContentDescription(td.getLabel());
      holder.loadedThumbnailAndIcon = td.isLoaded();
      if (td.isLoaded()) {
        updateIcon(holder, td.getIcon(), true, false);
      }
      if (index == 0) {
        if (mAnimateIconOfFirstTask) {
          if (mItemToAnimateInWhenWindowAnimationIsFinished != null) {
            holder.iconView.setAlpha(1f);
            holder.iconView.setTranslationX(0f);
            holder.iconView.setTranslationY(0f);
          }
          mItemToAnimateInWhenWindowAnimationIsFinished = holder;
          final int translation =
              -getResources()
                  .getDimensionPixelSize(R.dimen.status_bar_recents_app_icon_translate_distance);
          final Configuration config = getResources().getConfiguration();
          if (config.orientation == Configuration.ORIENTATION_PORTRAIT) {
            holder.iconView.setAlpha(0f);
            holder.iconView.setTranslationX(translation);
          } else {
            holder.iconView.setAlpha(0f);
            holder.iconView.setTranslationY(translation);
          }
          if (!mWaitingForWindowAnimation) {
            animateInIconOfFirstTask();
          }
        }
      }

      holder.taskDescription = td;
      holder.position = index;
      RecentsScrollView scrollView = (RecentsScrollView) mRecentsContainer;
      final View animView = scrollView.getChildContentView(convertView);
      animView.setAlpha(1f);
      animView.setTranslationY(0f);
      return convertView;
    }
 /*
  * (non-Javadoc)
  *
  * @see
  * android.support.v4.widget.CursorAdapter#newView(android.content.Context
  * , android.database.Cursor, android.view.ViewGroup)
  */
 @Override
 public View newView(Context context, Cursor cursor, ViewGroup parent) {
   LayoutInflater vi = getActivity().getLayoutInflater();
   ViewHolder holder = new ViewHolder();
   View view = vi.inflate(R.layout.list_row_channel, null);
   holder.v = (CheckableLinearLayout) view;
   holder.icon = (ImageView) view.findViewById(R.id.icon);
   holder.position = (TextView) view.findViewById(R.id.position);
   holder.channelName = (TextView) view.findViewById(R.id.title);
   holder.epgTime = (TextView) view.findViewById(R.id.epgTime);
   holder.progress = (ProgressBar) view.findViewById(R.id.progress);
   holder.epgTitle = (TextView) view.findViewById(R.id.epgTitle);
   holder.contextMenu = (ImageView) view.findViewById(R.id.contextMenu);
   holder.contextMenu.setOnClickListener(ChannelList.this);
   view.setTag(holder);
   return view;
 }
Пример #4
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    final ViewHolder holder;
    final ActivityInfo app = getItem(position);

    if (convertView == null) {
      convertView = mInflater.inflate(mTextViewResourceId, parent, false);
      holder = new ViewHolder();

      holder.icon = (ImageView) convertView.findViewById(R.id.icon);
      holder.name = (TextView) convertView.findViewById(R.id.name);

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    final View view = convertView;

    holder.position = position;

    // don't block the UI thread
    new Thread(
            new Runnable() {
              public void run() {
                final CharSequence label = app.loadLabel(mPackageManager);
                final Drawable drawable = app.loadIcon(mPackageManager);
                view.post(
                    new Runnable() {

                      @Override
                      public void run() {
                        if (holder.position == position) {
                          holder.name.setText(label);
                          holder.icon.setImageDrawable(drawable);
                        }
                      }
                    });
              }
            })
        .start();

    return convertView;
  }
Пример #5
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    final String textString = (String) getItem(position);
    ViewHolder holder;
    int type = types[position];
    if (convertView == null || ((ViewHolder) convertView.getTag()).position != position) {
      holder = new ViewHolder();
      if (type == TYPE_CANCEL) { //
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_cancel, null);
        holder.text = (TextView) convertView.findViewById(R.id.popup_text);
      } else if (type == TYPE_BUTTON) { //
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout, null);
        holder.text = (TextView) convertView.findViewById(R.id.popup_text);
        if (changeLenth == 1) {
          holder.text.setBackgroundResource(R.drawable.white_btn_n);
        } else if (changeLenth >= 2) {
          if (position == 0) {
            holder.text.setBackgroundResource(R.drawable.pop_top);
          } else if (position == changeLenth - 1) {
            holder.text.setBackgroundResource(R.drawable.pop_bottom);
          } else {
            holder.text.setBackgroundResource(R.drawable.pop_center);
          }
        }
      } else if (type == TYPE_TITLE || type == TYPE_EXIT) { //
        convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_title, null);
        holder.text = (TextView) convertView.findViewById(R.id.popup_text);
      } /*else if (type == TYPE_EXIT) {
        	convertView = View.inflate(context, R.layout.alert_dialog_menu_list_layout_special, null);
        }*/
      holder.position = position;
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    holder.text.setText(textString);
    return convertView;
  }
Пример #6
0
 @Override
 public View getView(int position, View convertView, ViewGroup parent) {
   LayoutInflater inflater = LayoutInflater.from(parent.getContext());
   ViewHolder holder;
   if (convertView == null) {
     convertView = inflater.inflate(R.layout.user_list_item, null, false);
     holder = new ViewHolder();
     holder.icon = (ImageView) convertView.findViewById(R.id.userIcon);
     holder.name = (TextView) convertView.findViewById(R.id.userName);
     holder.email = (TextView) convertView.findViewById(R.id.userEmail);
     holder.position = position;
     convertView.setTag(holder);
   } else {
     holder = (ViewHolder) convertView.getTag();
   }
   UgUser user = data.get(position);
   holder.name.setText(user.getDisplayName());
   holder.email.setText(user.getEmail());
   ImageLoader.getInstance()
       .displayImage(
           UrlBuilder.generateAvatarUrl(user.getUserName(), user.getAvatarId()), holder.icon);
   return convertView;
 }
Пример #7
0
  @Override
  public View getView(int i, View convertView, ViewGroup viewGroup) {
    ViewHolder viewHolder;

    if (convertView == null) {
      LayoutInflater layoutInflater =
          (LayoutInflater)
              context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); // getContext()
      convertView = layoutInflater.inflate(R.layout.list_item, null);

      viewHolder = new ViewHolder();
      viewHolder.textView = (TextView) convertView.findViewById(R.id.textView);
      viewHolder.imageView = (ImageView) convertView.findViewById(R.id.imageView);
      viewHolder.progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);

      convertView.setTag(viewHolder);
    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }

    try {
      if (jsonObject[i].has("title")) {
        viewHolder.textView.setText(jsonObject[i].getString("title") + " - " + i);
      } else {
        viewHolder.textView.setText(jsonObject[i].getString("pid") + " - " + i);
      }
    } catch (JSONException e) {
      Log.e("log123", "JSONException = " + e);
    }

    viewHolder.position = i;
    DownloadImage task = new DownloadImage(i, viewHolder);
    //		task.execute(jsonObject[i]);
    task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, jsonObject[i]);

    return convertView;
  }
Пример #8
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    ViewHolder viewHolder;

    if (convertView == null) {

      // inflate the layout
      LayoutInflater inflater = LayoutInflater.from(getContext());
      convertView = inflater.inflate(layoutResourceId, parent, false);

      // well set up the ViewHolder
      viewHolder = new ViewHolder();
      viewHolder.title = (TextView) convertView.findViewById(R.id.title);
      viewHolder.subtitle = (TextView) convertView.findViewById(R.id.subtitle);
      viewHolder.info = (TextView) convertView.findViewById(R.id.info);
      viewHolder.avatar = (ImageView) convertView.findViewById(R.id.imageView);

      // store the holder with the view.
      convertView.setTag(viewHolder);

    } else {
      viewHolder = (ViewHolder) convertView.getTag();
    }
    viewHolder.position = position;

    Matter matter = getItem(position);

    if (matter != null && viewHolder != null) {
      setTitle(viewHolder.title, matter);
      setSubtitle(viewHolder.subtitle, matter);
      setInfo(viewHolder.info, matter);
      setImage(viewHolder, matter, position);
    }

    return convertView;
  }
Пример #9
0
    public View getView(int position, View convertView, ViewGroup parent) {
      View view;
      ViewHolder holder;
      if (convertView == null) {
        view = inflater.inflate(R.layout.legislator_voter, null);

        holder = new ViewHolder();
        holder.name = (TextView) view.findViewById(R.id.name);
        holder.position = (TextView) view.findViewById(R.id.position);
        holder.vote = (TextView) view.findViewById(R.id.vote);
        holder.photo = (ImageView) view.findViewById(R.id.photo);
        holder.star = (ImageView) view.findViewById(R.id.star);

        view.setTag(holder);
      } else {
        view = convertView;
        holder = (ViewHolder) view.getTag();
      }

      Roll.Vote vote = getItem(position);
      Legislator legislator = vote.voter;

      // used as the hook to get the legislator image in place when it's loaded
      // and to link to the legislator's activity
      holder.bioguide_id = vote.voter_id;

      holder.name.setText(nameFor(legislator));
      holder.position.setText(positionFor(legislator));

      holder.star.setVisibility(starred ? View.VISIBLE : View.GONE);

      TextView voteView = holder.vote;
      String value = vote.vote;
      if (value.equals(Roll.YEA)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        voteView.setTextColor(resources.getColor(R.color.yea));
      } else if (value.equals(Roll.NAY)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        voteView.setTextColor(resources.getColor(R.color.nay));
      } else if (value.equals(Roll.PRESENT)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        voteView.setTextColor(resources.getColor(R.color.present));
      } else if (value.equals(Roll.NOT_VOTING)) {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        voteView.setTextColor(resources.getColor(R.color.not_voting));
      } else {
        voteView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        voteView.setTextColor(resources.getColor(android.R.color.white));
      }

      voteView.setText(vote.vote);

      BitmapDrawable photo =
          LegislatorImage.quickGetImage(
              LegislatorImage.PIC_MEDIUM, legislator.bioguide_id, context);
      if (photo != null) holder.photo.setImageDrawable(photo);
      else {
        holder.photo.setImageResource(R.drawable.loading_photo);
        context.loadPhoto(legislator.bioguide_id);
      }

      return view;
    }
Пример #10
0
 @Override
 public void onBindViewHolder(ViewHolder holder, int position) {
   holder.name.setText(timers.get(position).getName());
   holder.position = position;
 }
Пример #11
0
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder = null;
    if (convertView == null) {
      switch (mItemType) {
        case DETAILS:
          convertView = mInflater.inflate(R.layout.library_bookinfos_details, null);
          break;
        case LIST:
          convertView = mInflater.inflate(R.layout.library_bookinfos_list, null);
          break;
      }
      holder = new ViewHolder();
      convertView.setTag(holder);

      holder.icon = (ImageView) convertView.findViewById(R.id.icon);
      holder.format = (ImageView) convertView.findViewById(R.id.format);
      holder.title = (TextView) convertView.findViewById(R.id.title);
      holder.author = (TextView) convertView.findViewById(R.id.author);
      holder.size = (TextView) convertView.findViewById(R.id.size);
      holder.book_checkbox = (CheckBox) convertView.findViewById(R.id.book_checkbox);
      holder.creation_date = (TextView) convertView.findViewById(R.id.creation_date);
      holder.rate_info = (TextView) convertView.findViewById(R.id.rate_info);
      holder.rate_info_percent = (TextView) convertView.findViewById(R.id.rate_info_percent);
      holder.progressbar = (ProgressBar) convertView.findViewById(R.id.progressbar);
      holder.position = position;
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    final LocalBook book = mLocalBooks.get(position);
    holder.title.setText(book.title);
    holder.author.setText(book.author);
    holder.book_checkbox.setTag(book);
    holder.book_checkbox.setChecked(book.selected);
    holder.format.setImageResource(BaseViewHolder.getFormatDrawable(book.file));
    holder.icon.setImageBitmap(null);
    holder.icon.setImageResource(R.drawable.no_cover);
    Bitmap bitmap =
        ImageBuffer.getBitmap(
            mContext, (mItemType == ViewType.DETAILS) ? book.detail_image : book.list_image);
    if (bitmap != null) holder.icon.setImageBitmap(bitmap);
    //        // Using an AsyncTask to load the slow images in a background thread
    //        new AsyncTask<ViewHolder, Void, Bitmap>() {
    //            private ViewHolder v;
    //
    //            @Override
    //            protected Bitmap doInBackground(ViewHolder... params) {
    //                v = params[0];
    //                return ImageBuffer.getBitmap(mContext, (mItemType == ViewType.DETAILS) ?
    // book.detail_image : book.list_image);
    //            }
    //
    //            @Override
    //            protected void onPostExecute(Bitmap result) {
    //                super.onPostExecute(result);
    //                v.icon.setVisibility(View.VISIBLE);
    //                if (result != null)
    //                	v.icon.setImageBitmap(result);
    //            }
    //        }.execute(holder);

    holder.book_checkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

            LocalBook book = (LocalBook) buttonView.getTag();
            book.selected = isChecked;
            mCheckedChangedListener.onCheckedChanged(buttonView, isChecked);
          }
        });

    if (holder.creation_date != null)
      holder.creation_date.setText(date.format(new Date(book.addition_date)));

    if (holder.size != null) holder.size.setText(FileUtil.convertStorage(book.size));

    if (holder.rate_info != null
        && holder.rate_info_percent != null
        && holder.progressbar != null
        && book.total_offset > 0
        && book.total_page > 0) {
      holder.rate_info.setVisibility(View.VISIBLE);
      holder.rate_info_percent.setVisibility(View.VISIBLE);
      holder.progressbar.setVisibility(View.VISIBLE);

      holder.rate_info.setText(
          Long.toString(book.current_page) + "/" + Long.toString(book.total_page));

      int percent = (int) (100 * book.current_offset / book.total_offset);
      holder.progressbar.setProgress(percent);
      holder.rate_info_percent.setText(Integer.toString(percent) + "%");
    } else if (holder.rate_info != null
        && holder.rate_info_percent != null
        && holder.progressbar != null) {
      holder.rate_info.setVisibility(View.INVISIBLE);
      holder.rate_info_percent.setVisibility(View.INVISIBLE);
      holder.progressbar.setVisibility(View.INVISIBLE);
    }

    if (holder.progressbar != null) {
      holder.progressbar.setMax(100);
    }
    return convertView;
  }
  public View getView(int position, View view, ViewGroup parent) {
    final ThreadRowInfo row = data.getRowList().get(position);

    int lou = -1;
    if (row != null) lou = row.getLou();
    ViewHolder holder = null;
    boolean needin = false;
    SoftReference<View> ref = viewCache.get(position);
    View cachedView = null;
    if (ref != null) {
      cachedView = ref.get();
    }
    if (cachedView != null) {
      if (((ViewHolder) cachedView.getTag()).position == position) {
        Log.d(TAG, "get view from cache ,floor " + lou);
        return cachedView;
      } else {
        view = LayoutInflater.from(activity).inflate(R.layout.relative_aritclelist, parent, false);
        holder = initHolder(view);
        holder.position = position;
        view.setTag(holder);
        viewCache.put(position, new SoftReference<View>(view));
      }
    } else {
      view = LayoutInflater.from(activity).inflate(R.layout.relative_aritclelist, parent, false);
      holder = initHolder(view);
      holder.position = position;
      view.setTag(holder);
      viewCache.put(position, new SoftReference<View>(view));
    }
    if (!PhoneConfiguration.getInstance().showReplyButton) {
      holder.viewBtn.setVisibility(View.GONE);
    } else {
      MyListenerForReply myListenerForReply = new MyListenerForReply(position, data, activity);
      holder.viewBtn.setOnClickListener(myListenerForReply);
    }
    ThemeManager theme = ThemeManager.getInstance();
    int colorId = theme.getBackgroundColor(position);
    view.setBackgroundResource(colorId);

    // colorId = theme.getBackgroundColor(2);

    if (row == null) {
      return view;
    }

    handleAvatar(holder.avatarIV, row);

    int fgColorId = ThemeManager.getInstance().getForegroundColor();
    final int fgColor = parent.getContext().getResources().getColor(fgColorId);

    FunctionUtil.handleNickName(row, fgColor, holder.nickNameTV, activity);

    final int bgColor = parent.getContext().getResources().getColor(colorId);

    final WebView contentTV = holder.contentTV;

    final String floor = String.valueOf(lou);
    TextView floorTV = holder.floorTV;
    floorTV.setText("[" + floor + " 楼]");
    floorTV.setTextColor(fgColor);

    if (!StringUtil.isEmpty(row.getFromClientModel())) {
      MyListenerForClient myListenerForClient =
          new MyListenerForClient(position, data, activity, parent);
      String from_client_model = row.getFromClientModel();
      if (from_client_model.equals("ios")) {
        holder.clientBtn.setImageResource(R.drawable.ios); // IOS
      } else if (from_client_model.equals("wp")) {
        holder.clientBtn.setImageResource(R.drawable.wp); // WP
      } else if (from_client_model.equals("unknown")) {
        holder.clientBtn.setImageResource(R.drawable.unkonwn); // 未知orBB
      }
      holder.clientBtn.setVisibility(View.VISIBLE);
      holder.clientBtn.setOnClickListener(myListenerForClient);
    }
    if (ActivityUtil.isLessThan_4_3()) {
      new Thread(
              new Runnable() {
                public void run() {
                  FunctionUtil.handleContentTV(
                      contentTV, row, bgColor, fgColor, activity, null, client);
                }
              })
          .start();
    } else if (ActivityUtil.isLessThan_4_4()) {
      ((Activity) parent.getContext())
          .runOnUiThread(
              new Runnable() {
                public void run() {
                  FunctionUtil.handleContentTV(
                      contentTV, row, bgColor, fgColor, activity, null, client);
                }
              });
    } else {
      FunctionUtil.handleContentTV(contentTV, row, bgColor, fgColor, activity, null, client);
    }
    TextView postTimeTV = holder.postTimeTV;
    postTimeTV.setText(row.getPostdate());
    postTimeTV.setTextColor(fgColor);
    if (needin) {
      view.invalidate();
    }
    return view;
  }