@@ -0,0 +1,2285 @@
+package com.wlz.adslibrary;%0A%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.net.Uri;%0Aimport android.os.Parcelable;%0Aimport android.support.v4.view.PagerAdapter;%0Aimport android.support.v4.view.ViewPager;%0Aimport android.util.Log;%0Aimport android.view.View;%0Aimport android.view.View.OnClickListener;%0Aimport android.view.ViewGroup.LayoutParams;%0Aimport android.webkit.URLUtil;%0Aimport android.widget.ImageView;%0Aimport android.widget.ImageView.ScaleType;%0A%0Aimport com.bumptech.glide.Glide;%0Aimport com.bumptech.glide.load.engine.DiskCacheStrategy;%0A%0Aimport java.util.ArrayList;%0A%0Aclass AdsPagerAdapter extends PagerAdapter %7B%0A%0A%09private Context context;%0A%0A%09private ArrayList%3CAds%3E objects = new ArrayList%3CAds%3E();%0A%0A%0A%09AdsPagerAdapter(Context c, ArrayList%3CAds%3E objects) %7B%0A%09%09context = c;%0A        this.objects = objects;%0A%09%7D%0A%0A%09public Object instantiateItem(View collection, int position) %7B%0A%09%09Ads d = objects.get(position);%0A%0A%09%09View v = getDetailView(position, d);%0A%0A%09%09((ViewPager) collection).addView(v, 0);%0A%09%09return v;%0A%09%7D%0A%0A%09private View getDetailView(int position, final Ads p) %7B%0A%0A%09%09ImageView v = new ImageView(context);%0A%09%09v.setScaleType(ScaleType.FIT_XY);%0A%09%09v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));%0A        Glide.with(context)%0A                .load(p.image_url)%0A                .diskCacheStrategy(DiskCacheStrategy.ALL)%0A                .into(v);%0A%0A%09%09v.setOnClickListener(new OnClickListener() %7B%0A%0A%09%09%09@Override%0A%09%09%09public void onClick(View v) %7B%0A%09%09%09%09catchLog(p.link_url);%0A%09%09%09%09if(URLUtil.isValidUrl(p.link_url))%7B%0A%09%09%09%09%09Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(p.link_url));%0A%09%09%09%09%09context.startActivity(browserIntent);%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);%0A%0A%09%09return v;%0A%09%7D%0A%0A%09@Override%0A%09public int getCount() %7B%0A%09%09return objects.size();%0A%09%7D%0A%0A%09@Override%0A%09public void destroyItem(View collection, int position, Object view) %7B%0A%09%09((ViewPager) collection).removeView((View) view);%0A%09%7D%0A%0A%09@Override%0A%09public boolean isViewFromObject(View view, Object object) %7B%0A%09%09return view == ((View) object);%0A%09%7D%0A%0A%09@Override%0A%09public void restoreState(Parcelable arg0, ClassLoader arg1) %7B%0A%09%7D%0A%0A%09@Override%0A%09public Parcelable saveState() %7B%0A%09%09return null;%0A%09%7D%0A%0A%09private void catchLog(String log) %7B%0A%09%09if(BuildConfig.DEBUG) Log.i(getClass().getSimpleName(), log);%0A%09%7D%0A%7D%0A

Add Ads Pager Adapter