use of us.koller.cameraroll.data.models.Photo in project Camera-Roll-Android-App by kollerlukas.
the class ItemActivity method showInfoDialog.
public void showInfoDialog() {
final InfoRecyclerViewAdapter adapter = new InfoRecyclerViewAdapter();
boolean exifSupported = adapter.exifSupported(this, albumItem);
final View rootView = LayoutInflater.from(this).inflate(R.layout.info_dialog_layout, (ViewGroup) findViewById(R.id.root_view), false);
final View loadingBar = rootView.findViewById(R.id.progress_bar);
loadingBar.setVisibility(View.VISIBLE);
final View dialogLayout = rootView.findViewById(R.id.dialog_layout);
dialogLayout.setVisibility(View.GONE);
AlertDialog.Builder builder = new AlertDialog.Builder(this, theme.getDialogThemeRes()).setTitle(getString(R.string.info)).setView(rootView).setPositiveButton(R.string.done, null).setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
infoDialog = null;
}
});
if (exifSupported && !view_only) {
builder.setNeutralButton(R.string.edit_exif, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
Intent intent = new Intent(ItemActivity.this, ExifEditorActivity.class);
intent.putExtra(ExifEditorActivity.ALBUM_ITEM, albumItem);
startActivity(intent);
}
});
}
infoDialog = builder.create();
infoDialog.show();
// noinspection ConstantConditions
/*infoDialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);*/
boolean showColors = (albumItem instanceof Photo || albumItem instanceof Gif) && !view_only;
adapter.retrieveData(albumItem, showColors, new InfoRecyclerViewAdapter.OnDataRetrievedCallback() {
@Override
public void onDataRetrieved() {
ItemActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
RecyclerView recyclerView = rootView.findViewById(R.id.recyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(ItemActivity.this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
final View scrollIndicatorTop = rootView.findViewById(R.id.scroll_indicator_top);
final View scrollIndicatorBottom = rootView.findViewById(R.id.scroll_indicator_bottom);
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
scrollIndicatorTop.setVisibility(recyclerView.canScrollVertically(-1) ? View.VISIBLE : View.INVISIBLE);
scrollIndicatorBottom.setVisibility(recyclerView.canScrollVertically(1) ? View.VISIBLE : View.INVISIBLE);
}
});
loadingBar.setVisibility(View.GONE);
dialogLayout.setVisibility(View.VISIBLE);
}
});
}
@Override
public void failed() {
Toast.makeText(getContext(), R.string.error, Toast.LENGTH_SHORT).show();
}
@Override
public Context getContext() {
return ItemActivity.this;
}
});
}
Aggregations