Created
October 31, 2012 06:22
-
-
Save mixflame/3985361 to your computer and use it in GitHub Desktop.
Server List Activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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