Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_recent_sets);

            RecyclerView = FindViewById <RecyclerView>(Resource.Id.listRecentSets);
            RecyclerView.HasFixedSize = true;
            RecyclerView.SetLayoutManager(new LinearLayoutManager(this));
            RecyclerView.SetAdapter(new RecentSetsListAdapter(() => ImageSet.GetRecentSets(ApplicationContext), this));
        }
Beispiel #2
0
                public ViewHolder(RecentSetsActivity activity, View root) : base(root)
                {
                    Image        = root.FindViewById <ImageView>(Resource.Id.recentSetItem_Image);
                    Name         = root.FindViewById <TextView>(Resource.Id.recentSetItem_Name);
                    DeleteButton = root.FindViewById <ImageButton>(Resource.Id.recentSetItem_Delete);

                    DeleteButton.Click += (o, e) => {
                        ImageSet.RemoveRecentSet(activity.ApplicationContext, Set);
                        ((RecentSetsListAdapter)activity.RecyclerView.GetAdapter()).UpdateSet();
                        activity.RecyclerView.GetAdapter().NotifyItemRemoved(AdapterPosition);
                    };

                    root.Click += (o, e) => {
                        var data = new Intent()
                        {
                            ClipData = Set.Select(item => new ClipData.Item(item)).ToClipData("Recent set", "text/plain")
                        };
                        activity.SetResult(Result.Ok, data);
                        activity.Finish();
                    };
                }
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            if (resultCode == (int)Android.App.Result.Ok)
            {
                if (requestCode == PickSetImages)
                {
                    IReadOnlyList <Android.Net.Uri> uris;
                    if (data.Data == null)
                    {
                        uris = data.ClipData.AsList().ListSelect(item => item.Uri);
                    }
                    else
                    {
                        uris = new[] { data.Data };
                    }

                    m_SetImages = uris.ListSelect(oldPath => Util.GetPathFromUri(Activity.ApplicationContext, oldPath));
                }
                else if (requestCode == PickRecentImages)
                {
                    m_SetImages = data.ClipData.AsList().ListSelect(item => item.Text);
                }

                ImageSet.AddRecentSet(Activity.ApplicationContext, m_SetImages);                 // This causes the set to be moved to the top of the list if it was already there

                if (m_SetImages.Any() && m_SetImages.All(File.Exists))
                {
                    var adapter = new ImageListAdapter(Algorithm.Delta, this, m_SetImages);                     // TODO: let user specify algorithm
                    Activity.FindViewById <ViewPager2>(Resource.Id.pager).Adapter = adapter;
                }
            }
            else
            {
                m_SetImages = null;
            }
        }