Guest User

Untitled

a guest
Aug 21st, 2017
755
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class MyAdapter_home extends RecyclerView.Adapter<MyAdapter_home.MyAdapter_HomeViewHolder> {
  2.  
  3.  
  4.     private List<Datum> data;
  5.     private List<Datum2>data2;
  6.     private int rowLayout;
  7.     private Context context;
  8.     PopupMenu popupMenu ;
  9.     private View imageView;
  10.  
  11.  
  12.     public MyAdapter_home(List<Datum> data, int rowLayout, Context context) {
  13.         this.data = data;
  14.         this.rowLayout = rowLayout;
  15.         this.context = context;
  16.  
  17.     }
  18.     @Override
  19.     public MyAdapter_HomeViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  20.         View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_item_home, parent, false);
  21.  
  22.         return new MyAdapter_HomeViewHolder(view);
  23.     }
  24.     @Override
  25.     public void onBindViewHolder(final MyAdapter_HomeViewHolder holder, final int position) {
  26.  
  27.         holder.userNameTV.setText(data.get(position).getUserInfo().getFullName());
  28.         holder.msgBodyTV.setText(data.get(position).getBody());
  29.         holder.originator_iD.setText(data.get(position).getUserInfo().getId().toString());
  30.  
  31.         //message ID
  32.         holder.messageId.setText(data.get(position).getId().toString());
  33.        
  34.         holder.owner_type_ET.setText("1");
  35.         holder.subject_ET.setText("Message");
  36.  
  37.  
  38.         Glide.with(context).load("" +
  39.                 data.get(position).getUserInfo().getAvatar())
  40.                 .apply(RequestOptions.circleCropTransform()).into(holder.imV);
  41.  
  42.         holder.mCardView.setOnClickListener(new View.OnClickListener() {
  43.             @Override
  44.             public void onClick(View view) {
  45.  
  46.                 holder.imV.buildDrawingCache();
  47.                 Bitmap image= holder.imV.getDrawingCache();
  48.                 Intent intent = new Intent(view.getContext(), Single_Message.class);
  49.                 intent.putExtra("ORIGINATOR_ID", holder.originator_iD.getText().toString());
  50.                 intent.putExtra("OWNER_TYPE", holder.owner_type_ET.getText().toString());
  51.                 intent.putExtra("SUBJECT", holder.subject_ET.getText().toString());
  52.                 intent.putExtra("USERNAME", holder.userNameTV.getText().toString());
  53.                 Bundle extras = new Bundle();
  54.                 extras.putParcelable("imagebitmap", image);
  55.                 intent.putExtras(extras);
  56.  
  57.                 view.getContext().startActivity(intent);
  58.             }
  59.         });
  60.         holder.btnButton1.setOnClickListener(new View.OnClickListener() {
  61.             @Override
  62.             public void onClick(View view) {
  63.  
  64.                 holder.imV.buildDrawingCache();
  65.                 Bitmap image= holder.imV.getDrawingCache();
  66.  
  67.                 Intent intent = new Intent(view.getContext(), Menu_single_item_recent.class);
  68.                 intent.putExtra("ORIGINATOR_ID", holder.originator_iD.getText().toString());
  69.                 intent.putExtra("OWNER_TYPE", holder.owner_type_ET.getText().toString());
  70.                 intent.putExtra("SUBJECT", holder.subject_ET.getText().toString());
  71.                 intent.putExtra("USERNAME", holder.userNameTV.getText().toString());
  72.  
  73.                 Bundle extras = new Bundle();
  74.                 extras.putParcelable("imagebitmap", image);
  75.                 intent.putExtras(extras);
  76.  
  77.                 view.getContext().startActivity(intent);
  78.  
  79.             }
  80.         });
  81.  
  82.     }
  83.  
  84.     @Override
  85.     public int getItemCount() {
  86.         return data.size();
  87.     }
  88.  
  89.     public static class MyAdapter_HomeViewHolder extends RecyclerView.ViewHolder {
  90.  
  91.         TextView userNameTV;
  92.         TextView msgBodyTV;
  93.         CardView mCardView;
  94.         TextView originator_iD;
  95.         ImageView imV;
  96.         TextView messageId;
  97.  
  98.         ImageButton btnButton1;
  99.  
  100.  
  101.         ConversationAPIService conversationAPIService;
  102.         EditText owner_type_ET, subject_ET;
  103.  
  104.         public MyAdapter_HomeViewHolder(View itemView) {
  105.             super(itemView);
  106.             userNameTV = (TextView) itemView.findViewById(R.id.username);
  107.             msgBodyTV = itemView.findViewById(R.id.msgbody);
  108.             mCardView = (CardView) itemView.findViewById(R.id.card_view);
  109.             originator_iD = itemView.findViewById(R.id.frIdET);
  110.             imV = itemView.findViewById(R.id.iv_image_person);
  111.             owner_type_ET = (EditText) itemView.findViewById(R.id.owner_typeET);
  112.             subject_ET = (EditText) itemView.findViewById(R.id.subjectET);
  113.             btnButton1=(ImageButton)itemView.findViewById(R.id.imageButton);
  114.             messageId=itemView.findViewById(R.id.message_ID);
  115.         }
  116.     }
  117. }
RAW Paste Data