android-ibc-forum

Unnamed repository; edit this file 'description' to name the repository.
git clone http://git.code.weiherhei.de/android-ibc-forum.git
Log | Files | Refs

ExpandableForumContentAdapter.java (2976B)


      1 /**
      2  * 
      3  */
      4 package de.mtbnews.android.adapter;
      5 
      6 import java.util.List;
      7 
      8 import android.content.Context;
      9 import android.view.Gravity;
     10 import android.view.LayoutInflater;
     11 import android.view.View;
     12 import android.view.ViewGroup;
     13 import android.widget.BaseExpandableListAdapter;
     14 import android.widget.TextView;
     15 import de.mtbnews.android.R;
     16 import de.mtbnews.android.tapatalk.wrapper.Forum;
     17 
     18 /**
     19  * @author dankert
     20  * 
     21  */
     22 public class ExpandableForumContentAdapter extends BaseExpandableListAdapter
     23 {
     24 
     25 	/**
     26 	 * Hold onto a copy of the entire Contact List.
     27 	 */
     28 
     29 	private LayoutInflater inflator;
     30 	private List<Forum> forumList;
     31 
     32 	public ExpandableForumContentAdapter(Context context, List<Forum> forumList)
     33 	{
     34 		inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     35 
     36 		this.forumList = forumList;
     37 	}
     38 
     39 	@Override
     40 	public Object getChild(int arg0, int arg1)
     41 	{
     42 		Forum e = forumList.get(arg0).subForen.get(arg1);
     43 		return e;
     44 	}
     45 
     46 	@Override
     47 	public long getChildId(int groupPosition, int childPosition)
     48 	{
     49 		return childPosition;
     50 	}
     51 
     52 	@Override
     53 	public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
     54 			ViewGroup parent)
     55 	{
     56 		Forum e = forumList.get(groupPosition).subForen.get(childPosition);
     57 
     58 		final View itemView = inflator.inflate(R.layout.rss_item, null);
     59 
     60 		TextView datum = (TextView) itemView.findViewById(R.id.item_date);
     61 		datum.setVisibility(View.INVISIBLE);
     62 
     63 		TextView name = (TextView) itemView.findViewById(R.id.item_title);
     64 		name.setText(e.getTitle());
     65 
     66 		TextView desc = (TextView) itemView.findViewById(R.id.item_description);
     67 
     68 		desc.setText(e.getContent());
     69 
     70 		return itemView;
     71 	}
     72 
     73 	@Override
     74 	public int getChildrenCount(int groupPosition)
     75 	{
     76 		return forumList.get(groupPosition).subForen.size();
     77 	}
     78 
     79 	@Override
     80 	public Object getGroup(int groupPosition)
     81 	{
     82 		return forumList.get(groupPosition);
     83 	}
     84 
     85 	@Override
     86 	public int getGroupCount()
     87 	{
     88 		return forumList.size();
     89 	}
     90 
     91 	@Override
     92 	public long getGroupId(int groupPosition)
     93 	{
     94 		return groupPosition;
     95 	}
     96 
     97 	@Override
     98 	public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
     99 	{
    100 		final Forum forum = forumList.get(groupPosition);
    101 
    102 		final View itemView = inflator.inflate(R.layout.rss_item, null);
    103 
    104 		TextView datum = (TextView) itemView.findViewById(R.id.item_date);
    105 		datum.setText("");
    106 
    107 		TextView name = (TextView) itemView.findViewById(R.id.item_name);
    108 		name.setText("");
    109 
    110 		TextView title = (TextView) itemView.findViewById(R.id.item_title);
    111 		title.setGravity(Gravity.CENTER);
    112 		title.setText(forum.getTitle());
    113 
    114 		TextView desc = (TextView) itemView.findViewById(R.id.item_description);
    115 		desc.setText("");
    116 
    117 		return itemView;
    118 	}
    119 
    120 	@Override
    121 	public boolean hasStableIds()
    122 	{
    123 		return true;
    124 	}
    125 
    126 	@Override
    127 	public boolean isChildSelectable(int groupPosition, int childPosition)
    128 	{
    129 		return true;
    130 	}
    131 
    132 	@Override
    133 	public boolean areAllItemsEnabled()
    134 	{
    135 		return true;
    136 	}
    137 
    138 }