Пример #1
0
 public override Fragment GetItem(int index)
 {
     if (mPageReferenceMap.Get(index) != null)
     {
         return(GetItemAtIndex(index));
     }
     else
     {
         try
         {
             Fragment obj = (Fragment)mStepperFragment[index].NewInstance();
             mPageReferenceMap.Put(index, obj);
             return(obj);
         }
         catch (InstantiationException e)
         {
             e.PrintStackTrace();
             return(null);
         }
         catch (IllegalAccessException e)
         {
             e.PrintStackTrace();
             return(null);
         }
     }
 }
 public static Typeface GetTypeface(Font font)
 {
     if (!fontsLoaded)
     {
         LoadFonts();
     }
     return(fonts.Get(Convert.ToInt32(font)));
 }
Пример #3
0
        public static IntentExtras FromIdAndRelease(int id)
        {
            var map = ExtraStore.Get(id);

            if (map == null)
            {
                return(null);
            }

            ExtraStore.Remove(id);
            return(new IntentExtras(id, map));
        }
Пример #4
0
 /**
  * Call this method to reset animation status on all views.
  */
 public void reset()
 {
     for (int i = 0; i < mAnimators.Size(); i++)
     {
         mAnimators.Get(mAnimators.KeyAt(i)).Cancel();
     }
     mAnimators.Clear();
     mFirstAnimatedPosition = -1;
     mLastAnimatedPosition  = -1;
     mAnimationStartMillis  = -1;
     mShouldAnimate         = true;
 }
Пример #5
0
        public void Get_2()
        {
            var a = new SparseArray <char>(10);

            a.Set(1, 'a');
            Assert.AreEqual('a', a.Get(1));

            a.Set(1, 'a');
            Assert.AreEqual('a', a.Get(1));

            a.Set(1, 'b');
            Assert.AreEqual('b', a.Get(1));
        }
Пример #6
0
 public EasyLVHolder(Context context, int position, ViewGroup parent, int layoutId)
 {
     this.mConvertView = mConvertViews.Get(layoutId);
     this.mPosition    = position;
     this.mContext     = context;
     this.mLayoutId    = layoutId;
     if (mConvertView == null)
     {
         mConvertView = LayoutInflater.From(context).Inflate(layoutId, parent, false);
         mConvertViews.Put(layoutId, mConvertView);
         mConvertView.Tag = this;
     }
 }
 public override void Autofill(SparseArray values)
 {
     // User has just selected a Dataset from the list of autofill suggestions.
     // The Dataset is comprised of a list of AutofillValues, with each AutofillValue meant
     // to fill a specific autofillable view. Now we have to update the UI based on the
     // AutofillValues in the list.
     Log.Debug(LogTag, "autoFill(): " + values);
     for (int i = 0; i < values.Size(); i++)
     {
         var  id    = values.KeyAt(i);
         var  value = (AutofillValue)values.ValueAt(i);
         Item item  = VirtualViews.Get(id);
         if (item != null && item.Editable)
         {
             // Set the item's text to the text wrapped in the AutofillValue.
             item.Text = value.TextValue;
         }
         else if (item == null)
         {
             Log.Warn(LogTag, "No item for id " + id);
         }
         else
         {
             Log.Warn(LogTag, "Item for id " + id + " is not editable: " + item);
         }
     }
     PostInvalidate();
 }
        public View GetView(int position)
        {
            var nativeRecyclerViews = new List <View>();

            var size = _mScrap.Size();

            for (int i = 0; i < size; i++)
            {
                nativeRecyclerViews.Add(_mScrap.Get(i) as View);
            }

            // The spinner creates temporary view when measuring its size.
            // This item is not placed in the recycler so we can find it this way.
            var view = _views
                       .Except(nativeRecyclerViews)
                       .Where(v => !v.HasParent())
                       .FirstOrDefault();

            if (view != null)
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().DebugFormat("Reusing unassigned view {0}", view);
                }
            }

            return(view);
        }
Пример #9
0
        public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
        {
            if (viewType < 0 || viewType > layoutIds.Length)
            {
                throw new ArrayIndexOutOfBoundsException("layoutIndex");
            }
            if (layoutIds.Length == 0)
            {
                throw new IllegalArgumentException("not layoutId");
            }
            int  layoutId = layoutIds[viewType];
            View view     = mConvertViews.Get(layoutId);

            if (view == null)
            {
                view = mLInflater.Inflate(layoutId, parent, false);
            }
            EasyRVHolder viewHolder = (EasyRVHolder)view.Tag;

            if (viewHolder == null || viewHolder.getLayoutId() != layoutId)
            {
                viewHolder = new EasyRVHolder(mContext, layoutId, view);
                return(viewHolder);
            }
            return(viewHolder);
        }
