Search in sources :

Example 1 with ToggleAnimationClickListener

use of com.facebook.fresco.samples.showcase.common.ToggleAnimationClickListener in project fresco by facebook.

the class DraweeMediaPickerFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mSimpleDraweeView = (SimpleDraweeView) view.findViewById(R.id.drawee_view);
    mImagePath = (TextView) view.findViewById(R.id.image_path);
    mSimpleDraweeView.setOnClickListener(new ToggleAnimationClickListener(mSimpleDraweeView));
    View actionOpenDocumentButton = view.findViewById(R.id.pick_action_open_document);
    actionOpenDocumentButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                intent.addCategory(Intent.CATEGORY_OPENABLE);
                intent.setType("image/*");
                startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
            } else {
                Toast.makeText(getContext(), R.string.drawee_media_picker_action_open_document_not_supported, Toast.LENGTH_SHORT).show();
            }
        }
    });
    View actionGetContent = view.findViewById(R.id.pick_action_get_content);
    actionGetContent.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/*");
            startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
        }
    });
    View actionPickButton = view.findViewById(R.id.pick_action_pick);
    actionPickButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            StoragePermissionHelper.INSTANCE.withStoragePermission(getActivity(), new Function1<Unit, Unit>() {

                @Override
                public Unit invoke(Unit unit) {
                    Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                    startActivityForResult(intent, REQUEST_CODE_PICK_MEDIA);
                    return null;
                }
            });
        }
    });
}
Also used : Function1(kotlin.jvm.functions.Function1) ToggleAnimationClickListener(com.facebook.fresco.samples.showcase.common.ToggleAnimationClickListener) Intent(android.content.Intent) Unit(kotlin.Unit) TextView(android.widget.TextView) SimpleDraweeView(com.facebook.drawee.view.SimpleDraweeView) View(android.view.View)

Aggregations

Intent (android.content.Intent)1 View (android.view.View)1 TextView (android.widget.TextView)1 SimpleDraweeView (com.facebook.drawee.view.SimpleDraweeView)1 ToggleAnimationClickListener (com.facebook.fresco.samples.showcase.common.ToggleAnimationClickListener)1 Unit (kotlin.Unit)1 Function1 (kotlin.jvm.functions.Function1)1