Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 97

SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
01/09/14 04:57 PM (11 years ago)

New Plugin: Smug Climate for BTv2 and BTv3 iOS/Android available...

It is with pleasure that I release my second plugin: Smug Climate https://www.buzztouch.com/plugins/plugin.php?pid=F0DF3A80997EF9E9CDC2C28 A simple weather plugin in both iOS and/or Android. Compatible with BT for iOS v2 or 3 Compatible with BT for Android v2 or 3 Requires signup with 'worldweatheronline.com' to obtain a weather API. Abbreviated, the steps required are as follows: 1) Add your WWO API key enabled URL - save it. 2) Add a banner, or add a banner URL - save it. 3) Go! I don't 'welcome' all complaints, but face it; no one wants problems, and I'm here to help. Cheers! -- Smug
 
MacApple
Apple Fan
Profile
Posts: 4675
Reg: Oct 25, 2010
USA
61,150
like
01/09/14 05:06 PM (11 years ago)
Awesome buddy. Can't wait to try this one. Will grab at weekend. Good man! Some complicated steps there. 1, 2 3.
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
01/09/14 05:07 PM (11 years ago)
YEAPIE!!!!!!! Thank you thank you :)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/09/14 06:50 PM (11 years ago)
 
KennedyE
Android Fan
Profile
Posts: 373
Reg: Dec 07, 2013
PH, Nigeria
3,730
like
01/10/14 09:51 AM (11 years ago)
Sold! Will try it soon, thanks @SmugWimp for always considering Android in your Plugin development, God Bless you Brother.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/10/14 03:57 PM (11 years ago)
Congratulations! ... and Android also! Smug is making waves on both shores. :-) -- Niraj
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
01/26/14 04:45 PM (11 years ago)
Hey Smug, is there a way to change the displayed date format in the forecast row? Not sure if I should be looking at the code or the API... nothing really popped out at me in either, nor the API documentation Looking to make it a more Americanized date format... either 01-20-2014 or preferably January 20th, 2014. I was looking for a line of code or an api setting like mm/dd/yyyy or something similar to change, but didn't see anything like that anywhere, except in the API settings page where it says "date should be in yyyy-MM-dd format", but that's where you specify a specific dates forecast if wanted (optional). Is there a way (or should I say, a simple way) to parse the date when retrieved and change the displayed format?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/26/14 05:55 PM (11 years ago)
@Angry Ninja Look in the SW_smug_climate.m file, under the method 'titleForHeaderInSection'. That is where the information is being placed in the header. I get the info from the JSON data of the weather report (aka 'myObject.date'), so you'll have to take the data, reformat it, and then assign it to the sectionName property. Hope this helps. Let me know if not; we'll work through it with you. Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
01/27/14 10:17 AM (11 years ago)
Thanks Smug. I had a look at that, but my objective C skills are only about good enough to slightly modify some existing code, and not up to par enough to really write any. What kind of statement could I write to take the existing myObject.date and reformat it to display in the "January 20th, 2014" format, and declare it as myObject2.date? Sorry, writing the code from scratch is over my head... another reason I love BT :)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/27/14 06:50 PM (11 years ago)
It actually was a little more involved than I thought, but it's all good now. Replace the entire "titleForHeaderInSection" method with this: /////////////////////////////////////////////////////////////////////////////////////////////// ////// title For Header In Section /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////// - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { // date comes in this format: "date": "2013-06-08" YYYY-MM-DD SW_smug_climate_SectionArrayItem *myObject = [self.weatherItems objectAtIndex:section]; NSString *sectionName = [[NSString alloc]initWithString:myObject.date]; NSDateFormatter *df = [[NSDateFormatter alloc] init]; NSDateFormatter *dfa = [[NSDateFormatter alloc] init]; [df setDateFormat:@"yyyyMMdd"]; // // // [dfa setDateFormat:@"EEEE MMMM d, YYYY"]; // <-- uncomment this line, and comment out the next for 'Full' titles... [dfa setDateFormat:@"EEE MMM d, YYYY"]; // <-- this sets the format for the displayed date // // NSArray *dateArray = [myObject.date componentsSeparatedByString:@"-"]; if (section == 0) { sectionName = [NSString stringWithFormat:@"Now", nil]; } else { NSString *dateString = [[NSString alloc]initWithString:[dateArray objectAtIndex:0]]; dateString = [dateString stringByAppendingString:[dateArray objectAtIndex:1]]; dateString = [dateString stringByAppendingString:[dateArray objectAtIndex:2]]; NSDate *tmpDate = [df dateFromString:dateString]; sectionName = [dfa stringFromDate:tmpDate]; } return sectionName; } And you can uncomment/comment out the two 'format' lines to either have a full title (Saturday, January 1, 2014) or an abbreviated title (Sat Jan 1, 2014) Hope this is what you were looking for. Cheers! -- Smug
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
01/27/14 07:10 PM (11 years ago)
Perfect, thank you so much! That's exactly what I needed. :)
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.