Пример #10
0
        private void calculateAttributes(List <CalendarItem> calendarItems, float maxWidth, float groupLeftMargin, Dictionary <CalendarItem, int> originalIndexes, SparseArray <IList <AnchorData> > anchors)
        {
            var calendarItemLayoutAttributes = calendarLayoutCalculator.CalculateLayoutAttributes(calendarItems);

            for (var index = 0; index < calendarItemLayoutAttributes.Count; index++)
            {
                var calendarItem          = calendarItemLayoutAttributes[index];
                var startHour             = calendarItem.StartTime.Hour;
                var endHour               = calendarItem.EndTime.Hour;
                var eventAbsolutePosition = calendarItem.StartTime.Hour * hourHeight + calendarItem.StartTime.Minute / 60f * hourHeight;
                var totalItemSpacing      = (calendarItem.TotalColumns - 1) * itemSpacing;
                var eventWidth            = (maxWidth - leftPadding - rightPadding - totalItemSpacing) / calendarItem.TotalColumns;
                var eventHeight           = Math.Max(minHourHeight, hourHeight * (calendarItem.Duration.TotalMinutes / 60f));
                var adapterPosition       = originalIndexes[calendarItems[index]];

                for (var anchorIndex = startHour; anchorIndex <= endHour; anchorIndex++)
                {
                    var anchorAbsoluteTop = anchorIndex * hourHeight;
                    var anchoredData      = anchors.Get(anchorIndex, new List <AnchorData>());
                    var leftOffset        = (int)(groupLeftMargin + leftPadding + eventWidth * calendarItem.ColumnIndex + calendarItem.ColumnIndex * itemSpacing);
                    anchoredData.Add(new AnchorData(adapterPosition, (int)(eventAbsolutePosition - anchorAbsoluteTop), leftOffset, (int)eventHeight, (int)eventWidth));
                    anchors.Put(anchorIndex, anchoredData);
                }
            }
        }
Пример #11
0
        public void filter(FaceInfo[] infos, ImageFrame frame)
        {
            currentFrame.Clear();
            if (infos != null)
            {
                foreach (FaceInfo faceInfo in infos)
                {
                    TrackedModel face = getTrackedModel(faceInfo, frame);
                    currentFrame.Add(face);
                    face.setInfo(faceInfo);
                }
            }

            leftFaces.Clear();
            for (int i = 0; i < trackingFaces.Size(); i++)
            {
                int          key  = trackingFaces.KeyAt(i);
                TrackedModel face = trackingFaces.Get(key);
                if (!currentFrame.Contains(face))
                {
                    leftFaces.Add(key);
                }
                else
                {
                    if (onTrackListener != null)
                    {
                        face.setFrame(frame);
                        onTrackListener.onTrack(face);
                    }
                }
            }
            foreach (int?key in leftFaces)
            {
                TrackedModel left = trackingFaces.Get(key.Value);
                Log.Info("xx", " left:" + left);
                left.setEvent(Event.OnLeave);
                trackingFaces.Remove(key.Value);
                if (onTrackListener != null)
                {
                    onTrackListener.onTrack(left);
                }
                // TODO release argb?
            }
        }
Пример #12
0
        private void ShowColumn(int column, bool removeFromList)
        {
            VisibilityHandler.Column hiddenColumn = mHideColumnList.Get(column);
            if (hiddenColumn != null)
            {
                // add column model to the adapter
                mTableView.GetAdapter().AddColumn(column, (Adapter.IColumnHeader)hiddenColumn.GetColumnHeaderModel(),
                                                  (IList <Adapter.ICell>)hiddenColumn.GetCellModelList());
            }
            else
            {
                Log.Error(LogTag, "This column is already visible.");
            }

            if (removeFromList)
            {
                mHideColumnList.Remove(column);
            }
        }
