Android Open Source - SalesOrder Page1 List Adapter






From Project

Back to project page SalesOrder.

License

The source code is released under:

GNU General Public License

If you think the Android project SalesOrder 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.capgemini.SalesOrder;
/*from   w w  w  .  java 2  s. c  om*/

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.BusinessPartner;

/**
 * List adapter.
 */
public class Page1ListAdapter extends BaseAdapter
{  
  private List<BusinessPartner> entries;
  private List<BusinessPartner> filteredEntries;

  private Context mContext;

  /**
   * Constructs a new list adapter with the given context.
   * @param c - application context.
   */
  public Page1ListAdapter(Context c)
  {
    mContext = c;
  }

  /**
   * Returns the list of entries.
   * @return - list of entries.
   */
  public List<BusinessPartner> getEntries()
  {
    return entries;
  }

  /**
   * Sets the given entries.
   * @param entries
   */
  public void setEntries(List<BusinessPartner> entries)
  {
    this.entries = entries;
    this.filteredEntries = entries;
  }

  /**
   * Returns the number of entries.
   * @return - the number of entries.
   */
  public int getCount()
  {
    return filteredEntries.size();
  }

  /**
   * Returns the item in the given position.
   * @param position - the position of the desired item.
   * @return - the item in the given position.
   */
  public Object getItem(int position)
  {
    return filteredEntries.get(position);
  }

  /**
   * Returns the id of the item in the given position.
   * @param position - the position of the item.
   * @return - the id of the item in the given position.
   */
  public long getItemId(int position)
  {
    return position;
  }
  
  private static class ViewHolder 
  {
    public LinearLayout ll;
  }
  
  public View getView(int position, View convertView, ViewGroup parent)
  {
    View rowView = convertView;
    
    if (rowView == null) 
    {
      LayoutInflater mInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      // Inflate a view template
      rowView = mInflater.inflate(com.capgemini.SalesOrder.R.layout.item_entry, parent, false);
      
      ViewHolder holder = new ViewHolder();
      holder.ll = (LinearLayout) rowView.findViewById(com.capgemini.SalesOrder.R.id.linearLayout1);
      holder.ll.setPadding(10, 10, 10, 10);
      holder.ll.setOrientation(LinearLayout.VERTICAL);
      
      rowView.setTag(holder);
    }

    ViewHolder holder = (ViewHolder) rowView.getTag();
    holder.ll.removeAllViews();
    
    BusinessPartner entry = filteredEntries.get(position);
    
    TextView CompanyNameTextView = new TextView(mContext);
    //set the first property to bigger font
    CompanyNameTextView.setTextSize(22);
    CompanyNameTextView.setText(getPropertyValue(String.valueOf(entry.getCompanyName())));
    holder.ll.addView(CompanyNameTextView);  
    
    TextView BusinessPartnerIDTextView = new TextView(mContext); 
    BusinessPartnerIDTextView.setText(getPropertyValue(String.valueOf(entry.getBusinessPartnerID())));
    holder.ll.addView(BusinessPartnerIDTextView);  
    
    return rowView;
  }
  
  /**
   * Returns the property value.
   * @param value
   * @return - property value.
   */
  public String getPropertyValue(String value)
  {
    if (value.equalsIgnoreCase("null"))
    {
      return mContext.getString(com.capgemini.SalesOrder.R.string.no_value);
    }

    return value;
  }

  /**
   * Filters the items by the given constraint.
   * @param constraint
   */
  public void filter(CharSequence constraint)
  {
    if (constraint != null)
    {
      constraint = constraint.toString().toLowerCase();
      this.filteredEntries = new ArrayList<BusinessPartner>();
      for (BusinessPartner entry : entries)
      {
        ArrayList<String> values = new ArrayList<String>();

        values.add(String.valueOf(entry.getBusinessPartnerID()).toLowerCase());
        values.add(String.valueOf(entry.getCompanyName()).toLowerCase());
        boolean found = false;
        for (String s : values)
        {
          if (s != null && s.contains(constraint))
          {
            found = true;
            break;
          }
        }
        
        if(found)
          filteredEntries.add(entry);
      }
    } 
    else
    {
      this.filteredEntries = entries;
    }
    
    notifyDataSetChanged();
  }
}




Java Source Code List

com.capgemini.SalesOrder.LoginActivity.java
com.capgemini.SalesOrder.Page1ListActivity.java
com.capgemini.SalesOrder.Page1ListAdapter.java
com.capgemini.SalesOrder.Page2ListActivity.java
com.capgemini.SalesOrder.Page2ListAdapter.java
com.capgemini.SalesOrder.Page3ListActivity.java
com.capgemini.SalesOrder.Page3ListAdapter.java
com.capgemini.SalesOrder.Page4DetailsActivity.java
com.capgemini.SalesOrder.Page4DetailsAdapter.java
com.capgemini.SalesOrder.Page5DetailsActivity.java
com.capgemini.SalesOrder.Page5DetailsAdapter.java
com.capgemini.SalesOrder.Page6DetailsActivity.java
com.capgemini.SalesOrder.Page6DetailsAdapter.java
com.capgemini.SalesOrder.SplashScreen.java
com.capgemini.SalesOrder.preferences.GatewaySettingsPreferencesActivity.java
com.capgemini.SalesOrder.preferences.MainPreferencesActivity.java
com.capgemini.SalesOrder.preferences.PreferencesUtilities.java
com.capgemini.SalesOrder.preferences.SUPSettingsPreferencesActivity.java
com.capgemini.SalesOrder.zgwsample_srv.ServiceVersionConfigurations.java
com.capgemini.SalesOrder.zgwsample_srv.v0.ZGWSAMPLE_SRVRequestHandler.java
com.capgemini.SalesOrder.zgwsample_srv.v0.ZGWSAMPLE_SRVService.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.BusinessPartner.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.Contact.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.Product.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.SalesOrderLineItem.java
com.capgemini.SalesOrder.zgwsample_srv.v0.entitytypes.SalesOrder.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.IZGWSAMPLE_SRVRequestHandlerListener.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.ListenerWrapper.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.ZGWSAMPLE_SRVLoginAsyncTask.java
com.capgemini.SalesOrder.zgwsample_srv.v0.helpers.ZGWSAMPLE_SRVRequestID.java