Android Open Source - listmyaps App Adapter






From Project

Back to project page listmyaps.

License

The source code is released under:

Apache License

If you think the Android project listmyaps 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 de.onyxbits.listmyapps;
//from   w  w w.j a v  a 2 s .c om
import java.util.List;

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

/**
 * For mapping a SortablePackageInfo into a view.
 * 
 * @author patrick
 * 
 */
public class AppAdapter extends ArrayAdapter<SortablePackageInfo> {

  private int layout;

  public AppAdapter(Context context, int textViewResourceId, List<SortablePackageInfo> spi,
      int layout) {
    super(context, textViewResourceId, spi);
    this.layout = layout;
  }

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View ret = convertView;
    if (ret == null) {
      LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(
          Context.LAYOUT_INFLATER_SERVICE);
      ret = inflater.inflate(layout, null);
      ViewHolder vh = new ViewHolder();
      vh.appName = (TextView) ret.findViewById(R.id.appname);
      vh.appPackage = (TextView) ret.findViewById(R.id.apppackage);
      vh.appIcon = (ImageView) ret.findViewById(R.id.icon);
      vh.comment = (TextView) ret.findViewById(R.id.comments);
      vh.tags = (TextView) ret.findViewById(R.id.tags);
      ret.setTag(vh);
    }
    SortablePackageInfo spi = getItem(position);
    ViewHolder viewHolder = (ViewHolder) ret.getTag();

    viewHolder.appName.setText(spi.displayName);
    viewHolder.appPackage.setText(spi.packageName);
    new IconLoaderTask(getContext().getPackageManager(), viewHolder.appIcon).execute(spi.appInfo);

    switch (layout) {
      case R.layout.app_item: {
        CheckBox sel = ((CheckBox) ret.findViewById(R.id.selected));
        sel.setChecked(spi.selected);
        sel.setOnClickListener(spi);
        break;
      }
      case R.layout.app_item_annotation: {
        String tmp = MainActivity.noNull(spi.tags);
        if (tmp.length() > 0) {
          viewHolder.tags.setText(tmp);
          viewHolder.tags.setVisibility(View.VISIBLE);
        }
        else {
          viewHolder.tags.setVisibility(View.GONE);
        }

        tmp = MainActivity.noNull(spi.comment);
        if (tmp.length() > 0) {
          viewHolder.comment.setText(tmp);
          viewHolder.comment.setVisibility(View.VISIBLE);
        }
        else {
          viewHolder.comment.setVisibility(View.GONE);
        }
      }
    }
    return ret;
  }

}




Java Source Code List

de.onyxbits.listmyapps.AnnotationsActivity.java
de.onyxbits.listmyapps.AnnotationsSource.java
de.onyxbits.listmyapps.AppAdapter.java
de.onyxbits.listmyapps.AppRater.java
de.onyxbits.listmyapps.IconLoaderTask.java
de.onyxbits.listmyapps.ListTask.java
de.onyxbits.listmyapps.MainActivity.java
de.onyxbits.listmyapps.Schema.java
de.onyxbits.listmyapps.SortablePackageInfo.java
de.onyxbits.listmyapps.TagSelectionListener.java
de.onyxbits.listmyapps.TemplateData.java
de.onyxbits.listmyapps.TemplateEditorActivity.java
de.onyxbits.listmyapps.TemplateSource.java
de.onyxbits.listmyapps.TemplatesActivity.java
de.onyxbits.listmyapps.ViewHolder.java