Android Open Source - Amppercent7 Adapter Elems






From Project

Back to project page Amppercent7.

License

The source code is released under:

GNU General Public License

If you think the Android project Amppercent7 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 my.amppercent.adapters;
//from  ww w  . ja  va 2  s.c om
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

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

/**
 * Estensione dell'Array Adapter, allo scopo di puntualizzare l'inserimento e la
 * cancellazione degli elementi
 * 
 * @author jack
 * 
 * @param <T>
 */
public class AdapterElems<T> extends ArrayAdapter<T> {

  private int resource;
  private Context context;
  private List<T> list;

  /**
   * Restituisce la lista interna di tutti gli elementi contenuti all'interno
   * della lista formatasi
   * 
   * @return
   */
  public List<T> getList() {
    return this.list;
  }

  /**
   * 
   * @param context
   *            Contesto di visualizzatore della lista
   * @param resource
   *            Risorsa Layout associata alla visualizzazione di un singolo
   *            elemento.
   * @param textViewResourceId
   *            (Mantenuta per compatibilit con Android)
   * @param objects
   *            Lista di lementi che si vuole associare
   */
  public AdapterElems(Context context, int resource, int textViewResourceId,
      List<T> objects) {
    super(context, resource, textViewResourceId, objects);
    this.resource = resource;
    this.context = context;

    if (objects != null) {
      this.list = new LinkedList<T>();
      for (T x : objects)
        this.list.add(x);
    } else
      objects = null;
  }

  /**
   * La particolarit di questo metodo  quella di trasformare l'array passato
   * in lista, di modo da rendere sempre modificabili gli elementi contenuti
   * 
   * @param context
   * @param resource
   * @param textViewResourceId
   * @param objects
   */
  public AdapterElems(Context context, int resource, int textViewResourceId,
      T[] objects) {
    super(context, resource, textViewResourceId, objects);
    this.resource = resource;
    this.context = context;
    this.list = new LinkedList<T>();
    if (objects != null)
      for (T x : objects) {
        this.list.add(x);
      }
  }

  /**
   * Questa funzione effettua l'override della preesistente lato Android.
   * Tuttavia le sottoclassi dovranno ora richiamare sempre questa funzione.
   */
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater li = (LayoutInflater) this.context
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    convertView = li.inflate(this.resource, null);
    return convertView;
  }

  @Override
  public void addAll(T... ls) {
    super.addAll(ls);
    for (T x : ls) {
      this.list.add(x);
    }

  }

  @Override
  public void addAll(Collection<? extends T> ls) {
    super.addAll(ls);
    this.list.addAll(ls);

  }

  @Override
  public void add(T x) {
    super.add(x);
    this.list.add(x);
  }

  @Override
  public void remove(T x) {
    super.remove(x);
    this.list.remove(x);
  }

}




Java Source Code List

my.amppercent.adapters.AdapterChat.java
my.amppercent.adapters.AdapterElems.java
my.amppercent.adapters.AdapterIM.java
my.amppercent.adapters.AdapterUStatus.java
my.amppercent.adapters.ListViewAdapting.java
my.amppercent.adapters.ListView_XUser.java
my.amppercent.chatrequest.AvailabilitySettings.java
my.amppercent.chatrequest.SelectConnActivity.java
my.amppercent.chatrequest.connActivity.java
my.amppercent.chatrequest.serverActivity.java
my.amppercent.chattables.UberChat.java
my.amppercent.chattables.XConnect.java
my.amppercent.chattables.XRoster.java
my.amppercent.chattables.myChat.java
my.amppercent.project.Amppercent4Activity.java
my.amppercent.project.DownloadManager.java
my.amppercent.project.IBindRemoteService.java
my.amppercent.project.LaunchMe.java
my.amppercent.project.PrefActive.java
my.amppercent.project.TabFragment.java
my.amppercent.project.TextEntryActivity.java
my.amppercent.remoteservice.IFMessage.java
my.amppercent.remoteservice.IntentManage.java
my.amppercent.remoteservice.XUser.java
my.amppercent.remoteservice.chatAdapter.java
my.amppercent.types.Couple.java
my.amppercent.types.State.java
my.amppercent.types.myATask.java
my.amppercent.types.myNotification.java
my.amppercent.types.myYesNoDialog.java
my.amppercent.types.newActivity.java
org.jivesoftware.smackx.filetransfer.myOutgoingFileTransfer.java