Search in sources :

Example 1 with AttachmentsAdapter

use of in.bugzy.ui.caseevents.AttachmentsAdapter in project bugzy by cpunq.

the class CaseEditActivity method setupAttachmentsRecyclerView.

private void setupAttachmentsRecyclerView() {
    mAttachmentsLayoutManager = new LinearLayoutManager(this);
    mAttachmentsLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
    mAttachmentsRecyclerView.setLayoutManager(mAttachmentsLayoutManager);
    mAttachmentsRecyclerView.addItemDecoration(new ItemOffsetDecoration((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8f, getResources().getDisplayMetrics()), (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 0f, getResources().getDisplayMetrics())));
    mAttachmentsRecyclerView.setHasFixedSize(true);
    mAttachmentsAdapter = new AttachmentsAdapter(null, this, "");
    mAttachmentsRecyclerView.setAdapter(mAttachmentsAdapter);
    mAttachmentsAdapter.setOnItemClickListener(new AttachmentsAdapter.OnItemClickListener() {

        @Override
        public void onItemClick(View view, int position) {
            PopupMenu popupMenu = new PopupMenu(CaseEditActivity.this, view);
            popupMenu.setOnMenuItemClickListener(item -> {
                if (item.getTitle().equals("Remove")) {
                    mCaseEditViewModel.removeAttachment(position);
                } else {
                    openImageActivity(view, mAttachments.get(position).getUri().getPath());
                }
                return true;
            });
            popupMenu.getMenu().add("View");
            popupMenu.getMenu().add("Remove");
            popupMenu.show();
        }

        @Override
        public void onItemLongClick(View view, int position) {
        }
    });
}
Also used : Bundle(android.os.Bundle) Priority(in.bugzy.data.model.Priority) BaseActivity(in.bugzy.ui.BaseActivity) PackageManager(android.content.pm.PackageManager) ProgressBar(android.widget.ProgressBar) Date(java.util.Date) AttachmentsAdapter(in.bugzy.ui.caseevents.AttachmentsAdapter) Uri(android.net.Uri) FullScreenImageActivity(in.bugzy.ui.casedetails.FullScreenImageActivity) OnClick(butterknife.OnClick) FileProvider(android.support.v4.content.FileProvider) BindView(butterknife.BindView) Manifest(android.Manifest) Area(in.bugzy.data.model.Area) Locale(java.util.Locale) MediaStore(android.provider.MediaStore) NachoTextView(com.hootsuite.nachos.NachoTextView) Attachment(in.bugzy.data.model.Attachment) View(android.view.View) Button(android.widget.Button) ChipTerminatorHandler(com.hootsuite.nachos.terminator.ChipTerminatorHandler) AdapterView(android.widget.AdapterView) TargetApi(android.annotation.TargetApi) Log(android.util.Log) Milestone(in.bugzy.data.model.Milestone) R(in.bugzy.R) ImagePickerSheetView(com.flipboard.bottomsheet.commons.ImagePickerSheetView) Category(in.bugzy.data.model.Category) Status(in.bugzy.data.model.Status) ActivityOptionsCompat(android.support.v4.app.ActivityOptionsCompat) PopupMenu(android.support.v7.widget.PopupMenu) ItemOffsetDecoration(in.bugzy.ui.common.ItemOffsetDecoration) ActivityCompat(android.support.v4.app.ActivityCompat) Person(in.bugzy.data.model.Person) List(java.util.List) TextView(android.widget.TextView) Project(in.bugzy.data.model.Project) Nullable(android.support.annotation.Nullable) Snackbar(android.support.design.widget.Snackbar) Case(in.bugzy.data.model.Case) BottomSheetLayout(com.flipboard.bottomsheet.BottomSheetLayout) ButterKnife(butterknife.ButterKnife) Environment(android.os.Environment) CaseEvent(in.bugzy.data.model.CaseEvent) SimpleDateFormat(java.text.SimpleDateFormat) Intent(android.content.Intent) BugzyAlertDialog(in.bugzy.ui.common.BugzyAlertDialog) NonNull(android.support.annotation.NonNull) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) BugzyApp(in.bugzy.BugzyApp) Toast(android.widget.Toast) Menu(android.view.Menu) CaseDetailsActivity(in.bugzy.ui.casedetails.CaseDetailsActivity) Build(android.os.Build) ViewModelProvider(android.arch.lifecycle.ViewModelProvider) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) IOException(java.io.IOException) PropType(in.bugzy.ui.editcase.CaseEditViewModel.PropType) Tag(in.bugzy.data.model.Tag) File(java.io.File) Spinner(android.widget.Spinner) CaseEventsAdapter(in.bugzy.ui.caseevents.CaseEventsAdapter) ViewModelProviders(android.arch.lifecycle.ViewModelProviders) RecyclerView(android.support.v7.widget.RecyclerView) ArrayAdapter(android.widget.ArrayAdapter) AlertDialog(android.support.v7.app.AlertDialog) Const(in.bugzy.common.Const) Glide(com.bumptech.glide.Glide) TypedValue(android.util.TypedValue) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) CaseStatus(in.bugzy.data.model.CaseStatus) Activity(android.app.Activity) EditText(android.widget.EditText) AttachmentsAdapter(in.bugzy.ui.caseevents.AttachmentsAdapter) ItemOffsetDecoration(in.bugzy.ui.common.ItemOffsetDecoration) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) BindView(butterknife.BindView) NachoTextView(com.hootsuite.nachos.NachoTextView) View(android.view.View) AdapterView(android.widget.AdapterView) ImagePickerSheetView(com.flipboard.bottomsheet.commons.ImagePickerSheetView) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) PopupMenu(android.support.v7.widget.PopupMenu)

Aggregations

Manifest (android.Manifest)1 TargetApi (android.annotation.TargetApi)1 Activity (android.app.Activity)1 ViewModelProvider (android.arch.lifecycle.ViewModelProvider)1 ViewModelProviders (android.arch.lifecycle.ViewModelProviders)1 Intent (android.content.Intent)1 PackageManager (android.content.pm.PackageManager)1 Uri (android.net.Uri)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Environment (android.os.Environment)1 MediaStore (android.provider.MediaStore)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 Snackbar (android.support.design.widget.Snackbar)1 ActivityCompat (android.support.v4.app.ActivityCompat)1 ActivityOptionsCompat (android.support.v4.app.ActivityOptionsCompat)1 FileProvider (android.support.v4.content.FileProvider)1 Pair (android.support.v4.util.Pair)1 AlertDialog (android.support.v7.app.AlertDialog)1