Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. package com.nykkos.myaccount;
  2.  
  3. import java.io.Serializable;
  4. import java.util.List;
  5.  
  6. import android.app.Activity;
  7. import android.content.Context;
  8. import android.content.Intent;
  9. import android.view.LayoutInflater;
  10. import android.view.View;
  11. import android.view.ViewGroup;
  12. import android.view.View.OnClickListener;
  13. import android.widget.BaseAdapter;
  14. import android.widget.Button;
  15. import android.widget.ImageView;
  16. import android.widget.TextView;
  17.  
  18. import com.nykkos.myaccount.Youtube.Video;
  19.  
  20. public class UploadAdapter extends BaseAdapter implements Serializable{
  21. private Context context;
  22. private ImageLoader imageLoader;
  23. private Activity activity;
  24. List<Video> items;
  25. public UploadAdapter(Activity activity, List<Video> items) {
  26. // TODO Auto-generated constructor stub
  27. this.context = activity;
  28. imageLoader = new ImageLoader(context);
  29. this.items = items;
  30. this.activity = activity;
  31. }
  32.  
  33. @Override
  34. public int getCount() {
  35. // TODO Auto-generated method stub
  36. return items.size();
  37. }
  38.  
  39. @Override
  40. public Object getItem(int position) {
  41. // TODO Auto-generated method stub
  42.  
  43. return items.get(position);
  44. }
  45.  
  46. @Override
  47. public long getItemId(int position) {
  48. // TODO Auto-generated method stub
  49. return position;
  50. }
  51.  
  52. public static class ViewHolder {
  53. public TextView tvTitle;
  54. public TextView tvDescription;
  55. public ImageView image;
  56. public Button infoButton;
  57. // public TextView tvDescription;
  58. // public TextView tvViewCount;
  59. /*
  60. * public ImageView image; public TextView des;
  61. */
  62. }
  63.  
  64. @Override
  65. public View getView(final int position, View convertView, ViewGroup parent) {
  66. // TODO Auto-generated method stub
  67. ViewHolder holder;
  68.  
  69. if (convertView == null) {
  70. holder = new ViewHolder();
  71. LayoutInflater inflator = (LayoutInflater) context
  72. .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  73. convertView = inflator.inflate(R.layout.myaccount_row, null);
  74.  
  75. holder.tvTitle = (TextView) convertView.findViewById(R.id.txtDesc);
  76. holder.image = (ImageView) convertView.findViewById(R.id.imgPlate);
  77. holder.tvDescription = (TextView) convertView.findViewById(R.id.txtType);
  78. holder.infoButton = (Button)convertView.findViewById(R.id.infoButton);
  79.  
  80. convertView.setTag(holder);
  81.  
  82. } else
  83. holder = (ViewHolder) convertView.getTag();
  84.  
  85. // Set the ID
  86. convertView.setId(position);
  87.  
  88.  
  89. holder.tvTitle.setText(""+items.get(position).title);
  90.  
  91. holder.image.setTag(items.get(position).GetThumbnail());
  92. imageLoader.DisplayImage(items.get(position).GetThumbnail(), activity, holder.image);
  93.  
  94.  
  95. holder.tvDescription.setText(""+items.get(position).description);
  96.  
  97. holder.infoButton.setFocusable(false);
  98.  
  99. holder.infoButton.setOnClickListener(new OnClickListener() {
  100.  
  101. @Override
  102. public void onClick(View v) {Intent i = new Intent(v.getContext(),Simple.class);
  103. i.putExtra("position", position);
  104. i.putExtra("videoid", items.get(position).GetId());
  105. i.putExtra("duration", items.get(position).GetDuration());
  106. v.getContext().startActivity(i);}
  107. });
  108.  
  109. return convertView;
  110. }
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement