public static final int button84=0x7f05003b;\r
public static final int button85=0x7f05003c;\r
public static final int button86=0x7f05003d;\r
- public static final int buttona1=0x7f050045;\r
+ public static final int buttona1=0x7f050046;\r
public static final int checkBox=0x7f050000;\r
public static final int checkBox61=0x7f050022;\r
public static final int checkBox62=0x7f050023;\r
public static final int textView51=0x7f05003e;\r
public static final int textView81=0x7f050035;\r
public static final int textViewa1=0x7f050044;\r
+ public static final int waitViewa1=0x7f050045;\r
}\r
public static final class layout {\r
public static final int check_list_item_1=0x7f030000;\r
public static final int wait=0x7f03000a;\r
}\r
public static final class string {\r
- public static final int add_button=0x7f040028;\r
+ public static final int add_button=0x7f040029;\r
public static final int app_name=0x7f040001;\r
- public static final int cancel_button=0x7f04002b;\r
+ public static final int cancel_button=0x7f04002c;\r
public static final int comma_msg=0x7f04001a;\r
- public static final int conf_button=0x7f040027;\r
+ public static final int conf_button=0x7f040028;\r
public static final int conf_route_msg=0x7f040017;\r
public static final int conf_time_msg=0x7f040018;\r
public static final int conf_title=0x7f040005;\r
public static final int date_title=0x7f040002;\r
- public static final int def_button=0x7f040025;\r
- public static final int delete_button=0x7f04002a;\r
+ public static final int def_button=0x7f040026;\r
+ public static final int delete_button=0x7f04002b;\r
public static final int do_service_msg=0x7f04001b;\r
+ public static final int end_rouote_msg=0x7f04001d;\r
public static final int end_service_qmsg=0x7f040015;\r
public static final int end_time_title=0x7f040004;\r
- public static final int exit_button=0x7f040024;\r
+ public static final int exit_button=0x7f040025;\r
public static final int friday_title=0x7f04000c;\r
public static final int hello=0x7f040000;\r
- public static final int history_button=0x7f040022;\r
+ public static final int history_button=0x7f040023;\r
public static final int history_tite=0x7f040010;\r
- public static final int keyword_button=0x7f040023;\r
+ public static final int keyword_button=0x7f040024;\r
public static final int keyword_title=0x7f04000e;\r
public static final int monday_title=0x7f040008;\r
- public static final int monitor_button=0x7f04001f;\r
- public static final int return_button=0x7f040026;\r
- public static final int route_button=0x7f04001e;\r
+ public static final int monitor_button=0x7f040020;\r
+ public static final int return_button=0x7f040027;\r
+ public static final int route_button=0x7f04001f;\r
public static final int route_title=0x7f04000f;\r
public static final int saturday_title=0x7f04000d;\r
- public static final int start_service_button=0x7f040020;\r
+ public static final int start_rouote_msg=0x7f04001c;\r
+ public static final int start_service_button=0x7f040021;\r
public static final int start_service_msg=0x7f040019;\r
public static final int start_service_qmsg=0x7f040014;\r
public static final int start_time_title=0x7f040003;\r
- public static final int stop_service_button=0x7f040021;\r
+ public static final int stop_service_button=0x7f040022;\r
public static final int sunday_title=0x7f040007;\r
public static final int thursday_title=0x7f04000b;\r
public static final int time_title=0x7f040011;\r
public static final int tpm_title=0x7f040012;\r
public static final int tuesday_title=0x7f040009;\r
- public static final int update_button=0x7f040029;\r
- public static final int update_route_button=0x7f04001d;\r
+ public static final int update_button=0x7f04002a;\r
+ public static final int update_route_button=0x7f04001e;\r
public static final int update_route_msg=0x7f040016;\r
- public static final int wait_rouote_msg=0x7f04001c;\r
public static final int warn_dialog_title=0x7f040013;\r
public static final int wednesday_title=0x7f04000a;\r
public static final int week_title=0x7f040006;\r
- public static final int yes_button=0x7f04002c;\r
+ public static final int yes_button=0x7f04002d;\r
}\r
}\r
reply.writeNoException();
return true;
}
+case TRANSACTION_stop:
+{
+data.enforceInterface(DESCRIPTOR);
+this.stop();
+reply.writeNoException();
+return true;
+}
}
return super.onTransact(code, data, reply, flags);
}
_data.recycle();
}
}
+public void stop() throws android.os.RemoteException
+{
+android.os.Parcel _data = android.os.Parcel.obtain();
+android.os.Parcel _reply = android.os.Parcel.obtain();
+try {
+_data.writeInterfaceToken(DESCRIPTOR);
+mRemote.transact(Stub.TRANSACTION_stop, _data, _reply, 0);
+_reply.readException();
+}
+finally {
+_reply.recycle();
+_data.recycle();
+}
+}
}
static final int TRANSACTION_doExecute = (android.os.IBinder.FIRST_CALL_TRANSACTION + 0);
static final int TRANSACTION_setListener = (android.os.IBinder.FIRST_CALL_TRANSACTION + 1);
+static final int TRANSACTION_stop = (android.os.IBinder.FIRST_CALL_TRANSACTION + 2);
}
public int doExecute(java.lang.String msg) throws android.os.RemoteException;
public void setListener(com.td.service.ITrainServiceCallback callback) throws android.os.RemoteException;
+public void stop() throws android.os.RemoteException;
}
android:id="@+id/linearLayouta0"
android:layout_height="wrap_content"
android:background="#999999"
+ android:layout_weight="0"
android:padding="3dip"
android:layout_width="fill_parent">
- <TextView android:text="@+string/wait_rouote_msg"
+ <TextView android:text="@+string/start_rouote_msg"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="#cccccc"
android:id="@+id/textViewa1"
android:layout_width="fill_parent"
- android:layout_height="wrap_content">
- </TextView>
+ android:layout_height="wrap_content" />
</LinearLayout>
- <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
+ <com.td.WaitView
+ android:id="@+id/waitViewa1"
+ android:layout_margin="0dip"
+ android:layout_weight="1"
+ android:layout_width="fill_parent"
+ android:layout_height="0dip" />
+ <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0" >
<Button android:text="@+string/return_button" android:layout_weight="1" android:id="@+id/buttona1" android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<string name="start_service_msg">監視を開始してください</string>
<string name="comma_msg">、</string>
<string name="do_service_msg">を監視しています。</string>
- <string name="wait_rouote_msg">路線の情報を更新しています。しばらくお待ちください。</string>
+ <string name="start_rouote_msg">路線の情報を更新しています。</string>
+ <string name="end_rouote_msg">路線の情報を更新しました。メニューに戻って、監視する路線を設定してください。</string>
<string name="update_route_button">路線の情報を更新する</string>
<string name="route_button">監視する路線を設定する</string>
}\r
}\r
\r
-\r
+ // TODO w\r
public static int W = 0;\r
@Override\r
public void onWindowFocusChanged(boolean hasFocus) {\r
}
@Override
+ protected void onDestroy() {
+ if (receiver != null){
+ unregisterReceiver(receiver);
+ }
+
+ super.onDestroy();
+ }
+
+ @Override
protected void onStart() {
super.onStart();
import android.view.View;\r
import android.view.View.OnClickListener;\r
import android.widget.Button;\r
+import android.widget.TextView;\r
import android.widget.Toast;\r
\r
import com.td.service.ITrainService;\r
public class WaitActivity extends BaseActivity implements ServiceConnection {\r
private static final int ID = 100;\r
private ITrainService serviceImpl;\r
+ private TextView textView;\r
+ private WaitView waitView;\r
private Button button;\r
\r
@Override\r
super.onCreate(savedInstanceState);\r
setContentView(R.layout.wait);\r
\r
+ textView = (TextView)findViewById(R.id.textViewa1);\r
+ waitView = (WaitView)findViewById(R.id.waitViewa1);\r
button = (Button)findViewById(R.id.buttona1);\r
- button.setOnClickListener(new OnClickListener() {\r
+\r
+ button.setOnClickListener(new OnClickListener() {\r
public void onClick(View v) {\r
WaitActivity.this.finish();\r
}\r
// Activity\82ª\8e\80\82ñ\82Å\82à\83T\81[\83r\83X\82ð\8fI\97¹\82³\82¹\82È\82¢\82½\82ß\r
startService(intent);\r
}\r
+ \r
+ @Override\r
+ protected void onStop() {\r
+ unbindService(this);\r
+ \r
+ // \83T\81[\83r\83X\82Í\81A\92â\8e~\82³\82¹\82È\82¢(stopService\82ð\8cÄ\82Î\82È\82¢)\r
+ //stopService(new Intent(this, TrainService.class));\r
+\r
+ super.onStop();\r
+ }\r
+ \r
\r
+ @Override\r
+ protected void onDestroy() {\r
+ super.onDestroy();\r
+ }\r
+ \r
public void onServiceConnected(ComponentName name, IBinder service) {\r
serviceImpl = ITrainService.Stub.asInterface(service);\r
try {\r
// final String minute = Integer.toString(msg.arg1/60000);\r
// final String second = Integer.toString(msg.arg1%60000/1000);\r
// text.setText(minute+":"+second);\r
+ // TODO \83v\83\8d\83Z\83X\82Ì\8dÄ\8bN\93®\82É\82Í\91Î\89\9e\82Å\82«\82È\82¢\r
+ waitView.stop();\r
+ textView.setText(getString(R.string.end_rouote_msg));\r
button.setEnabled(true);\r
break;\r
default:\r
break;\r
}\r
}\r
- };}\r
+ };\r
+\r
+\r
+}\r
--- /dev/null
+package com.td;\r
+\r
+import android.content.Context;\r
+import android.graphics.Canvas;\r
+import android.graphics.Color;\r
+import android.graphics.Paint;\r
+import android.os.Handler;\r
+import android.util.AttributeSet;\r
+import android.view.View;\r
+\r
+public class WaitView extends View {\r
+ private static final String MESSAGE = "\82µ\82Î\82ç\82\82¨\91Ò\82¿\82\82¾\82³\82¢\81B";\r
+\r
+ private boolean flag = false;\r
+ private int x = 0;\r
+ private int y = 0;\r
+ private Thread thread = null;\r
+ private Paint paint = new Paint();\r
+\r
+ public WaitView(Context context, AttributeSet attrs) {\r
+ super(context, attrs);\r
+\r
+ initialize();\r
+ }\r
+\r
+ public void stop(){\r
+ if (thread != null){\r
+ thread.stop();\r
+ thread = null;\r
+ }\r
+ }\r
+ \r
+ private void initialize() {\r
+ final Handler handler = new Handler();\r
+ thread = new Thread() {\r
+ public void run() {\r
+ while (thread != null) {\r
+ try {\r
+ handler.post(new Runnable() {\r
+ public void run() {\r
+ WaitView.this.invalidate();\r
+ }\r
+ });\r
+ Thread.sleep(100);\r
+ } catch (InterruptedException e) {\r
+ ;\r
+ }\r
+ }\r
+ handler.post(new Runnable() {\r
+ public void run() {\r
+ WaitView.this.invalidate();\r
+ }\r
+ });\r
+ }\r
+ };\r
+ thread.start();\r
+ }\r
+\r
+ @Override\r
+ protected void onDraw(Canvas canvas) {\r
+ if (thread == null){\r
+ return;\r
+ }\r
+ int h = getHeight();\r
+ paint.setColor(Color.BLACK);\r
+ paint.setTextSize(h / 10);\r
+ int w = (int)paint.measureText(MESSAGE);\r
+\r
+ if (!flag) {\r
+ x = getWidth();\r
+ y = getHeight() / 2;\r
+ flag = true;\r
+ }\r
+ else if (x < -w){\r
+ x = getWidth(); \r
+ }\r
+ canvas.drawText(MESSAGE, x, y, paint);\r
+ x -= 5;\r
+ }\r
+\r
+ @Override\r
+ protected void onDetachedFromWindow() {\r
+ super.onDetachedFromWindow();\r
+ \r
+ stop();\r
+ }\r
+ \r
+ \r
+}\r
interface ITrainService {\r
int doExecute(in String msg);\r
void setListener(in ITrainServiceCallback callback);\r
+ void stop();\r
}\r
package com.td.service;\r
\r
-import com.td.utility.Debug;\r
-import com.td.webapi.RouteUpdater;\r
+import java.lang.ref.WeakReference;\r
\r
import android.app.Service;\r
import android.content.Intent;\r
import android.os.IBinder;\r
import android.os.RemoteException;\r
\r
+import com.td.utility.Debug;\r
+import com.td.webapi.RouteUpdater;\r
+\r
public class TrainService extends Service {\r
- private ITrainServiceCallback callback;\r
+ private WeakReference<ITrainServiceCallback> callbackRef;\r
+ private Thread thread = null;\r
+ // 2\8fd\8bN\93®\97}\8e~\r
+ private boolean isStart = false;\r
+ \r
+// public TrainService(){\r
+// Debug.t(this, "TrainService create"); \r
+// }\r
\r
private ITrainService.Stub impl = new ITrainService.Stub(){\r
public int doExecute(String branch) throws RemoteException {\r
- Thread thread = new Thread(){\r
+ if (isStart){\r
+ return -1;\r
+ }\r
+ thread = new Thread(){\r
public void run(){\r
+ if (isStart){\r
+ return;\r
+ }\r
+ isStart = true;\r
try {\r
Debug.t(TrainService.this, "TrainService start");\r
RouteUpdater ru = new RouteUpdater();\r
ru.update();\r
- callback.notify("msg");\r
+ ITrainServiceCallback callback = callbackRef.get();\r
+ if (callback != null){\r
+ callbackRef.clear();\r
+ callback.notify("msg");\r
+ callback = null;\r
+ }\r
Debug.t(TrainService.this, "TrainService end");\r
} catch (RemoteException e) {\r
// TODO Auto-generated catch block\r
e.printStackTrace();\r
}\r
TrainService.this.stopSelf();\r
+ thread = null;\r
}\r
};\r
thread.start();\r
\r
public void setListener(ITrainServiceCallback callback)\r
throws RemoteException {\r
- TrainService.this.callback = callback;\r
+ TrainService.this.callbackRef = new WeakReference<ITrainServiceCallback>(\r
+ callback);\r
+ }\r
+\r
+ public void stop() throws RemoteException {\r
+ TrainService.this.stopSelf();\r
}\r
};\r
\r
}\r
\r
@Override\r
+ protected void onPause() {\r
+ super.onPause();\r
+ Debug.d(this, Debug.ON_PAUSE);\r
+ }\r
+\r
+ @Override\r
protected void onStop() {\r
super.onStop();\r
Debug.d(this, Debug.ON_STOP);\r
public static final String ON_DESTROY = "onDestroy";\r
public static final String ON_START = "onStart";\r
public static final String ON_STOP = "onStop";\r
+ public static final String ON_PAUSE = "onPause";\r
public static final String ON_RESTART = "onRestart";\r
public static final String ON_RESUME = "onResume";\r
public static final String ON_REBIND = "onRebind";\r