public int GetRowHeight() {
			if (_rowHeight > 0) {
				return _rowHeight;
			}
			IListAdapter adapter = Adapter;
			int numColumns = GetNumColumnsCompatible();

			// adapter has not been set or has no views in it;
			if (adapter == null || adapter.Count <= numColumns * (_headerViewInfos.Count + _footerViewInfos.Count)) {
				return -1;
			}
			int mColumnWidth = GetColumnWidthCompatible();
			View view = Adapter.GetView(numColumns * _headerViewInfos.Count, _viewForMeasureRowHeight, this);
			AbsListView.LayoutParams p = (AbsListView.LayoutParams) view.LayoutParameters;
			if (p == null) {
				p = new AbsListView.LayoutParams(-1, -2, 0);
				view.LayoutParameters=p;
			}
			int childHeightSpec = GetChildMeasureSpec(
				MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified), 0, p.Height);
			int childWidthSpec = GetChildMeasureSpec(
				MeasureSpec.MakeMeasureSpec(mColumnWidth, MeasureSpecMode.Exactly), 0, p.Width);
			view.Measure(childWidthSpec, childHeightSpec);
			_viewForMeasureRowHeight = view;
			_rowHeight = view.MeasuredHeight;
			return _rowHeight;
		}
Beispiel #2
0
        private void Initialize(IAttributeSet attrs = null)
        {
            Orientation      = Orientation.Vertical;
            LayoutParameters = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);

            //TODO: Initialize cell from attrs
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.PullToZoomListViewLayout);
            ActionBar.SetDisplayHomeAsUpEnabled(true);

            _listView = (PullToZoomListViewEx)FindViewById(Resource.Id.listView);

            String[] adapterData = new String[] { "Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
                                                  "DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
                                                  "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
                                                  "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient" };

            _listView.SetAdapter(new ArrayAdapter <String>(this, Android.Resource.Layout.SimpleListItem1, adapterData));
            _listView.SetOnItemClickListener(this);

            DisplayMetrics localDisplayMetrics = new DisplayMetrics();

            WindowManager.DefaultDisplay.GetMetrics(localDisplayMetrics);
            int mScreenHeight = localDisplayMetrics.HeightPixels;
            int mScreenWidth  = localDisplayMetrics.WidthPixels;

            AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int)(9.0F * (mScreenWidth / 16.0F)));
            _listView.SetHeaderLayoutParams(localObject);
        }
 public void SetHeaderLayoutParams(AbsListView.LayoutParams layoutParams)
 {
     if (_headerContainer != null)
     {
         _headerContainer.LayoutParameters = layoutParams;
         _headerHeight = layoutParams.Height;
     }
 }
        public TextView GetGenericView(String name)
        {
            AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FillParent, (int)(40 * context.Resources.DisplayMetrics.Density));
            TextView textView = new TextView(context, null, 0);

            textView.LayoutParameters = layoutParams;
            textView.Gravity          = GravityFlags.CenterVertical | GravityFlags.Left;
            textView.Text             = name;
            return(textView);
        }
Beispiel #6
0
        public View GenerateView(int position)
        {
            var inflater = _context.LayoutInflater;

            var rootView = new LinearLayout(_context)
            {
                Orientation = Orientation.Horizontal
            };

            var rootParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent);

            rootView.LayoutParameters = rootParams;

            var card1 = (LinearLayout)inflater.Inflate(Resource.Layout.CardItem, null);
            var card2 = (LinearLayout)inflater.Inflate(Resource.Layout.CardItem, null);
            var card3 = (LinearLayout)inflater.Inflate(Resource.Layout.CardItem, null);
            var card4 = (LinearLayout)inflater.Inflate(Resource.Layout.CardItem, null);

            card1.Id = 1;
            card2.Id = 2;
            card3.Id = 3;
            card4.Id = 4;

            var leftView = new LinearLayout(_context)
            {
                Orientation = Orientation.Vertical
            };

            var leftParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            leftView.LayoutParameters = leftParams;

            leftView.AddView(card1);
            leftView.AddView(card2);

            var rightView = new LinearLayout(_context)
            {
                Orientation = Orientation.Vertical
            };

            var rightParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            rightView.LayoutParameters = rightParams;

            rightView.AddView(card3);
            rightView.AddView(card4);

            rootView.AddView(leftView);
            rootView.AddView(rightView);

            rootView.SetBackgroundColor(Android.Graphics.Color.ParseColor("#FFE5E5E5"));

            return(rootView);
        }
        public TextView getGenericView()
        {
            var lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, 64);

            var textView = new TextView(activity.ApplicationContext);

            textView.SetTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Black));
            textView.SetTextSize(Android.Util.ComplexUnitType.Dip, 18);
            textView.Gravity = GravityFlags.CenterVertical | GravityFlags.Left;
            textView.SetPadding(36, 0, 0, 0);

            return(textView);
        }
 /**
  * 设置HeaderView高度
  *
  * @param width  宽
  * @param height 高
  */
 public void SetHeaderViewSize(int width, int height)
 {
     if (_headerContainer != null)
     {
         Object localObject = _headerContainer.LayoutParameters;
         if (localObject == null)
         {
             localObject = new AbsListView.LayoutParams(width, height);
         }
         ((ViewGroup.LayoutParams)localObject).Width  = width;
         ((ViewGroup.LayoutParams)localObject).Height = height;
         _headerContainer.LayoutParameters            = (ViewGroup.LayoutParams)localObject;
         _headerHeight = height;
     }
 }
        public MultiItemRowListAdapter(Context context, IListAdapter adapter, int itemsPerRow, int cellSpacing, bool canClickAtRow = false)
        {
            if (itemsPerRow <= 0) {
                throw new IllegalArgumentException("Number of items per row must be positive");
                }
                _contextReference = new WeakReference<Context>(context);
                _adapter = adapter;
                _itemsPerRow = itemsPerRow;
                _cellSpacing = cellSpacing;
            _canClickAtRow = canClickAtRow;

            _itemLayoutParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MatchParent);
                _itemLayoutParams.SetMargins(cellSpacing, cellSpacing, 0, 0);
                _itemLayoutParams.Weight = 1;
                _rowLayoutParams = new AbsListView.LayoutParams(AbsListView.LayoutParams.MatchParent, AbsListView.LayoutParams.WrapContent);
        }
        public MultiItemRowListAdapter(Context context, IListAdapter adapter, int itemsPerRow, int cellSpacing, bool canClickAtRow = false)
        {
            if (itemsPerRow <= 0)
            {
                throw new IllegalArgumentException("Number of items per row must be positive");
            }
            _contextReference = new WeakReference <Context>(context);
            _adapter          = adapter;
            _itemsPerRow      = itemsPerRow;
            _cellSpacing      = cellSpacing;
            _canClickAtRow    = canClickAtRow;

            _itemLayoutParams = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.MatchParent);
            _itemLayoutParams.SetMargins(cellSpacing, cellSpacing, 0, 0);
            _itemLayoutParams.Weight = 1;
            _rowLayoutParams         = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
        }
