Search in sources :

Example 6 with Photo

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;
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Context(android.content.Context) InfoRecyclerViewAdapter(us.koller.cameraroll.adapter.item.InfoRecyclerViewAdapter) DialogInterface(android.content.DialogInterface) Gif(us.koller.cameraroll.data.models.Gif) Intent(android.content.Intent) Photo(us.koller.cameraroll.data.models.Photo) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) RecyclerView(android.support.v7.widget.RecyclerView) RecyclerView(android.support.v7.widget.RecyclerView)

Aggregations

Photo (us.koller.cameraroll.data.models.Photo)6 View (android.view.View)3 ImageView (android.widget.ImageView)3 SubsamplingScaleImageView (com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)3 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ImageViewState (com.davemorrissey.labs.subscaleview.ImageViewState)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Uri (android.net.Uri)1 PrintHelper (android.support.v4.print.PrintHelper)1 ViewPager (android.support.v4.view.ViewPager)1 ActionBar (android.support.v7.app.ActionBar)1 AlertDialog (android.support.v7.app.AlertDialog)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 Toolbar (android.support.v7.widget.Toolbar)1 ViewGroup (android.view.ViewGroup)1 FileNotFoundException (java.io.FileNotFoundException)1 InfoRecyclerViewAdapter (us.koller.cameraroll.adapter.item.InfoRecyclerViewAdapter)1