Skip to content

Instantly share code, notes, and snippets.

@mixflame
Created October 31, 2012 06:22
Show Gist options
  • Save mixflame/3985361 to your computer and use it in GitHub Desktop.
Save mixflame/3985361 to your computer and use it in GitHub Desktop.
Server List Activity
require 'ruboto/widget'
require 'ruboto/util/toast'
require 'server_list_controller'
ruboto_import_widgets :Button, :LinearLayout, :TextView, :ListView, :EditText
class ServerList
def on_create(bundle)
super
set_title 'Server List'
$sl = self
Thread.new {
require 'net/http'
$server_list_hash = Net::HTTP.get('nexusnet.herokuapp.com', '/msl').
split("\n").
collect do |s|
par = s.split("-!!!-")
{:host => par[1], :name => par[0], :port => par[2]}
end
$names = $server_list_hash.map { |i| i[:name] }
$activity.run_on_ui_thread do
$sl.content_view =
linear_layout :orientation => :vertical do
$server_list = list_view(:list => $names)
end
end
}
rescue
puts "Exception creating activity: #{$!}"
puts $!.backtrace.join("\n")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment