i want to develop one music app that connect to server(include music name , singer name, image ,download URL , preview URL) and show in listview and perform user request for downloading music i provide some code and app connect to server and fetch data topublic class MusicDownloadStructure { volatile public String DownloadStatus; volatile public int Progress; volatile public int Size; volatile String Song_Name; volatile String image_id; volatile String sing_type; volatile String singer_name; volatile private ProgressBar ProgressBarRefrence; volatile private TextView ProgressTextviewRefrence;}
`public class Tab2OnlineStoreViewAdapter extends ArrayAdapter { private final Context context; private Download downloadmanager; Fonts font; MusicDownloadStructure[] ModelDownloadData;
private static class ViewHolder {
public Button Downloadbtn;
public ProgressBar DownloadProgressbar;
public TextView DownloadProgress;
public MusicDownloadStructure data;
}
public Tab2OnlineStoreViewAdapter(Context context2,
MusicDownloadStructure[] modelDownloadData2) {
// TODO Auto-generated constructor stub
super(context2, R.id.listview_tab2, modelDownloadData2);
context = context2;
mplayerforprev = new MediaPlayer();
font = new Fonts(this.context);
tempfolderpath = MainActivity.fileManger.getTempFolderPath();
ModelDownloadData = modelDownloadData2;
}
@Override
public View getView(int position, View view, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder viewHolder = null;
View convertView = view;
// service
final MusicDownloadStructure data = getItem(position);
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.tab2_online_store_row_item,
null, false);
viewHolder = new ViewHolder();
viewHolder.Downloadbtn = (Button) convertView
.findViewById(R.id.tab2_btn_download);
viewHolder.DownloadProgressbar = (ProgressBar) convertView
.findViewById(R.id.tab2_downloadProgressbar);
viewHolder.DownloadProgress = (TextView) convertView
.findViewById(R.id.tab2_downloadProgressText);
viewHolder.data = data;
convertView.setTag(viewHolder);
} else {
viewHolder = (ViewHolder) convertView.getTag();
viewHolder.data.setProgressBarRefrence(null);
viewHolder.data.setProgressTextviewRefrence(null);
viewHolder.data = data;
}
data.setProgressBarRefrence(viewHolder.DownloadProgressbar);
data.setProgressTextviewRefrence(viewHolder.DownloadProgress);
viewHolder.DownloadProgress.setText(data.getDownloadStatus());
viewHolder.Downloadbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
downloadmanager = new Download();
downloadmanager.Downloadmusic(
data,
"http://www.englishathome.ir/public/karaoke/"
+ data.getImage_id() + ".zip", context,
data.getImage_id(), data.getSong_Name());
}
});
return convertView;
}<br/>
0 comments:
Post a Comment