use of com.ningcui.mylibrary.viewLib.Imagepicker.decoration.GridSpacingItemDecoration in project JustAndroid by chinaltz.
the class PictureSelectorActivity method initView.
/**
* init views
*/
private void initView(Bundle savedInstanceState) {
preview_textColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_preview_textColor);
complete_textColor = AttrsUtils.getTypeValueColor(this, R.attr.picture_complete_textColor);
rl_picture_title = (RelativeLayout) findViewById(R.id.rl_picture_title);
picture_left_back = (ImageView) findViewById(R.id.picture_left_back);
picture_title = (TextView) findViewById(R.id.picture_title);
picture_right = (TextView) findViewById(R.id.picture_right);
picture_tv_ok = (TextView) findViewById(R.id.picture_tv_ok);
picture_id_preview = (TextView) findViewById(R.id.picture_id_preview);
picture_tv_img_num = (TextView) findViewById(R.id.picture_tv_img_num);
picture_recycler = (RecyclerView) findViewById(R.id.picture_recycler);
rl_bottom = (RelativeLayout) findViewById(R.id.rl_bottom);
id_ll_ok = (LinearLayout) findViewById(R.id.id_ll_ok);
tv_empty = (TextView) findViewById(R.id.tv_empty);
rl_bottom.setVisibility(selectionMode == PictureConfig.SINGLE ? View.GONE : View.VISIBLE);
isNumComplete(numComplete);
if (mimeType == PictureMimeType.ofAll()) {
popupWindow = new PhotoPopupWindow(this);
popupWindow.setOnItemClickListener(this);
}
picture_id_preview.setOnClickListener(this);
picture_id_preview.setVisibility(mimeType == PictureConfig.TYPE_VIDEO ? View.GONE : View.VISIBLE);
picture_left_back.setOnClickListener(this);
picture_right.setOnClickListener(this);
id_ll_ok.setOnClickListener(this);
picture_title.setOnClickListener(this);
picture_title.setText(getString(R.string.picture_camera_roll));
folderWindow = new FolderPopWindow(this);
folderWindow.setPictureTitleView(picture_title);
folderWindow.setOnItemClickListener(this);
picture_recycler.setHasFixedSize(true);
picture_recycler.addItemDecoration(new GridSpacingItemDecoration(spanCount, ScreenUtils.dip2px(this, 2), false));
picture_recycler.setLayoutManager(new GridLayoutManager(this, spanCount));
// 解决调用 notifyItemChanged 闪烁问题,取消默认动画
((SimpleItemAnimator) picture_recycler.getItemAnimator()).setSupportsChangeAnimations(false);
mediaLoader = new LocalMediaLoader(this, mimeType, isGif, videoSecond);
rxPermissions.request(Manifest.permission.READ_EXTERNAL_STORAGE).subscribe(new Observer<Boolean>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Boolean aBoolean) {
showPleaseDialog();
if (aBoolean) {
readLocalMedia();
} else {
showToast(getString(R.string.picture_jurisdiction));
dismissDialog();
}
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
StringUtils.tempTextFont(tv_empty);
if (savedInstanceState != null) {
// 防止拍照内存不足时activity被回收,导致拍照后的图片未选中
selectionMedias = PictureSelector.obtainSelectorList(savedInstanceState);
}
adapter = new PictureImageGridAdapter(mContext, config);
adapter.bindSelectImages(selectionMedias);
changeImageNumber(selectionMedias);
picture_recycler.setAdapter(adapter);
adapter.setOnPhotoSelectChangedListener(PictureSelectorActivity.this);
String titleText = picture_title.getText().toString().trim();
if (isCamera) {
isCamera = StringUtils.isCamera(titleText);
}
}
Aggregations