use of com.bilibili.boxing.model.entity.AlbumEntity in project boxing by Bilibili.
the class PickerModuleTest method testLoadImage.
@Test
public void testLoadImage() {
assertNotNull(mPickerManager);
mPickerManager.setBoxingConfig(new BoxingConfig(BoxingConfig.Mode.MULTI_IMG));
BoxingConfig config = mPickerManager.getBoxingConfig();
assertNotNull(config);
Assert.assertEquals(config.getMode(), BoxingConfig.Mode.MULTI_IMG);
ContentResolver cr = RuntimeEnvironment.application.getContentResolver();
assertNotNull(cr);
mPickerManager.loadAlbum(cr, new IAlbumTaskCallback() {
@Override
public void postAlbumList(List<AlbumEntity> list) {
assertNotNull(list);
}
});
}
use of com.bilibili.boxing.model.entity.AlbumEntity in project boxing by Bilibili.
the class AlbumTask method buildAlbumInfo.
private void buildAlbumInfo(ContentResolver cr) {
String[] distinctBucketColumns = new String[] { Media.BUCKET_ID, Media.BUCKET_DISPLAY_NAME };
Cursor bucketCursor = null;
try {
bucketCursor = cr.query(Media.EXTERNAL_CONTENT_URI, distinctBucketColumns, "0==0)" + " GROUP BY(" + Media.BUCKET_ID, null, Media.DATE_MODIFIED + " desc");
if (bucketCursor != null && bucketCursor.moveToFirst()) {
do {
String buckId = bucketCursor.getString(bucketCursor.getColumnIndex(Media.BUCKET_ID));
String name = bucketCursor.getString(bucketCursor.getColumnIndex(Media.BUCKET_DISPLAY_NAME));
AlbumEntity album = buildAlbumInfo(name, buckId);
if (!TextUtils.isEmpty(buckId)) {
buildAlbumCover(cr, buckId, album);
}
} while (bucketCursor.moveToNext() && !bucketCursor.isLast());
}
} finally {
if (bucketCursor != null) {
bucketCursor.close();
}
}
}
use of com.bilibili.boxing.model.entity.AlbumEntity in project boxing by Bilibili.
the class BoxingAlbumAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final AlbumViewHolder albumViewHolder = (AlbumViewHolder) holder;
albumViewHolder.mCoverImg.setImageResource(R.drawable.ic_default_image);
final int adapterPos = holder.getAdapterPosition();
final AlbumEntity album = mAlums.get(adapterPos);
if (album != null && album.hasImages()) {
albumViewHolder.mNameTxt.setText(album.mBucketName);
ImageMedia media = (ImageMedia) album.mImageList.get(0);
if (media != null) {
BoxingMediaLoader.getInstance().displayThumbnail(albumViewHolder.mCoverImg, media.getPath(), 50, 50);
}
albumViewHolder.mLayout.setTag(adapterPos);
albumViewHolder.mLayout.setOnClickListener(this);
albumViewHolder.mCheckedImg.setVisibility(album.mIsSelected ? View.VISIBLE : View.GONE);
albumViewHolder.mSizeTxt.setText(albumViewHolder.mSizeTxt.getResources().getString(R.string.album_images_fmt, album.mCount));
} else {
albumViewHolder.mNameTxt.setText(UNKNOW_ALBUM_NAME);
albumViewHolder.mSizeTxt.setVisibility(View.GONE);
}
}
use of com.bilibili.boxing.model.entity.AlbumEntity in project boxing by Bilibili.
the class AlbumTask method buildAlbumInfo.
@NonNull
private AlbumEntity buildAlbumInfo(String bucketName, String bucketId) {
AlbumEntity album = null;
if (!TextUtils.isEmpty(bucketId)) {
album = mBucketMap.get(bucketId);
}
if (album == null) {
album = new AlbumEntity();
if (!TextUtils.isEmpty(bucketId)) {
album.mBucketId = bucketId;
} else {
album.mBucketId = String.valueOf(mUnknownAlbumNumber);
mUnknownAlbumNumber++;
}
if (!TextUtils.isEmpty(bucketName)) {
album.mBucketName = bucketName;
} else {
album.mBucketName = UNKNOWN_ALBUM_NAME;
mUnknownAlbumNumber++;
}
if (album.mImageList.size() > 0) {
mBucketMap.put(bucketId, album);
}
}
return album;
}
Aggregations