Android Open Source - Amppercent7 Adapter U Status






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  .  j a va2 s  . c o m
import java.util.LinkedList;
import java.util.List;

import my.amppercent.project.R;
import my.amppercent.remoteservice.XUser;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * Array per la visualizzazione degli utenti
 * 
 * @author jack
 * 
 */
public class AdapterUStatus extends AdapterElems<XUser> {

  public List<String> wannachatwith;
  public List<XUser> wantchatxuser;

  /**
   * 
   * @param context
   *            Contesto nel quale effettuare la visualizzazione
   * @param resource
   * @param textViewResourceId
   *            Opzionale
   * @param active
   *            Attitivt nella quale verr effettuata la visualizzazione
   * @param field
   *            Sono i campi nei quali verranno settati i valori: 1) Valore
   *            dello stato 2) Nickname 3) Jid utente
   * @param objects
   */

  public AdapterUStatus(Context context, int resource,
      int textViewResourceId, List<XUser> objects) {
    super(context, resource, textViewResourceId, objects);
    wannachatwith = new LinkedList<String>();
    wantchatxuser = new LinkedList<XUser>();
  }

  public View getView(int position, View convertView, ViewGroup parent) {
    Integer pos = position;
    if (getItem(position) == null) {
      Log.e("error", "nullo @" + pos.toString());
      return null;
    }
    final XUser user = getItem(position);

    View row = super.getView(position, convertView, parent);

    /* 1) Valore dello stato */
    ImageView stato = (ImageView) row.findViewById(R.id.Status);
    if (user.getState() == null)
      stato.setImageResource(android.R.drawable.presence_offline);
    else
      switch (user.getState()) {
      case DoNotDisturb:
        stato.setImageResource(android.R.drawable.presence_busy);
        break;
      case Chat:
        stato.setImageResource(android.R.drawable.presence_online);
        break;
      case Away:
      case ExtendedAway:
        stato.setImageResource(android.R.drawable.presence_away);
        break;
      default:
        stato.setImageResource(android.R.drawable.presence_offline);
      }

    /* 2) Nickname */
    final TextView text = (TextView) row.findViewById(R.id.Nickname);
    text.setText(user.getNickname());

    /* 3) jid */
    final TextView text2 = (TextView) row.findViewById(R.id.user_jid);
    text2.setText(user.getJid());

    /* 4) Button Handler */
    final ImageButton ib = (ImageButton) row.findViewById(R.id.doChat);
    if (wannachatwith.contains(user.getJid()))
      ib.setImageResource(android.R.drawable.ic_menu_add);
    ib.setOnClickListener(new OnClickListener() {

      public void onClick(View v) {
        String jid = text2.getText().toString();
        if (!wannachatwith.contains(jid)) {
          user.selected = true;
          ib.setImageResource(android.R.drawable.ic_menu_add);
          wannachatwith.add(jid);
          wantchatxuser.add(user);
        } else {
          XUser todel = null;
          user.selected = false;
          wannachatwith.remove(jid);
          for (XUser x : wantchatxuser) {
            if (x.getJid().equals(jid)) {
              todel = x;
              break;
            }
          }
          if (todel != null) {
            wannachatwith.remove(todel);
            for (XUser x : wantchatxuser) {
              if (x.getJid().equals(jid)) {
                wantchatxuser.remove(x);
                break;
              }
            }
          }
          ib.setImageResource(android.R.drawable.sym_action_chat);
        }
      }
    });

    return row;
  }

  /**
   * Restituisce la lista di XUser selezionati dall'utente
   * 
   * @return
   */
  public List<XUser> getChatWith() {
    return this.wantchatxuser;
  }

}




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