update ui layout
[freespace.git] / weibosrc / com / weibo / sina / RetweetMessage.java
blobfb29f308f4b48e4f3294bd16a61864277b406fa3
2 package com.weibo.sina;
4 import com.weibo.client.Weibo;
5 import com.weibo.net.WeiboException;
7 import android.app.Activity;
8 import android.os.Bundle;
9 import android.os.Handler;
10 import android.os.Message;
11 import android.util.Log;
12 import android.view.View;
13 import android.view.View.OnClickListener;
14 import android.view.View.OnFocusChangeListener;
15 import android.view.inputmethod.InputMethodManager;
16 import android.widget.Button;
17 import android.widget.EditText;
18 import android.widget.TextView;
19 import android.widget.Toast;
21 public class RetweetMessage extends Activity {
22 private static final String TAG = "RetweetMessage";
24 private EditText mUpdate_edit;
26 private static final int RETWEET = 0x00;
28 private long mId;
30 private final Handler mHandler = new Handler() {
31 public void handleMessage(Message msg) {
32 switch (msg.what) {
33 case RETWEET:
34 String tmpString = mUpdate_edit.getEditableText().toString();
35 tmpString = tmpString.trim();
36 if (tmpString.length() == 0) {
37 Toast.makeText(getBaseContext(), R.string.content_empty, Toast.LENGTH_LONG)
38 .show();
39 return;
41 if (tmpString.length() > 140) {
42 Toast.makeText(getBaseContext(), R.string.content_outnumber,
43 Toast.LENGTH_LONG).show();
44 return;
46 try {
47 Weibo.getInstance().repost(mUpdate_edit.getEditableText().toString(),
48 mId + "");
49 } catch (WeiboException e) {
50 // TODO Auto-generated catch block
51 e.printStackTrace();
53 // ProgressBar progressBar = (ProgressBar)
54 // findViewById(R.id.updateProgressBar);
55 // progressBar.setVisibility(View.INVISIBLE);
56 Toast.makeText(getBaseContext(), R.string.tips_send_ok, Toast.LENGTH_LONG)
57 .show();
58 finish();
59 overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
64 @Override
65 protected void onCreate(Bundle savedInstanceState) {
66 setContentView(R.layout.reply_layout);
67 super.onCreate(savedInstanceState);
68 mUpdate_edit = (EditText) findViewById(R.id.post_edit);
70 mUpdate_edit.setOnFocusChangeListener(new OnFocusChangeListener() {
72 public void onFocusChange(View v, boolean hasFocus) {
73 // TODO Auto-generated method stub
74 // Log.e(TAG, "onFocuseChange");
75 if (hasFocus) {
76 Log.e(TAG, "get Focuse");
77 InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
78 if (imm != null) {
80 imm.showSoftInput(mUpdate_edit, InputMethodManager.SHOW_FORCED);
82 } else {
83 Log.e(TAG, "lost Focuse");
84 if (RetweetMessage.this.getCurrentFocus() != null) {
85 // Log.e(TAG, "hideSoftInputFromWindow");
86 ((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
87 .hideSoftInputFromWindow(RetweetMessage.this.getCurrentFocus()
88 .getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
92 });
94 Button btn = (Button) findViewById(R.id.update_button);
95 btn.setOnClickListener(new OnClickListener() {
97 public void onClick(View v) {
99 // ProgressBar progressBar = (ProgressBar)
100 // findViewById(R.id.updateProgressBar);
101 // progressBar.setVisibility(View.VISIBLE);
102 mHandler.obtainMessage(RETWEET).sendToTarget();
106 btn = (Button) findViewById(R.id.cancel_button);
107 btn.setOnClickListener(new OnClickListener() {
108 public void onClick(View v) {
109 finish();
110 Log.e(TAG, "finish()");
111 overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
114 mUpdate_edit.requestFocus();
115 View reply = (View) findViewById(R.id.reply_view);
116 reply.setVisibility(View.VISIBLE);
117 TextView nick = (TextView) findViewById(R.id.nick);
118 Log.e(TAG, "name=" + getIntent().getStringExtra("name"));
119 Log.e(TAG, "content=" + getIntent().getStringExtra("content"));
120 nick.setText(getIntent().getStringExtra("name"));
121 nick = (TextView) findViewById(R.id.content);
122 nick.setText(getIntent().getStringExtra("content"));
123 mId = getIntent().getLongExtra("id", 0);