Android Open Source - socialcde4android Users Adapter






From Project

Back to project page socialcde4android.

License

The source code is released under:

MIT License

If you think the Android project socialcde4android 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 it.uniba.socialcde4android.adapters;
/*  www  .jav  a 2s.  com*/
import java.util.ArrayList;

import android.content.Context;
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 it.uniba.socialcde4android.R;
import it.uniba.socialcde4android.shared.library.WUser;

import com.nostra13.universalimageloader.core.ImageLoader;

public class UsersAdapter extends ArrayAdapter<WUser>{


  private final int TYPE_MAX_COUNT = 6;
  private final int TYPE_USER = 0;
  private final int TYPE_TITLE_SUGG = 1;
  private final int TYPE_TITLE_FLLING = 4;
  private final int TYPE_TITLE_FLLERS = 5;
  private final int TYPE_TITLE_HIDDEN = 3;
  private final int TYPE_NOUSER = 2;
  private LayoutInflater infalInflater;
  private int length_suggested = 0;
  private int length_following = 0;
  private int length_followers = 0;
  private int length_hidden = 0;
  private ArrayList<Integer> type_list = null;
  //private int add_positions = 0;
  private Boolean[] added = new Boolean[5];

  private ImageLoader imageloader;




  public UsersAdapter(Context context, int resource,ArrayList<WUser> allwusers,  int[] wUsersNumType_SuggFingFersHidd ) {
    super(context, resource, allwusers);

    for (int j=0;j<added.length;j++){
      added[j]=false;
    }
    //  this.context = context;
    if (wUsersNumType_SuggFingFersHidd.length != 0){
    length_suggested = wUsersNumType_SuggFingFersHidd[0];
    length_following = wUsersNumType_SuggFingFersHidd[1];
    length_followers = wUsersNumType_SuggFingFersHidd[2];
    length_hidden = wUsersNumType_SuggFingFersHidd[3];
    }
    //posso creare un array per memorizare i tipi
    type_list = new ArrayList<Integer>();
    type_list.add(this.TYPE_TITLE_SUGG);
    if (length_suggested == 0)   type_list.add(this.TYPE_NOUSER);
    else {
      for (int i=0; i < length_suggested;i++){
        type_list.add(this.TYPE_USER);
      }
    }
    type_list.add(this.TYPE_TITLE_FLLING);
    if (length_following == 0)   type_list.add(this.TYPE_NOUSER);
    else {
      for (int i=0; i < length_following;i++){
        type_list.add(this.TYPE_USER);
      }
    }
    type_list.add(this.TYPE_TITLE_FLLERS);
    if (length_followers == 0)   type_list.add(this.TYPE_NOUSER);
    else {
      for (int i=0; i < length_followers;i++){
        type_list.add(this.TYPE_USER);
      }
    }
    type_list.add(this.TYPE_TITLE_HIDDEN);
    if (length_hidden == 0)   type_list.add(this.TYPE_NOUSER);
    else {
      for (int i=0; i < length_hidden;i++){
        type_list.add(this.TYPE_USER);
      }
    }

    infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageloader = ConfiguratedImageLoader.getImageLoader(context);


  }

  public int getUserTypeID(){
    return this.TYPE_USER;
  }

  @Override
  public int getViewTypeCount() {
    return TYPE_MAX_COUNT;
  }
  
  
  public int getArrayPosition(int position){
    int pos=position;
    for (int j=0;j<position;j++){
      if (!type_list.get(j).equals(this.TYPE_USER)){
        pos--;
      }
    }
    return pos;
  }
  
  
  @Override
  public int getItemViewType(int position) {

    return type_list.get(position);
  }

  public int getCount() {
    return type_list.size();
  }


  @Override
  public View getView(int position, View rowView, ViewGroup parent) 
  {
    ViewHolder view = null;
    int type = getItemViewType(position);

    switch (type) {

    case TYPE_TITLE_SUGG:
      rowView = infalInflater.inflate(R.layout.drawer_services_title, null);
      TextView title = (TextView) rowView.findViewById(R.id.textViewdrawerTileServices);
      title.setText("Suggestions");
      break;
    case TYPE_TITLE_FLLING:    
      rowView = infalInflater.inflate(R.layout.drawer_services_title, null);
      TextView title_fing = (TextView) rowView.findViewById(R.id.textViewdrawerTileServices);
      title_fing.setText("Followings");
      break;
    case TYPE_TITLE_FLLERS:    
      rowView = infalInflater.inflate(R.layout.drawer_services_title, null);
      TextView title_fillers = (TextView) rowView.findViewById(R.id.textViewdrawerTileServices);
      title_fillers.setText("Followers");
      break;
    case TYPE_TITLE_HIDDEN:    
      rowView = infalInflater.inflate(R.layout.drawer_services_title, null);
      TextView title_hidden = (TextView) rowView.findViewById(R.id.textViewdrawerTileServices);
      title_hidden.setText("Hidden");
      break;

    case TYPE_NOUSER:    
      rowView = infalInflater.inflate(R.layout.drawer_no_users_item, null);
      break;

    case TYPE_USER:  

      if (rowView == null)  {
        view = new ViewHolder();
        rowView = infalInflater.inflate(R.layout.drawer_user_tem,parent, false);
        view.textViewUser = (TextView) rowView.findViewById(R.id.textViewdrawerUSER);
        view.imageviewUser = (ImageView) rowView.findViewById(R.id.imageViewdrawerUSER); 
        rowView.setTag(view);
      }else {
        view = (ViewHolder) rowView.getTag();
      }
      
      WUser wuser = (WUser) UsersAdapter.this.getItem(getArrayPosition(position));
      view.textViewUser.setText(wuser.getUsername());
      String avatar_address = wuser.getAvatar();
      if (avatar_address != null){
        imageloader.displayImage(avatar_address, view.imageviewUser);
      }

      break;

    }


    return rowView;
  }

