Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. public class HorizntallMediaList extends
  2. ArrayAdapter<ItemsMediaSuggestion> {
  3. String ImageURL;
  4. Context context;
  5. int table = 0;
  6. List<ItemsMediaSuggestion> objects;
  7.  
  8. ItemsMediaSuggestion related;
  9.  
  10. public HorizntallMediaList(Context context, int textViewResourceId,
  11. List<ItemsMediaSuggestion> objects,
  12. int table) {
  13. super(context, textViewResourceId, objects);
  14.  
  15. this.context = context;
  16. this.objects = objects;
  17. this.table = table;
  18. }
  19.  
  20. viewHolder holder = new viewHolder();
  21.  
  22. private class viewHolder {
  23.  
  24. private RelativeLayout relativeLayout;
  25. private ImageView userImage, addImage;
  26. private TextView userName;
  27.  
  28. }
  29.  
  30. @Override
  31. public long getItemId(int position) {
  32.  
  33. return super.getItemId(position);
  34. }
  35.  
  36. @Override
  37. public int getCount() {
  38.  
  39. return super.getCount();
  40. }
  41.  
  42. @Override
  43. public ItemsMediaSuggestion getItem(int position) {
  44.  
  45. return super.getItem(position);
  46. }
  47.  
  48.  
  49. @Override
  50. public View getView(final int position, View convertView, ViewGroup parent) {
  51.  
  52. try{
  53. related = getItem(position);
  54. } catch (IndexOutOfBoundsException e) {
  55.  
  56. }
  57.  
  58. LayoutInflater inflater = (LayoutInflater) context
  59. .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
  60. if (convertView == null) {
  61. convertView = inflater.inflate(R.layout.items_wall_horizntal,
  62. parent, false);
  63.  
  64. holder = new viewHolder();
  65.  
  66. holder.relativeLayout = (RelativeLayout) convertView
  67. .findViewById(R.id.horRelative);
  68. holder.userImage = (ImageView) convertView
  69. .findViewById(R.id.HorUserImage);
  70.  
  71. holder.userName = (TextView) convertView.findViewById(R.id.HorName);
  72. holder.addImage = (ImageView) convertView.findViewById(R.id.HorAdd);
  73. holder.addImage.setVisibility(View.GONE);
  74. convertView.setTag(holder);
  75.  
  76. } else {
  77.  
  78. holder = (viewHolder) convertView.getTag();
  79. }
  80.  
  81.  
  82. holder.relativeLayout
  83. .setBackgroundColor(GlobalConstants.ColorPicker_int);
  84.  
  85. if (table == 5) {
  86. ImageURL = GlobalConstants.server_file
  87. + table
  88. + "/m/"
  89. + related.getStorage()
  90. + "."
  91. + related.getStorageRand() + ".jpg";
  92.  
  93. holder.userName.setText(PublicMethods.readable(related
  94. .getDescribtion()));
  95.  
  96.  
  97. } else if (table == 6) {
  98.  
  99. if (related.getStorage().equals("0")) {
  100. holder.userName.setText(PublicMethods.readable(related
  101. .getTitle()));
  102.  
  103. ImageURL = "https://img.youtube.com/vi/"
  104. + related.getStorageRand() + "/1" + ".jpg";
  105.  
  106.  
  107. } else {
  108. ImageURL = GlobalConstants.server_file
  109. + table
  110. + "/m/"
  111. + related.getStorage()
  112. + "."
  113. + related.getStorageRand() + ".jpg";
  114.  
  115. holder.userName.setText(PublicMethods.readable(related
  116. .getTitle()));
  117.  
  118.  
  119.  
  120. }
  121. } else {
  122.  
  123. ImageURL = GlobalConstants.server_file
  124. + 5
  125. + "/m/"
  126. + related.getStorage()
  127. + "."
  128. + related.getStorageRand() + ".jpg";
  129.  
  130. holder.userName.setText(PublicMethods.readable(related.getTitle()));
  131.  
  132.  
  133. }
  134. Picasso.with(context).load(ImageURL).fit().into(holder.userImage);
  135.  
  136. return convertView;
  137. }
  138.  
  139. }
  140.  
  141. <?xml version="1.0" encoding="utf-8"?>
  142. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  143. android:layout_width="wrap_content"
  144. android:layout_height="wrap_content"
  145. android:background="@drawable/background_with_shadow"
  146. android:orientation="vertical" >
  147.  
  148. <RelativeLayout
  149. android:layout_width="200dp"
  150. android:layout_height="200dp" >
  151.  
  152. <ImageView
  153. android:id="@+id/HorUserImage"
  154. android:layout_width="wrap_content"
  155. android:layout_height="wrap_content"
  156. android:layout_alignParentBottom="true"
  157. android:layout_alignParentLeft="true"
  158. android:layout_alignParentRight="true"
  159. android:layout_alignParentTop="true"
  160. />
  161.  
  162. <RelativeLayout
  163. android:id="@+id/horRelative"
  164. android:layout_width="match_parent"
  165. android:layout_height="40dp"
  166. android:layout_alignParentBottom="true"
  167. android:layout_alignParentLeft="true" >
  168.  
  169. <TextView
  170. android:id="@+id/HorName"
  171. android:layout_width="match_parent"
  172. android:layout_height="wrap_content"
  173. android:layout_alignParentRight="true"
  174. android:layout_centerVertical="true"
  175. android:layout_marginLeft="20dp"
  176. android:layout_marginRight="5dp"
  177. android:layout_toLeftOf="@+id/HorAdd"
  178. android:gravity="right"
  179. android:maxLines="1"
  180. android:text="Name"
  181. android:textColor="@color/WhiteColor"
  182. android:textSize="18sp" />
  183.  
  184. <ImageView
  185. android:id="@+id/HorAdd"
  186. android:layout_width="40dp"
  187. android:layout_height="wrap_content"
  188. android:layout_alignParentLeft="true"
  189. android:layout_centerVertical="true"
  190. android:src="@drawable/plus" />
  191. </RelativeLayout>
  192. </RelativeLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement