Skip to content

Commit

Permalink
添加rss时下面添加一些常用和热门的关键字,更新了下默认的rss源
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed May 29, 2014
1 parent 36d464b commit d5e318f
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 29 deletions.
32 changes: 16 additions & 16 deletions RSSRead/RecommendFeedList.plist
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
</dict>
<dict>
<key>title</key>
<string>dApps开发者</string>
<string>大洋24小时滚动新闻</string>
<key>link</key>
<string>http://www.dapps.net</string>
<string>http://www.dayoo.com/roll</string>
<key>summary</key>
<string>为手机应用APP开发、手机游戏开发,移动互联网、云计算、HTML5等开发者提供专业的资讯!</string>
<string>大洋网是立足广州、辐射华南的综合性区域门户网站,为用户提供新闻、生活、论坛、书城等20多个频道及广州日报集团旗下《广州日报》《信息时报》等20家报刊杂志电子版</string>
<key>url</key>
<string>http://www.dapps.net/feed</string>
<string>http://rss.dayoo.com/feed/news/roll.xml</string>
</dict>
<dict>
<key>title</key>
Expand All @@ -44,13 +44,13 @@
</dict>
<dict>
<key>title</key>
<string>Solidot</string>
<string>科技--华尔街日报</string>
<key>link</key>
<string>http://www.solidot.org</string>
<string>http://cn.wsj.com/gb/tech.asp</string>
<key>summary</key>
<string>奇客的资讯,重要的东西</string>
<string>《华尔街日报》中文版络版最新科技要闻</string>
<key>url</key>
<string>http://feeds2.feedburner.com/solidot</string>
<string>http://cn.wsj.com/gb/rsstech.xml</string>
</dict>
<dict>
<key>title</key>
Expand All @@ -74,13 +74,13 @@
</dict>
<dict>
<key>title</key>
<string>爱范儿 · Beats of Bits</string>
<string>新闻要闻-新浪新闻</string>
<key>link</key>
<string>http://www.ifanr.com</string>
<string>http://roll.news.sina.com.cn/s/</string>
<key>summary</key>
<string>发现创新价值的科技媒体</string>
<string>新闻中心-新闻要闻</string>
<key>url</key>
<string>http://fulltextrssfeed.com/www.ifanr.com</string>
<string>http://rss.sina.com.cn/news/marquee/ddt.xml</string>
</dict>
<dict>
<key>title</key>
Expand All @@ -94,13 +94,13 @@
</dict>
<dict>
<key>title</key>
<string>和邪社</string>
<string>Mashable</string>
<key>link</key>
<string>http://www.hexieshe.com/</string>
<string>http://mashable.com/</string>
<key>summary</key>
<string>你的ACG生活 文不在长.内涵则明 图不在色.意淫则灵</string>
<string>Mashable is a leading source for news</string>
<key>url</key>
<string>http://www.hexieshe.com/feed/</string>
<string>http://feeds.mashable.com/Mashable</string>
</dict>
</array>
</plist>
59 changes: 53 additions & 6 deletions RSSRead/SMAddRSSViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ @interface SMAddRSSViewController ()<SMAddRSSToolbarDelegate,UITableViewDelegate
@property(nonatomic,weak) SMAddRSSToolbar *toolbar;
@property(nonatomic,strong)NSMutableArray *RSSArray;
@property(nonatomic,weak)UITableView *tableView;
@property(nonatomic,strong)NSArray *keyWords;
@property(nonatomic,strong)UIView *keywordsView;
@end

