Esempio n. 1
0
    @Override
    public void onPostExecute(Roll roll) {
      if (isCancelled()) return;

      // last check - if the database is closed, then onDestroy must have run,
      // even if the task didn't get marked as cancelled for some reason
      if (context.database.closed) return;

      if (exception != null && roll == null) context.onLoadRoll(tag, exception);
      else context.onLoadRoll(tag, roll);
    }
Esempio n. 2
0
 public VoterAdapter(RollInfo context, List<Vote> starred2, boolean starred) {
   super(context, 0, starred2);
   this.context = context;
   this.resources = context.getResources();
   this.inflater = LayoutInflater.from(context);
   this.starred = starred;
 }
Esempio n. 3
0
 public VoterAdapter(RollInfo context, List<Vote> rest) {
   super(context, 0, rest);
   this.context = context;
   this.resources = context.getResources();
   this.inflater = LayoutInflater.from(context);
   this.starred = false;
 }
Esempio n. 4
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;
    }