Пример #13
0
        private void ShowRow(int row, bool removeFromList)
        {
            VisibilityHandler.Row hiddenRow = mHideRowList.Get(row);
            if (hiddenRow != null)
            {
                // add row model to the adapter
                mTableView.GetAdapter().AddRow(row, (Adapter.IRowHeader)hiddenRow.GetRowHeaderModel(),
                                               (IList <Adapter.ICell>)hiddenRow.GetCellModelList());
            }
            else
            {
                Log.Error(LogTag, "This row is already visible.");
            }

            if (removeFromList)
            {
                mHideRowList.Remove(row);
            }
        }
Пример #14
0
        public View GetView(int viewId)
        {
            View view = views.Get(viewId);

            if (view == null)
            {
                view = convertView.FindViewById(viewId);
                views.Put(viewId, view);
            }
            return(view);
        }
Пример #15
0
        public T GetView <T>(int viewId) where T : View
        {
            View view = Views.Get(viewId);

            if (view == null)
            {
                view = ConvertView.FindViewById <T>(viewId);
                Views.Put(viewId, view);
            }
            return((T)view);
        }
Пример #16
0
            public GroupInfo GetGroupInfo(int groupPosition)
            {
                GroupInfo info = groupInfo.Get(groupPosition);

                if (info == null)
                {
                    info = new GroupInfo();
                    groupInfo.Put(groupPosition, info);
                }
                return(info);
            }
        /// <summary>
        /// Returns the window corresponding to the id from the <seealso cref="#sWindows"/>
        /// cache.
        /// </summary>
        /// <param name="id">
        ///            The id representing the window. </param>
        /// <param name="cls">
        ///            The class of the implementation of the window. </param>
        /// <returns> The window corresponding to the id if it exists in the cache, or
        ///         null if it does not. </returns>
        public virtual Window GetCache(int id, Type cls)
        {
            SparseArray <Window> l2 = SWindows.GetValueOrNull(cls);

            if (l2 == null)
            {
                return(null);
            }

            return(l2.Get(id));
        }
Пример #18
0
        public T GetView <T>(int viewId) where T : View
        {
            View view = views.Get(viewId);

            if (view == null)
            {
                view = ItemView.FindViewById(viewId);
                views.Put(viewId, view);
            }
            return((T)view);
        }
Пример #19
0
        public V getView <V>(int viewId) where V : View
        {
            View view = mViews.Get(viewId);

            if (view == null)
            {
                view = mConvertView.FindViewById(viewId);
                mViews.Put(viewId, view);
            }
            return((V)view);
        }
Пример #20
0
        public T GetView <T>(int viewId)
        {
            View view = mViews.Get(viewId);

            if (view == null)
            {
                view = mConvertView.FindViewById(viewId);
                mViews.Put(viewId, view);
            }
            return((T)Convert.ChangeType(view, view.GetType()));
        }
Пример #21
0
 protected override void DispatchRestoreInstanceState(SparseArray container)
 {
     if (Id > 0)
     {
         var bundle = container.Get(Id) as IParcelable;
         if (bundle != null)
         {
             OnRestoreInstanceState(bundle);
         }
     }
 }
Пример #22
0
        public override IParcelable SaveState()
        {
            IParcelable p      = base.SaveState();
            Bundle      bundle = new Bundle();

            bundle.PutParcelable(_stateSuperState, p);

            bundle.PutInt(_statePages, _pages.Size());
            if (0 < _pages.Size())
            {
                for (int i = 0; i < _pages.Size(); i++)
                {
                    int position = _pages.KeyAt(i);
                    bundle.PutInt(CreateCacheIndex(i), position);
                    Fragment f = _pages.Get(position);
                    _fm.PutFragment(bundle, CreateCacheKey(position), f);
                }
            }
            return(bundle);
        }
Пример #23
0
        private GroupInfo GetGroupInfo(int groupPosition)
        {
            GroupInfo f    = new GroupInfo();
            GroupInfo info = _groupInfo.Get(groupPosition);

            if (info == null)
            {
                info = new GroupInfo();
                _groupInfo.Put(groupPosition, info);
            }
            return(info);
        }
