So basically I have maybe 50 records with images & text etc. There isn't too much data to be loaded in each list item but when I call setAdapter it is taking atleast 8 seconds to load only the first 3 items which are visible to the end user. I added logs and found that getView() in adapter is getting called twice. Is there any way I can reduce this time?
Before any one asks, I cannot use AsyncTask since I need to call setAdapter in main thread and the problem still occurs.
Would using a RecycleView make this a little more efficient? I understand that RecycleView is the next version of listView but I was not able to see any particular difference when it comes to setting the adapter.
Any help is appreciated! Thanks
UPDATE: This is my adapter code:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final ViewHolder view;
if (convertView == null) {
view = new ViewHolder();
convertView = layoutInflater.inflate(R.layout.fragment_test, null);
view.inActiveView = convertView.findViewById(R.id.front);
view.inActiveRewardTxt = (TextView) convertView.findViewById(R.id.status_lock_reward);
view.inActiveTitleTxt = (TextView) convertView.findViewById(R.id.status_lock_title);
view.completedView = convertView.findViewById(R.id.offerTitlePanel);
view.activeView = convertView.findViewById(R.id.back);
view.offerNumberTxt = (TextView) convertView.findViewById(R.id.offerNumberTxt);
view.walletView = convertView.findViewById(R.id.offerWalletPanel);
view.walletGiftView = (ImageView) convertView.findViewById(R.id.offerGiftImg);
view.rewardTxt = (TextView) convertView.findViewById(R.id.offerWalletRibbonTxt);
view.offerTitleTxt = (TextView) convertView.findViewById(R.id.offerTitleTxt);
view.offerDescTxt = (TextView) convertView.findViewById(R.id.pagerDescTaskTxt);
view.offerActionTxt = (TextView) convertView.findViewById(R.id.offerActionTxt);
view.offerTimerTxt = (TextView) convertView.findViewById(R.id.offerTimerTxt);
view.offerStatusBtn = (TextView) convertView.findViewById(R.id.offerStatusBtn);
view.offerReportBtn = (TextView) convertView.findViewById(R.id.offerReportBtn);
view.dataProgressBar = (ProgressBar) convertView.findViewById(R.id.data_loader);
view.dataLoadedView = convertView.findViewById(R.id.loaded_view);
view.calendarView = (CalendarView) convertView.findViewById(R.id.calendar_view);
view.dataView = convertView.findViewById(R.id.dataView);
view.dataInfoTxt = (TextView) convertView.findViewById(R.id.dataInfoTxt);
view.dataEarnedTxt = (TextView) convertView.findViewById(R.id.dataEarnedTxt);
view.dataProgress = (ProgressBar) convertView.findViewById(R.id.dataProgress);
convertView.setTag(view);
} else {
view = (ViewHolder) convertView.getTag();
}
//display all the values here
return convertView;