@implementation SMAddRSSViewController
Expand Down Expand Up @@ -132,6 +134,7 @@ - (void)btnClickAddRssUsingTag:(UIButton *)btn
*/
- (void)loadRssSourcesWithStr:(NSString *)str
{
[_keywordsView removeFromSuperview];
[MBProgressHUD showHUDAddedTo:self.view animated:YES];

AFHTTPRequestOperationManager *mgr = [AFHTTPRequestOperationManager manager];
Expand Down Expand Up @@ -358,7 +361,6 @@ - (void)keyboardWillHide:(NSNotification *)note
#pragma mark - 加载自定义控件
- (void)setupSearchBar
{

UIButton *closeButton = [[UIButton alloc] initWithFrame:CGRectMake(8, 0, 50, 50)];
[closeButton setTitleColor:[UIColor rss_darkGrayColor] forState:UIControlStateNormal];
[closeButton setTitle:@"返回" forState:UIControlStateNormal];
Expand Down Expand Up @@ -397,22 +399,67 @@ - (void)setupResultView
tableView.delegate =self;
tableView.dataSource =self;

_keywordsView = [[UIView alloc] initWithFrame:tableView.bounds];

//介绍
UILabel *introLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[introLabel setFont:[UIFont systemFontOfSize:16]];
[introLabel setTextColor:[UIColor rss_darkGrayColor]];
[introLabel setBackgroundColor:[UIColor clearColor]];
[introLabel setText:@"这里可以搜索订阅源哦。喵。^V^"];
[introLabel setNumberOfLines:0];
[introLabel sizeToFit];
introLabel.left = (_keywordsView.width - introLabel.width)/2;
introLabel.top = tableView.top + 10;
[_keywordsView addSubview:introLabel];

//推荐搜索关键字,
//TODO:大家有什么觉得比较常用的关键字放这里好,还有颜色
_keyWords = @[@"科技",@"体育",@"电影",@"音乐",@"新闻",@"文学",@"艺术",@"北京",@"上海",@"杭州",@"程序员",@"云计算",@"创意",@"设计",@"创造",@"游戏",@"旅游",@"英雄联盟",@"PlayStation",@"Xbox"];
NSArray *colorArray = @[@"#ff96aa",@"#25c0dc",@"#3edc13",@"#1dcba8"];

CGFloat leftPadding = 10;
CGFloat topPadding = 10;
// CGRect rect = CGRectMake(leftPadding, topPadding, 0, 0);
CGFloat x = leftPadding;
CGFloat y = topPadding + introLabel.top + 20;

CGSize btSize = CGSizeZero;

UIView *view = [[UIView alloc] initWithFrame:tableView.bounds];
introLabel.left = (view.width - introLabel.width)/2;
introLabel.top = 150;
[view addSubview:introLabel];
[tableView setBackgroundView:view];
NSInteger i = 0;
for (NSString *kw in _keyWords) {
UIButton *btKw = [[UIButton alloc]initWithFrame:CGRectZero];
int r = arc4random() % [colorArray count];
NSString *colorStr = colorArray[r];
[btKw setBackgroundColor:[SMUIKitHelper colorWithHexString:colorStr]];
[btKw setTitle:kw forState:UIControlStateNormal];
[btKw setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
btKw.titleLabel.font = [UIFont systemFontOfSize:14];
btKw.size = [kw sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14]}];
btSize = CGSizeMake(btKw.width + 10, btKw.height + 10);

if (x + btSize.width + leftPadding > SCREEN_WIDTH - 15) {
x = leftPadding;
y += btSize.height + topPadding;
}

btKw.frame = CGRectMake(x, y, btSize.width, btSize.height);
btKw.tag = i;
[btKw addTarget:self action:@selector(keyWordClick:) forControlEvents:UIControlEventTouchUpInside];

x += btSize.width + leftPadding;

[_keywordsView addSubview:btKw];
i++;
}
_tableView =tableView;
[self.view addSubview:tableView];
[self.view addSubview:_keywordsView];
}

-(void)keyWordClick:(UIButton *)sender {
[self loadRssSourcesWithStr:_keyWords[sender.tag]];
NSLog(@"come here");
}


Expand Down
7 changes: 1 addition & 6 deletions RSSRead/SMAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)];
[APService setupWithOption:launchOptions];
//模糊图片写入沙盒
// [SMBlurBackground SMRSSbackgroundImage:nil];



return YES;
}
Expand Down Expand Up @@ -199,7 +195,7 @@ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory]
stringByAppendingPathComponent: @"RSS.sqlite"]];
NSError *error = nil;
//下面的options能够解决每次修改coredata数据结构的不删除app就crash的问题。
//下面的options能够解决每次修改coredata数据结构的不删除app就crash的问题。要注意,改变coredata数据结构时需要添加一个新版本xcdatamodeldz,具体操作可以查看项目wiki
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
Expand All @@ -209,7 +205,6 @@ - (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
configuration:nil URL:storeUrl options:options error:&error]) {
/*Error for store creation should be handled in here*/
}

return _persistentStoreCoordinator;
}

Expand Down
1 change: 0 additions & 1 deletion RSSRead/SMRSSListCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ -(void)setRss:(RSS *)rss {
} else {
_lbTitle.textColor = [SMUIKitHelper colorWithHexString:_darkcolor];
}
rss.summary = [rss.summary stringByReplacingOccurrencesOfString:@" " withString:@""];
[_lbSummary setText:[rss.summary stringByConvertingHTMLToPlainText]];
[self setNeedsDisplay];
}
Expand Down

0 comments on commit d5e318f

Please sign in to comment.