Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
174 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
51 changes: 50 additions & 1 deletion
51
app/src/main/java/com/joker/gankor/adapter/PicturePagerAdapter.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 |
---|---|---|
@@ -1,7 +1,56 @@ | ||
package com.joker.gankor.adapter; | ||
|
||
import android.content.Context; | ||
import android.support.v4.view.PagerAdapter; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
|
||
import com.joker.gankor.R; | ||
import com.joker.gankor.model.GankWelfare; | ||
import com.joker.gankor.utils.ImageUtil; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by joker on 2016/8/31. | ||
*/ | ||
public class PicturePagerAdapter { | ||
public class PicturePagerAdapter extends PagerAdapter { | ||
private List<GankWelfare.ResultsBean> bean; | ||
private LayoutInflater mInflater; | ||
|
||
public PicturePagerAdapter(Context context, List<GankWelfare.ResultsBean> bean) { | ||
this.bean = bean; | ||
mInflater = LayoutInflater.from(context); | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return bean.size(); | ||
} | ||
|
||
@Override | ||
public boolean isViewFromObject(View view, Object object) { | ||
return view == object; | ||
} | ||
|
||
@Override | ||
public Object instantiateItem(ViewGroup container, int position) { | ||
ImageView view = (ImageView) mInflater.inflate(R.layout.activity_picture_item, container, false); | ||
ImageUtil.getInstance().displayImage(bean.get(position).getUrl(), view); | ||
container.addView(view); | ||
|
||
return view; | ||
} | ||
|
||
@Override | ||
public void destroyItem(ViewGroup container, int position, Object object) { | ||
container.removeView((ImageView) object); | ||
} | ||
|
||
public void addList(List<GankWelfare.ResultsBean> beanList) { | ||
bean.addAll(beanList); | ||
notifyDataSetChanged(); | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ImageView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"> | ||
|
||
</ImageView> | ||
<ImageView | ||
android:id="@+id/iv_pic" | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_gravity="center"/> |