-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.抽离基类BaseViewPagerAdapter,图片加载也抽象成一个方法。具体的加载需要实现一个BaseViewPagerAdapter
2.传入的参数设置为泛型,可以直接传URL地址,也可以传对象集合
- Loading branch information
Showing
12 changed files
with
298 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
###AutoViewPager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/src/main/java/com/kcode/autoviewpager/PictureViewPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.kcode.autoviewpager; | ||
|
||
import android.content.Context; | ||
import android.support.v4.view.ViewPager; | ||
import android.widget.ImageView; | ||
|
||
import com.kcode.autoscrollviewpager.view.AutoViewPager; | ||
import com.kcode.autoscrollviewpager.view.BaseViewPagerAdapter; | ||
import com.kcode.autoviewpager.bean.Picture; | ||
import com.squareup.picasso.Picasso; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by caik on 2016/10/11. | ||
*/ | ||
|
||
public class PictureViewPagerAdapter extends BaseViewPagerAdapter<Picture> implements ViewPager.OnPageChangeListener{ | ||
|
||
|
||
private Context mContext; | ||
|
||
public PictureViewPagerAdapter(Context context, AutoViewPager viewPager) { | ||
super(context,viewPager); | ||
mContext = context; | ||
} | ||
|
||
public PictureViewPagerAdapter(Context context, AutoViewPager viewPager, OnAutoViewPagerItemClickListener listener) { | ||
super(context, viewPager, listener); | ||
this.mContext = context; | ||
} | ||
|
||
@Override | ||
public void loadImage(ImageView view, int position, Picture picture) { | ||
Picasso.with(mContext).load(picture.getPath()).into(view); | ||
} | ||
|
||
public PictureViewPagerAdapter(Context context, List<Picture> data, AutoViewPager viewPager, OnAutoViewPagerItemClickListener listener) { | ||
super(context, data, viewPager, listener); | ||
this.mContext = context; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/kcode/autoviewpager/ViewPagerAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.kcode.autoviewpager; | ||
|
||
import android.content.Context; | ||
import android.support.v4.view.ViewPager; | ||
import android.widget.ImageView; | ||
|
||
import com.kcode.autoscrollviewpager.view.AutoViewPager; | ||
import com.kcode.autoscrollviewpager.view.BaseViewPagerAdapter; | ||
import com.squareup.picasso.Picasso; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by caik on 2016/10/11. | ||
*/ | ||
|
||
public class ViewPagerAdapter extends BaseViewPagerAdapter<String> implements ViewPager.OnPageChangeListener{ | ||
|
||
|
||
private Context mContext; | ||
|
||
public ViewPagerAdapter(Context context, AutoViewPager viewPager) { | ||
super(context,viewPager); | ||
mContext = context; | ||
} | ||
|
||
public ViewPagerAdapter(Context context, AutoViewPager viewPager, OnAutoViewPagerItemClickListener listener) { | ||
super(context, viewPager, listener); | ||
this.mContext = context; | ||
} | ||
|
||
public ViewPagerAdapter(Context context, List<String> data, AutoViewPager viewPager, OnAutoViewPagerItemClickListener listener) { | ||
super(context, data, viewPager, listener); | ||
this.mContext = context; | ||
} | ||
|
||
@Override | ||
public void loadImage(ImageView view, int position, String url) { | ||
Picasso.with(mContext).load(url).into(view); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
app/src/main/java/com/kcode/autoviewpager/bean/Picture.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.kcode.autoviewpager.bean; | ||
|
||
/** | ||
* Created by caik on 2016/10/19. | ||
*/ | ||
|
||
public class Picture { | ||
private String path; | ||
private String name; | ||
|
||
public Picture(String path, String name) { | ||
this.path = path; | ||
this.name = name; | ||
} | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public void setPath(String path) { | ||
this.path = path; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.