Beispiel #11
0
        private void Init()
        {
            MIN_FLING        = Dp2Px(15);
            MAX_VELOCITYX    = -Dp2Px(500);
            LayoutParameters = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent,
                                                            ViewGroup.LayoutParams.WrapContent);
            mGestureListener = new DefaultOnGestureListener((x) =>
            {
                IsFling = x;
            }, MIN_FLING, MAX_VELOCITYX);
            mGestureDetector = new GestureDetectorCompat(Context, mGestureListener);

            if (mCloseInterpolator != null)
            {
                mCloseScroller = ScrollerCompat.Create(Context, mCloseInterpolator);
            }
            else
            {
                mCloseScroller = ScrollerCompat.Create(Context);
            }
            if (mOpenInterpolator != null)
            {
                mOpenScroller = ScrollerCompat.Create(Context, mOpenInterpolator);
            }
            else
            {
                mOpenScroller = ScrollerCompat.Create(Context);
            }

            LayoutParams contentParams = new LayoutParams(LayoutParams.MatchParent,
                                                          LayoutParams.WrapContent);

            ContentView.LayoutParameters = contentParams;
            if (ContentView.Id < 1)
            {
                ContentView.Id = CONTENT_VIEW_ID;
            }

            MenuView.Id = MENU_VIEW_ID;
            MenuView.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent,
                                                                   ViewGroup.LayoutParams.WrapContent);

            AddView(ContentView);
            AddView(MenuView);
        }
        public StickyHeaderListView(Context context, View header, int minHeightHeader, HeaderAnimator headerAnimator, ListView listView)
            : base(context, header, listView, minHeightHeader, headerAnimator)
        {
            // fake header
            var lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, heightHeader);
            fakeHeader = new Space(context)
            {
                LayoutParameters = lp
            };
            this.listView.AddHeaderView(fakeHeader);

            // scroll events
            this.listView.Scroll += (sender, e) =>
            {
                var scrolledY = -CalculateScrollYList();
                headerAnimator.OnScroll(scrolledY);
            };
        }
        public PackageRow(Context context)
            : base(context)
        {
            SetBackgroundColor(Color.Rgb(240, 240, 240));

            Orientation = Orientation.Horizontal;

            textContainer = new LinearLayout(context);
            textContainer.Orientation = Orientation.Vertical;

            AddView(textContainer);

            buttonContainer = new LinearLayout(context);
            AddView(buttonContainer);

            int height = context.Resources.DisplayMetrics.HeightPixels / 10;
            LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, height);

            textContainer.LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 7);
            buttonContainer.LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 3);

            nameLabel = new TextView(context);
            nameLabel.SetTextColor(Color.Black);
            nameLabel.Gravity = Android.Views.GravityFlags.CenterVertical;
            nameLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);
            nameLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 16);
            textContainer.AddView(nameLabel);

            statusLabel = new TextView(context);
            statusLabel.SetTextColor(Color.DarkGray);
            statusLabel.Gravity = Android.Views.GravityFlags.Top;
            statusLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);

            textContainer.AddView(statusLabel);

            Button = new PMButton(context);
            buttonContainer.AddView(Button);

            buttonContainer.Measure(0, 0);

            padding = buttonContainer.MeasuredHeight / 3;

            Button.LayoutParameters = GetButtonParams(padding);
        }
