77 lines
2.2 KiB
Java
77 lines
2.2 KiB
Java
package fishrungames.bashgid;
|
|
|
|
import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
|
|
|
|
import fishrungames.networkutils.ImageManager;
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.support.v4.view.PagerAdapter;
|
|
import android.support.v4.view.ViewPager;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
|
|
public class PhotoFragmentAdapter extends PagerAdapter {
|
|
|
|
private Context context;
|
|
|
|
AlbumFullData album;
|
|
|
|
//int currentPhoto;
|
|
|
|
public PhotoFragmentAdapter(Context context, AlbumFullData album/*, int currentPhoto*/) {
|
|
this.context = context;
|
|
this.album = album;
|
|
//this.currentPhoto = currentPhoto;
|
|
}
|
|
|
|
@Override
|
|
public int getCount() {
|
|
return album.photoRecordArr.size();
|
|
}
|
|
|
|
@Override
|
|
public boolean isViewFromObject(View view, Object object) {
|
|
return view == ((LinearLayout) object);
|
|
}
|
|
|
|
@Override
|
|
public Object instantiateItem(ViewGroup container, int position) {
|
|
|
|
|
|
|
|
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
View viewLayout = inflater.inflate(R.layout.photo_page_element, container,
|
|
false);
|
|
|
|
TextView titleTextView = (TextView) viewLayout.findViewById(R.id.titleTextView);
|
|
|
|
titleTextView.setText(album.photoRecordArr.get(position).title);
|
|
|
|
TextView descriptionTextView = (TextView) viewLayout.findViewById(R.id.descriptionTextView);
|
|
|
|
descriptionTextView.setText(album.photoRecordArr.get(position).description);
|
|
|
|
|
|
ImageView image = (ImageView) viewLayout.findViewById(R.id.image);
|
|
|
|
ImageManager.getInstance().ApplyImageToImageView(image, album.photoRecordArr.get(position).imageUrl);
|
|
|
|
((ViewPager) container).addView(viewLayout);
|
|
|
|
return viewLayout;
|
|
}
|
|
|
|
@Override
|
|
public void destroyItem(ViewGroup container, int position, Object object) {
|
|
((ViewPager) container).removeView((LinearLayout) object);
|
|
|
|
}
|
|
} |