i am making android app using Rest Api and date getting from my WordPress Website , all works fine , i have added AdMob ads between content and when its loading page 2 from page 1 there is ProgressBar showing that "Posts Are Loading" at the bottom , now the problem is that when ProgressBar and Ads comes to same number than ProgressBar hides under AdMob ads , i mean it doesn’t show than , how can i make it visible and should be visible after ad ?
this is my code in Adapter
public RecyclerView.ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
mContext = parent.getContext();
if (viewType == AD) {
adview = new AdView(mContext);
adview.setAdSize( AdSize.LARGE_BANNER);
adview.setAdUnitId(mContext.getResources().getString(R.string.banner_ad_unit_id));
float density = mContext.getResources().getDisplayMetrics().density;
int height = Math.round(AdSize.LARGE_BANNER.getHeight() * density);
AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.FILL_PARENT, height);
adview.setLayoutParams(params);
new RequestConfiguration.Builder().setTestDeviceIds(Arrays.asList("C5468C2B8941779E34B14EB796B9EA1B"));
AdRequest request = new AdRequest.Builder().build();
adview.loadAd(request);
return new Holder(adview);
}
if (viewType == viewTypeData){
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.post_list,parent,false);
return new MyDataHolder(view);
}else {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_loading,parent,false);
return new MyProgressHolder(view);
}
}
private int getRealPosition(int position) {
if (LIST_AD_DELTA == 0) {
return position;
} else {
return position - position / LIST_AD_DELTA;
}
}
@Override
public int getItemCount() {
return dataset.size();
}
@Override
public int getItemViewType(int position){
if (position > 0 && position % LIST_AD_DELTA == 0) {
return AD;
}
else if (dataset.get(position).title.equals("progress")) {
return viewTypeProgress;
}
return viewTypeData;
}
void showHideProgress(boolean shouldShowProgress){
if (shouldShowProgress){
dataset.add(new Model("progress","","","","","","","","",""));
Handler handler = new Handler();
final Runnable r = new Runnable() {
public void run() {
notifyItemInserted(dataset.size()-1);
}
};
handler.post(r);
}else {
dataset.remove(dataset.size()-1);
notifyItemRemoved(dataset.size()-1);
}
}
i have tried to change LIST_AD_DELTA numbers but still no gain
int viewTypeData = 0,viewTypeProgress = 2 ;
private static final int AD = 1;
private static final int LIST_AD_DELTA = 4;