1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
| package com.expway.android;
import java.util.ArrayList;
import com.expway.android.ISDBT.ISDBT_JNI;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
public class MyCustomBaseAdapter extends BaseAdapter
{
private static ArrayList<FragList> searchArrayList;
ISDBT_JNI jni = null;
public ViewHolder holder = new ViewHolder();
private LayoutInflater mInflater;
public MyCustomBaseAdapter(Context context, ArrayList<FragList> results) {
searchArrayList = results;
mInflater = LayoutInflater.from(context);
}
public int getCount()
{
return searchArrayList.size();
}
public Object getItem(int position)
{
return searchArrayList.get(position);
}
public long getItemId(int position)
{
return position;
}
public View getView(int position, View convertView, ViewGroup parent)
{
//instanciation du JNI
jni = ISDBT_JNI.getInstance();
if (convertView == null)
{
convertView = mInflater.inflate(R.layout.custom_row_view, null);
holder.TxtV_DownloadCrid = (TextView) convertView.findViewById(R.id.crid);
holder.TxtV_DownloadId = (TextView) convertView.findViewById(R.id.id);
holder.TxtV_DownloadPercentage = (TextView)convertView.findViewById(R.id.tel_progres);
holder.TxtV_DownloadState = (TextView)convertView.findViewById(R.id.state);
holder.TxtV_DownloadTime = (TextView)convertView.findViewById(R.id.ValDureeTelech);
holder.Btn_DownloadPause = (Button)convertView.findViewById(R.id.btn_pause_dwl);
holder.Btn_DownloadStart = (Button)convertView.findViewById(R.id.btn_start_dwl);
holder.Btn_DownloadStop = (Button)convertView.findViewById(R.id.btn_stop_dwl);
holder.Pb_Download = (ProgressBar)convertView.findViewById(R.id.pb_id);
//holder.TxtV_DownloadState.setText("voilà");
holder.Btn_DownloadPause.setTag(position);
holder.Btn_DownloadStart.setTag(position);
holder.Btn_DownloadStop.setTag(position);
//holder.txtPhone = (TextView) convertView.findViewById(R.id.phone);
convertView.setTag(holder);
}
else
{
holder = (ViewHolder) convertView.getTag();
}
holder.TxtV_DownloadCrid.setText(searchArrayList.get(position).getId());
holder.TxtV_DownloadId.setText(searchArrayList.get(position).getCrid());
holder.Btn_DownloadPause.setOnClickListener(Download);
holder.Btn_DownloadStart.setOnClickListener(Download);
holder.Btn_DownloadStop.setOnClickListener(Download);
//holder.txtPhone.setText(searchArrayList.get(position).getPhone());
return convertView;
}
OnClickListener Download = new OnClickListener()
{
@Override
public void onClick(View v)
{
//ViewHolder holder = new ViewHolder();
switch(v.getId())
{
case R.id.btn_pause_dwl:
break;
case R.id.btn_start_dwl:
holder.TxtV_DownloadState.setText("voilà");
//holder.TxtV_DownloadState =(TextView) findViewById(R.id.state);
// LinearLayout vwParentRow = (LinearLayout)v.getParent();
//LinearLayout parentLinear = (LinearLayout)vwParentRow.getParent();
//TextView telechargement = (TextView)parentLinear.getChildAt(5);
//telechargement.setText(" c start !! ");
break;
case R.id.btn_stop_dwl:
// LinearLayout vwParent = (LinearLayout)v.getParent();
// LinearLayout parentLine = (LinearLayout)vwParent.getParent();
//TextView telecharge = (TextView)parentLine.getChildAt(5);
//telecharge.setText(" c Stop !! ");
// getv .setText("telechargement");
break;
}
}
};
private class ViewHolder
{
TextView TxtV_DownloadCrid;
TextView TxtV_DownloadId;
TextView TxtV_DownloadPercentage;
TextView TxtV_DownloadState;
TextView TxtV_DownloadTime;
Button Btn_DownloadStart;
Button Btn_DownloadStop;
Button Btn_DownloadPause;
ProgressBar Pb_Download;
}
} |
Partager