Android Open Source - App-Growth-Engine-Android-TabUI Friends Adapter






From Project

Back to project page App-Growth-Engine-Android-TabUI.

License

The source code is released under:

Apache License

If you think the Android project App-Growth-Engine-Android-TabUI 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.hookmobile.tabui;
/*  ww  w. jav a  2 s.  c o  m*/
import static com.hookmobile.tabui.TabUIUtils.getResourceId;

import java.util.List;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

class FriendsAdapter extends BaseAdapter {
  
  private Activity context;
  private TabUI tabui;
  private List<PhoneBookContact> friends;

  
  public FriendsAdapter(Activity context, TabUI tabui, List<PhoneBookContact> friends) {
    this.context = context;
    this.tabui = tabui;
    this.friends = friends;
  }
  
  public View getView(final int position, View view, ViewGroup parent) {
    if (view == null) {
      LayoutInflater inflator = context.getLayoutInflater();
      view = inflator.inflate(getResourceId(context, "tabui_mutualcontactitem", "layout"), null);
    }

    final ViewHolder viewHolder = new ViewHolder();
    viewHolder.text = (TextView) view.findViewById(getResourceId(context, "contactname", "id"));
    viewHolder.check = (ImageView) view.findViewById(getResourceId(context, "contactcheck", "id"));

    view.setOnClickListener(new OnClickListener() {
      public void onClick(View v) {
        if (tabui.isPlayButtonVisible()) {
          PhoneBookContact element = friends.get(position);
          
          if (element.isInvited()) {
            element.setInvited(false);
            viewHolder.check.setVisibility(View.INVISIBLE);
          } else {
            element.setInvited(true);
            viewHolder.check.setVisibility(View.VISIBLE);
          }
          
          notifyDataSetChanged();
        }
      }
    });

    viewHolder.text.setText(friends.get(position).getName());

    if (friends.get(position).isInvited())
      viewHolder.check.setVisibility(View.VISIBLE);
    else
      viewHolder.check.setVisibility(View.INVISIBLE);
    
    return view;
  }
  
  public int getCount() {
    return friends.size();
  }
  
  public Object getItem(int position) {
    return friends.get(position);
  }
  
  public long getItemId(int position) {
    return position;
  }
  
  public List<PhoneBookContact> getFriends() {
    return friends;
  }

  public void setFriends(List<PhoneBookContact> friends) {
    this.friends = friends;
  }
  
  private class ViewHolder {
    private TextView text;
    private ImageView check;
  }
  
}




Java Source Code List

com.hookmobile.tabui.FriendsAdapter.java
com.hookmobile.tabui.PhoneBookContact.java
com.hookmobile.tabui.PhoneBookContactsActivity.java
com.hookmobile.tabui.PhoneBookContactsAdapter.java
com.hookmobile.tabui.Playable.java
com.hookmobile.tabui.RecommendedContact.java
com.hookmobile.tabui.RecommendedContactsAdapter.java
com.hookmobile.tabui.SmsType.java
com.hookmobile.tabui.TabUIConstants.java
com.hookmobile.tabui.TabUIUtils.java
com.hookmobile.tabui.TabUI.java
com.hookmobile.tabui.sample.MainActivity.java
com.hookmobile.tabui.sample.SplashScreenActivity.java