Beispiel #14
0
        public PackageRow(Context context) : base(context)
        {
            SetBackgroundColor(Color.Rgb(240, 240, 240));

            Orientation = Orientation.Horizontal;

            textContainer             = new LinearLayout(context);
            textContainer.Orientation = Orientation.Vertical;

            AddView(textContainer);

            buttonContainer = new LinearLayout(context);
            AddView(buttonContainer);

            int height = context.Resources.DisplayMetrics.HeightPixels / 10;

            LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, height);

            textContainer.LayoutParameters   = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 7);
            buttonContainer.LayoutParameters = new LinearLayout.LayoutParams(0, LayoutParams.MatchParent, 3);

            nameLabel = new TextView(context);
            nameLabel.SetTextColor(Color.Black);
            nameLabel.Gravity  = Android.Views.GravityFlags.CenterVertical;
            nameLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);
            nameLabel.SetTextSize(Android.Util.ComplexUnitType.Dip, 16);
            textContainer.AddView(nameLabel);

            statusLabel = new TextView(context);
            statusLabel.SetTextColor(Color.DarkGray);
            statusLabel.Gravity  = Android.Views.GravityFlags.Top;
            statusLabel.Typeface = Typeface.Create("Helvetica Neue", TypefaceStyle.Normal);

            textContainer.AddView(statusLabel);

            Button = new PMButton(context);
            buttonContainer.AddView(Button);

            buttonContainer.Measure(0, 0);

            padding = buttonContainer.MeasuredHeight / 3;

            Button.LayoutParameters = GetButtonParams(padding);
        }
Beispiel #15
0
        public StickyHeaderListView(Context context, View header, int minHeightHeader, HeaderAnimator headerAnimator, ListView listView, bool preventTouchBehindHeader)
            : base(context, header, listView, minHeightHeader, headerAnimator, preventTouchBehindHeader)
        {
            // fake header
            var lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, heightHeader);

            fakeHeader = new Space(context)
            {
                LayoutParameters = lp
            };
            this.listView.AddHeaderView(fakeHeader);

            // scroll events
            this.listView.Scroll += (sender, e) =>
            {
                var scrolledY = -CalculateScrollYList();
                headerAnimator.OnScroll(scrolledY);
            };
        }
Beispiel #16
0
        /// <summary>
        /// Отобразить выбор элемента на Activity.
        /// </summary>
        /// <param name="adapter">Адаптер с элементами которые нужно отобразить.</param>
        /// <param name="selectItem">Действие которое вызовется при выборе элемента.</param>
        public void ShowChoiceItem(ArrayAdapter adapter, Action <int> selectItem)
        {
            LinearLayout contenerListView = FindViewById <LinearLayout>(Resource.Id.ContenerForListItemChoices);

            var layoutParams = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);

            ListView listView = new ListView(this)
            {
                LayoutParameters = layoutParams
            };

            contenerListView.RemoveAllViews();
            contenerListView.AddView(listView);

            listView.ItemClick += null;
            listView.Adapter    = adapter;
            listView.ItemClick += (sender, args) =>
            {
                var posotion = args.Position;
                selectItem.Invoke(posotion);
            };
        }
Beispiel #17
0
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                TextView textView;

                if (convertView == null)
                {
                    textView = new TextView(mContext);
                    AbsListView.LayoutParams _params = new AbsListView.LayoutParams(
                        ViewGroup.LayoutParams.MatchParent,
                        ViewGroup.LayoutParams.MatchParent);
                    textView.LayoutParameters = _params;
                    // int twelvePx = Util.dpToPx(12, getResources());
                    int twelvePx = 14;
                    textView.SetPadding(twelvePx, twelvePx, twelvePx, twelvePx);
                    textView.SetTextColor(SmTextColor);
                }
                else
                {
                    textView = (TextView)convertView;
                }
                textView.Text = mStrings[position];
                return(textView);
            }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView(Resource.Layout.PullToZoomListViewLayout);
			ActionBar.SetDisplayHomeAsUpEnabled(true);

			_listView = (PullToZoomListViewEx) FindViewById(Resource.Id.listView);

			String[] adapterData = new String[]{"Activity", "Service", "Content Provider", "Intent", "BroadcastReceiver", "ADT", "Sqlite3", "HttpClient",
				"DDMS", "Android Studio", "Fragment", "Loader", "Activity", "Service", "Content Provider", "Intent",
				"BroadcastReceiver", "ADT", "Sqlite3", "HttpClient", "Activity", "Service", "Content Provider", "Intent",
				"BroadcastReceiver", "ADT", "Sqlite3", "HttpClient"};

			_listView.SetAdapter(new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, adapterData));
			_listView.SetOnItemClickListener (this);

			DisplayMetrics localDisplayMetrics = new DisplayMetrics();
			WindowManager.DefaultDisplay.GetMetrics(localDisplayMetrics);
			int mScreenHeight = localDisplayMetrics.HeightPixels;
			int mScreenWidth = localDisplayMetrics.WidthPixels;
			AbsListView.LayoutParams localObject = new AbsListView.LayoutParams(mScreenWidth, (int) (9.0F * (mScreenWidth / 16.0F)));
			_listView.SetHeaderLayoutParams(localObject);
		}
                public GroupListItem( Context context ) : base( context )
                {
                    SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) );
                    LayoutParameters = new AbsListView.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );

                    Orientation = Orientation.Vertical;

                    LinearLayout contentLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    contentLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );
                    contentLayout.Orientation = Orientation.Horizontal;
                    AddView( contentLayout );

                    TitleLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    TitleLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.WrapContent, LayoutParams.WrapContent );
                    TitleLayout.Orientation = Orientation.Vertical;
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Weight = 1;
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).LeftMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( 15 );
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( 5 );
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).BottomMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( 5 );
                    contentLayout.AddView( TitleLayout );

                    Title = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    Title.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    Title.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal );
                    Title.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Medium_FontSize );
                    Title.SetSingleLine( );
                    Title.Ellipsize = Android.Text.TextUtils.TruncateAt.End;
                    Title.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
                    TitleLayout.AddView( Title );

                    Typeface buttonFontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary );

                    JoinButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    JoinButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    ( (LinearLayout.LayoutParams)JoinButton.LayoutParameters ).Weight = 0;
                    ( (LinearLayout.LayoutParams)JoinButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
                    JoinButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
                    JoinButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateConnectConfig.GroupFinder_Join_IconSize );
                    JoinButton.Text = PrivateConnectConfig.GroupFinder_JoinIcon;
                    JoinButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
                    JoinButton.Background = null;
                    JoinButton.FocusableInTouchMode = false;
                    JoinButton.Focusable = false;
                    contentLayout.AddView( JoinButton );

                    JoinButton.Click += (object sender, EventArgs e ) =>
                        {
                            ParentAdapter.OnClick( Position, 1 );
                        };
                    
                    MeetingTime = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    MeetingTime.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    MeetingTime.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal );
                    MeetingTime.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
                    MeetingTime.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
                    TitleLayout.AddView( MeetingTime );

                    Distance  = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    Distance.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    Distance.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Light ), TypefaceStyle.Normal );
                    Distance.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
                    Distance.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
                    TitleLayout.AddView( Distance );

                    // add our own custom seperator at the bottom
                    View seperator = new View( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    seperator.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, 0 );
                    seperator.LayoutParameters.Height = 2;
                    seperator.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) );
                    AddView( seperator );
                }
