module BubbleWrap::NetworkIndicator

Constants

DELAY

Public Instance Methods

counter() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 7
def counter
  @counter ||= 0
end
hide() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 22
def hide
  if Dispatch::Queue.current.to_s == 'com.apple.main-thread'
    @counter = [self.counter - 1, 0].max
    if self.counter == 0
      if @hide_indicator_timer
        @hide_indicator_timer.invalidate
      end
      @hide_indicator_timer = NSTimer.timerWithTimeInterval(DELAY - 0.01, target: self, selector: :update_spinner_timer, userInfo: nil, repeats: false)
      NSRunLoop.mainRunLoop.addTimer(@hide_indicator_timer, forMode:NSRunLoopCommonModes)
    end
  else
    Dispatch::Queue.main.async do
      self.hide
    end
  end
end
reset!() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 61
def reset!
  @counter = 0
  self.update_spinner
end
show() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 11
def show
  if Dispatch::Queue.current.to_s == 'com.apple.main-thread'
    @counter = self.counter + 1
    self.update_spinner
  else
    Dispatch::Queue.main.async do
      self.show
    end
  end
end
update_spinner() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 43
def update_spinner
  if Dispatch::Queue.current.to_s == 'com.apple.main-thread'
    if @hide_indicator_timer
      @hide_indicator_timer.invalidate
      @hide_indicator_timer = nil
    end
    UIApplication.sharedApplication.networkActivityIndicatorVisible = (@counter > 0)
  else
    Dispatch::Queue.main.async do
      self.update_spinner
    end
  end
end
update_spinner_timer() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 39
def update_spinner_timer
  update_spinner
end
visible?() click to toggle source
# File motion/network-indicator/network-indicator.rb, line 57
def visible?
  UIApplication.sharedApplication.networkActivityIndicatorVisible?
end