  protected static class ViewHolder{
    protected TextView textViewUser;
    protected ImageView imageviewUser;
  }
}




Java Source Code List

it.uniba.socialcde4android.activity.HomeActivity.java
it.uniba.socialcde4android.activity.LoginActivity.java
it.uniba.socialcde4android.activity.RegistrationActivity.java
it.uniba.socialcde4android.activity.WebViewActivity.java
it.uniba.socialcde4android.adapters.ConfiguratedImageLoader.java
it.uniba.socialcde4android.adapters.FeaturesAdapter.java
it.uniba.socialcde4android.adapters.ServicesAdapter.java
it.uniba.socialcde4android.adapters.SquareImageView.java
it.uniba.socialcde4android.adapters.TimeLineAdapter.java
it.uniba.socialcde4android.adapters.UserAvatarsAdapter.java
it.uniba.socialcde4android.adapters.UsersAdapter.java
it.uniba.socialcde4android.config.Config.java
it.uniba.socialcde4android.costants.Consts.java
it.uniba.socialcde4android.costants.Error_consts.java
it.uniba.socialcde4android.costants.Services_id.java
it.uniba.socialcde4android.data.operation.Authorize_Operation.java
it.uniba.socialcde4android.data.operation.ChangePasswordWithPassword_Operation.java
it.uniba.socialcde4android.data.operation.GetAvailableAvatars_Operation.java
it.uniba.socialcde4android.data.operation.GetColleagueProfile_Operation.java
it.uniba.socialcde4android.data.operation.GetFeatures_Operation.java
it.uniba.socialcde4android.data.operation.GetFriends_Operation.java
it.uniba.socialcde4android.data.operation.GetHideSettings_Operation.java
it.uniba.socialcde4android.data.operation.GetOAuthData_Operation.java
it.uniba.socialcde4android.data.operation.GetUser_Operation.java
it.uniba.socialcde4android.data.operation.IsUsernameAvailable_Operation.java
it.uniba.socialcde4android.data.operation.IsWebServiceRunning_Operation.java
it.uniba.socialcde4android.data.operation.RecordService_Operation.java
it.uniba.socialcde4android.data.operation.RetrieveServices_Operation.java
it.uniba.socialcde4android.data.operation.SendTFSpost_Operation.java
it.uniba.socialcde4android.data.operation.SetActiveFeatures_Operation.java
it.uniba.socialcde4android.data.operation.SetAvatar_Operation.java
it.uniba.socialcde4android.data.operation.SetFollowed_Operation.java
it.uniba.socialcde4android.data.operation.SetHideSettings_Operation.java
it.uniba.socialcde4android.data.operation.SubscribeUser_Operation.java
it.uniba.socialcde4android.data.operation.UnregisterService_Operation.java
it.uniba.socialcde4android.data.requestmanager.SocialCDERequestFactory.java
it.uniba.socialcde4android.data.requestmanager.SocialCDERequestManager.java
it.uniba.socialcde4android.data.service.SocialCDERequestService.java
it.uniba.socialcde4android.dialogs.ChangePasswordDialog.java
it.uniba.socialcde4android.dialogs.ChooseAvatarDialog.java
it.uniba.socialcde4android.dialogs.HideUnhideDialog.java
it.uniba.socialcde4android.dialogs.NoNetworkDialog.java
it.uniba.socialcde4android.dialogs.SetServiceFeaturesDialog.java
it.uniba.socialcde4android.dialogs.TFSAuthDialog.java
it.uniba.socialcde4android.fragments.TimeLine_AbstractFragment.java
it.uniba.socialcde4android.fragments.TimeLine_Fragment.java
it.uniba.socialcde4android.fragments.WUserColleagueProfile_Fragment.java
it.uniba.socialcde4android.fragments.WUserProfile_Fragment.java
it.uniba.socialcde4android.preferences.Preferences.java
it.uniba.socialcde4android.shared.library.JsonDateDeserializer.java
it.uniba.socialcde4android.shared.library.WFeature.java
it.uniba.socialcde4android.shared.library.WHidden.java
it.uniba.socialcde4android.shared.library.WOAuthData.java
it.uniba.socialcde4android.shared.library.WPost.java
it.uniba.socialcde4android.shared.library.WService.java
it.uniba.socialcde4android.shared.library.WUser.java
it.uniba.socialcde4android.utility.ScreenUtility.java