Beispiel #20
0
        /**
         * Override {@link #getChildView(int, int, boolean, View, ViewGroup)} instead.
         */
        public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
        {
            GroupInfo info = GetGroupInfo(groupPosition);

            if (info.Animating)
            {
                // If this group is animating, return the a DummyView...
                if (convertView is DummyView == false)
                {
                    convertView = new DummyView(parent.Context);
                    convertView.LayoutParameters = new AbsListView.LayoutParams(AbsListView.LayoutParams.MatchParent, 0);
                }

                if (childPosition < info.FirstChildPosition)
                {
                    // The reason why we do this is to support the collapse
                    // this group when the group view is not visible but the
                    // children of this group are. When notifyDataSetChanged
                    // is called, the ExpandableListView tries to keep the
                    // list position the same by saving the first visible item
                    // and jumping back to that item after the views have been
                    // refreshed. Now the problem is, if a group has 2 items
                    // and the first visible item is the 2nd child of the group
                    // and this group is collapsed, then the dummy view will be
                    // used for the group. But now the group only has 1 item
                    // which is the dummy view, thus when the ListView is trying
                    // to restore the scroll position, it will try to jump to
                    // the second item of the group. But this group no longer
                    // has a second item, so it is forced to jump to the next
                    // group. This will cause a very ugly visual glitch. So
                    // the way that we counteract this is by creating as many
                    // dummy views as we need to maintain the scroll position
                    // of the ListView after notifyDataSetChanged has been
                    // called.
                    convertView.LayoutParameters.Height = 0;
                    return(convertView);
                }

                ExpandableListView listview = (ExpandableListView)parent;

                DummyView dummyView = (DummyView)convertView;

                // Clear the views that the dummy view draws
                dummyView.ClearViews();

                // Set the style of the divider
                dummyView.SetDivider(listview.Divider, parent.MeasuredWidth, listview.DividerHeight);

                // Make measure specs to measure child views
                int measureSpecW = View.MeasureSpec.MakeMeasureSpec(parent.Width, MeasureSpecMode.Exactly);
                int measureSpecH = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);

                int totalHeight = 0;
                int clipHeight  = parent.Height;

                int len = GetRealChildrenCount(groupPosition);
                for (int i = info.FirstChildPosition; i < len; i++)
                {
                    View childView = GetRealChildView(groupPosition, i, (i == len - 1), null, parent);

                    AbsListView.LayoutParams p = (AbsListView.LayoutParams)childView.LayoutParameters;
                    if (p == null)
                    {
                        p = (AbsListView.LayoutParams)GenerateDefaultLayoutParams();
                        childView.LayoutParameters = p;
                    }

                    int lpHeight = p.Height;

                    int childHeightSpec;
                    if (lpHeight > 0)
                    {
                        childHeightSpec = View.MeasureSpec.MakeMeasureSpec(lpHeight, MeasureSpecMode.Exactly);
                    }
                    else
                    {
                        childHeightSpec = measureSpecH;
                    }

                    childView.Measure(measureSpecW, childHeightSpec);
                    totalHeight += childView.MeasuredHeight;

                    if (totalHeight < clipHeight)
                    {
                        // we only need to draw enough views to fool the user...
                        dummyView.AddFakeView(childView);
                    }
                    else
                    {
                        dummyView.AddFakeView(childView);

                        // if this group has too many views, we don't want to
                        // calculate the height of everything... just do a light
                        // approximation and break
                        int averageHeight = totalHeight / (i + 1);
                        totalHeight += (len - i - 1) * averageHeight;
                        break;
                    }
                }

                Java.Lang.Object o;
                int state = (o = dummyView.Tag) == null ? STATE_IDLE : (Int16)o;

                if (info.Expanding && state != STATE_EXPANDING)
                {
                    ExpandAnimation ani = new ExpandAnimation(dummyView, 0, totalHeight, info);
                    ani.Duration = _parent.GetAnimationDuration();
                    ani.SetAnimationListener(new ExpandAnimationListener(this, groupPosition, dummyView));
                    dummyView.StartAnimation(ani);
                    dummyView.Tag = STATE_EXPANDING;
                }
                else if (!info.Expanding && state != STATE_COLLAPSING)
                {
                    if (info.DummyHeight == -1)
                    {
                        info.DummyHeight = totalHeight;
                    }

                    ExpandAnimation ani = new ExpandAnimation(dummyView, info.DummyHeight, 0, info);
                    ani.Duration = _parent.GetAnimationDuration();
                    ani.SetAnimationListener(new CollapseAnimationListener(this, groupPosition, listview, info, dummyView));

                    dummyView.StartAnimation(ani);
                    dummyView.Tag = STATE_COLLAPSING;
                }

                return(convertView);
            }
            else
            {
                return(GetRealChildView(groupPosition, childPosition, isLastChild, convertView, parent));
            }
        }
