コード例 #1
0
 public HistoryTouchCallback(int dragDirs, int swipeDirs, AndroidX.RecyclerView.Widget.RecyclerView recyclerView,
                             List <HistoryViewModel> historyViewModels, Android.Support.V4.App.Fragment fragment) : base(dragDirs, swipeDirs)
 {
     this.recyclerView      = recyclerView;
     this.historyViewModels = historyViewModels;
     this.fragment          = fragment;
 }
コード例 #2
0
 public RVItemTouchCallback(int dragDir, int swipeDir,
                            AndroidX.RecyclerView.Widget.RecyclerView recyclerView, Android.Support.V4.App.Fragment fragment, List <ImageFileNameModel> imageFileNameModels,
                            MainActivity mainActivity)
     : base(dragDir, swipeDir)
 {
     RecyclerView        = recyclerView;
     Fragment            = fragment;
     ImageFileNameModels = imageFileNameModels;
     this.mainActivity   = mainActivity;
 }
コード例 #3
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            AdLoader.Builder adLoader = new AdLoader.Builder(this.Context, "");

            View view = inflater.Inflate(Resource.Layout.newtask_fragment, container, false);

            fileChooserCard = view.FindViewById <CardView>(Resource.Id.fileChooserGroup);

            fileChooserBtn = view.FindViewById <Button>(Resource.Id.fileChooserButton);

            processingGroup = view.FindViewById <CardView>(Resource.Id.extractRProcessingGroup);

            processingTextView = view.FindViewById <TextView>(Resource.Id.processingTextView);

            processingProgressBar = view.FindViewById <ProgressBar>(Resource.Id.processingBar);

            _recyclerView = view.FindViewById <AndroidX.RecyclerView.Widget.RecyclerView>(Resource.Id.imageRecyclerView);

            LinearLayoutManager = new AndroidX.RecyclerView.Widget.LinearLayoutManager(this.Context);

            _recyclerView.SetLayoutManager(LinearLayoutManager);

            _recyclerView.NestedScrollingEnabled = false;

            _recyclerView.HasFixedSize = true;

            var decoration  = new AndroidX.RecyclerView.Widget.DividerItemDecoration(this.Context, LinearLayoutManager.Orientation);
            int pixelMargin = Context.Resources.GetDimensionPixelSize(Resource.Dimension.divider_margin_vertical);

            decoration.Drawable = (new InsetDrawable
                                       (Context.GetDrawable(Resource.Drawable.abc_list_divider_material), 0, pixelMargin, 0, pixelMargin));

            _recyclerView.AddItemDecoration(decoration);

            FoundImagesAdapter foundImagesAdapter = new FoundImagesAdapter(ImageFileNameModels, this);

            foundImagesAdapter.ItemClick += FoundImagesAdapter_ItemClick;

            _recyclerView.SetAdapter(foundImagesAdapter);


            AndroidX.RecyclerView.Widget.ItemTouchHelper itemTouchHelper = new AndroidX.RecyclerView.Widget.ItemTouchHelper(new RVItemTouchCallback(0, ItemTouchHelper.Right | ItemTouchHelper.Left,
                                                                                                                                                    _recyclerView, this, ImageFileNameModels, mainActivity));

            itemTouchHelper.AttachToRecyclerView(_recyclerView);

            fileChooserBtn.Click += FileChooserBtn_Click;

            mainActivity.SupportActionBar.Subtitle = $"Working with {ImageFileNameModels.Count} items";

            return(view);
        }
コード例 #4
0
        public override void OnChildViewHolderSelected(AndroidX.RecyclerView.Widget.RecyclerView parent, AndroidX.RecyclerView.Widget.RecyclerView.ViewHolder child, int position, int subposition)
        {
            base.OnChildViewHolderSelected(parent, child, position, subposition);

            var adapter = parent.GetAdapter() as IMvxRecyclerAdapter;
            var item    = adapter?.GetItem(position);

            if (item == null)
            {
                MvxAndroidLog.Instance.Log(LogLevel.Error, "Could not retrieve item from adapter. Can't pass currently selected item through!");
                return;
            }

            if (ItemSelection != null && ItemSelection.CanExecute(item))
            {
                ItemSelection.Execute(item);
            }
        }