Пример #24
0
        /// <summary>
        /// 获得视图
        /// </summary>
        /// <param name="viewId">控件id</param>
        /// <typeparam name="TV">控件类型</typeparam>
        /// <returns></returns>
        public TV GetView <TV>(int viewId) where TV : View
        {
            var view = _views.Get(viewId);

            if (view != null)
            {
                return((TV)view);
            }

            view = _convertView.FindViewById(viewId);
            _views.Put(viewId, view);

            return((TV)view);
        }
        private double GetPositionRatio(int position)
        {
            double ratio = SPositionHeightRatios.Get(position, 0.0);

            // if not yet done generate and stash the columns height
            // in our real world scenario this will be determined by
            // some match based on the known height and width of the image
            // and maybe a helpful way to get the column height!
            if (ratio == 0)
            {
                ratio = RandomHeightRatio;
                SPositionHeightRatios.Append(position, ratio);
                Console.WriteLine(TAG, "getPositionRatio:" + position + " ratio:" + ratio);
            }
            return(ratio);
        }
Пример #26
0
        private Typeface ObtainTypeface(Context context, int typefaceValue)
        {
            try
            {
                Typeface typeface = Typefaces.Get(typefaceValue);
                if (typeface == null)
                {
                    typeface = this.CreateTypeface(context, typefaceValue);
                    Typefaces.Put(typefaceValue, typeface);
                }
                return(typeface);
            }
            catch (Exception ex)
            {
            }

            return(null);
        }
Пример #27
0
        public void Get_1()
        {
            var a = new SparseArray <char>(10);

            a.Set(1, 'a');
            a.Set(5, 'e');
            a.Set(3, 'c');

            Assert.AreEqual('a', a.Get(1));
            Assert.AreEqual('c', a.Get(3));
            Assert.AreEqual('e', a.Get(5));

            a.Set(2, 'b');
            a.Set(4, 'd');

            Assert.AreEqual('a', a.Get(1));
            Assert.AreEqual('b', a.Get(2));
            Assert.AreEqual('c', a.Get(3));
            Assert.AreEqual('d', a.Get(4));
            Assert.AreEqual('e', a.Get(5));
        }
Пример #28
0
        public int HowManyMissingBelow(int lastPosition, SparseArray <bool> positionsOffscreen)
        {
            int itemsSkipped = 0;
            int itemsFound   = 0;

            for (int i = lastPosition; itemsFound < positionsOffscreen.Size(); i--)
            {
                if (positionsOffscreen.Get(i, false))
                {
                    itemsFound += 1;
                }
                else
                {
                    itemsSkipped += 1;
                }
            }

            return(itemsSkipped);
        }
Пример #29
0
        private NativeBitmapDescriptor GetIcon(ICluster cluster, BitmapDescriptor descriptor)
        {
            var bitmapDescriptorFactory = DefaultBitmapDescriptorFactory.Instance;
            var icon = GetFromIconCache(cluster);

            if (icon == null)
            {
                int bucket = GetBucket(cluster);
                icon = mIcons.Get(bucket);
                if (icon == null)
                {
                    mColoredCircleBackground.Paint.Color = Color.White;
                    icon = AndroidBitmapDescriptorFactory.FromBitmap(mIconGenerator.MakeIcon(bucket.ToString()));
                    mIcons.Put(bucket, icon);
                }

                AddToIconCache(cluster, icon);
            }
            return(icon);
        }
Пример #30
0
        public List <Anchor> CalculateAnchors(IList <CalendarItem> calendarItems, bool hasCalendarsLinked)
        {
            var calendarEvents  = new List <CalendarItem>();
            var timeEntries     = new List <CalendarItem>();
            var originalIndexes = new Dictionary <CalendarItem, int>(calendarItems.Count);
            var adapterIndex    = anchorCount;

            foreach (var calendarItem in calendarItems)
            {
                if (calendarItem.Source == CalendarItemSource.TimeEntry)
                {
                    timeEntries.Add(calendarItem);
                }
                else
                {
                    calendarEvents.Add(calendarItem);
                }
                originalIndexes.Add(calendarItem, adapterIndex++);
            }

            var newAnchors = new SparseArray <IList <AnchorData> >(anchorCount);

            if (hasCalendarsLinked || calendarEvents.Count > 0)
            {
                calculateAttributes(calendarEvents, halfAvailableWidth, leftMargin, originalIndexes, newAnchors);
                calculateAttributes(timeEntries, halfAvailableWidth, leftMargin + halfAvailableWidth, originalIndexes, newAnchors);
            }
            else
            {
                calculateAttributes(timeEntries, availableWidth, leftMargin, originalIndexes, newAnchors);
            }

            return(Enumerable.Range(0, anchorCount)
                   .Select(anchor => new Anchor((int)hourHeight, newAnchors.Get(anchor, emptyAnchorData).ToArray()))
                   .ToList());
        }