Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.15 KB | None | 0 0
  1. package bhouse.radiovolumes;
  2.  
  3. import android.content.Context;
  4. import android.media.Image;
  5. import android.support.v7.widget.RecyclerView;
  6. import android.util.Log;
  7. import android.view.LayoutInflater;
  8. import android.view.View;
  9. import android.view.ViewGroup;
  10. import android.widget.ArrayAdapter;
  11. import android.widget.CheckBox;
  12. import android.widget.FrameLayout;
  13. import android.widget.ImageView;
  14. import android.widget.ListView;
  15. import android.widget.TextView;
  16.  
  17. import com.squareup.picasso.Picasso;
  18.  
  19. import java.util.ArrayList;
  20.  
  21. /**
  22. * Created by kranck on 8/3/2017.
  23. */
  24.  
  25. public class ScannerListAdapter extends ArrayAdapter<SliceItem>{
  26. private Context context;
  27. private LayoutInflater inflater;
  28. private ArrayList<SliceItem> slices;
  29.  
  30. public ScannerListAdapter(Context context, ArrayList<SliceItem> slices){
  31. super(context, R.layout.list_view_scan, slices);
  32. this.context = context;
  33. this.slices = slices;
  34. inflater = LayoutInflater.from(context);
  35. }
  36.  
  37.  
  38. @Override
  39. public View getView(int position, View convertView, ViewGroup parent){
  40.  
  41. ViewHolder holder;
  42.  
  43. if (convertView == null){
  44. convertView = LayoutInflater.from(context).inflate(R.layout.list_view_scan, parent, false);
  45. convertView.setMinimumHeight(parent.getMeasuredHeight());
  46. holder = new ViewHolder();
  47. SliceItem item = getItem(position);
  48. holder.scanView = (ImageView)convertView.findViewById(R.id.view_scan);
  49. holder.frameLayout = (FrameLayout) convertView.findViewById(R.id.zoomLayout);
  50.  
  51. int resIdScan = this.context.getResources().getIdentifier(item.getStorageLocation(), "drawable", context.getPackageName());
  52. Picasso
  53. .with(context)
  54. .load(resIdScan)
  55. .error(R.drawable.borabora)
  56. .into(holder.scanView);
  57.  
  58.  
  59. for (int i = 0; i < item.getVectorStorageLocation().size(); i++){
  60. ImageView imageView = new ImageView(context);
  61. String truc = item.getVectorStorageLocation().get(i);
  62. //int resId = context.getResources().getIdentifier( item.getVectorStorageLocation().get(i), "drawable", context.getPackageName());
  63. String resourceName = "cylindre__2___"+String.valueOf(position);
  64. int resId = context.getResources().getIdentifier( resourceName, "drawable", context.getPackageName());
  65. imageView.setImageResource(resId);
  66. holder.frameLayout.addView(imageView);
  67. }
  68. convertView.setTag(holder);
  69.  
  70. }
  71. else{
  72. holder = (ViewHolder)convertView.getTag();
  73.  
  74. }
  75.  
  76. return convertView;
  77.  
  78. }
  79.  
  80. static class ViewHolder
  81. {
  82. FrameLayout frameLayout;
  83. ImageView scanView;
  84. }
  85. }
  86.  
  87. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  88. android:layout_width="match_parent"
  89. android:layout_height="match_parent">
  90. <bhouse.radiovolumes.ZoomView
  91. android:layout_width="match_parent"
  92. android:layout_height="match_parent"
  93.  
  94. android:layout_centerInParent="true" >
  95.  
  96. <FrameLayout
  97. android:id="@+id/zoomLayout"
  98. android:layout_width="match_parent"
  99. android:layout_height="match_parent">
  100. <ImageView
  101. android:id="@+id/view_scan"
  102. android:layout_width="match_parent"
  103. android:layout_height="match_parent"
  104. android:clickable="true"
  105. >
  106. </ImageView>
  107. </FrameLayout>
  108.  
  109. </bhouse.radiovolumes.ZoomView>
  110. </LinearLayout>
  111.  
  112. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  113. android:layout_width="match_parent"
  114. android:layout_height="match_parent">
  115. <bhouse.radiovolumes.ZoomView
  116. android:layout_width="match_parent"
  117. android:layout_height="match_parent"
  118.  
  119. android:layout_centerInParent="true" >
  120.  
  121. <FrameLayout
  122. android:id="@+id/zoomLayout"
  123. android:layout_width="match_parent"
  124. android:layout_height="match_parent">
  125. <ImageView
  126. android:id="@+id/view_scan"
  127. android:layout_width="match_parent"
  128. android:layout_height="match_parent"
  129. android:clickable="true"
  130. >
  131. </ImageView>
  132. </FrameLayout>
  133.  
  134. </bhouse.radiovolumes.ZoomView>
  135. </LinearLayout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement