Mercurial > 510ConnectbotMonitor
comparison src/com/five_ten_sg/connectbot/monitor/MonitorActivity.java @ 2:f6a1aabf384f
add copyright
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Mon, 23 Jun 2014 16:57:39 -0700 |
parents | 5564580fe160 |
children | 2be5bca648ab |
comparison
equal
deleted
inserted
replaced
1:f12df02aa228 | 2:f6a1aabf384f |
---|---|
34 private MonitorService bound = null; | 34 private MonitorService bound = null; |
35 private Handler handler = new Handler() { | 35 private Handler handler = new Handler() { |
36 @Override | 36 @Override |
37 public void handleMessage (Message msg) { | 37 public void handleMessage (Message msg) { |
38 if (msg.what == MESSAGE_CODE_PRINT) { | 38 if (msg.what == MESSAGE_CODE_PRINT) { |
39 String s = (String)msg.obj; | 39 printer((String)msg.obj); |
40 if (count < LINES) count++; | |
41 else start = (start+1) % LINES; | |
42 texts[(start+count-1) % LINES] = s + "\n"; | |
43 String c = ""; | |
44 for (int i=0; i<count; i++) c = c.concat(texts[(start+i) % LINES]); | |
45 text.setText(c); | |
46 } else { | 40 } else { |
47 super.handleMessage(msg); | 41 super.handleMessage(msg); |
48 } | 42 } |
49 } | 43 } |
50 }; | 44 }; |
63 @Override | 57 @Override |
64 public void onCreate(Bundle savedInstanceState) { | 58 public void onCreate(Bundle savedInstanceState) { |
65 super.onCreate(savedInstanceState); | 59 super.onCreate(savedInstanceState); |
66 setContentView(R.layout.main); | 60 setContentView(R.layout.main); |
67 text = (TextView) findViewById(R.id.text2); | 61 text = (TextView) findViewById(R.id.text2); |
62 printer(getString(R.string.copyright)); | |
68 Log.i(TAG, "binding to monitor service"); | 63 Log.i(TAG, "binding to monitor service"); |
69 Intent intent = new Intent ("com.five_ten_sg.connectbot.monitor.MonitorService"); | 64 Intent intent = new Intent ("com.five_ten_sg.connectbot.monitor.MonitorService"); |
70 bindService(intent, connection, Context.BIND_AUTO_CREATE); | 65 bindService(intent, connection, Context.BIND_AUTO_CREATE); |
71 } | 66 } |
72 | 67 |
73 public void printer(String msg) { | 68 private void printer(String msg) { |
74 handler.sendMessage(handler.obtainMessage(MonitorActivity.MESSAGE_CODE_PRINT, msg)); | 69 if (count < LINES) count++; |
70 else start = (start+1) % LINES; | |
71 texts[(start+count-1) % LINES] = s + "\n"; | |
72 String c = ""; | |
73 for (int i=0; i<count; i++) c = c.concat(texts[(start+i) % LINES]); | |
74 text.setText(c); | |
75 } | 75 } |
76 | 76 |
77 @Override | 77 @Override |
78 protected void onStart() { | 78 protected void onStart() { |
79 super.onStart(); | 79 super.onStart(); |
80 printer("activity onStart()"); | |
81 Log.i(TAG, "activity onStart()"); | 80 Log.i(TAG, "activity onStart()"); |
82 } | 81 } |
83 | 82 |
84 @Override | 83 @Override |
85 protected void onRestart() { | 84 protected void onRestart() { |