Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Removed the CPCollectionView

  • Loading branch information...
commit 9559781a7d018c7a7ecbfd5008eecccaa91e19be 1 parent 7f4bfc5
Howard M. Lewis Ship authored
31 src/main/webapp/app/TwitView.j
@@ -6,29 +6,26 @@
6 6 CPTextField _label;
7 7 }
8 8
9   -- (void) setRepresentedObject:(JSONObject)obj
  9 +- (id)initWithFrame:(CGRect)frame
10 10 {
11   - if (!_label)
12   - {
13   - _label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
14   - [_label setFont:[CPFont systemFontOfSize:12]];
15   - [_label setTextColor:[CPColor whiteColor]];
16   - [_label setAutoresizingMask:CPViewWidthSizable];
17   - [self addSubview:_label];
18   - }
  11 + self = [super initWithFrame:frame];
  12 +
  13 + _label = [[CPTextField alloc] initWithFrame:frame];
  14 + [_label setFont:[CPFont systemFontOfSize:12]];
  15 + [_label setTextColor:[CPColor whiteColor]];
  16 + [_label setAutoresizingMask:CPViewWidthSizable];
  17 + [_label setLineBreakMode:CPLineBreakByWordWrapping];
19 18
20   - [_label setStringValue:obj.text];
21   -
22   - [_label setFrameSize:CGSizeMake(200, 60)];
  19 + [self addSubview:_label];
23 20
24   - [_label setLineBreakMode:CPLineBreakByWordWrapping];
  21 + return self;
25 22 }
26 23
27   -- (void)setSelected:(BOOL)isSelected
  24 +- (void)setRepresentedObject:(JSONObject)obj
28 25 {
29   - var color = isSelected ? [CPColor blueColor] :nil;
30   -
31   - [self setBackgroundColor:color];
  26 + CPLog.debug(obj.text);
  27 +
  28 + [_label setStringValue:obj.text];
32 29 }
33 30
34 31 @end
62 src/main/webapp/app/TwitterController.j
@@ -10,7 +10,6 @@
10 10 CPPanel _panel;
11 11 CPTextField _field;
12 12 CPScollView _scrollView;
13   - CPCollectionView _timelineView;
14 13 }
15 14
16 15 - (id)init
@@ -42,28 +41,7 @@
42 41
43 42 [_scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
44 43 [_scrollView setAutohidesScrollers:YES];
45   -
46   - var scrollViewBounds = [[_scrollView contentView] bounds];
47   -
48   - var itemPrototype = [[CPCollectionViewItem alloc] init];
49   - [itemPrototype setView:[[TwitView alloc] initWithFrame:CGRectMakeZero()]];
50   -
51   - _timelineView = [[CPCollectionView alloc] initWithFrame:CGRectMake(0, 0,
52   - CGRectGetWidth(scrollViewBounds), 60)];
53   - [_timelineView setItemPrototype:itemPrototype];
54   - [_timelineView setDelegate:self];
55   - [_timelineView setMaxNumberOfColumns:1];
56   -
57   - [_timelineView setAutoresizingMask:CPViewWidthSizable];
58   -
59   - [_scrollView setDocumentView:_timelineView];
60 44
61   - [[CPNotificationCenter defaultCenter]
62   - addObserver:self
63   - selector:@selector(scrollViewDidResize:)
64   - name:CPViewFrameDidChangeNotification
65   - object:_scrollView];
66   -
67 45 // Will fire an initial notification because the value changed.
68 46 [_scrollView setPostsFrameChangedNotifications:YES];
69 47
@@ -74,19 +52,6 @@
74 52
75 53 return self;
76 54 }
77   -
78   -- (void)scrollViewDidResize:(id)notification
79   -{
80   - var bounds = [_scrollView bounds];
81   -
82   - CPLog.debug("new size: " + CPRectGetWidth(bounds) + " x " + CPRectGetHeight(bounds));
83   -
84   - var newSize = CGSizeMake(CPRectGetWidth(bounds), 60);
85   -
86   - [_timelineView setMinItemSize:newSize];
87   - [_timelineView setMaxItemSize:newSize];
88   -}
89   -
90 55 - (void)show
91 56 {
92 57 [_panel orderFront:self];
@@ -108,7 +73,27 @@
108 73 {
109 74 var timeline = JSON.parse(data);
110 75
111   - [_timelineView setContent:timeline];
  76 + [self updateTimeline:timeline];
  77 +}
  78 +
  79 +- (void)updateTimeline:(CPArray) timeline
  80 +{
  81 + var width = CPRectGetWidth([_scrollView bounds]) - 4;
  82 + var container = [_scrollView contentView];
  83 +
  84 + var count = [timeline count];
  85 +
  86 + CPLog.debug("updateTimeline: " + count + " rows")
  87 +
  88 + for (row = 0; row < count; row++)
  89 + {
  90 + var frame = CGRectMake(2, 64 * row + 2, width, 60);
  91 + var view = [[TwitView alloc] initWithFrame:frame];
  92 + [view setRepresentedObject:[timeline objectAtIndex:row]];
  93 + [view setAutoresizingMask:CPViewWidthSizable];
  94 +
  95 + [container addSubview:view];
  96 + }
112 97 }
113 98
114 99
@@ -117,9 +102,4 @@
117 102 CPLog.error(error);
118 103 }
119 104
120   -- (void)adjustTimelineSize
121   -{
122   -
123   -}
124   -
125 105 @end

0 comments on commit 9559781

Please sign in to comment.
Something went wrong with that request. Please try again.