'RecyclerViewAdapter lags with mapview

I'm facing an issue regarding RecyclerViewAdapter. I'm using fragments, i have 4 fragments. 3 fragments are working fine with no lags. but in 4th fragment, i used mapview and my recyclerViewslows down means not a smooth scrolling as previous fragments when i scroll.

Here is my recyclerViewAdapter:

public class VenturesAdapter extends RecyclerView.Adapter<VenturesAdapter.MyViewHolder>{
    Context mContext;
    List<venturesPojo> venturesList=new ArrayList<>();
    OnBottomReachedListener onBottomReachedListener;
    GoogleMap googleMap1;



    public class MyViewHolder extends RecyclerView.ViewHolder

    {

        TextView title,description,address;
        ImageView logo;
        Button viewWeb;
        private MapView mapView;
        public MyViewHolder(View itemView) {
            super(itemView);

            title = (TextView) itemView.findViewById(R.id.title);
            description = (TextView) itemView.findViewById(R.id.description);
            address = (TextView) itemView.findViewById(R.id.address);
            logo = (ImageView) itemView.findViewById(R.id.logo);
            viewWeb = (Button) itemView.findViewById(R.id.viewWebsites);
            mapView = (MapView) itemView.findViewById(R.id.mapView);
            description.setMovementMethod(new ScrollingMovementMethod());
            description.setNestedScrollingEnabled(true);
            description.setVerticalScrollBarEnabled(true);
            description.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    // Disallow the touch request for parent scroll on touch of child view
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });
        }


    }

    public VenturesAdapter(Context mContext, List<venturesPojo> venturesList) {
        this.mContext = mContext;
        this.venturesList = venturesList;
    }

    @Override
    public VenturesAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.single_ventures_list, parent, false);
        return new VenturesAdapter.MyViewHolder(itemView);
    }

    public void setOnBottomReachedListener(OnBottomReachedListener onBottomReachedListener) {
        this.onBottomReachedListener = onBottomReachedListener;
    }
    @Override
    public void onBindViewHolder(VenturesAdapter.MyViewHolder holder, int position) {
        venturesPojo venturesPojo=venturesList.get(position);

        if (position ==venturesList.size() - 2  ){

            onBottomReachedListener.onBottomReached(position);

        }
        holder.mapView.onCreate(null);

        holder.mapView.onResume();

     final   String lat=venturesPojo.getLatitude();
     final   String lng=venturesPojo.getLongitude();

     if(!TextUtils.isEmpty(lat) || !TextUtils.isEmpty(lng)) {
         final LatLng target=new LatLng(Double.parseDouble(lat),Double.parseDouble(lng));

         holder.mapView.getMapAsync(new OnMapReadyCallback() {
             @Override
             public void onMapReady(GoogleMap googleMap) {
                 googleMap1=googleMap;
                 googleMap.addMarker(new MarkerOptions().position(target));
                 googleMap.getUiSettings().setZoomControlsEnabled(true);
                 googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(target,16));
                 googleMap.animateCamera(CameraUpdateFactory.zoomIn());
                 googleMap.animateCamera(CameraUpdateFactory.zoomTo(16), 1500, null);

             }
         });
     }

        holder.title.setText(venturesPojo.getAgency_name());
        holder.description.setText(Html.escapeHtml(venturesPojo.getDescription()));
        holder.address.setText(venturesPojo.getAddress());




        if(!TextUtils.isEmpty(Config.agencyLogo+venturesPojo.getLogo().trim()))
        {
            String logoUrl=Config.agencyLogo+venturesPojo.getLogo().replace(" ","%20");
            Log.d("images",logoUrl);
            Glide
                    .with(mContext)
                    .load(logoUrl)
                    .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.RESOURCE))
                    .into(holder.logo);
        }
        else
        {
            holder.logo.setImageResource(R.drawable.thum);
        }


    }


    @Override
    public int getItemCount() {
        return venturesList.size();
    }

    @Override
    public void onViewRecycled(MyViewHolder holder) {

        if(googleMap1!=null)
        {
           googleMap1.clear();
           googleMap1.setMapType(GoogleMap.MAP_TYPE_NONE);
        }
    }
}

i added onViewRecycled because when i searched some members gave this solution but didn't work for me, still lags.



Solution 1:[1]

You can reach some performance improvements by applying the following:

recyclerView.setHasFixedSize(true);
recyclerView.setDrawingCacheEnabled(true);

..in combination with lite mode of MapsView:

<com.google.android.gms.maps.MapView
        ...
        app:liteMode="true"
        app:mapType="normal" />

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 goemic