Beispiel #21
0
                public MessageListItem(Context context) : base(context)
                {
                    SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));
                    LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

                    Orientation = Orientation.Vertical;

                    // Content Layout will hold all the items for this row
                    LinearLayout contentLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    contentLayout.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    contentLayout.Orientation      = Orientation.Vertical;
                    AddView(contentLayout);

                    // Title Layout holds the title, and the MessageDetailsLayout (which contains date / speaker)
                    TitleLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    TitleLayout.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
                    TitleLayout.Orientation      = Orientation.Horizontal;
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).Weight     = 1;
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).LeftMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(15);
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).TopMargin  = (int)Rock.Mobile.Graphics.Util.UnitToPx(15);
                    contentLayout.AddView(TitleLayout);

                    Title = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    Title.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)Title.LayoutParameters).Gravity   = GravityFlags.Top;
                    ((LinearLayout.LayoutParams)Title.LayoutParameters).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-4);
                    Title.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Bold), TypefaceStyle.Normal);
                    Title.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Medium_FontSize);
                    Title.SetSingleLine( );
                    Title.Ellipsize = Android.Text.TextUtils.TruncateAt.End;
                    Title.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor));
                    TitleLayout.AddView(Title);


                    // This Stores the Date / Speaker
                    MessageDetailsLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    MessageDetailsLayout.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.WrapContent);
                    MessageDetailsLayout.Orientation      = Orientation.Vertical;
                    ((LinearLayout.LayoutParams)MessageDetailsLayout.LayoutParameters).Weight      = 1;
                    ((LinearLayout.LayoutParams)MessageDetailsLayout.LayoutParameters).Gravity     = GravityFlags.Right;
                    ((LinearLayout.LayoutParams)MessageDetailsLayout.LayoutParameters).LeftMargin  = (int)Rock.Mobile.Graphics.Util.UnitToPx(15);
                    ((LinearLayout.LayoutParams)MessageDetailsLayout.LayoutParameters).TopMargin   = (int)Rock.Mobile.Graphics.Util.UnitToPx(15);
                    ((LinearLayout.LayoutParams)MessageDetailsLayout.LayoutParameters).RightMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(15);
                    TitleLayout.AddView(MessageDetailsLayout);

                    Date = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    Date.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)Date.LayoutParameters).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-4);
                    ((LinearLayout.LayoutParams)Date.LayoutParameters).Gravity   = GravityFlags.Right;
                    Date.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Regular), TypefaceStyle.Normal);
                    Date.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                    Date.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor));
                    MessageDetailsLayout.AddView(Date);

                    Speaker = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    Speaker.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)Speaker.LayoutParameters).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-4);
                    ((LinearLayout.LayoutParams)Speaker.LayoutParameters).Gravity   = GravityFlags.Right;
                    Speaker.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Regular), TypefaceStyle.Normal);
                    Speaker.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                    Speaker.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor));
                    Speaker.SetMaxLines(1);
                    MessageDetailsLayout.AddView(Speaker);

                    // add our own custom seperator at the bottom
                    View seperator = new View(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    seperator.LayoutParameters        = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 0);
                    seperator.LayoutParameters.Height = 2;
                    seperator.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));
                    AddView(seperator);


                    // setup the buttons
                    LinearLayout buttonLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    buttonLayout.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    ((LinearLayout.LayoutParams)buttonLayout.LayoutParameters).Weight = 1;
                    buttonLayout.Orientation = Orientation.Horizontal;
                    contentLayout.AddView(buttonLayout);

                    Typeface buttonFontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary);

                    ListenButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    ListenButton.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)ListenButton.LayoutParameters).RightMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-10);
                    ListenButton.SetTypeface(buttonFontFace, TypefaceStyle.Normal);
                    ListenButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize);
                    ListenButton.Text = PrivateNoteConfig.Series_Table_Listen_Icon;
                    ListenButton.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(NoteConfig.Details_Table_IconColor));
                    ListenButton.Background = null;
                    buttonLayout.AddView(ListenButton);

                    WatchButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    WatchButton.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)WatchButton.LayoutParameters).RightMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-10);
                    WatchButton.SetTypeface(buttonFontFace, TypefaceStyle.Normal);
                    WatchButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize);
                    WatchButton.Text = PrivateNoteConfig.Series_Table_Watch_Icon;
                    WatchButton.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(NoteConfig.Details_Table_IconColor));
                    WatchButton.Background = null;
                    buttonLayout.AddView(WatchButton);

                    DiscussionGuideButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    DiscussionGuideButton.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)DiscussionGuideButton.LayoutParameters).RightMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-10);
                    DiscussionGuideButton.SetTypeface(buttonFontFace, TypefaceStyle.Normal);
                    DiscussionGuideButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize);
                    DiscussionGuideButton.Text = PrivateNoteConfig.Series_Table_DiscussionGuide_Icon;
                    DiscussionGuideButton.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(NoteConfig.Details_Table_IconColor));
                    DiscussionGuideButton.Background = null;
                    buttonLayout.AddView(DiscussionGuideButton);

                    TakeNotesButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    TakeNotesButton.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)TakeNotesButton.LayoutParameters).RightMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(-10);
                    TakeNotesButton.SetTypeface(buttonFontFace, TypefaceStyle.Normal);
                    TakeNotesButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize);
                    TakeNotesButton.Text = PrivateNoteConfig.Series_Table_TakeNotes_Icon;
                    TakeNotesButton.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(NoteConfig.Details_Table_IconColor));
                    TakeNotesButton.Background = null;
                    buttonLayout.AddView(TakeNotesButton);

                    ListenButton.Click += (object sender, EventArgs e) =>
                    {
                        ParentAdapter.OnClick(Position, 0);
                    };

                    WatchButton.Click += (object sender, EventArgs e) =>
                    {
                        ParentAdapter.OnClick(Position, 1);
                    };

                    TakeNotesButton.Click += (object sender, EventArgs e) =>
                    {
                        ParentAdapter.OnClick(Position, 2);
                    };

                    DiscussionGuideButton.Click += (object sender, EventArgs e) =>
                    {
                        ParentAdapter.OnClick(Position, 3);
                    };
                }
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            if (nn_historycard [position].isdefaultcard) {
                RelativeLayout layout = new RelativeLayout (nn_context);
                AbsListView.LayoutParams param=new AbsListView.LayoutParams (AbsListView.LayoutParams.MatchParent,TapUtil.dptodx(45));
                layout.LayoutParameters = param;
                layout.SetPadding (TapUtil.dptodx(5),TapUtil.dptodx(5),TapUtil.dptodx(5),TapUtil.dptodx(5));

                TextView defaultinfo = new TextView (nn_context);
                defaultinfo.Gravity = GravityFlags.Center;
                RelativeLayout.LayoutParams infoparam=new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.MatchParent,RelativeLayout.LayoutParams.WrapContent);
                infoparam.AddRule (LayoutRules.CenterInParent);
                defaultinfo.LayoutParameters = infoparam;
                defaultinfo.Text = nn_historycard [position].defaultinfo;

                layout.AddView (defaultinfo);

                return layout;
            }
            ViewHolder holder = null;
            if (convertView == null) {
                LayoutInflater inflator = LayoutInflater.From (nn_context);
                convertView = inflator.Inflate (Resource.Layout.goals_eventhistory_item, null);

                holder = new ViewHolder ();
                holder.ContentView = convertView;
                holder.eventnametextview = (TextView)convertView.FindViewById (Resource.Id.goals_eventhistory_eventnametextview);
                holder.organizationtextview = (TextView)convertView.FindViewById (Resource.Id.goals_eventhistory_organizationnametextview);
                holder.enddatetextview = (TextView)convertView.FindViewById (Resource.Id.goals_eventhistory_enddatetextview);
                holder.sellresulttextview = (TextView)convertView.FindViewById (Resource.Id.goals_eventhistory_sellresulttextview);
                holder.eventimageview=(ImageView)convertView.FindViewById (Resource.Id.goals_eventhistory_eventimage);
                convertView.Tag=holder;
            } else {
                holder= (ViewHolder) convertView.Tag;
            }

            holder.eventnametextview.Text = nn_historycard [position].eventinfo.event_name;
            holder.organizationtextview.Text = nn_historycard [position].eventinfo.organization;

            string datetimestring="";
            try{
                DateTime eventEndTime=DateTime.ParseExact (nn_historycard [position].eventinfo.event_end_time.Substring (0, 19),
                    "yyyy-MM-ddTHH:mm:ss", null);
                datetimestring=eventEndTime.ToShortDateString();
            }
            catch{
                datetimestring = "";
            }
            holder.enddatetextview.Text = HistoryScreenData.RaisedLabelText+datetimestring;

            int peronalrise = 0;
            int goalamount = 0;
            if (!string.IsNullOrEmpty(nn_historycard [position].eventinfo.gross_sales) ) {
                peronalrise = Int32.Parse(nn_historycard [position].eventinfo.gross_sales);
            }
            if(!string.IsNullOrEmpty(nn_historycard [position].eventinfo.seller_goal)){
                goalamount = Int32.Parse(nn_historycard [position].eventinfo.seller_goal);
            }

            decimal percent=(decimal)0;
            if (!string.IsNullOrEmpty(nn_historycard [position].eventinfo.gross_sales) && !string.IsNullOrEmpty(nn_historycard [position].eventinfo.seller_goal)) {
                if (peronalrise < 0 | goalamount < 0) {
                    percent = 0;
                }else if(peronalrise>=goalamount){
                    percent = 1;
                }else if(peronalrise<goalamount){
                    percent = (decimal)peronalrise / goalamount;
                }
            }
            string sellresult_percentageformat = Math.Round(percent*100) +"%";

            string raisedstring=String.Format(HistoryScreenData.RaisedLabelText+"{0}/"+HistoryScreenData.GoalLabelText+"{1}({2})",peronalrise,goalamount,sellresult_percentageformat);

            holder.sellresulttextview.Text = raisedstring;

            holder.eventimageview.SetImageBitmap (nn_historycard[position].bitmmapeventimage);

            return convertView;
        }
                public MessageListItem( Context context ) : base( context )
                {
                    SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor ) );
                    LayoutParameters = new AbsListView.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );

                    Orientation = Orientation.Vertical;

                    LinearLayout contentLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    contentLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );
                    contentLayout.Orientation = Orientation.Horizontal;
                    AddView( contentLayout );

                    TitleLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    TitleLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.WrapContent );
                    TitleLayout.Orientation = Orientation.Vertical;
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Weight = 1;
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).LeftMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( 15 );
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( 15 );
                    ( (LinearLayout.LayoutParams)TitleLayout.LayoutParameters ).BottomMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( 15 );
                    contentLayout.AddView( TitleLayout );

                    Title = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    Title.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    Title.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Bold ), TypefaceStyle.Normal );
                    Title.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Medium_FontSize );
                    Title.SetSingleLine( );
                    Title.Ellipsize = Android.Text.TextUtils.TruncateAt.End;
                    Title.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ) );
                    TitleLayout.AddView( Title );

                    Date = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    Date.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    Date.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
                    Date.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
                    Date.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
                    ( (LinearLayout.LayoutParams)Date.LayoutParameters ).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( -4 );
                    TitleLayout.AddView( Date );

                    Speaker = new TextView( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    Speaker.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    Speaker.SetTypeface( Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( ControlStylingConfig.Font_Regular ), TypefaceStyle.Normal );
                    Speaker.SetTextSize( Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize );
                    Speaker.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor ) );
                    ( (LinearLayout.LayoutParams)Speaker.LayoutParameters ).TopMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx( -4 );
                    Speaker.SetMaxLines( 1 );
                    TitleLayout.AddView( Speaker );

                    // add our own custom seperator at the bottom
                    View seperator = new View( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    seperator.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, 0 );
                    seperator.LayoutParameters.Height = 2;
                    seperator.SetBackgroundColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ) );
                    AddView( seperator );


                    // setup the buttons
                    LinearLayout buttonLayout = new LinearLayout( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    buttonLayout.LayoutParameters = new LinearLayout.LayoutParams( LayoutParams.MatchParent, LayoutParams.MatchParent );
                    ( (LinearLayout.LayoutParams)buttonLayout.LayoutParameters ).Weight = 1;
                    buttonLayout.Orientation = Orientation.Horizontal;
                    contentLayout.AddView( buttonLayout );

                    Typeface buttonFontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary );

                    ListenButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    ListenButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    ( (LinearLayout.LayoutParams)ListenButton.LayoutParameters ).Weight = 1;
                    ( (LinearLayout.LayoutParams)ListenButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
                    ListenButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
                    ListenButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize );
                    ListenButton.Text = PrivateNoteConfig.Series_Table_Listen_Icon;
                    ListenButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( NoteConfig.Details_Table_IconColor ) );
                    ListenButton.Background = null;
                    buttonLayout.AddView( ListenButton );

                    WatchButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    WatchButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    ( (LinearLayout.LayoutParams)WatchButton.LayoutParameters ).Weight = 1;
                    ( (LinearLayout.LayoutParams)WatchButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
                    WatchButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
                    WatchButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize );
                    WatchButton.Text = PrivateNoteConfig.Series_Table_Watch_Icon;
                    WatchButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( NoteConfig.Details_Table_IconColor ) );
                    WatchButton.Background = null;
                    buttonLayout.AddView( WatchButton );

                    TakeNotesButton = new Button( Rock.Mobile.PlatformSpecific.Android.Core.Context );
                    TakeNotesButton.LayoutParameters = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent );
                    ( (LinearLayout.LayoutParams)TakeNotesButton.LayoutParameters ).Weight = 1;
                    ( (LinearLayout.LayoutParams)TakeNotesButton.LayoutParameters ).Gravity = GravityFlags.CenterVertical;
                    TakeNotesButton.SetTypeface( buttonFontFace, TypefaceStyle.Normal );
                    TakeNotesButton.SetTextSize( Android.Util.ComplexUnitType.Dip, PrivateNoteConfig.Details_Table_IconSize );
                    TakeNotesButton.Text = PrivateNoteConfig.Series_Table_TakeNotes_Icon;
                    TakeNotesButton.SetTextColor( Rock.Mobile.UI.Util.GetUIColor( NoteConfig.Details_Table_IconColor ) );
                    TakeNotesButton.Background = null;
                    buttonLayout.AddView( TakeNotesButton );

                    ListenButton.Click += (object sender, EventArgs e ) =>
                        {
                            ParentAdapter.OnClick( Position, 0 );
                        };

                    WatchButton.Click += (object sender, EventArgs e ) =>
                        {
                            ParentAdapter.OnClick( Position, 1 );
                        };

                    TakeNotesButton.Click += (object sender, EventArgs e ) =>
                        {
                            ParentAdapter.OnClick( Position, 2 );
                        };
                }
