I have a list of saved locations coming from the server that I want to display inside a RecyclerView with a map snapshot of the location.
I coded it according to code samples provided for the same by Google but unfortunately the list wouldn't show on the UI.
I am attaching the code to my RecyclerView Adapter & item XML.
public class SavedLocationAdapter extends RecyclerView.Adapter<SavedLocationAdapter.ViewHolder> {
private Context mContext;
private ArrayList<SavedLocationDetails> savedLocationList;
private LoadMoreLocationsInterface loadMoreLocationsInterface;
public SavedLocationAdapter(Context context, LoadMoreLocationsInterface loadMoreLocationsInterface) {
//super(DIFF_CALLBACK);
super();
mContext = context;
this.savedLocationList = new ArrayList<>();
this.loadMoreLocationsInterface = loadMoreLocationsInterface;
}
public void updateList(List<SavedLocationDetails> savedLocationList) {
this.savedLocationList.addAll(savedLocationList);
notifyDataSetChanged();
}
#NonNull
#Override
public ViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_saved_location, parent, false));
}
#Override
public void onBindViewHolder(#NonNull ViewHolder holder, int position) {
SavedLocationDetails savedLocationDetails = savedLocationList.get(position);
if (savedLocationDetails != null)
holder.bindView(savedLocationDetails);
if (position == getItemCount()-1)
loadMoreLocationsInterface.loadMoreLocations(savedLocationDetails.getLid());
}
#Override
public int getItemCount() {
return savedLocationList.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements OnMapReadyCallback {
MapView mapView;
TextView locationType;
TextView friendlyName;
TextView fullAddress;
public GoogleMap map;
View layout;
public ViewHolder(#NonNull View itemView) {
super(itemView);
layout = itemView;
locationType = layout.findViewById(R.id.savedLocationTypeTV);
fullAddress = layout.findViewById(R.id.savedLocationAddressTV);
friendlyName = layout.findViewById(R.id.friendlyNameTV);
mapView = layout.findViewById(R.id.savedLocationMap);
if(mapView != null) {
mapView.onCreate(null);
mapView.onResume();
mapView.onPause();
mapView.getMapAsync(this);
}
}
#Override
public void onMapReady(GoogleMap googleMap) {
MapsInitializer.initialize(mContext);
map = googleMap;
setMapLocation();
}
private void setMapLocation() {
if (map == null)
return;
SavedLocationDetails savedLocationDetails = (SavedLocationDetails) mapView.getTag();
if (savedLocationDetails == null)
return;
LatLng locationLatLng = new LatLng(savedLocationDetails.getLat(), savedLocationDetails.getLng());
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.location_marker_black_solid);
MarkerOptions markerOptions = (new MarkerOptions()).position(locationLatLng).icon(icon);
map.animateCamera(CameraUpdateFactory.newLatLngZoom(locationLatLng, 18f));
map.addMarker(markerOptions);
}
public void bindView(SavedLocationDetails savedLocationDetails) {
layout.setTag(this);
mapView.setTag(savedLocationDetails);
setMapLocation();
if((savedLocationDetails.getLtp() != null) && (savedLocationDetails.getLtp() == 3)) {
locationType.setVisibility(GONE);
friendlyName.setText(savedLocationDetails.getFn());
friendlyName.setVisibility(View.VISIBLE);
} else {
friendlyName.setVisibility(GONE);
locationType.setVisibility(View.VISIBLE);
locationType.setText("Home");
}
fullAddress.setText(savedLocationDetails.getAdd());
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
app:cardBackgroundColor="#color/appBar"
app:cardElevation="3dp"
app:cardCornerRadius="30dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.gms.maps.MapView
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/savedLocationMap"
android:layout_width="match_parent"
android:layout_height="225dp"
app:mapType="normal"
map:liteMode="true"
map:mapType = "normal" />
<RelativeLayout
android:id="#+id/savedLocationDataRL"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignBottom="#+id/savedLocationMap"
android:background="#color/white"
android:visibility="gone">
<TextView
android:id="#+id/savedLocationTypeTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:text="Work"
android:textColor="#color/quantum_black_100"
android:textStyle="bold"
android:textSize="15sp"/>
<TextView
android:id="#+id/friendlyNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:text="Friendly Name"
android:textColor="#color/quantum_black_100"
android:textSize="15sp"
android:textStyle="bold"
android:visibility="gone"/>
<TextView
android:id="#+id/savedLocationAddressTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/savedLocationTypeTV"
android:layout_marginTop="3dp"
android:layout_marginStart="10dp"
android:text="Full Address"
android:textColor="#color/quantum_black_100"
android:textSize="13sp"/>
</RelativeLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
Related
I have a recycler inside fragment in view pager.
The problem that it put likes on user accounts in UI randomly but in DB everything is fine.
In logs, I see that random is not influence on BD. So the bug is only in UI part. After the refresh of the list, it can appear again and after that disappear.
I would like to share code but I already don't have an I idea where the problem could be. It might be in adapter/refresh list listener / XML or any other places. Please let me know what part of the code you need and I will provide it. Maybe it is a bug of recycler as itself and I can't fix it.
Adapter class code:
public class SearchAdapter extends RecyclerView.Adapter<SearchAdapter.UserViewHolder>{
private List<FsUser> fsUserList = new ArrayList<>();
private OnItemClickListener.OnItemClickCallback onItemClickCallback;
private OnItemClickListener.OnItemClickCallback onChatClickCallback;
private OnItemClickListener.OnItemClickCallback onLikeClickCallback;
private Context context;
public SearchAdapter(OnItemClickListener.OnItemClickCallback onItemClickCallback,
OnItemClickListener.OnItemClickCallback onChatClickCallback,
OnItemClickListener.OnItemClickCallback onLikeClickCallback) {
this.onItemClickCallback = onItemClickCallback;
this.onChatClickCallback = onChatClickCallback;
this.onLikeClickCallback = onLikeClickCallback;
}
public void addUsers(List<FsUser> userList) {
fsUserList.addAll(userList);
notifyItemRangeInserted(fsUserList.size() - userList.size(), fsUserList.size());
}
public void clearData(){
fsUserList.clear();
notifyDataSetChanged();
}
#NonNull
#Override
public UserViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_user, parent, false);
return new UserViewHolder(v);
}
#Override
public void onBindViewHolder(#NonNull UserViewHolder holder, int position) {
FsUser fsUser = fsUserList.get(position);
holder.bind(fsUser, position);
}
#Override
public int getItemCount() {
return fsUserList.size();
}
public String getLastItemId(){
return fsUserList.get(fsUserList.size() - 1).getUid();
}
class UserViewHolder extends RecyclerView.ViewHolder {
RelativeLayout container;
ImageView imageView, like, chat;
TextView name, country;
private LottieAnimationView animationView;
UserViewHolder(View itemView) {
super(itemView);
context = itemView.getContext();
container = itemView.findViewById(R.id.item_user_container);
imageView = itemView.findViewById(R.id.user_img);
like = itemView.findViewById(R.id.search_btn_like);
chat = itemView.findViewById(R.id.search_btn_chat);
name = itemView.findViewById(R.id.user_name);
country = itemView.findViewById(R.id.user_country);
animationView = itemView.findViewById(R.id.lottieAnimationView);
}
void bind(FsUser fsUser, int position){
ViewCompat.setTransitionName(imageView, fsUser.getName());
if (FirebaseUtils.isUserExist() && fsUser.getUid() != null) {
new FriendRepository().isLiked(fsUser.getUid(), flag -> {
if (flag) {
like.setBackground(ContextCompat.getDrawable(context, R.drawable.ic_favorite));
animationView.setVisibility(View.VISIBLE);
}
});
}
if(fsUser.getUid() != null) {
chat.setOnClickListener(new OnItemClickListener(position, onChatClickCallback));
like.setOnClickListener(new OnItemClickListener(position, onLikeClickCallback));
}
imageView.setOnClickListener(new OnItemClickListener(position, onItemClickCallback));
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
if(fsUser.getImage().equals("default")){
Glide.with(context).load(context.getResources().getDrawable(R.drawable.default_avatar)).into(imageView);
} else {
Glide.with(context).load(fsUser.getImage()).thumbnail(0.5f).into(imageView);
}
name.setText(fsUser.getName());
country.setText(fsUser.getCountry());
ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(500);
animator.addUpdateListener(valueAnimator ->
animationView.setProgress((Float) valueAnimator.getAnimatedValue()));
if (animationView.getProgress() == 0f) {
animator.start();
} else {
animationView.setProgress(0f);
}
}
}
}
And xml file of RecyclerView item:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/item_user_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:layout_width="#dimen/user_cv_width"
android:layout_height="#dimen/user_cv_height"
android:layout_margin="#dimen/dp4"
android:elevation="#dimen/dp4">
<RelativeLayout
android:id="#+id/item_user_main_relative_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:id="#+id/item_user_top_relative_container"
android:layout_width="#dimen/user_rl_width"
android:layout_height="#dimen/user_rl_height">
<ImageView
android:id="#+id/user_img"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="centerCrop"
android:src="#drawable/default_avatar" />
<RelativeLayout
android:id="#+id/item_user_top_relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/user_item_bg"
android:orientation="vertical">
<TextView
android:id="#+id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/dp4"
android:textColor="#android:color/white"
android:textSize="#dimen/medium_text_size" />
<TextView
android:id="#+id/user_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/white"
android:layout_marginStart="#dimen/dp4"
android:textSize="#dimen/medium_text_size" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/item_user_bottom_relative_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dp12">
<ImageView
android:id="#+id/search_btn_like"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/heart_outline"
android:contentDescription="#string/search_btn_like_desc"/>
<com.airbnb.lottie.LottieAnimationView
android:id="#+id/lottieAnimationView"
android:visibility="gone"
android:layout_width="#dimen/lottie_animation_view_size"
android:layout_height="#dimen/lottie_animation_view_size"
app:lottie_loop="true"
app:lottie_autoPlay="true"
app:lottie_fileName="like.json"/>
</RelativeLayout>
<ImageView
android:id="#+id/search_btn_chat"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="#dimen/dp12"
android:layout_weight="1"
android:src="#drawable/message_outline" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
Override this two methods inside your adapter
#Override
public long getItemId(int position) {
return position;
}
#Override
public int getItemViewType(int position) {
return position;
}
I tried below code to implement an expend and collapse content using recyclerview(listview) a link
final boolean isExpanded = position==mExpandedPosition;
holder.details.setVisibility(isExpanded?View.VISIBLE:View.GONE);
holder.itemView.setActivated(isExpanded);
if (isExpanded)
previousExpandedPosition = position;
holder.itemView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mExpandedPosition = isExpanded ? -1:position;
notifyItemChanged(previousExpandedPosition);
notifyItemChanged(position);
}
});
In my case when i click the particular position in recyclerview its expanding but it goes above the recyclerview.I cant see the full expanded content.i can see only partial content.In this case i need to scroll the recyclerview to view the full content.But i am searching for a solution to view the content without scroll the recyclerview. If i click another position in recyclerview that should be placed over an recyclerview.
Hear is My Code
public class CommonFragment extends Fragment {
#BindView(R.id.news_lists)
RecyclerView news_lists;
#BindView(R.id.nested_scroll)
NestedScrollView nested_scroll;
ArrayList<String> Names;
ArrayList<String> responseProducts = null;
NewsListAdaspters mAdapter;
Context mContext;
String position_name;
public CommonFragment() {
}
public static CommonFragment getInstance(String position, ArrayList<String> response) {
CommonFragment fragmentDummy = new CommonFragment();
Bundle args = new Bundle();
args.putStringArrayList("Types", response);
args.putString("position", position);
fragmentDummy.setArguments(args);
return fragmentDummy;
}
#Override
public void setArguments(Bundle args) {
super.setArguments(args);
this.responseProducts = args.getStringArrayList("Types");
this.position_name = args.getString("position");
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
View view;
#Nullable
#Override
public View onCreateView(#NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null)
parent.removeView(view);
}
try {
view = inflater.inflate(R.layout.fragment_common, container, false);
ButterKnife.bind(this, view);
} catch (InflateException ignored) {
}
mContext = getActivity();
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
news_lists.setLayoutManager(mLayoutManager);
news_lists.setNestedScrollingEnabled(false);
Names = new ArrayList<>();
Names.clear();
for (int i = 0; i < 15; i++) {
Names.add("News Details " + i);
}
Log.e("position_name==>", "" + position_name);
getList();
return view;
}
private void getList() {
if (responseProducts.size() > 0) {
mAdapter = new NewsListAdaspters(mContext, responseProducts, position_name);
news_lists.setAdapter(mAdapter);
}
}
public class NewsListAdaspters extends RecyclerView.Adapter<NewsListAdaspters.MyViewHolder> {
private ArrayList<String> data;
private Context context;
private String name;
int mExpandedPosition = -1;
int previousExpandedPosition = -1;
NewsListAdaspters(Context context, ArrayList<String> maps, String selectedFragmentName) {
this.context = context;
this.data = maps;
this.name = selectedFragmentName;
}
#NonNull
#Override
public MyViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.common_view, parent, false);
final MyViewHolder holder = new MyViewHolder(itemView);
return holder;
}
#Override
public void onBindViewHolder(#NonNull final MyViewHolder holder, #SuppressLint("RecyclerView") final int position) {
holder.news_description.setText(data.get(position));
holder.news_title.setText(name);
final boolean isExpanded = position == mExpandedPosition;
Log.e("isExpanded=====>", "" + isExpanded);
holder.expend_layout.setVisibility(isExpanded ? View.VISIBLE : View.GONE);
holder.itemView.setActivated(isExpanded);
if (isExpanded)
previousExpandedPosition = position;
holder.news_image.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent(context, Activity_NewsFullDetails.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
holder.expand_click_layout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
mExpandedPosition = isExpanded ? -1 : position;
notifyItemChanged(previousExpandedPosition);
notifyItemChanged(position);
}
});
holder.share_fb.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "WORKING!!!!", Toast.LENGTH_SHORT).show();
}
});
holder.share_whatsapp.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "WORKING!!!!", Toast.LENGTH_SHORT).show();
}
});
holder.share_twet.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(context, "WORKING!!!!", Toast.LENGTH_SHORT).show();
}
});
}
#Override
public int getItemCount() {
return data.size();
}
public class MyViewHolder extends RecyclerView.ViewHolder {
#BindView(R.id.news_title)
public TextView news_title;
#BindView(R.id.news_hour)
public TextView news_hour;
#BindView(R.id.news_description)
public TextView news_description;
#BindView(R.id.news_image)
public ImageView news_image;
#BindView(R.id.expand_click_layout)
RelativeLayout expand_click_layout;
#BindView(R.id.expend_layout)
public LinearLayout expend_layout;
#BindView(R.id.full_title)
public TextView full_title;
#BindView(R.id.txt_description)
public TextView txt_description;
#BindView(R.id.share_twet)
public ImageView share_twet;
#BindView(R.id.share_whatsapp)
public ImageView share_whatsapp;
#BindView(R.id.share_fb)
public ImageView share_fb;
MyViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
}
}
XML file
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#03000000">
<android.support.v4.widget.NestedScrollView
android:id="#+id/nested_scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:fitsSystemWindows="false"
android:focusable="true"
android:focusableInTouchMode="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:descendantFocusability="blocksDescendants">
<android.support.v7.widget.RecyclerView
android:id="#+id/news_lists"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nestedScrollingEnabled="false"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
ITEM XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="2dp"
android:animateLayoutChanges="true"
android:background="#drawable/comment_background"
android:stateListAnimator="#animator/comment_selection"
android:elevation="3dp"
card_view:cardCornerRadius="2dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/news_image"
android:layout_width="130dp"
android:layout_height="130dp"
android:layout_margin="2dp"
android:background="#drawable/icon_card"
android:scaleType="fitXY" />
<RelativeLayout
android:id="#+id/expand_click_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/news_image"
android:layout_alignTop="#+id/news_image"
android:layout_toEndOf="#+id/news_image"
android:layout_toRightOf="#+id/news_image">
<TextView
android:id="#+id/news_description"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_layout"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
android:maxEms="3"
android:maxLines="4"
android:padding="4dp"
android:text=""
android:textColor="#color/black_color"
android:textSize="18sp" />
<RelativeLayout
android:id="#+id/bottom_layout"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_alignParentBottom="true"
android:layout_margin="4dp">
<TextView
android:id="#+id/news_hour"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/center_text"
android:layout_toStartOf="#+id/center_text"
android:maxLines="2"
android:text="Hours"
android:textColor="#color/black_color"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="#+id/center_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true" />
<TextView
android:id="#+id/news_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toEndOf="#+id/center_text"
android:layout_toRightOf="#+id/center_text"
android:gravity="end"
android:text="News Title"
android:textColor="#color/black_color"
android:textSize="16sp" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/expend_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/news_image"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="#+id/full_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Title Text"
android:textColor="#color/black_color"
android:textSize="20sp" />
<TextView
android:id="#+id/txt_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="#string/large_text1"
android:textColor="#color/black_color"
android:textSize="18sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:orientation="horizontal">
<ImageView
android:id="#+id/share_fb"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#drawable/share_facebook" />
<ImageView
android:id="#+id/share_whatsapp"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#drawable/share_whatsapp" />
<ImageView
android:id="#+id/share_twet"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#drawable/share_tweet" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Try to use NestedScrollView instead of ScrollView and set below to your activity :-
recyclerView.setNestedScrollingEnabled(false);
For more information you can refer below stackoverflow links:-
How to use RecyclerView inside NestedScrollView?
Recyclerview inside ScrollView not scrolling smoothly
RecyclerView Adapter Class.
public class TravelListAdapter extends RecyclerView.Adapter<TravelListAdapter.ViewHolder> {
Context mContext;
OnItemClickListener mItemClickListener;
String []names = {"Hotels", "Travel", "Medicine", "Education", "Travel", "Hotels"};
private int[] advertImageList = {R.drawable.hotel, R.drawable.travel, R.drawable.medical, R.drawable.education, R.drawable.travel, R.drawable.hotel};
// 2
public void setOnItemClickListener(OnItemClickListener mItemClickListener) {
this.mItemClickListener = mItemClickListener;
}
public TravelListAdapter(Context context) {
this.mContext = context;
}
// 3
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
public LinearLayout placeHolder;
public LinearLayout placeNameHolder;
public TextView placeName;
public ImageView placeImage;
public ViewHolder(View itemView) {
super(itemView);
placeHolder = itemView.findViewById(R.id.mainHolder);
placeName = itemView.findViewById(R.id.placeName);
placeNameHolder = itemView.findViewById(R.id.placeNameHolder);
placeImage = itemView.findViewById(R.id.placeImage);
placeHolder.setOnClickListener(this);
}
#Override
public void onClick(View v) {
if (mItemClickListener != null) {
mItemClickListener.onItemClick(itemView, getPosition());
}
}
}
public interface OnItemClickListener {
void onItemClick(View view, int position);
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.category_row_item, parent, false);
return new ViewHolder(view);
}
#Override
public void onBindViewHolder(final ViewHolder holder, int position) {
// final Place place = new PlaceData().placeList().get(position);
holder.placeName.setText(names[position]);
holder.placeName.setTextColor(R.color.black);
Picasso.with(mContext).load(advertImageList[position]).into(holder.placeImage);
Bitmap photo = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.image2);
Palette.generateAsync(photo, new Palette.PaletteAsyncListener() {
public void onGenerated(Palette palette) {
//int bgColor = palette.getMutedColor(mContext.getResources().getColor(android.R.color.transparent));
holder.placeNameHolder.setBackgroundColor(mContext.getResources().getColor(android.R.color.transparent));
}
});
}
#Override
public int getItemCount() {
return names.length;
}
}`
My Xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/placeCard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:cardBackgroundColor="#android:color/transparent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/placeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="center"
android:transitionName="tImage"
android:layout_centerInParent="true"
android:tint="#android:color/white"
android:padding="10dp"/>
<!-- Used for the ripple effect on touch -->
<LinearLayout
android:id="#+id/mainHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?android:selectableItemBackground"
android:orientation="horizontal" />
<LinearLayout
android:id="#+id/placeNameHolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:transitionName="tNameHolder"
android:padding="5dp"
android:layout_below="#+id/placeImage">
<TextView
android:id="#+id/placeName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceListItem"
android:textColor="#android:color/white"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
I am using vector images generated from Android Studio but those images are not displayed in recyclerView.
What should i do? Let me mention that the vector images that i use inside recyclerView are properly displayed if i use them in simple image views.
This has to be the most absurd thing ever.
I have a RecyclerView with repeated custom items. Inside these items, there are a few textfields, buttons and a single MapView.
The issue is that when the list loads, the MapView only displays the Google logo and no other tile or detail (or marker). However, when I tap once on the map, it shows the marker I added. On the next tap, it loads a pixellated map. On another tap, it loads a better quality map. On further clicks it adds the text labels for nearby locations. LatLngBounds are also not working but that's a secondary problem.
Why is this happening?
My code is as follows:
JobAdapter.java
public class JobAdapter extends RecyclerView.Adapter<JobAdapter.ViewHolder>
{
private Context context;
private static List<Job> jobList;
private HashSet<MapView> mapViews = new HashSet<>();
private GoogleMap googleMap;
public JobAdapter(Context con, List<Job> jobs)
{
context = con;
jobList = jobs;
}
#Override
public int getItemCount()
{
return jobList.size();
}
#Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType)
{
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.listitem_booking, parent, false);
ViewHolder viewHolder = new ViewHolder(view);
mapViews.add(viewHolder.mapView);
return viewHolder;
}
#Override
public void onBindViewHolder(ViewHolder holder, int position)
{
Job job = jobList.get(position);
holder.mapView.setClickable(false);
if(job.getJobType().equalsIgnoreCase("Now"))
{
holder.pickup.setBackgroundColor(ContextCompat.getColor(context, R.color.lightRed));
}
holder.pickup.setText(job.getPickupAddress());
if(job.getDestinationAddress() != null && !job.getDestinationAddress().equalsIgnoreCase(""))
{
holder.destination.setText(job.getDestinationAddress());
}
else
{
holder.destination.setVisibility(View.GONE);
}
holder.person.setText(job.getContact());
holder.datetime.setText(job.getDate() + " at " + job.getTime());
}
class ViewHolder extends RecyclerView.ViewHolder implements /*View.OnClickListener,*/ OnMapReadyCallback
{
#BindView(R.id.pickup)
TextView pickup;
#BindView(R.id.destination)
TextView destination;
#BindView(R.id.person)
TextView person;
#BindView(R.id.datetime)
TextView datetime;
#BindView(R.id.map_listitem)
MapView mapView;
#BindView(R.id.acceptJob)
Button acceptJob;
#BindView(R.id.declineJob)
Button declineJob;
#BindView(R.id.buttonLayout)
LinearLayout buttonLayout;
private ViewHolder(View itemView)
{
super(itemView);
ButterKnife.bind(this, itemView);
// itemView.setOnClickListener(this);
mapView.onCreate(null);
mapView.getMapAsync(this);
}
private void addMarkers(Job job)
{
googleMap.clear();
boolean hasDestination = true;
String[] destinationLatlng = null;
LatLng destination = null;
if(job.getDestinationAddress() == null || job.getDestinationAddress().equalsIgnoreCase(""))
{
hasDestination = false;
}
else
{
destinationLatlng = job.getDestinationLatLong().split(",");
destination = new LatLng(Double.valueOf(destinationLatlng[0]), Double.parseDouble(destinationLatlng[1]));
}
final String[] pickupLatlng = job.getPickupLatLong().split(",");
final LatLng pickup = new LatLng(Double.valueOf(pickupLatlng[0]), Double.parseDouble(pickupLatlng[1]));
if(hasDestination)
{
googleMap.addMarker(new MarkerOptions()
.position(pickup)
.title(job.getPickupAddress()));
googleMap.addMarker(new MarkerOptions()
.position(destination)
.title(job.getDestinationAddress()));
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(pickup);
builder.include(destination);
LatLngBounds bounds = builder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 5);
googleMap.animateCamera(cameraUpdate);
}
else
{
googleMap.addMarker(new MarkerOptions()
.position(pickup)
.title(job.getPickupAddress()));
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(pickup, 15);
googleMap.animateCamera(cameraUpdate);
}
}
/*#Override
public void onClick(View view)
{
final Job job = jobList.get(getAdapterPosition());
}*/
#Override
public void onMapReady(GoogleMap gMap)
{
googleMap = gMap;
addMarkers(jobList.get(getAdapterPosition()));
}
}
}
listitem_booking
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:map="http://schemas.android.com/tools"
android:orientation="vertical"
app:cardElevation="2dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/pickup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:textSize="16sp"
android:text="Complex"
android:background="#color/lessLightGreen"
android:gravity="center_vertical"
android:drawableStart="#drawable/google_maps"
android:drawablePadding="2dp"
android:textColor="#color/colorPrimaryText"/>
<TextView
android:id="#+id/destination"
android:layout_below="#id/pickup"
android:text="Golra"
android:visibility="visible"
android:drawableStart="#drawable/directions"
android:drawablePadding="2dp"
style="#style/listitem_secondary_text"/>
<TextView
android:id="#+id/person"
android:drawablePadding="2dp"
android:layout_below="#id/destination"
android:text="Asfandyar Khan"
android:drawableStart="#drawable/account"
style="#style/listitem_secondary_text"/>
<TextView
android:id="#+id/datetime"
android:layout_below="#id/person"
android:text="7th April 2017 at 9:00am"
android:drawableStart="#drawable/time"
style="#style/listitem_secondary_text"/>
<com.google.android.gms.maps.MapView
android:id="#+id/map_listitem"
android:layout_width="match_parent"
android:layout_height="170dp"
android:layout_marginTop="2dp"
android:layout_below="#id/datetime"
map:liteMode="true"
android:padding="10dp"/>
<LinearLayout
android:id="#+id/buttonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="#id/map_listitem"
android:gravity="end"
android:layout_margin="4dp">
<Button
android:backgroundTint="#color/colorPrimary"
android:textColor="#android:color/white"
android:id="#+id/acceptJob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Accept"/>
<Button
android:backgroundTint="#color/darkRed"
android:textColor="#android:color/white"
android:id="#+id/declineJob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Decline"/>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
I've tried various things but nothing seems to be working.
Try adding onResume, like this:
mapView.onCreate(null);
mapView.getMapAsync(this);
mapView.onResume();
Edit:
I've just noticed you are using
map:liteMode="true"
Try removing it (at least to test) or adding the following to the xml:
map:cameraZoom="15"
map:mapType="normal"
Either way, I think the onResume is needed.
When I use liteMode it sometimes takes a few seconds (about 5) for the map to show after the logo.
There might another issue in your code. The "map" should be:
xmlns:map="http://schemas.android.com/apk/res-auto"
but not:
xmlns:map="http://schemas.android.com/tools"
I am implementing recyclerview with swipe layout from right side using this. I have hide one of the child view in adapteron first position as you can see but problem is that once it hide successfully, blank white space show while swiping from right side.
Below is my adapter view.xml. Below I have attached image in which you can see the exact problem.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<!--for background layout-->
<LinearLayout
android:id="#+id/rowBG"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:orientation="horizontal">
<RelativeLayout
android:id="#+id/add"
android:layout_width="#dimen/swipeWidth"
android:layout_height="match_parent"
android:background="#color/swipeoption_blue"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="?android:selectableItemBackground"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_add_black_24dp"
android:tint="#android:color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="Add"
android:textColor="#android:color/white"
android:textSize="12sp"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/edit"
android:layout_width="#dimen/swipeWidth"
android:layout_height="match_parent"
android:background="#color/swipeoption_green"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="?android:selectableItemBackground"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_mode_edit_black_24dp"
android:tint="#android:color/white"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="Edit"
android:textColor="#android:color/white"
android:textSize="12sp"/>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/change"
android:layout_width="#dimen/swipeWidth"
android:layout_height="match_parent"
android:background="#color/swipeoption_purple"
android:clickable="true"
android:focusable="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="?android:selectableItemBackground"
android:gravity="center_vertical|left"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:tint="#android:color/white"
app:srcCompat="#drawable/ic_build_black_24dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:text="Change"
android:textColor="#android:color/white"
android:textSize="12sp"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<!--for Forground layout-->
<LinearLayout
android:id="#+id/rowFG"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:clickable="true"
android:elevation="4dp"
android:focusable="true"
android:orientation="horizontal"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingTop="16dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="6"
android:orientation="vertical">
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="No Calls Found"
android:textSize="16sp"
android:textStyle="bold"
tools:text="Row 1"/>
<TextView
android:id="#+id/subText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:maxLines="1"
tools:text="Some text ..."/>
</LinearLayout>
<Button
android:id="#+id/rowButton"
style="?attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:gravity="right|center_vertical"
android:text="Button"/>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#67676767"
android:elevation="5dp"/>
</RelativeLayout>
Here is my activity
public class MainActivity extends Activity implements RecyclerTouchListener.RecyclerTouchListenerHelper {
private RecyclerView mRecyclerView;
private ArrayList<MyModel> arrayList = new ArrayList<MyModel>();
private Adapter mAdapter;
protected Handler handler;
private MyModel model;
private int test = 1;
private Boolean flag = true;
private RecyclerTouchListener onTouchListener;
private OnActivityTouchListener touchListener;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);
setRecycler();
setTouchListner();
}
private void setTouchListner() {
onTouchListener = new RecyclerTouchListener(MainActivity.this, mRecyclerView);
onTouchListener
.setIndependentViews(R.id.rowButton)
.setViewsToFade(R.id.rowButton)
.setClickable(new RecyclerTouchListener.OnRowClickListener() {
#Override
public void onRowClicked(int position) {
Log.e("Row clicked ","!!!!!!!!");
}
#Override
public void onIndependentViewClicked(int independentViewID, int position) {
Toast.makeToast(getApplicationContext(), "Button in row " + (position + 1) + " clicked!");
}
})
.setLongClickable(true, new RecyclerTouchListener.OnRowLongClickListener() {
#Override
public void onRowLongClicked(int position) {
Log.e("Row Long clicked ","##########");
}
})
.setSwipeOptionViews(R.id.add, R.id.edit, R.id.change)
.setSwipeable(R.id.rowFG, R.id.rowBG, new RecyclerTouchListener.OnSwipeOptionsClickListener() {
#Override
public void onSwipeOptionClicked(int viewID, int position) {
String message = "";
if (viewID == R.id.add) {
Log.e("Add ", "Clicked ");
} else if (viewID == R.id.edit) {
Log.e("Edit ", "Clicked ");
}
Log.v("log", "POSSSSSSSSS: " + position);
}
});
}
private void setRecycler() {
createlist(); // in this method, Create a list of items.
final LinearLayoutManager layoutManager = new LinearLayoutManager(MainActivity.this);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mRecyclerView.setLayoutManager(layoutManager);
mRecyclerView.setHasFixedSize(true);
mAdapter = new Adapter(arrayList, mRecyclerView,MainActivity.this);
mRecyclerView.setAdapter(mAdapter);
handler = new Handler();
mAdapter.setOnLoadMoreListener(new Adapter.OnLoadMoreListener() {
#Override
public void onLoadMore() {
//add progress item
arrayList.add(null);
mAdapter.notifyItemInserted(arrayList.size() - 1);
handler.postDelayed(new Runnable() {
#Override
public void run() {
flag = false;
//remove progress item
arrayList.remove(arrayList.size() - 1);
mAdapter.notifyItemRemoved(arrayList.size());
createlist();
mAdapter.notifyItemInserted(arrayList.size());
mAdapter.setLoaded();
}
}, 2000);
System.out.println("load");
flag = true;
}
});
}
// this method is used to create list of items.
public void createlist() {
for (int i = 1; i <= 10; i++) {
model = new MyModel();
model.setStrFname("Testing" + test);
model.setStrLname("Testing");
arrayList.add(model);
test++;
}
}
// Below all methond is used for swipe from right using library.
#Override
public void setOnActivityTouchListener(OnActivityTouchListener listener) {
this.touchListener = listener;
}
#Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (flag) {
return false;
} else {
if (touchListener != null) {
touchListener.getTouchCoordinates(ev);
}
return super.dispatchTouchEvent(ev);
}
}
#Override
protected void onResume() {
super.onResume();
mRecyclerView.addOnItemTouchListener(onTouchListener);
}
#Override
protected void onPause() {
super.onPause();
mRecyclerView.removeOnItemTouchListener(onTouchListener);
}
}
and Here my adapter
public class Adapter<T> extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final int VIEW_ITEM = 1;
private final int VIEW_PROG = 0;
private List<MyModel> mDataset;
private MyModel model;
// The minimum amount of items to have below your current scroll position before loading more.
private int visibleThreshold = 2;
private int lastVisibleItem, totalItemCount;
private boolean loading;
private OnLoadMoreListener onLoadMoreListener;
private MainActivity mainActivity;
public Adapter(List<MyModel> myDataSet, RecyclerView recyclerView, MainActivity mainActivity) {
mDataset = myDataSet;
this.mainActivity = mainActivity;
if (recyclerView.getLayoutManager() instanceof LinearLayoutManager) {
final LinearLayoutManager linearLayoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
#Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
totalItemCount = linearLayoutManager.getItemCount();
lastVisibleItem = linearLayoutManager.findLastVisibleItemPosition();
if (!loading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
// End has been reached
// Do something
if (onLoadMoreListener != null) {
onLoadMoreListener.onLoadMore();
}
loading = true;
}
}
});
}
}
#Override
public int getItemViewType(int position) {
return mDataset.get(position) != null ? VIEW_ITEM : VIEW_PROG;
}
#Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
RecyclerView.ViewHolder vh;
if (viewType == VIEW_ITEM) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.recycler_row, parent, false);
vh = new TextViewHolder(itemView);
} else {
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.progressbar_item, parent, false);
vh = new ProgressViewHolder(v);
}
return vh;
}
#Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof TextViewHolder) {
Log.v("log", "POS: " + position);
// Here I have hide the first postion of recyclerView
if(position==1)
{
((TextViewHolder) holder).change.setVisibility(View.GONE);
}
model = mDataset.get(position);
holder.setIsRecyclable(false);
((TextViewHolder) holder).mainText.setText(model.getStrFname());
((TextViewHolder) holder).subText.setText(model.getStrLname());
} else {
((ProgressViewHolder) holder).progressBar.setIndeterminate(true);
}
}
public void setLoaded() {
loading = false;
}
#Override
public int getItemCount() {
return mDataset.size();
}
public void setOnLoadMoreListener(OnLoadMoreListener onLoadMoreListener) {
this.onLoadMoreListener = onLoadMoreListener;
}
public interface OnLoadMoreListener {
void onLoadMore();
}
public static class TextViewHolder extends RecyclerView.ViewHolder {
TextView mainText, subText;
RelativeLayout change;
LinearLayout rowBG;
public TextViewHolder(View itemView) {
super(itemView);
mainText = (TextView) itemView.findViewById(R.id.mainText);
subText = (TextView) itemView.findViewById(R.id.subText);
change = (RelativeLayout) itemView.findViewById(R.id.change);
rowBG = (LinearLayout) itemView.findViewById(R.id.rowBG);
}
}
public static class ProgressViewHolder extends RecyclerView.ViewHolder {
public ProgressBar progressBar;
public ProgressViewHolder(View v) {
super(v);
progressBar = (ProgressBar) v.findViewById(R.id.progressBar);
}
}
}