OSDN Git Service

Scheduler用のテストクラス作成(1ケース)
[train-delayed/source.git] / workspace / TrainDelayed / src / com / td / TrainDelayedActivity.java
1 package com.td;
2
3 import twitter4j.AsyncTwitter;
4 import twitter4j.AsyncTwitterFactory;
5 import android.app.AlarmManager;
6 import android.app.Notification;
7 import android.app.NotificationManager;
8 import android.app.PendingIntent;
9 import android.content.Context;
10 import android.content.Intent;
11 import android.os.Bundle;
12 import android.view.View;
13 import android.view.View.OnClickListener;
14 import android.widget.Button;
15
16 import com.td.db.HistoryDao;
17 import com.td.service.SchedulerTest;
18 import com.td.service.TrainDelayedServiceImpl;
19 import com.td.utility.BaseActivity;
20
21 public class TrainDelayedActivity extends BaseActivity {
22         private AsyncTwitterFactory factory = new AsyncTwitterFactory();
23         private AsyncTwitter twitter = factory.getInstance();
24
25         // private TrainTwitterAdapter listener = new TrainTwitterAdapter(this, 1);
26         // private List<TrainTwitterAdapter> adapterList = new
27         // ArrayList<TrainTwitterAdapter>();
28
29         @Override
30         public void onCreate(Bundle savedInstanceState) {
31                 super.onCreate(savedInstanceState);
32                 setContentView(R.layout.main);
33
34                 final TrainTwitterAdapter listener = new TrainTwitterAdapter(this);
35                 twitter.addListener(listener);
36
37                 Button button1 = (Button) this.findViewById(R.id.button01);
38                 button1.setOnClickListener(new OnClickListener() {
39                         public void onClick(View v) {
40                                 SchedulerTest.main();
41                         }});
42
43                 Button button2 = (Button) this.findViewById(R.id.button02);
44                 button2.setOnClickListener(new OnClickListener() {
45                         public void onClick(View view) {
46                                 Intent intent = new Intent(TrainDelayedActivity.this,
47                                                 (Class<?>) TrainListActivity.class);
48                                 startActivityForResult(intent, -1);
49                         }
50                 });
51
52                 Button button3 = (Button) this.findViewById(R.id.button03);
53                 button3.setOnClickListener(new OnClickListener() {
54                         public void onClick(View view) {
55                                 Intent intent = new Intent(TrainDelayedActivity.this,
56                                                 (Class<?>)MonitorTimeActivity.class);
57                                 startActivityForResult(intent, -1);
58                         }
59                 });
60                 
61                 Button button4 = (Button) this.findViewById(R.id.button04);
62                 button4.setOnClickListener(new OnClickListener() {
63                         public void onClick(View view) {
64                                 // \83T\81[\83r\83X\82ð\8aJ\8en
65                                 Intent intent = new Intent(TrainDelayedActivity.this,
66                                                 TrainDelayedServiceImpl.class);
67                                 startService(intent);
68                         }
69                 });
70
71                 Button button5 = (Button) this.findViewById(R.id.button05);
72                 button5.setOnClickListener(new OnClickListener() {
73                         public void onClick(View view) {
74                                 // TODO
75                                 HistoryDao.getInstance().delete(TrainDelayedActivity.this);
76
77                                 Intent intent = new Intent(TrainDelayedActivity.this,
78                                                 TrainDelayedServiceImpl.class);
79                                 PendingIntent alarmSender = PendingIntent.getService(
80                                                 TrainDelayedActivity.this, 0, intent, 0);
81                                 AlarmManager alerm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
82                                 alerm.cancel(alarmSender);
83                         }
84                 });
85                 
86                 Button button6 = (Button) this.findViewById(R.id.button06);
87                 button6.setOnClickListener(new OnClickListener() {
88                         public void onClick(View view) {
89                                 HistoryActivity.init(TrainDelayedActivity.this);
90                                 Intent intent = new Intent(TrainDelayedActivity.this,
91                                                 (Class<?>) HistoryActivity.class);
92                                 startActivityForResult(intent, -1);
93                         }
94                 });
95                         
96                 Button button7 = (Button) this.findViewById(R.id.button07);
97                 button7.setOnClickListener(new OnClickListener() {
98                         public void onClick(View view) {
99                                 Intent intent = new Intent(TrainDelayedActivity.this,
100                                                 (Class<?>)SearchWordActivity.class);
101                                 startActivityForResult(intent, -1);
102                         }
103                 });
104
105                 Button button9 = (Button) this.findViewById(R.id.button09);
106                 button9.setOnClickListener(new OnClickListener() {
107                         public void onClick(View view) {
108                                 TrainDelayedActivity.this.finish();
109                         }
110                 });
111         }
112
113         // private class TrainDelayedReceiver extends BroadcastReceiver {
114         // @Override
115         // public void onReceive(Context context, Intent intent) {
116         // Debug.d(this, "onReceive");
117         // }
118         // }
119         //
120         // private TrainDelayedServiceImpl trainDelayedService;
121         // private final TrainDelayedReceiver receiver = new TrainDelayedReceiver();
122         //
123         // private ServiceConnection serviceConnection = new ServiceConnection() {
124         // public void onServiceConnected(ComponentName name, IBinder service) {
125         // Debug.d(this, "onServiceConnected");
126         //
127         // trainDelayedService =
128         // ((TrainDelayedServiceImpl.TrainDelayedBinder)service).getService();
129         // //trainDelayedService.schedule(10 * 60 * 1000);
130         // }
131         //
132         // public void onServiceDisconnected(ComponentName name) {
133         // Debug.d(this, "onServiceDisconnected");
134         // trainDelayedService = null;
135         // }
136         // };
137
138         @Override
139         public void onDestroy() {
140                 super.onDestroy();
141
142                 // Intent intent = new Intent(this, TrainDelayedServiceImpl.class);
143                 // stopService(intent);
144                 // trainDelayedService.scheduleStop();
145
146                 // unbindService(serviceConnection); // \83o\83C\83\93\83h\89ð\8f\9c
147                 // unregisterReceiver(receiver); // \93o\98^\89ð\8f\9c
148                 // trainDelayedService.stopSelf(); // \83T\81[\83r\83X\82Í\95K\97v\82È\82¢\82Ì\82Å\8fI\97¹\82³\82¹\82é\81B
149         }
150
151         // private void getColumnData(Cursor cur) {
152         // if (cur.moveToFirst()) {
153         // do {
154         // int val = cur.getInt(0);
155         // Debug.d(this, "VAL=" + val);
156         // } while (cur.moveToNext());
157         //
158         // }
159         // }
160 }