Android Open Source - list-a-porter List Adaprter Like G P






From Project

Back to project page list-a-porter.

License

The source code is released under:

Apache License

If you think the Android project list-a-porter 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.android.angelo.widget;
/*from  ww  w.  j a  va2s.  c  om*/
import java.util.ArrayList;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.android.angelo.listaporter.R;
import com.android.angelo.usedobject.ListItem;


public class ListAdaprterLikeGP extends BaseAdapter{

  private class ViewHolder{
    public TextView nome;
    public TextView desc;
    public TextView data;
    public TextView bigD;
  }
  
  boolean orientation ; //true landscape, false portrait
  ArrayList<ListItem> data;
  Context mContext;
  LayoutInflater mLayoutInflater;
  ViewHolder mViewHolder;
  
  int mLastPosition = -1;
  
  public ListAdaprterLikeGP(Context context, ArrayList<ListItem> data) {
    this.data = data;
    this.mContext = context;
    this.mLayoutInflater = (LayoutInflater) 
        this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.orientation = false;
  }
  
  public ListAdaprterLikeGP(Context context, ArrayList<ListItem> data,boolean orientation) {
    this.data = data;
    this.mContext = context;
    this.mLayoutInflater = (LayoutInflater) 
        this.mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    this.orientation = orientation;
  }

  @Override
  public int getCount() {
    return data.size();
  }

  @Override
  public Object getItem(int position) {
    return data.get(position);
  }

  @Override
  public long getItemId(int position) {
    return position;
  }

  @Override
  public View getView(int position, View view, ViewGroup parent) {
    SharedPreferences pr = PreferenceManager.getDefaultSharedPreferences(mContext);
    mViewHolder = null;
    if(view == null){
      view = mLayoutInflater.inflate(R.layout.list_item_layout, null);
      mViewHolder = new ViewHolder();
      mViewHolder.nome = (TextView) view.findViewById(R.id.textView_Nome);
      mViewHolder.desc = (TextView) view.findViewById(R.id.textView_Desc);
      mViewHolder.data = (TextView) view.findViewById(R.id.textView_Data);
      mViewHolder.bigD = (TextView) view.findViewById(R.id.textView_BigD);
      view.setTag(mViewHolder);
    }else{
      mViewHolder = (ViewHolder) view.getTag();
    }
    final ListItem item = (ListItem) data.get(position);
    mViewHolder.nome.setText(item.getmName(orientation));
    String color ;
    if(pr.getString("colors","1").equals("2")){
      color="#000066";
    }else if(pr.getString("colors","1").equals("3")){
      color="#FF0000";
    }else{
      color="#000000";
    }
    mViewHolder.nome.setTextColor(Color.parseColor(color));
    mViewHolder.desc.setText(item.getmDesc(orientation));
    if(pr.getString("formatdata", "2").equals("1")){
      item.setDateFormat(1);
    }else{
      item.setDateFormat(2);
    }
    mViewHolder.data.setText(item.getmDataString());
    if(pr.getBoolean("showBig", true)==true) mViewHolder.bigD.setText(item.getmValueString());
    
     // animate the item
        TranslateAnimation animation = null;
        if (position > mLastPosition) {
            animation = new TranslateAnimation(
                Animation.RELATIVE_TO_SELF,
                0.0f, Animation.RELATIVE_TO_SELF, 0.0f,
                Animation.RELATIVE_TO_SELF, 1.0f,
                Animation.RELATIVE_TO_SELF, 0.0f);

            animation.setDuration(600);
            view.startAnimation(animation);
            mLastPosition = position;
        }
    return view;
  }
  
  public void add(Object ob){
    data.add((ListItem)ob);
  }
  
  public void remove(Object ob){
    data.remove(ob);
  }

}




Java Source Code List

com.android.angelo.listaporter.ListAdapter.java
com.android.angelo.listaporter.MainActivity.java
com.android.angelo.listaporter.NotificationService.java
com.android.angelo.listaporter.SettingsActivity.java
com.android.angelo.listaporter.SettingsFragment.java
com.android.angelo.listaporter.ShowItemActivity.java
com.android.angelo.listaporter.ShowItemFragment.java
com.android.angelo.usedobject.DrawerListener.java
com.android.angelo.usedobject.ListItem.java
com.android.angelo.usedobject.UndoBarController.java
com.android.angelo.widget.ListAdaprterLikeGP.java
com.android.angelo.widget.ListAdapter.java