Class: Elevate::HTTP::ActivityIndicator

Inherits:
Object
  • Object
show all
Defined in:
lib/elevate/http/activity_indicator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeActivityIndicator

Returns a new instance of ActivityIndicator.



10
11
12
13
# File 'lib/elevate/http/activity_indicator.rb', line 10

def initialize
  @lock = NSLock.alloc.init
  @count = 0
end

Class Method Details

.instanceObject



4
5
6
7
8
# File 'lib/elevate/http/activity_indicator.rb', line 4

def self.instance
  Dispatch.once { @instance = new }

  @instance
end

Instance Method Details

#hideObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/elevate/http/activity_indicator.rb', line 15

def hide
  toggled = false

  @lock.lock
  @count -= 1 if @count > 0
  toggled = @count == 0
  @lock.unlock

  update_indicator(false) if toggled
end

#showObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/elevate/http/activity_indicator.rb', line 26

def show
  toggled = false

  @lock.lock
  toggled = @count == 0
  @count += 1
  @lock.unlock

  update_indicator(true) if toggled
end