コード例 #1
0
ファイル: CarouselPageAdapter.cs プロジェクト: zmtzawqlp/maui
        public override bool IsViewFromObject(global::Android.Views.View p0, Java.Lang.Object p1)
        {
            var       holder = (ObjectJavaBox <Tuple <ViewGroup, Page, int> >)p1;
            ViewGroup frame  = holder.Instance.Item1;

            return(p0 == frame);
        }
コード例 #2
0
ファイル: CarouselPageAdapter.cs プロジェクト: zmtzawqlp/maui
        public override int GetItemPosition(Java.Lang.Object item)
        {
            // The int is the current index.
            var     holder = (ObjectJavaBox <Tuple <ViewGroup, Page, int> >)item;
            Element parent = holder.Instance.Item2.RealParent;

            if (parent == null)
            {
                return(PositionNone);
            }

            // Unfortunately we can't just call CarouselPage.GetIndex, because we need to know
            // if the item has been removed. We could update MultiPage<T> to set removed items' index
            // to -1 to support this if it ever becomes an issue.
            int index = ((CarouselPage)parent).Children.IndexOf(holder.Instance.Item2);

            if (index == -1)
            {
                return(PositionNone);
            }

            if (index != holder.Instance.Item3)
            {
                holder.Instance = new Tuple <ViewGroup, Page, int>(holder.Instance.Item1, holder.Instance.Item2, index);
                return(index);
            }

            return(PositionUnchanged);
        }
コード例 #3
0
        protected bool ChooseFile(IValueCallback filePathCallback, Intent intent, string title)
        {
            if (_activity == null)
            {
                return(false);
            }

            Action <Result, Intent> callback = (resultCode, intentData) =>
            {
                if (filePathCallback == null)
                {
                    return;
                }

                Java.Lang.Object result = ParseResult(resultCode, intentData);
                filePathCallback.OnReceiveValue(result);
            };

            _requestCodes = _requestCodes ?? new List <int>();

            int newRequestCode = ActivityResultCallbackRegistry.RegisterActivityResultCallback(callback);

            _requestCodes.Add(newRequestCode);

            _activity.StartActivityForResult(Intent.CreateChooser(intent, title), newRequestCode);

            return(true);
        }
コード例 #4
0
        public override void OnViewRecycled(Java.Lang.Object holder)
        {
            if (holder is TemplatedItemViewHolder templatedItemViewHolder)
            {
                templatedItemViewHolder.Recycle(ItemsView);
            }

            base.OnViewRecycled(holder);
        }
コード例 #5
0
ファイル: CarouselPageAdapter.cs プロジェクト: zmtzawqlp/maui
        public override void DestroyItem(ViewGroup p0, int p1, Java.Lang.Object p2)
        {
            var  holder        = (ObjectJavaBox <Tuple <ViewGroup, Page, int> >)p2;
            Page destroyedPage = holder.Instance.Item2;

            IVisualElementRenderer renderer = Platform.GetRenderer(destroyedPage);

            renderer.View.RemoveFromParent();
            holder.Instance.Item1.RemoveFromParent();
        }
コード例 #6
0
        private void PopulateView(View gv, PwGroup pw)
        {
            _pwGroup = pw;

            ImageView iv = (ImageView)gv.FindViewById(Resource.Id.icon);

            Database db;

            try
            {
                db = App.Kp2a.FindDatabaseForElement(pw);
            }
            catch (Exception e)
            {
                //for some reason, since Android 12 we get here when the database is reloaded (after making remote changes and selecting sync)
                //we can just ignore this.
                Console.WriteLine(e);
                return;
            }

            db.DrawableFactory.AssignDrawableTo(iv, _groupBaseActivity, db.KpDatabase, pw.IconId, pw.CustomIconUuid, true);
            gv.FindViewById(Resource.Id.icon).Visibility       = ViewStates.Visible;
            gv.FindViewById(Resource.Id.check_mark).Visibility = ViewStates.Invisible;


            _textview.Text = pw.Name;

            if (_defaultTextColor == null)
            {
                _defaultTextColor = _textview.TextColors.DefaultColor;
            }

            if (_groupBaseActivity.IsBeingMoved(_pwGroup.Uuid))
            {
                int elementBeingMoved = Context.Resources.GetColor(Resource.Color.element_being_moved);
                _textview.SetTextColor(new Color(elementBeingMoved));
            }
            else
            {
                _textview.SetTextColor(new Color((int)_defaultTextColor));
            }

            _label.Text = _groupBaseActivity.GetString(Resource.String.group) + " - ";
            uint numEntries = CountEntries(pw);

            if (numEntries == 1)
            {
                _label.Text += Context.GetString(Resource.String.Entry_singular);
            }
            else
            {
                Java.Lang.Object obj = (int)numEntries;
                _label.Text += Context.GetString(Resource.String.Entry_plural, obj);
            }
        }
コード例 #7
0
        public override void OnViewRecycled(Java.Lang.Object holder)
        {
            if (holder is SelectableViewHolder selectable)
            {
                _currentViewHolders.Remove(selectable);
                selectable.Clicked   -= SelectableClicked;
                selectable.IsSelected = false;
            }

            base.OnViewRecycled(holder);
        }
コード例 #8
0
            public override void OnResourceReady(Java.Lang.Object resource, ITransition transition)
            {
                try
                {
                    if (MAdapter.AttachmentList?.Count > 0)
                    {
                        var item = MAdapter.AttachmentList[Position];
                        if (item != null && string.IsNullOrEmpty(item.Thumb?.FileUrl))
                        {
                            var fileName = item.FileUrl.Split('/').Last();
                            var fileNameWithoutExtension = fileName.Split('.').First();

                            var pathImage = Methods.Path.FolderDcimImage + "/" + fileNameWithoutExtension + ".png";

                            var videoImage = Methods.MultiMedia.GetMediaFrom_Gallery(Methods.Path.FolderDcimImage, fileNameWithoutExtension + ".png");
                            if (videoImage == "File Dont Exists")
                            {
                                if (resource is Bitmap bitmap)
                                {
                                    Methods.MultiMedia.Export_Bitmap_As_Image(bitmap, fileNameWithoutExtension, Methods.Path.FolderDcimImage);

                                    File file2    = new File(pathImage);
                                    var  photoUri = FileProvider.GetUriForFile(MAdapter.ActivityContext, MAdapter.ActivityContext.PackageName + ".fileprovider", file2);

                                    Glide.With(MAdapter.ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(ViewHolder.Image);

                                    item.Thumb = new Attachments.VideoThumb
                                    {
                                        FileUrl = photoUri.ToString()
                                    };
                                }
                            }
                            else
                            {
                                File file2    = new File(pathImage);
                                var  photoUri = FileProvider.GetUriForFile(MAdapter.ActivityContext, MAdapter.ActivityContext.PackageName + ".fileprovider", file2);

                                Glide.With(MAdapter.ActivityContext).Load(photoUri).Apply(new RequestOptions()).Into(ViewHolder.Image);

                                item.Thumb = new Attachments.VideoThumb
                                {
                                    FileUrl = photoUri.ToString()
                                };
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Methods.DisplayReportResultTrack(e);
                }
            }
コード例 #9
0
        private static Java.Lang.Object[] CreateJavaStringArray(List <string> inputList)
        {
            if (inputList == null)
            {
                return(null);
            }

            var toReturn = new Java.Lang.Object[inputList.Count];

            for (var i = 0; i < inputList.Count; i++)
            {
                toReturn[i] = new Java.Lang.String(inputList[i]);
            }

            return(toReturn);
        }
コード例 #10
0
 public override void OnViewRecycled(Java.Lang.Object holder)
 {
     try
     {
         if (holder != null)
         {
             if (holder is MentionAdapterViewHolder viewHolder)
                 Glide.With(ActivityContext).Clear(viewHolder.Image);
         }
         base.OnViewRecycled(holder);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
コード例 #11
0
        public static TObject ToNetObject <TObject>(this Java.Lang.Object value)
        {
            if (value == null)
            {
                return(default(TObject));
            }

            if (!(value is JavaHolder))
            {
                throw new InvalidOperationException("Unable to convert to .NET object. Only Java.Lang.Object created with .ToJavaObject() can be converted.");
            }

            TObject returnVal;

            try { returnVal = (TObject)((JavaHolder)value).Instance; }
            finally { value.Dispose(); }
            return(returnVal);
        }
コード例 #12
0
        private void PopulateView(View gv, PwGroup pw)
        {
            _pwGroup = pw;

            ImageView iv = (ImageView)gv.FindViewById(Resource.Id.icon);
            Database  db = App.Kp2a.FindDatabaseForElement(pw);

            db.DrawableFactory.AssignDrawableTo(iv, _groupBaseActivity, db.KpDatabase, pw.IconId, pw.CustomIconUuid, true);
            gv.FindViewById(Resource.Id.icon).Visibility       = ViewStates.Visible;
            gv.FindViewById(Resource.Id.check_mark).Visibility = ViewStates.Invisible;


            _textview.Text = pw.Name;

            if (_defaultTextColor == null)
            {
                _defaultTextColor = _textview.TextColors.DefaultColor;
            }

            if (_groupBaseActivity.IsBeingMoved(_pwGroup.Uuid))
            {
                int elementBeingMoved = Context.Resources.GetColor(Resource.Color.element_being_moved);
                _textview.SetTextColor(new Color(elementBeingMoved));
            }
            else
            {
                _textview.SetTextColor(new Color((int)_defaultTextColor));
            }

            _label.Text = _groupBaseActivity.GetString(Resource.String.group) + " - ";
            uint numEntries = CountEntries(pw);

            if (numEntries == 1)
            {
                _label.Text += Context.GetString(Resource.String.Entry_singular);
            }
            else
            {
                Java.Lang.Object obj = (int)numEntries;
                _label.Text += Context.GetString(Resource.String.Entry_plural, obj);
            }
        }
コード例 #13
0
 public void OnSuccess(Java.Lang.Object obj)
 {
     owner.HandlePendingAction();
     owner.UpdateUI();
 }
コード例 #14
0
 public override bool IsViewFromObject(View view, Java.Lang.Object @object)
 {
     return(view == @object);
 }
コード例 #15
0
#pragma warning disable CS0672 // Member overrides obsolete member
        public override void DestroyItem(View container, int position, Java.Lang.Object @object)
#pragma warning restore CS0672 // Member overrides obsolete member
        {
            ((ViewGroup)container).RemoveView((View)@object);
        }
コード例 #16
0
 /// <summary>
 /// <para>
 /// Handles a request to tear down the most recently created event stream.
 /// </para>
 /// <para>
 /// Any uncaught exception thrown by this method will be caught by the channel implementation and logged.
 /// An error result message will be sent back to Flutter.
 /// </para>
 /// <para>
 /// The channel implementation may call this method with null arguments to separate a pair of two consecutive set up requests.
 /// Such request pairs may occur during Flutter hot restart.
 /// Any uncaught exception thrown in this situation will be logged without notifying Flutter.
 /// </para>
 /// <para>
 /// Invoked when the first listener is registered with the Stream associated to this channel on the Flutter side.
 /// </para>
 /// </summary>
 /// <param name="arguments">Stream configuration arguments, possibly null.</param>
 /// <param name="events">An <see cref="EventChannel.IEventSink"/> for emitting events to the Flutter receiver.</param>
 public void OnListen(Java.Lang.Object arguments, EventChannel.IEventSink events)
 {
     _events = events;
 }
コード例 #17
0
        //public override ICharSequence GetPageTitleFormatted(int position)
        //{
        //    return new Java.Lang.String("Problem " + (position + 1));
        //}

        public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object @object)
        {
            container.RemoveView((View)@object);
        }
コード例 #18
0
 public abstract void OnComplete(string response, Java.Lang.Object state);
コード例 #19
0
 public Object Convert(Java.Lang.Object p0)
 {
     return(Convert((JSONObject)p0));
 }
コード例 #20
0
 public override void DestroyItem(ViewGroup container, int position, Java.Lang.Object obj)
 {
     container.RemoveView((LinearLayout)obj);
 }
コード例 #21
0
ファイル: DataChangeObserver.cs プロジェクト: zmtzawqlp/maui
 public override void OnItemRangeChanged(int positionStart, int itemCount, Java.Lang.Object payload)
 {
     base.OnItemRangeChanged(positionStart, itemCount, payload);
     _onDataChange?.Invoke();
 }
コード例 #22
0
        public static T Cast <T>(Java.Lang.Object obj) where T : class
        {
            var propertyInfo = obj.GetType().GetProperty("Instance");

            return(propertyInfo == null ? null : propertyInfo.GetValue(obj, null) as T);
        }
コード例 #23
0
 public override void OnLoadFinished(Android.Support.V4.Content.Loader p0, Java.Lang.Object p1)
 {
     OnLoadFinished(p0, p1.JavaCast <Android.Support.V7.Util.SortedList> ());
 }