Beispiel #24
0
                public GroupListItem(Context context) : base(context)
                {
                    SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BackgroundColor));
                    LayoutParameters = new AbsListView.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);

                    Orientation = Orientation.Vertical;

                    LinearLayout contentLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    contentLayout.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                    contentLayout.Orientation      = Orientation.Horizontal;
                    AddView(contentLayout);

                    TitleLayout = new LinearLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    TitleLayout.LayoutParameters = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
                    TitleLayout.Orientation      = Orientation.Vertical;
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).Weight       = 1;
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).Gravity      = GravityFlags.CenterVertical;
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).LeftMargin   = (int)Rock.Mobile.Graphics.Util.UnitToPx(15);
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).TopMargin    = (int)Rock.Mobile.Graphics.Util.UnitToPx(5);
                    ((LinearLayout.LayoutParams)TitleLayout.LayoutParameters).BottomMargin = (int)Rock.Mobile.Graphics.Util.UnitToPx(5);
                    contentLayout.AddView(TitleLayout);

                    Title = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    Title.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    Title.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Bold), TypefaceStyle.Normal);
                    Title.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Medium_FontSize);
                    Title.SetSingleLine( );
                    Title.Ellipsize = Android.Text.TextUtils.TruncateAt.End;
                    Title.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor));
                    TitleLayout.AddView(Title);

                    Typeface buttonFontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary);

                    JoinButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    JoinButton.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    ((LinearLayout.LayoutParams)JoinButton.LayoutParameters).Weight  = 0;
                    ((LinearLayout.LayoutParams)JoinButton.LayoutParameters).Gravity = GravityFlags.CenterVertical;
                    JoinButton.SetTypeface(buttonFontFace, TypefaceStyle.Normal);
                    JoinButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateConnectConfig.GroupFinder_Join_IconSize);
                    JoinButton.Text = PrivateConnectConfig.GroupFinder_JoinIcon;
                    JoinButton.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.TextField_PlaceholderTextColor));
                    JoinButton.Background           = null;
                    JoinButton.FocusableInTouchMode = false;
                    JoinButton.Focusable            = false;
                    contentLayout.AddView(JoinButton);

                    JoinButton.Click += (object sender, EventArgs e) =>
                    {
                        ParentAdapter.OnClick(Position, 1);
                    };

                    MeetingTime = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    MeetingTime.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    MeetingTime.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Light), TypefaceStyle.Normal);
                    MeetingTime.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                    MeetingTime.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor));
                    TitleLayout.AddView(MeetingTime);

                    Distance = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    Distance.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    Distance.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Light), TypefaceStyle.Normal);
                    Distance.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                    Distance.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor));
                    TitleLayout.AddView(Distance);

                    Childcare = new TextView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
                    Childcare.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
                    Childcare.SetTypeface(Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(ControlStylingConfig.Font_Light), TypefaceStyle.Normal);
                    Childcare.SetTextSize(Android.Util.ComplexUnitType.Dip, ControlStylingConfig.Small_FontSize);
                    Childcare.SetTextColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.Label_TextColor));
                    TitleLayout.AddView(Childcare);

                    // add our own custom seperator at the bottom
                    View seperator = new View(Rock.Mobile.PlatformSpecific.Android.Core.Context);

                    seperator.LayoutParameters        = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 0);
                    seperator.LayoutParameters.Height = 2;
                    seperator.SetBackgroundColor(Rock.Mobile.UI.Util.GetUIColor(ControlStylingConfig.BG_Layer_BorderColor));
                    AddView(seperator);
                }
