use of org.litepal.crud.callback.SaveCallback in project GomoTest by suReZj.
the class MainActivity method setListener.
private void setListener() {
springView.setListener(new SpringView.OnFreshListener() {
@Override
public void onRefresh() {
}
@Override
public void onLoadmore() {
setImage(++page);
}
});
adapter.setOnItemClickLitener(new main_recycle_adapter.OnItemClickLitener() {
@Override
public void onItemClick(final View view, final int position) {
imageUrl = list.get(position);
// intent.putStringArrayListExtra("list", list);
DataSupport.saveAllAsync(showList).listen(new SaveCallback() {
@Override
public void onFinish(boolean success) {
Log.e("showList", showList.size() + "");
Intent intent = new Intent(MainActivity.this, ShowActivity.class);
intent.putExtra("position", position);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(MainActivity.this, view, "shareNames").toBundle());
} else {
startActivity(intent);
}
}
});
}
@Override
public void onItemLongClick(View view, int position) {
}
});
toolbar.setOnTouchListener(new OnDoubleClickListener(new OnDoubleClickListener.DoubleClickCallback() {
@Override
public void onDoubleClick() {
recyclerView.scrollToPosition(0);
}
}));
}
use of org.litepal.crud.callback.SaveCallback in project GomoTest by suReZj.
the class SelectActivity method getData.
public void getData() {
final List<AlbumBean> list = new ArrayList<>();
allPhotosTemp = new HashMap<>();
albumName = new ArrayList<>();
new Thread(new Runnable() {
@Override
public void run() {
String[] projImage = { MediaStore.Images.Media._ID, MediaStore.Images.Media.DATA, MediaStore.Images.Media.SIZE, MediaStore.Images.Media.DISPLAY_NAME };
Cursor mCursor = getContentResolver().query(mImageUri, projImage, MediaStore.Images.Media.MIME_TYPE + "=? or " + MediaStore.Images.Media.MIME_TYPE + "=? or " + MediaStore.Images.Media.MIME_TYPE + "=? or " + MediaStore.Images.Media.MIME_TYPE + "=?", new String[] { "image/jpeg", "image/png", "image/jpg", "image/bmp" }, MediaStore.Images.Media.DATE_MODIFIED + " desc");
if (mCursor != null) {
while (mCursor.moveToNext()) {
// 获取图片的路径
String path = mCursor.getString(mCursor.getColumnIndex(MediaStore.Images.Media.DATA));
int size = mCursor.getInt(mCursor.getColumnIndex(MediaStore.Images.Media.SIZE)) / 1024;
String displayName = mCursor.getString(mCursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME));
// 用于展示相册初始化界面
mediaBeen.add(new MediaBean(path, size, displayName));
// 获取该图片的父路径名
String dirPath = new File(path).getParentFile().getAbsolutePath();
// 存储对应关系
AlbumBean bean = new AlbumBean();
if (allPhotosTemp.containsKey(dirPath)) {
List<MediaBean> data = allPhotosTemp.get(dirPath);
data.add(new MediaBean(path, size, displayName));
bean.setAlbumName(dirPath);
bean.setPath(path);
list.add(bean);
continue;
} else {
albumName.add(dirPath);
List<MediaBean> data = new ArrayList<>();
data.add(new MediaBean(path, size, displayName));
allPhotosTemp.put(dirPath, data);
bean.setAlbumName(dirPath);
bean.setPath(path);
list.add(bean);
}
}
mCursor.close();
}
// 更新界面
runOnUiThread(new Runnable() {
@Override
public void run() {
adapter = new select_recycle_adapter(allPhotosTemp, albumName);
recyclerView.setAdapter(adapter);
recyclerView.setLayoutManager(new LinearLayoutManager(SelectActivity.this));
DataSupport.deleteAll(AlbumBean.class);
DataSupport.saveAllAsync(list).listen(new SaveCallback() {
@Override
public void onFinish(boolean success) {
if (flag) {
EventBus.getDefault().post(event);
flag = false;
}
}
});
adapter.setOnItemClickLitener(new select_recycle_adapter.OnItemClickLitener() {
@Override
public void onItemClick(View view, int position) {
Intent intent = new Intent(SelectActivity.this, AlbumActivity.class);
String name = albumName.get(position);
intent.putExtra("name", name);
startActivity(intent);
}
@Override
public void onItemLongClick(View view, int position) {
}
});
}
});
}
}).start();
}
use of org.litepal.crud.callback.SaveCallback in project GomoTest by suReZj.
the class AlbumActivity method setListener.
public void setListener() {
adapter.setOnItemClickLitener(new album_recycle_adapter.OnItemClickLitener() {
@Override
public void onItemClick(final View view, final int position) {
albumPath = list.get(position).getPath();
DataSupport.saveAllAsync(urlList).listen(new SaveCallback() {
@Override
public void onFinish(boolean success) {
Intent showItent = new Intent(AlbumActivity.this, AlbumDetailActivity.class);
showItent.putExtra("position", position);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
startActivity(showItent, ActivityOptions.makeSceneTransitionAnimation(AlbumActivity.this, view, "shareNames").toBundle());
} else {
startActivity(showItent);
}
}
});
}
@Override
public void onItemLongClick(View view, int position) {
}
});
}
Aggregations