Chaton > Archives > 2009/07/03

2009/07/03 04:38:06 UTCyasuyuki
#
test from android
#
test from android (2)
#
test from android (3)
2009/07/03 04:49:17 UTCyasuyuki
#
test from android (4)
2009/07/03 04:51:20 UTCえんどう
#
package org.javaopen.chaton;

import java.io.IOException;
import java.util.HashMap;

import net.it4myself.util.RestfulClient;

import org.apache.http.client.ClientProtocolException;
import org.javaopen.lisp.Env;
import org.javaopen.lisp.List;
import org.javaopen.lisp.Reader;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Chaton extends Activity {
	private static final String TAG = "Chaton";
	
	private Handler handler;
	private Client client;
	private TextView chatView;
	private EditText sayText;
	private Button sayButton;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        handler = new Handler(Looper.myLooper());
        
        chatView = (TextView)findViewById(R.id.chat_view);
        sayText = (EditText)findViewById(R.id.say_text);
        sayButton = (Button)findViewById(R.id.say_button);
        
        String uri = Settings.getUri(this);
        String nickname = Settings.getNickname(this);
        
        if (nickname == null || nickname.length() == 0) {
            Dialog r = new RoomDialog(this);
            r.setTitle("Setup Room uri and Nickname");
            r.show();
        }
        
        connect();
        
        sayText.setOnKeyListener(new View.OnKeyListener() {
        	public boolean onKey(View view, int keyCode, KeyEvent event) {
        		if (keyCode == KeyEvent.KEYCODE_ENTER) {
        			return say();
        		}
        		return false;
        	}
        });
        
        sayButton.set
#
これでおけーかも
#
あ、切れてる。
#
sayText.setOnKeyListener(new View.OnKeyListener() {
        	public boolean onKey(View view, int keyCode, KeyEvent event) {
        		if (keyCode == KeyEvent.KEYCODE_ENTER) {
        			return say();
        		}
        		return false;
        	}
        });
        
        sayButton.setOnClickListener(new View.OnClickListener() {
        	public void onClick(View view) {
        		say();
        	}
        });
	}
#
private void connect() {
        // connect
		String uri = Settings.getUri(this);
        Uri.Builder builder =
        	Uri.parse(uri).buildUpon().appendPath(Client.LOGIN_PATH);
        Uri logpath = builder.build();
        HashMap<String, String> map = new HashMap<String, String>();
        map.put(Client.WHO_KEY, Settings.getNickname(this));
        Env env = new Env();
        Reader reader = new Reader(env);
        final Context me = this;
        try {
			String sexp = RestfulClient.Post(logpath.toString(), map);
			Log.d(TAG, "sexp=" + sexp);
			List conn = (List)reader.readFromString(sexp);
			client = new Client(uri, conn);
			final TextView view = chatView;
			client.setOnStateChangedListener(new Client.OnStateChangedListener() {
				public void stateChanged(Client client, String content) {
					final String text = content;
					//chatView.append(content);
					handler.post(new Runnable() {
						public void run() {
							view.append(text);
						}
					});
					Log.d(TAG, "stateChange: content=" + content);
				}
			});
			new Thread(client).start();
			Log.d(TAG, "conn=" + conn.serialize());
		} catch (ClientProtocolException e) {
			Log.d(TAG, e + e.getMessage());
		} catch (IOException e) {
			Log.d(TAG, e + e.getMessage());
		}
    }
	
	private boolean say() {
		String text = sayText.getText().toString();
		if (text == null || text.length() == 0) return false;
		String post = client.getPostUri();
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("text", text);
		map.put("nick", Settings.getNickname(this));
		String result = null;
		try {
			result = RestfulClient.Post(post, map);
			sayText.getText().clear();
			return true;
		} catch (ClientProtocolException e) {
			Log.d(TAG, e + e.getMessage());
			return false;
		} catch (IOException e) {
			Log.d(TAG, e + e.getMessage());
			return false;
		}
	}
2009/07/03 05:00:35 UTCyasuyuki
#
yatto dekita
#
scroll test
#
dev phone 1 kara kakiko
#
mouicho
#
hoge
#
piyo
2009/07/03 05:08:25 UTCyasuyuki
#
fullscroll dekinai orz
2009/07/03 06:43:10 UTCyasuyuki
#
shiro san ga kita
2009/07/03 06:47:29 UTCyasuyuki
#
test
2009/07/03 07:47:56 UTCyasuyuki
#
test from emulator
2009/07/03 08:46:07 UTCyasuyuki
#
test with WebView
#
test
#
test with WebView (2)
#
test3
#
test4
2009/07/03 08:58:01 UTCyasuyuki
#
test
2009/07/03 09:13:32 UTCyasuyuki
#
test (6)
#
test (7)
2009/07/03 10:08:20 UTCyasuyuki
#
test test
#
test test test
2009/07/03 10:32:04 UTCyasuyuki
#
dekita
#
dekita
#
scroll shinai. nazeda
2009/07/03 10:42:35 UTCyasuyuki
#
hoge
#
piyo
#
uga
#
scroll shinai
#
test
2009/07/03 10:49:33 UTCえんどう
#
なにか
2009/07/03 11:01:07 UTCyasuyuki
#
test
2009/07/03 11:11:21 UTCyasuyuki
#
test
#
test2
2009/07/03 11:11:51 UTCえんどう
#
どうだ
#
#
http://farm3.static.flickr.com/2618/3682565717_978b965166.jpg
2009/07/03 11:14:19 UTCyasuyuki
#
dekai
2009/07/03 11:14:42 UTCえんどう
#
画像の大きさは工夫した方がいいかなあ
2009/07/03 11:16:08 UTCyasuyuki
#
scroll muzukasii
#
test
#
test from dev phone
#
test from emulator
2009/07/03 14:29:51 UTCえんどう
#
Flashは単に空白で表示される。HTC Heroだったらちゃんと埋め込まれるんだろうか。
2009/07/03 22:07:31 UTCyasuyuki
#
test
#
WebKit no scroll ga
#
yokuwakaranai