コード例 #5
0
ファイル: HistoryFragment.cs プロジェクト: bolkay/ExtractR
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            View view = inflater.Inflate(Resource.Layout.history_fragment, container, false);

            nohistory = view.FindViewById <CardView>(Resource.Id.noHistoryGroup);

            if (historyViewModels.Any())
            {
                nohistory.Visibility = ViewStates.Gone;
            }
            else
            {
                nohistory.Visibility = ViewStates.Visible;
            }

            HistoryAdapter historyAdapter = new HistoryAdapter(historyViewModels, mainActivity);

            layoutManager = new AndroidX.RecyclerView.Widget.LinearLayoutManager(this.Context);
            recyclerView  = view.FindViewById <AndroidX.RecyclerView.Widget.RecyclerView>(Resource.Id.historyRecyclerView);
            recyclerView.SetLayoutManager(layoutManager);
            recyclerView.NestedScrollingEnabled = false;
            recyclerView.HasFixedSize           = true;

            var           decoration    = new AndroidX.RecyclerView.Widget.DividerItemDecoration(this.Context, layoutManager.Orientation);
            var           inset         = Resources.GetDimensionPixelSize(Resource.Dimension.divider_margin_vertical);
            InsetDrawable insetDrawable = new InsetDrawable(ContextCompat.GetDrawable(this.Context, Resource.Drawable.abc_list_divider_material)
                                                            , 0, inset, 0, inset);

            decoration.Drawable = (insetDrawable);
            AndroidX.RecyclerView.Widget.ItemTouchHelper itemTouchHelper = new AndroidX.RecyclerView.Widget.ItemTouchHelper(new HistoryTouchCallback(
                                                                                                                                0, ItemTouchHelper.Right | ItemTouchHelper.Left, recyclerView, historyViewModels, this));

            itemTouchHelper.AttachToRecyclerView(recyclerView);

            recyclerView.SetAdapter(historyAdapter);

            historyAdapter.ItemClick     += HistoryAdapter_ItemClick;
            historyAdapter.ItemLongClick += HistoryAdapter_ItemLongClick;

            mainActivity.SupportActionBar.Subtitle = $"Stored {historyViewModels.Count} items";

            return(view);
        }
コード例 #6
0
 public override bool OnMove(AndroidX.RecyclerView.Widget.RecyclerView recyclerView,
                             AndroidX.RecyclerView.Widget.RecyclerView.ViewHolder viewHolder, AndroidX.RecyclerView.Widget.RecyclerView.ViewHolder target)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            first  = inflater.Inflate(Resource.Layout.NewPost, null);
            second = inflater.Inflate(Resource.Layout.NewPost2, null);

            userId = new UserSettings(this.Activity).getUserID();

            if (!activeSecond)
            {
                if (ContextCompat.CheckSelfPermission(this.Activity, Manifest.Permission.ReadExternalStorage) == (int)Permission.Granted)
                {
                    addViewModel = new AddViewModel();

                    ImageButton takePctrBtn  = first.FindViewById <ImageButton>(Resource.Id.takePictureBtn);
                    ImageButton chooseFewBtn = first.FindViewById <ImageButton>(Resource.Id.fewPictures);

                    takePctrBtn.Click  += (sender, e) => StartCameraActivity();
                    chooseFewBtn.Click += (sender, e) => ShowCheckCircles();

                    recView = first.FindViewById <AndroidX.RecyclerView.Widget.RecyclerView>(Resource.Id.recView);

                    var galleryPhotos = getPhotosFromGallery();

                    var imgAdapter = new ImageShortCutAdapter(this.Activity, galleryPhotos);

                    var grid = new AndroidX.RecyclerView.Widget.GridLayoutManager(this.Activity, 3);

                    recView.HasFixedSize = true;
                    recView.SetLayoutManager(grid);
                    recView.SetAdapter(imgAdapter);

                    imgAdapter.ItemClick += (sender, e) =>
                    {
                        int position = e;

                        if (imgAdapter.fewSelectActive)
                        {
                            var view = recView.GetChildAt(position);
                            var vh   = recView.FindViewHolderForLayoutPosition(position);

                            if (view == null)
                            {
                                view = vh.ItemView;
                            }

                            if (!imgAdapter.CheckedPositions.Contains(position))
                            {
                                if (imgAdapter.CheckedPositions.Count >= 10)
                                {
                                    Toast.MakeText(this.Activity, "You could clip up to 10 photos", ToastLength.Short).Show();
                                }
                                else
                                {
                                    imgAdapter.CheckedPositions.Add(position);
                                }
                            }
                            else
                            {
                                imgAdapter.CheckedPositions.Remove(position);
                            }
                            imgAdapter.BindViewHolder(vh, position);
                        }
                        else
                        {
                            SelectedImgsFromGallery(new List <string>()
                            {
                                galleryPhotos[position]
                            });
                        }
                    };
                }
                else
                {
                    ActivityCompat.RequestPermissions(this.Activity, new string[] { Manifest.Permission.ReadExternalStorage }, 200);
                    OnCreateView(inflater, container, savedInstanceState);
                }

                return(first);
            }
            else
            {
                return(second);
            }
        }