Android Open Source - imslpdroid Score Adapter






From Project

Back to project page imslpdroid.

License

The source code is released under:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, includin...

If you think the Android project imslpdroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.imslpdroid.gui;
//from   w w w.jav a2  s  .  c  om
import java.util.List;

import org.jsoup.Jsoup;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.imslpdroid.R;
import com.imslpdroid.data.Score;

public class ScoreAdapter extends ArrayAdapter<Score> {

  private List<Score> items;

  public ScoreAdapter(Context context, int textViewResourceId,
      List<Score> items) {
    super(context, textViewResourceId, items);
    this.items = items;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;

    if (v == null) {
      LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
          Context.LAYOUT_INFLATER_SERVICE);
      v = vi.inflate(R.layout.row, null);
    }
    
    Score o = items.get(position);
    if (o != null) {
      TextView upText = (TextView) v.findViewById(R.id.toptext);
      TextView bottomText = (TextView) v.findViewById(R.id.bottomtext);
      ImageView iconSx = (ImageView) v.findViewById(R.id.score_listitem_icon);
      if (o.isSeparator()) {
        String tab = "";
        for(int i = 3; i < o.getSeparatorLevel(); i++)
          tab += "&nbsp;";
        upText.setText(Html.fromHtml(String.format("<h"+o.getSeparatorLevel()+">%s</h"+o.getSeparatorLevel()+"> ", tab + o.getAuthor().trim())));
        bottomText.setText("");
        iconSx.setVisibility(View.GONE);        
        bottomText.setVisibility(View.GONE);
        
      } else {
        upText.setText(Html.fromHtml(String.format(
            "<h3>%s</h3> - <i>%s<i>", o.getTitle().trim(), o
                .getPagesAndCo())));
        bottomText.setText(Jsoup.parse(o.getPublisherInfo()).text());
        if (o.isBlocked())
          iconSx.setImageResource(R.drawable.score_blocked);
        else if (o.isDownloaded())
          iconSx.setImageResource(R.drawable.score_downloaded);
        else
          iconSx.setImageResource(R.drawable.score_downloadable);
        
        iconSx.setVisibility(View.VISIBLE);
        bottomText.setVisibility(View.VISIBLE);
//        v.setBackgroundDrawable(null);
      }
    }

    return v;
  }
}




Java Source Code List

com.imslpdroid.AboutAppActivity.java
com.imslpdroid.ComposersActivity.java
com.imslpdroid.DownloadedActivity.java
com.imslpdroid.ImslpdroidActivity.java
com.imslpdroid.InstrumentationActivity.java
com.imslpdroid.NationalityActivity.java
com.imslpdroid.PiecesActivity.java
com.imslpdroid.RestrictedComposersActivity.java
com.imslpdroid.ScoreDownloadActivity.java
com.imslpdroid.ScoresActivity.java
com.imslpdroid.TimePeriodActivity.java
com.imslpdroid.WorkTypesActivity.java
com.imslpdroid.data.DataStorageHelper.java
com.imslpdroid.data.DataStorage.java
com.imslpdroid.data.ExternalStorageUnavailableException.java
com.imslpdroid.data.Score.java
com.imslpdroid.gui.IntentUtils.java
com.imslpdroid.gui.RestrictableListView.java
com.imslpdroid.gui.ScoreAdapter.java
com.imslpdroid.gui.StorableRestrictableListView.java