0
private class CustomPagerAdapter extends PagerAdapter {
private Context mContext;
private LayoutInflater mLayoutInflater;
private ImageView displayArt;
private ImageView songImage;
private TextView playerName;
private CustomPagerAdapter(Context context) {
mContext = context;
mLayoutInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return songList.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
View itemView = mLayoutInflater.inflate(R.layout.adapter_audio_player, container, false);
FieldIntialization(itemView);
updatePlayerView(position);
container.addView(itemView);
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((RelativeLayout) object);
}
private void FieldIntialization(View view) {
displayArt = (ImageView) view.findViewById(R.id.songImage);
songImage = (ImageView) view.findViewById(R.id.songDisplayArt);
playerName = (TextView) view.findViewById(R.id.songName);
}
@Override
public int getItemPosition(Object object) {
return PagerAdapter.POSITION_NONE;
}
private void updatePlayerView(int songIndex) {
playerName.setText(songList.get(songIndex).getPlayerTitle());
displayArt.setScaleType(ImageView.ScaleType.FIT_XY);
final String contentURI = "content://media/external/audio/media/" + songList.get(songIndex).getPlayerId() + "/albumart";
Glide.with(getApplicationContext()).load(contentURI).dontAnimate().
error(R.drawable.music_player_background)
.bitmapTransform(new BlurTransformation(getApplicationContext()))
.into(displayArt);
songImage.setScaleType(ImageView.ScaleType.FIT_XY);
Bitmap originalBitmap = null;
try {
originalBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), Constants.getDefaultAlbumUri(
String.valueOf(songList.get(songIndex).getPlayerAlbumId())
));
} catch (IOException e) {
e.printStackTrace();
}
if ((originalBitmap == null || originalBitmap.equals(""))) {
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.no_photo);
RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(getResources(), largeIcon);
roundDrawable.setCircular(true);
songImage.setImageDrawable(roundDrawable);
} else {
RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.create(getResources(), originalBitmap);
roundDrawable.setCircular(true);
songImage.setImageDrawable(roundDrawable);
}
}
}
私はviewpager.Iは、誰もが与えるimages.pls表示するためにグライドを使用スワイプするとき丸いimage.iと背景が遅れabove.Itsのように行われてきたようにぼやけた画像を表示する必要があります私はsoln.Thanks事前にラグ
ok.canを使用することができますか? –
はい、ビットマップ操作を別のスレッドに入れることは常に良い考えです –