Beispiel #25
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            CalendarViewHolder holder;

            if (convertView == null)
            {
                convertView      = mLayoutInflater.Inflate(Resource.Layout.calendar_cell, null);
                holder           = new CalendarViewHolder(mContext);
                holder.day_      = convertView.FindViewById <TextView>(Resource.Id.dateText);
                holder.foodList_ = convertView.FindViewById <LinearLayout>(Resource.Id.menu_in_cell);
                convertView.Tag  = holder;
            }
            else
            {
                holder = (CalendarViewHolder)convertView.Tag;
            }

            holder.foodList_.RemoveAllViews();
            var count = 0;

            foreach (var m in data_.Where(elm => elm.date_ == dateArray[position]).ToList())
            {
                if (count++ > 4)
                {
                    break;
                }
                var tv = new TextView(mContext);
                if (m.menu_.Length > 5)
                {
                    tv.Text = m.menu_.Substring(0, 4) + "..";
                }
                else
                {
                    tv.Text = m.menu_;
                }
                tv.SetTextSize(Android.Util.ComplexUnitType.Dip, 12);
                tv.SetTextColor(new Android.Graphics.Color(mContext.GetColor(Resource.Color.cyan)));
                holder.foodList_.AddView(tv);
            }



            /*convertView.Click += (sender, e) => {
             * Toast.MakeText(mContext, holder.day_.Text, ToastLength.Long).Show();
             * Toast.MakeText(mContext, position.ToString(), ToastLength.Long).Show();
             * var a = dataManager_.dataRef_.Where(elm => elm.date_.Date == dateArray[position]);
             * var intent = new Intent(mContext, typeof(CalendarCell.CalendarCellActivity));
             * intent.PutExtra("date", dateArray[position].ToString("yyyy年MM月dd日"));
             * intent.PutParcelableArrayListExtra("card", a.ToArray()); // intent に Card を詰める
             *
             * mContext.StartActivity(intent);
             * };*/

            //セルのサイズを指定
            float dp = mContext.Resources.DisplayMetrics.Density;

            AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams(parent.Width / 7 - (int)dp, (parent.Height - (int)dp * dateManager_.getWeeks()) / dateManager_.getWeeks());
            convertView.LayoutParameters = layoutParams;

            //日付のみ表示させる
            holder.day_.Text = dateArray[position].Day.ToString();

            //当月以外のセルをグレーアウト
            if (dateManager_.isCurrentMonth(dateArray[position]))
            {
                convertView.SetBackgroundColor(new Android.Graphics.Color(mContext.GetColor(Resource.Color.white)));
            }
            else
            {
                convertView.SetBackgroundColor(new Android.Graphics.Color(mContext.GetColor(Resource.Color.dimgray)));
            }

            //日曜日を赤、土曜日を青に
            int colorId;

            switch (dateManager_.getDayOfWeek(dateArray[position]))
            {
            case 0:
                colorId = Resource.Color.red;
                break;

            case 6:
                colorId = Resource.Color.blue;
                break;

            default:
                colorId = Resource.Color.black;
                break;
            }
            holder.day_.SetTextColor(new Android.Graphics.Color(mContext.GetColor(colorId)));

            return(convertView);
        }