Created
February 18, 2018 16:38
-
-
Save ebnrdwan/cebcbda0fb503e5f4a9299049fb8f6b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.mohamedhamdy.courses.Adapter; | |
| import android.content.Context; | |
| import android.content.Intent; | |
| import android.support.v7.widget.RecyclerView; | |
| import android.util.Log; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.widget.ImageView; | |
| import android.widget.TextView; | |
| import com.example.mohamedhamdy.courses.Model.PopularCoursesResponse; | |
| import com.example.mohamedhamdy.courses.R; | |
| import com.example.mohamedhamdy.courses.Ui.Activities.Design; | |
| import java.util.ArrayList; | |
| /** | |
| * Created by A-Hamdy on 16/02/2018. | |
| */ | |
| public class PopularCorsesAdapter extends RecyclerView.Adapter<PopularCorsesAdapter.PopularCoursesAdaptarHolder> { | |
| ArrayList<PopularCoursesResponse.DataBean> popData; | |
| Context mContext; | |
| public PopularCorsesAdapter(Context mContext, ArrayList<PopularCoursesResponse.DataBean> popularData) { | |
| this.mContext = mContext; | |
| this.popData = popularData; | |
| } | |
| @Override | |
| public PopularCoursesAdaptarHolder onCreateViewHolder(ViewGroup viewGroup, int i) { | |
| View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.recycle_popular_courses, viewGroup, false); | |
| PopularCoursesAdaptarHolder viewHolder = new PopularCoursesAdaptarHolder(view); | |
| return viewHolder; | |
| } | |
| @Override | |
| public void onBindViewHolder(PopularCoursesAdaptarHolder holder, int i) { | |
| final PopularCoursesResponse.DataBean course = popData.get(i); | |
| holder.title.setText(course.getName()); | |
| holder.descrip.setText(course.getDescription()); | |
| holder.price.setText(course.getPrice()); | |
| // holder.pic.setImageResource(Integer.parseInt(course.getImage())); | |
| holder.itemView.setOnClickListener(new View.OnClickListener() { | |
| @Override | |
| public void onClick(View v) { | |
| Intent mIntent = new Intent(mContext , Design.class); | |
| mIntent.putExtra("design" , course ); | |
| mIntent.putExtra("test" , 111 ); | |
| mIntent.putExtra("test" , false ); | |
| mIntent.putExtra("test" , "ghgjgfj" ); | |
| mIntent.putExtra("test" , 111 ); | |
| mContext.startActivity(mIntent); | |
| } | |
| }); | |
| Log.e("test adapte value", course.getAddby_name()); | |
| } | |
| @Override | |
| public void onAttachedToRecyclerView(RecyclerView recyclerView) { | |
| super.onAttachedToRecyclerView(recyclerView); | |
| } | |
| @Override | |
| public int getItemCount() { | |
| return (null != popData ? popData.size() : 0); | |
| } | |
| class PopularCoursesAdaptarHolder extends RecyclerView.ViewHolder { | |
| TextView title, descrip, price; | |
| ImageView pic; | |
| public PopularCoursesAdaptarHolder(View itemView) { | |
| super(itemView); | |
| title = itemView.findViewById(R.id.textView27); | |
| descrip = itemView.findViewById(R.id.textView31); | |
| price = itemView.findViewById(R.id.textView32); | |
| pic = itemView.findViewById(R.id.imageView13); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment