1
  • I'm using Recyclerview to load more than 200 datas to display in home page.

  • Volley taking 3 minutes loader initially.then after three to four seconds, recycler view loading more than 200 datas in adapter.So totally it takes seven seconds to load the image contents to display it into UI in home page.

  • But I have to load images in only three seconds.is it possible to do? If I get any suggestion regarding to this it will be helpful to me.

HomeActivity.java:

        if(createdBy.equals("event")){

            String eventName = jsonObject.getString("name");
            String eventDate = jsonObject.getString("event_date");
            String eventMonthYear = jsonObject.getString("event_date_year");
            String eventLocation = jsonObject.getString("location");

            homePostItems.setEventPost(createdBy);
            homePostItems.setEventName(eventName);
            homePostItems.setEventDate(eventDate);
            homePostItems.setEventMonthYear(eventMonthYear);
            homePostItems.setEventLocation(eventLocation);

            }

            if(createdBy.equals("post")){

             homePostItems.setPostData(createdBy);

              }

           homePostItems.setSharePopup("socialAndGolive");

           homePostItemsList.add(homePostItems);

           homePostitemsAdapter.notifyDataSetChanged();

HomeAdapter.java:

 @Override
    public void onBindViewHolder(final MyViewHolder holder, int position) {


    if (rowItem.getEventPost() != null) {
        if (rowItem.getEventPost().equals("event")) {

            holder.rlPostItems.setVisibility(View.GONE);
            holder.ivPostFlag.setVisibility(View.GONE);
            holder.userMenuImage.setVisibility(View.GONE);
            holder.ivPostedImage.setClickable(false);
            holder.rlEventDetails.setVisibility(View.VISIBLE);
            holder.tvSubtitle.setText("Event");
            holder.tvDateEvent.setText(rowItem.getEventDate());
            holder.tvMonthYearEvent.setText(rowItem.getEventMonthYear());
            holder.tvNameEvent.setText(rowItem.getEventName());
            holder.tvAddressEvent.setText(rowItem.getEventLocation());

            Typeface typeDate = Typeface.createFromAsset(context.getAssets(), "kausan.otf");
            holder.tvDateEvent.setTypeface(typeDate);

            Typeface typeName = Typeface.createFromAsset(context.getAssets(), "abz.ttf");
            holder.tvMonthYearEvent.setTypeface(typeName);


        } else {

            holder.rlEventDetails.setVisibility(View.GONE);

        }

    } else {
        holder.rlEventDetails.setVisibility(View.GONE);
    }
  }
Steve
  • 9,114
  • 15
  • 82
  • 133
  • Do not load your 200 items at once, load only datas which is enough to fill your Recyclerview, then when the user scrolls unto it then thats another time to download another batch of data until you completed your 200 items. When the user doesn't scroll that much then there is no point to complete downloading all 200 items. – Enzokie Oct 07 '16 at 10:53
  • @Enzokie ok.let me try that suggestion and tell you. – Steve Oct 07 '16 at 11:12

1 Answers1

0
  • Actual process of recycler view not loading all the images initially.For Example, I'm having more than 300 images to load in home page.

  • Recyclerview won't load all images initially.I used NestedSCrollView inside recyclerview.So that all 300 images will load initially.it took 7 seconds more to load the home page.

  • Removing nested scroll view solved my issue.You can refer this and this to understand when pagenation with recyclerview also not working when using nested scroll view.

Community
  • 1
  • 1
Steve
  • 9,114
  • 15
  • 82
  • 133