Slrtce/app/src/main/java/com/sssa/slrtce/ui/fragments/NoticeFragment.java
/**
     * Material Dialog Picker for file upload i.e. from camera or directory
     */
Material Dialog Picker for file upload i.e. from camera or directory
Material Dialog Picker for file upload i . e . from camera or directory
private void filepickerDialog(){
        View view = LayoutInflater.from(getContext()).inflate(R.layout.filepicker_dailog, null);
        filePicker  = (ImageView) view.findViewById(R.id.file_picker);
        cameraPicker = (ImageView) view.findViewById(R.id.camera_picker);
        final MaterialDialog.Builder builder = new MaterialDialog.Builder(getContext());
        builder.title("Upload");
        builder.negativeText(android.R.string.cancel);
        builder.positiveText(android.R.string.ok);
        builder.onNegative(new MaterialDialog.SingleButtonCallback() {
            @Override
            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                builder.autoDismiss(true);
            }
        });
        builder.customView(view,false);
        builder.show();
        cameraPicker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                if (cameraIntent.resolveActivity(getContext().getPackageManager()) != null) {
                    File photoFile = Helper.createImageFile();
                    if (photoFile != null) {
                        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                        startActivityForResult(cameraIntent, ReqCodeImage);
                        builder.dismissListener(new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialogInterface) {
                                dialogInterface.dismiss();
                            }
                        });
                    }
                }
            }
        });
        filePicker.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Helper.filePicker(ReqCode, NoticeFragment.this);
                builder.dismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialogInterface) {
                        dialogInterface.dismiss();
                    }
                });
            }
        });
    }
private void filepickerDialog ( ) { View view = LayoutInflater . from ( getContext ( ) ) . inflate ( R . layout . filepicker_dailog , null ) ; filePicker = ( ImageView ) view . findViewById ( R . id . file_picker ) ; cameraPicker = ( ImageView ) view . findViewById ( R . id . camera_picker ) ; final MaterialDialog . Builder builder = new MaterialDialog . Builder ( getContext ( ) ) ; builder . title ( "Upload" ) ; builder . negativeText ( android . R . string . cancel ) ; builder . positiveText ( android . R . string . ok ) ; builder . onNegative ( new MaterialDialog . SingleButtonCallback ( ) { @ Override public void onClick ( @ NonNull MaterialDialog dialog , @ NonNull DialogAction which ) { builder . autoDismiss ( true ) ; } } ) ; builder . customView ( view , false ) ; builder . show ( ) ; cameraPicker . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View view ) { Intent cameraIntent = new Intent ( MediaStore . ACTION_IMAGE_CAPTURE ) ; if ( cameraIntent . resolveActivity ( getContext ( ) . getPackageManager ( ) ) != null ) { File photoFile = Helper . createImageFile ( ) ; if ( photoFile != null ) { cameraIntent . putExtra ( MediaStore . EXTRA_OUTPUT , Uri . fromFile ( photoFile ) ) ; startActivityForResult ( cameraIntent , ReqCodeImage ) ; builder . dismissListener ( new DialogInterface . OnDismissListener ( ) { @ Override public void onDismiss ( DialogInterface dialogInterface ) { dialogInterface . dismiss ( ) ; } } ) ; } } } } ) ; filePicker . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View view ) { Helper . filePicker ( ReqCode , NoticeFragment . this ) ; builder . dismissListener ( new DialogInterface . OnDismissListener ( ) { @ Override public void onDismiss ( DialogInterface dialogInterface ) { dialogInterface . dismiss ( ) ; } } ) ; } } ) ; }
Material Dialog Picker for file upload i.e.
Material Dialog Picker for file upload i . e .
// Create the File where the photo should go // Continue only if the File was successfully created