Sha256: a0ab4fa1d84da0a077fdea398ffe4f6a58bf07f54beea879e2831ff2ee4380e4

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

require 'ruboto/base'
require 'ruboto/package'

#######################################################
#
# ruboto/service.rb
#
# Basic service set up and callback configuration.
#
#######################################################

#
# Context
#

module Ruboto
  module Context
    def initialize_ruboto()
      eval("#{$new_context_global} = self")
      $new_context_global = nil

      instance_eval &$context_init_block if $context_init_block
      $context_init_block = nil
      setup_ruboto_callbacks 

      @initialized = true
      self
    end
  
    def start_ruboto_service(global_variable_name = '$service', klass=RubotoService, &block)
      $context_init_block = block
      $new_context_global = global_variable_name
  
      if @initialized or (self == $service) or ($service == nil) # FIx mix between activity and service
        self.startService Java::android.content.Intent.new(self, klass.java_class)
      else
        initialize_ruboto
        on_create
      end
  
      self
    end
  end
end

java_import "android.content.Context"
Context.class_eval do
  include Ruboto::Context
end

#
# Leave for legacy Service Subclass Setup
#

module Ruboto
  module Service
  end
end

#
# Basic Service Setup
#

def ruboto_configure_service(klass)
  klass.class_eval do
    include Ruboto::Service
    
    def on_create
    end
  end
end

ruboto_import "org.ruboto.RubotoService"
ruboto_configure_service(RubotoService)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruboto-0.9.0 assets/src/ruboto/service.rb
ruboto-0.9.0.rc.1 assets/src/ruboto/service.rb
ruboto-0.9.0.rc.0 assets/src/ruboto/service.rb
ruboto-0.8.1 assets/src/ruboto/service.rb
ruboto-0.8.0 assets/src/ruboto/service.rb