Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
lscheinkman committed Jan 19, 2016
1 parent 059a842 commit 35dbe1b
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 106 deletions.
2 changes: 1 addition & 1 deletion taurus-mobile/ios/src/app/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MFMailComposeViewControll

/** mail delegate
*/
func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!) {
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {


controller.dismissViewControllerAnimated(true, completion: nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,21 @@ class InstanceDetailsViewController: UIViewController, UITableViewDataSource, UI

/** Datasource delegate to return number of rows in a cell.
*/
func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return metricChartData.count
}


/** bind data to cell and return the cell
*/
func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell = self.instanceTable.dequeueReusableCellWithIdentifier("metricCell")

cell?.selectionStyle = UITableViewCellSelectionStyle.None
let metricCell = cell as! MetricCell?

if ( metricCell == nil ){
return metricCell
return metricCell!
}

metricCell?.chart.emptyTextString = "Market Closed"
Expand All @@ -356,7 +356,7 @@ class InstanceDetailsViewController: UIViewController, UITableViewDataSource, UI


loadChartData( metricCell!, data: cellData)
return cell
return cell!
}

/** Handle selection of row
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class InstanceViewController: UIViewController, UITableViewDataSource, UITableVi



func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{

let data = tableData[ getSectionIndex(section)]
if (data != nil){
Expand All @@ -321,7 +321,7 @@ class InstanceViewController: UIViewController, UITableViewDataSource, UITableVi
return 0
}

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let cell:InstanceCell? = self.instanceTable.dequeueReusableCellWithIdentifier("InstanceCell") as! InstanceCell?

cell?.backgroundColor = UIColor.clearColor()
Expand Down
5 changes: 2 additions & 3 deletions taurus-mobile/ios/src/controllers/ModelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ class ModelController: NSObject, UIPageViewControllerDataSource {
return self.viewControllerAtIndex(index, storyboard: viewController.storyboard!)
}

func presentationCountForPageViewController(pageViewController: UIPageViewController!) -> Int {
func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int {
return pageData.count
}

func presentationIndexForPageViewController(pageViewController: UIPageViewController!) -> Int {
func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int {
return 0
}

}

12 changes: 6 additions & 6 deletions taurus-mobile/ios/src/service/TaurusDataSyncService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public class TaurusDataSyncService: DataSyncService{
if (now >= DataUtils.timestampFromDate(date!)) {
// Download the previous hour
from -= DataUtils.MILLIS_PER_HOUR;
let units : NSCalendarUnit = [NSCalendarUnit.NSYearCalendarUnit,
NSCalendarUnit.NSMonthCalendarUnit ,
NSCalendarUnit.NSDayCalendarUnit ,
NSCalendarUnit.NSHourCalendarUnit ,
NSCalendarUnit.NSMinuteCalendarUnit]
let units : NSCalendarUnit = [NSCalendarUnit.Year,
NSCalendarUnit.Month,
NSCalendarUnit.Day,
NSCalendarUnit.Hour,
NSCalendarUnit.Minute]



var newDate = NSCalendar.currentCalendar().dateByAddingUnit(
NSCalendarUnit.NSHourCalendarUnit, // adding hours
NSCalendarUnit.Hour, // adding hours
value: 1,
toDate: nowDate ,
options: []
Expand Down
172 changes: 82 additions & 90 deletions taurus-mobile/ios/src/views/TimeSliderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import Foundation
import UIKit

/** View for holding a
*/
*/

class TimeSliderView: UIView {

var endDate :NSDate = NSDate()
var showTop : Bool = true
var showBottom : Bool = true
Expand All @@ -36,105 +36,104 @@ class TimeSliderView: UIView {

var chartTotalBars = TaurusApplication.getTotalBarsOnChart()
var aggregation : AggregationType = AggregationType(period:60)

var labelCenterBottom : Double = 20.0
var labelCenterTop : Double = 5.0


let labelFormatter = NSDateFormatter()

var openColor : CGColorRef = UIColor.whiteColor().CGColor
var closedColor : CGColorRef = UIColor(red: 192.0/255.0, green: 192.0/255.0, blue: 192.0/255.0, alpha: 80.0/255.0).CGColor

let leftMargin = Appearence.viewMargin

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setup()

}

override init( frame : CGRect){
super.init(frame: frame)
setup()
}

func setup(){
labelFormatter.dateFormat = "haaaaaa"

}



/** draw the view*
-prameter rect: rect to draw in
*/
override func drawRect(rect: CGRect) {
-prameter rect: rect to draw in
*/
override func drawRect(rect: CGRect) {
var bar = chartTotalBars
var previousCollapsed = false

let interval = aggregation.milliseconds()

var time :Int64 = (Int64(endDate.timeIntervalSince1970*1000)/interval)*interval
let floatWidth = Double(rect.width)
let floatWidth = Double(rect.width)
let barWidth = (floatWidth - (leftMargin * 2)) / Double(chartTotalBars)
var left = Double(rect.width) - barWidth-0.5 - leftMargin

let startLeft = left
let top = Double(frame.origin.y)
let bottom = Double(frame.height)
var lastLeft: Double = Double(frame.width) - leftMargin
// print (endDate)
// print (endDate)
let context = UIGraphicsGetCurrentContext()
// Draw right to left all of the bars.
while (bar>0){
/* if (transparentBackground){
if (!previousCollapsed){
calendarTime = NSDate(timeIntervalSince1970: Double(time)/1000.0)
//drawLabelsBackground()
let hourOfDay = getHour (calendarTime)
if (hourOfDay%3==0){
drawLabel (rect, time: time, left: left, top: top, right: 0.0, bottom:bottom)
}
}
/* if (transparentBackground){
if (!previousCollapsed){
calendarTime = NSDate(timeIntervalSince1970: Double(time)/1000.0)
//drawLabelsBackground()
let hourOfDay = getHour (calendarTime)
if (hourOfDay%3==0){
drawLabel (rect, time: time, left: left, top: top, right: 0.0, bottom:bottom)
}
}
}*/


let open = TaurusApplication.marketCalendar.isOpen(time + DataUtils.METRIC_DATA_INTERVAL)

if (showBackground){


CGContextSaveGState( context)


if (open){
CGContextSetFillColorWithColor(context, self.openColor)

}else{
CGContextSetFillColorWithColor(context, self.closedColor)
}








let width :Double = ceil(lastLeft - left)
lastLeft -= width
let backRect : CGRect = CGRectMake(floor(CGFloat(lastLeft)), CGFloat(top), (CGFloat(width)), CGFloat(bottom))
// print (backRect)
// print (backRect)

CGContextSetAllowsAntialiasing (context, false)
CGContextFillRect(context, backRect)
CGContextSetAllowsAntialiasing (context, true)

CGContextRestoreGState( context)

}

if (!previousCollapsed ){
calendarTime = NSDate(timeIntervalSince1970: Double(time)/1000.0)
//drawLabelsBackground()
Expand All @@ -143,82 +142,82 @@ class TimeSliderView: UIView {
drawLabel (rect, time: time, left: left, top: top, right: 0.0, bottom:bottom)
}
}

previousCollapsed = false

if (collapsed){
var newTime = time
while ( open == false ) {
newTime -= interval
let marketOpen = TaurusApplication.marketCalendar.isOpen(newTime + DataUtils.METRIC_DATA_INTERVAL)

if (marketOpen)
{
break
}
time-=interval
}

}
// lastLeft = left

// lastLeft = left
left -= barWidth
time -= interval
bar--

}
// Draw Seperator line
CGContextSetStrokeColorWithColor(context, UIColor.lightGrayColor().CGColor)
CGContextSetStrokeColorWithColor(context, UIColor.lightGrayColor().CGColor)
CGContextMoveToPoint(context, CGFloat(10.0), CGFloat(20.0))
CGContextAddLineToPoint(context, CGFloat(rect.width-10.0), CGFloat(20.0))
CGContextStrokePath(context)
CGContextStrokePath(context)
}


/** draw label for time at top and bottom of screen
- parameter rect: drawing rectangle
- parameter time: time to draw
- paramter left: left location for label
- parameter top: top location for top label
- parameter right: right
- parameter bottom: bottom of drawing rectangle
*/
- parameter rect: drawing rectangle
- parameter time: time to draw
- paramter left: left location for label
- parameter top: top location for top label
- parameter right: right
- parameter bottom: bottom of drawing rectangle
*/
func drawLabel( rect: CGRect, time: Int64, left :Double, top: Double, right: Double, bottom: Double) {
// set the text color to dark gray
let fieldColor: UIColor = UIColor(red: 0.3, green: 0.3, blue: 0.3, alpha: 1.0)
let fontName = "HelveticaNeue-Bold"
let helveticaBold = UIFont(name: fontName, size: 12.0)

let date = NSDate(timeIntervalSince1970: Double(time)/1000.0)
let text : NSString = labelFormatter.stringFromDate(date)

if (self.showTop){
text.drawAtPoint(CGPointMake(CGFloat(left), CGFloat(top+labelCenterTop)),
withAttributes: [NSFontAttributeName : helveticaBold!, NSForegroundColorAttributeName: fieldColor])
withAttributes: [NSFontAttributeName : helveticaBold!, NSForegroundColorAttributeName: fieldColor])
}

if (self.showBottom){
text.drawAtPoint(CGPointMake(CGFloat(left), CGFloat(bottom-labelCenterBottom)),
withAttributes: [NSFontAttributeName : helveticaBold!, NSForegroundColorAttributeName: fieldColor])

}
}


/** hour for given date in local time
- parameter time: time to get hour of
- returns: hour of day in local time
*/
func getHour (time : NSDate)->Int{
- parameter time: time to get hour of
- returns: hour of day in local time
*/
func getHour (time : NSDate)->Int{
let calendar = NSCalendar.autoupdatingCurrentCalendar()
let comp = calendar.components((NSCalendarUnit.NSHourCalendarUnit), fromDate: time)
let comp = calendar.components((NSCalendarUnit.Hour), fromDate: time)
let hour = comp.hour
return hour
}


/** allow ignoring of touches to allow the views behind the time slider view to handle the event
*/
/** allow ignoring of touches to allow the views behind the time slider view to handle the event
*/
override func pointInside(point: CGPoint,
withEvent event: UIEvent?) -> Bool {
if (disableTouches ){
Expand All @@ -228,11 +227,4 @@ class TimeSliderView: UIView {
}
return false
}







}

0 comments on commit 35dbe1b

Please sign in to comment.