Search in sources :

Example 1 with AlbumEntity

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);
        }
    });
}
Also used : AlbumEntity(com.bilibili.boxing.model.entity.AlbumEntity) BoxingConfig(com.bilibili.boxing.model.config.BoxingConfig) IAlbumTaskCallback(com.bilibili.boxing.model.callback.IAlbumTaskCallback) ContentResolver(android.content.ContentResolver) Test(org.junit.Test)

Example 2 with AlbumEntity

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();
        }
    }
}
Also used : AlbumEntity(com.bilibili.boxing.model.entity.AlbumEntity) Cursor(android.database.Cursor)

Example 3 with AlbumEntity

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);
    }
}
Also used : AlbumEntity(com.bilibili.boxing.model.entity.AlbumEntity) ImageMedia(com.bilibili.boxing.model.entity.impl.ImageMedia)

Example 4 with AlbumEntity

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;
}
Also used : AlbumEntity(com.bilibili.boxing.model.entity.AlbumEntity) NonNull(android.support.annotation.NonNull)

Aggregations

AlbumEntity (com.bilibili.boxing.model.entity.AlbumEntity)4 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 NonNull (android.support.annotation.NonNull)1 IAlbumTaskCallback (com.bilibili.boxing.model.callback.IAlbumTaskCallback)1 BoxingConfig (com.bilibili.boxing.model.config.BoxingConfig)1 ImageMedia (com.bilibili.boxing.model.entity.impl.ImageMedia)1 Test (org.junit.Test)1