Search in sources :

Example 1 with DeleteAccountImageTask

use of org.edx.mobile.user.DeleteAccountImageTask in project edx-app-android by edx.

the class EditUserProfileFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    viewHolder = new ViewHolder(view);
    viewHolder.profileImageProgress.setVisibility(View.GONE);
    viewHolder.username.setText(username);
    viewHolder.username.setContentDescription(ResourceUtil.getFormattedString(getResources(), R.string.profile_username_description, "username", username));
    final IconDrawable icon = new IconDrawable(getActivity(), FontAwesomeIcons.fa_camera).colorRes(getActivity(), R.color.disableable_button_text).sizeRes(getActivity(), R.dimen.fa_x_small).tint(// IconDrawable is tinted by default, but we don't want it to be tinted here
    null);
    TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(viewHolder.changePhoto, icon, null, null, null);
    viewHolder.changePhoto.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final PopupMenu popup = new PopupMenu(getActivity(), v);
            popup.getMenuInflater().inflate(R.menu.change_photo, popup.getMenu());
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                public boolean onMenuItemClick(MenuItem item) {
                    switch(item.getItemId()) {
                        case R.id.take_photo:
                            {
                                startActivityForResult(helper.createCaptureIntent(getActivity()), CAPTURE_PHOTO_REQUEST);
                                break;
                            }
                        case R.id.choose_photo:
                            {
                                final Intent galleryIntent = new Intent().setType("image/*").setAction(Intent.ACTION_GET_CONTENT);
                                startActivityForResult(galleryIntent, CHOOSE_PHOTO_REQUEST);
                                break;
                            }
                        case R.id.remove_photo:
                            {
                                final Task task = new DeleteAccountImageTask(getActivity(), username);
                                task.setProgressDialog(viewHolder.profileImageProgress);
                                executePhotoTask(task);
                                break;
                            }
                    }
                    return true;
                }
            });
            popup.show();
        }
    });
    setData(account, formDescription);
}
Also used : Task(org.edx.mobile.task.Task) DeleteAccountImageTask(org.edx.mobile.user.DeleteAccountImageTask) GetProfileFormDescriptionTask(org.edx.mobile.user.GetProfileFormDescriptionTask) SetAccountImageTask(org.edx.mobile.user.SetAccountImageTask) DeleteAccountImageTask(org.edx.mobile.user.DeleteAccountImageTask) IconDrawable(com.joanzapata.iconify.IconDrawable) MenuItem(android.view.MenuItem) Intent(android.content.Intent) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) TextView(android.widget.TextView) IconImageView(com.joanzapata.iconify.widget.IconImageView) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

Intent (android.content.Intent)1 PopupMenu (android.support.v7.widget.PopupMenu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1 TextView (android.widget.TextView)1 IconDrawable (com.joanzapata.iconify.IconDrawable)1 IconImageView (com.joanzapata.iconify.widget.IconImageView)1 CircleImageView (de.hdodenhof.circleimageview.CircleImageView)1 Task (org.edx.mobile.task.Task)1 DeleteAccountImageTask (org.edx.mobile.user.DeleteAccountImageTask)1 GetProfileFormDescriptionTask (org.edx.mobile.user.GetProfileFormDescriptionTask)1 SetAccountImageTask (org.edx.mobile.user.SetAccountImageTask)1