Reintegrate 29115-reviewgraph/observoice
@@ -1,7 +1,6 @@ | ||
1 | 1 | package jp.sourceforge.observoice.adapter; |
2 | 2 | |
3 | 3 | import java.util.ArrayList; |
4 | -import java.util.Collections; | |
5 | 4 | import java.util.List; |
6 | 5 | |
7 | 6 | import jp.sourceforge.observoice.entity.Comment; |
@@ -14,7 +13,7 @@ | ||
14 | 13 | |
15 | 14 | /** |
16 | 15 | * コメントリストのアダプター |
17 | - * | |
16 | + * | |
18 | 17 | * @author rtakizawa |
19 | 18 | */ |
20 | 19 | public class CommentListAdapter extends ArrayAdapter<Comment> { |
@@ -4,15 +4,12 @@ | ||
4 | 4 | import java.util.List; |
5 | 5 | |
6 | 6 | import jp.sourceforge.observoice.R; |
7 | -import jp.sourceforge.observoice.R.id; | |
8 | 7 | import jp.sourceforge.observoice.entity.Course; |
9 | - | |
10 | 8 | import android.content.Context; |
11 | 9 | import android.view.LayoutInflater; |
12 | 10 | import android.view.View; |
13 | 11 | import android.view.ViewGroup; |
14 | 12 | import android.widget.ArrayAdapter; |
15 | -import android.widget.Button; | |
16 | 13 | import android.widget.ListView; |
17 | 14 | import android.widget.TextView; |
18 | 15 |
@@ -1,65 +1,45 @@ | ||
1 | 1 | package jp.sourceforge.observoice.adapter; |
2 | 2 | |
3 | -import jp.sourceforge.observoice.R; | |
4 | -import jp.sourceforge.observoice.R.layout; | |
5 | -import android.support.v4.view.PagerAdapter; | |
6 | -import android.support.v4.view.ViewPager; | |
7 | -import android.view.LayoutInflater; | |
8 | -import android.view.View; | |
9 | -import android.view.ViewGroup; | |
10 | -import android.widget.ImageView; | |
11 | -import android.widget.ListView; | |
3 | +import jp.sourceforge.observoice.fragment.CommentListFragment; | |
4 | +import jp.sourceforge.observoice.fragment.UnderstandabilityChartFragment; | |
5 | +import android.support.v4.app.Fragment; | |
6 | +import android.support.v4.app.FragmentManager; | |
7 | +import android.support.v4.app.FragmentStatePagerAdapter; | |
12 | 8 | |
13 | 9 | /** |
14 | 10 | * 復習ページのスワイプ部分のアダプタ |
15 | - * | |
11 | + * | |
16 | 12 | * @author rtakizawa |
17 | 13 | */ |
18 | -public class ReviewLecturePagerAdapter extends PagerAdapter { | |
14 | +public class ReviewLecturePagerAdapter extends FragmentStatePagerAdapter { | |
19 | 15 | |
20 | - private ListView mReviewCommentListView; | |
21 | - private ImageView mGraphView; //dummy | |
16 | + private Fragment[] fragments = new Fragment[2]; | |
22 | 17 | |
23 | - private int[] pages = { R.layout.comment_list_fragment, R.layout.graph_fragment }; | |
24 | - | |
25 | - public ReviewLecturePagerAdapter(LayoutInflater inflater) { | |
26 | - mReviewCommentListView = (ListView) inflater.inflate(R.layout.comment_list_fragment, null); | |
27 | - mGraphView = (ImageView) inflater.inflate(R.layout.graph_fragment, null); | |
18 | + public ReviewLecturePagerAdapter(FragmentManager fm) { | |
19 | + super(fm); | |
28 | 20 | } |
29 | 21 | |
30 | 22 | @Override |
31 | - public Object instantiateItem(ViewGroup container, int position) { | |
32 | - View view = null; | |
33 | - switch (pages[position]) { | |
34 | - case R.layout.comment_list_fragment: | |
35 | - view = mReviewCommentListView; | |
36 | - break; | |
37 | - case R.layout.graph_fragment: | |
38 | - view = mGraphView; | |
39 | - break; | |
40 | - } | |
41 | - container.addView(view); | |
42 | - return view; | |
23 | + public Fragment getItem(int position) { | |
24 | + Fragment f = null; | |
25 | + switch (position) { | |
26 | + case 0: | |
27 | + f = new CommentListFragment(); | |
28 | + break; | |
29 | + case 1: | |
30 | + f = new UnderstandabilityChartFragment(); | |
31 | + break; | |
32 | + } | |
33 | + fragments[position] = f; | |
34 | + return f; | |
43 | 35 | } |
44 | 36 | |
45 | 37 | @Override |
46 | 38 | public int getCount() { |
47 | - return pages.length; | |
39 | + return 2; | |
48 | 40 | } |
49 | - | |
50 | - @Override | |
51 | - public void destroyItem(ViewGroup container, int position, Object object) { | |
52 | - ((ViewPager) container).removeView((View) object); | |
53 | - } | |
54 | 41 | |
55 | - @Override | |
56 | - public boolean isViewFromObject(View view, Object object) { | |
57 | - // TODO Auto-generated method stub | |
58 | - return view.equals(object); | |
42 | + public Fragment getCachedItem(int position) { | |
43 | + return fragments[position]; | |
59 | 44 | } |
60 | - | |
61 | - public ListView getCommentListView() { | |
62 | - return mReviewCommentListView; | |
63 | - } | |
64 | - | |
65 | 45 | } |
@@ -4,17 +4,16 @@ | ||
4 | 4 | import java.text.SimpleDateFormat; |
5 | 5 | import java.util.ArrayList; |
6 | 6 | import java.util.Calendar; |
7 | -import java.util.Collections; | |
8 | -import java.util.Comparator; | |
9 | 7 | import java.util.HashMap; |
10 | 8 | import java.util.List; |
11 | 9 | import java.util.Map; |
12 | 10 | |
13 | -import jp.sourceforge.observoice.adapter.CommentListAdapter; | |
14 | 11 | import jp.sourceforge.observoice.adapter.ReviewLecturePagerAdapter; |
15 | 12 | import jp.sourceforge.observoice.entity.Comment; |
16 | 13 | import jp.sourceforge.observoice.entity.WatchingCourseInfo; |
17 | 14 | import jp.sourceforge.observoice.exception.ObsvException; |
15 | +import jp.sourceforge.observoice.fragment.CommentListFragment; | |
16 | +import jp.sourceforge.observoice.fragment.UnderstandabilityChartFragment; | |
18 | 17 | import jp.sourceforge.observoice.network.RequestConfiguration; |
19 | 18 | import jp.sourceforge.observoice.network.response.CommentListResponse; |
20 | 19 | import jp.sourceforge.observoice.network.response.ObsvResponseObject; |
@@ -21,19 +20,20 @@ | ||
21 | 20 | import jp.sourceforge.observoice.network.task.GetCommentListTask; |
22 | 21 | import jp.sourceforge.observoice.network.task.ObsvNetworkListener; |
23 | 22 | import jp.sourceforge.observoice.util.Util; |
24 | -import roboguice.activity.RoboActivity; | |
23 | +import roboguice.activity.RoboFragmentActivity; | |
25 | 24 | import roboguice.inject.InjectExtra; |
26 | 25 | import roboguice.inject.InjectView; |
27 | 26 | import android.app.AlertDialog; |
28 | -import android.content.Context; | |
27 | +import android.app.DatePickerDialog; | |
28 | +import android.app.DatePickerDialog.OnDateSetListener; | |
29 | 29 | import android.os.Bundle; |
30 | +import android.support.v4.app.Fragment; | |
30 | 31 | import android.support.v4.view.ViewPager; |
31 | -import android.view.LayoutInflater; | |
32 | +import android.util.Log; | |
32 | 33 | import android.view.View; |
33 | -import android.widget.AdapterView; | |
34 | -import android.widget.ArrayAdapter; | |
35 | -import android.widget.ListView; | |
36 | -import android.widget.Spinner; | |
34 | +import android.view.View.OnClickListener; | |
35 | +import android.widget.Button; | |
36 | +import android.widget.DatePicker; | |
37 | 37 | |
38 | 38 | /** |
39 | 39 | * 復習画面 |
@@ -41,18 +41,39 @@ | ||
41 | 41 | * @author torikawa |
42 | 42 | * @author rtakizawa |
43 | 43 | */ |
44 | -public class ReviewLectureActivity extends RoboActivity { | |
44 | +public class ReviewLectureActivity extends RoboFragmentActivity | |
45 | + implements OnClickListener { | |
45 | 46 | |
46 | - @InjectView(R.id.review_lecture_day_selecter) | |
47 | - private Spinner mDaySelector; | |
47 | + /** | |
48 | + * 日付選択画面(カレンダー or DatePickerDialogなど)により選択された日付を表す | |
49 | + * @author uchan_nos | |
50 | + */ | |
51 | + public static class SelectedDate { | |
52 | + public final int year, month, dayOfMonth; | |
53 | + public SelectedDate(int year, int month, int dayOfMonth) { | |
54 | + this.year = year; | |
55 | + this.month = month; | |
56 | + this.dayOfMonth = dayOfMonth; | |
57 | + } | |
58 | + public SelectedDate(SelectedDate date) { | |
59 | + this.year = date.year; | |
60 | + this.month = date.month; | |
61 | + this.dayOfMonth = date.dayOfMonth; | |
62 | + } | |
63 | + } | |
64 | + | |
48 | 65 | @InjectView(R.id.review_lecture_viewpager) |
49 | 66 | private ViewPager mViewPager; |
50 | 67 | @InjectExtra("ReviewLectureInfo") |
51 | 68 | private WatchingCourseInfo mReviewLecture; |
69 | + @InjectView(R.id.day_begin_select_button) | |
70 | + private Button mDayBeginButton; | |
71 | + @InjectView(R.id.day_end_select_button) | |
72 | + private Button mDayEndButton; | |
52 | 73 | |
53 | 74 | private int mCourceId; |
54 | 75 | |
55 | - private Context mContext; | |
76 | + private SelectedDate mSelectedDateBegin, mSelectedDateEnd; | |
56 | 77 | |
57 | 78 | /** |
58 | 79 | * このアクティビティで使用する日付の文字列表現 |
@@ -75,14 +96,22 @@ | ||
75 | 96 | |
76 | 97 | mRequestConfiguration = RequestConfiguration.load(Util.getObsvSharedPreferences(this)); |
77 | 98 | |
78 | - mContext = this; | |
79 | - | |
80 | 99 | mCourceId = mReviewLecture.getCourse().getCourceId(); |
81 | 100 | mCommentMap = new HashMap<String, List<Comment>>(); |
82 | 101 | |
102 | + /* | |
83 | 103 | mPagerAdapter = new ReviewLecturePagerAdapter( |
84 | 104 | (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)); |
105 | + */ | |
106 | + mPagerAdapter = new ReviewLecturePagerAdapter(getSupportFragmentManager()); | |
85 | 107 | mViewPager.setAdapter(mPagerAdapter); |
108 | + | |
109 | + Calendar today = Calendar.getInstance(); | |
110 | + mSelectedDateEnd = new SelectedDate(today.get(Calendar.YEAR), today.get(Calendar.MONTH), today.get(Calendar.DAY_OF_MONTH)); | |
111 | + mSelectedDateBegin = new SelectedDate(mSelectedDateEnd); | |
112 | + | |
113 | + mDayBeginButton.setText(toStringWithFormat(mFormat, mSelectedDateBegin)); | |
114 | + mDayEndButton.setText(toStringWithFormat(mFormat, mSelectedDateEnd)); | |
86 | 115 | } |
87 | 116 | |
88 | 117 | @Override |
@@ -100,8 +129,10 @@ | ||
100 | 129 | List<Comment> responseComments = ((CommentListResponse) response).getCommentList(); |
101 | 130 | mapComments(responseComments); |
102 | 131 | |
103 | - mDaySelector.setAdapter(createCommentDatesAdapter()); | |
104 | - mDaySelector.setOnItemSelectedListener(new DaySelectorListener(mContext)); | |
132 | + mDayBeginButton.setOnClickListener(ReviewLectureActivity.this); | |
133 | + mDayEndButton.setOnClickListener(ReviewLectureActivity.this); | |
134 | + | |
135 | + updateCommentList(); | |
105 | 136 | } |
106 | 137 | |
107 | 138 | @Override |
@@ -135,25 +166,6 @@ | ||
135 | 166 | } |
136 | 167 | |
137 | 168 | /** |
138 | - * コメントリストから日付のリストをもつアダプターを作成する | |
139 | - * | |
140 | - * @return | |
141 | - */ | |
142 | - private ArrayAdapter<String> createCommentDatesAdapter() { | |
143 | - List<String> dates = new ArrayList<String>(); | |
144 | - for (Map.Entry<String, List<Comment>> entry : mCommentMap.entrySet()) { | |
145 | - dates.add(entry.getKey()); | |
146 | - } | |
147 | - Collections.sort(dates); | |
148 | - | |
149 | - ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, | |
150 | - android.R.layout.simple_spinner_dropdown_item, dates); | |
151 | - adapter.setDropDownViewResource(android.R.layout.select_dialog_item); | |
152 | - | |
153 | - return adapter; | |
154 | - } | |
155 | - | |
156 | - /** | |
157 | 169 | * Calendarから日付の文字列表現を得る |
158 | 170 | * |
159 | 171 | * @param cal |
@@ -164,31 +176,138 @@ | ||
164 | 176 | } |
165 | 177 | |
166 | 178 | /** |
167 | - * 日付選択ドロップダウンのリスナー | |
179 | + * 日付選択ボタンが押された | |
168 | 180 | * |
169 | - * @author rtakizawa | |
181 | + * @author uchan_nos | |
170 | 182 | */ |
171 | - private class DaySelectorListener implements AdapterView.OnItemSelectedListener { | |
183 | + @Override | |
184 | + public void onClick(View v) { | |
185 | + if (v == mDayBeginButton) { | |
186 | + // mSelectedDateBeginを初期値として日付選択ダイアログを表示 | |
187 | + DatePickerDialog dialog = new DatePickerDialog(this, | |
188 | + new OnDateSetListener() { | |
189 | + @Override | |
190 | + public void onDateSet(DatePicker view, int year, int monthOfYear, | |
191 | + int dayOfMonth) { | |
192 | + // 日付が選択されたらmSelectedDateBeginを新しい日付に更新 | |
193 | + mSelectedDateBegin = new SelectedDate(year, monthOfYear, dayOfMonth); | |
194 | + // ボタンのテキストも選択された日付に更新 | |
195 | + mDayBeginButton.setText(toStringWithFormat(mFormat, mSelectedDateBegin)); | |
172 | 196 | |
173 | - private Context mContext; | |
197 | + updateCommentList(); | |
198 | + } | |
199 | + }, | |
200 | + mSelectedDateBegin.year, mSelectedDateBegin.month, mSelectedDateBegin.dayOfMonth); | |
201 | + dialog.show(); | |
202 | + } else if (v == mDayEndButton) { | |
203 | + DatePickerDialog dialog = new DatePickerDialog(this, | |
204 | + new OnDateSetListener() { | |
205 | + @Override | |
206 | + public void onDateSet(DatePicker view, int year, int monthOfYear, | |
207 | + int dayOfMonth) { | |
208 | + mSelectedDateEnd = new SelectedDate(year, monthOfYear, dayOfMonth); | |
209 | + mDayEndButton.setText(toStringWithFormat(mFormat, mSelectedDateEnd)); | |
174 | 210 | |
175 | - public DaySelectorListener(Context context) { | |
176 | - mContext = context; | |
211 | + updateCommentList(); | |
212 | + } | |
213 | + }, | |
214 | + mSelectedDateEnd.year, mSelectedDateEnd.month, mSelectedDateEnd.dayOfMonth); | |
215 | + dialog.show(); | |
177 | 216 | } |
217 | + } | |
178 | 218 | |
179 | - @Override | |
180 | - public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { | |
181 | - Spinner spinner = (Spinner) parent; | |
182 | - String date = spinner.getSelectedItem().toString(); | |
183 | - ListView v = mPagerAdapter.getCommentListView(); | |
184 | - CommentListAdapter adapter = new CommentListAdapter(mContext, mCommentMap.get(date)); | |
185 | - v.setAdapter(adapter); | |
219 | + /** | |
220 | + * 指定された日付を指定されたフォーマットに従って変換する | |
221 | + * @param f 日付のフォーマット | |
222 | + * @param d 日付 | |
223 | + * @return 変換された日付を表す文字列 | |
224 | + */ | |
225 | + private static String toStringWithFormat(DateFormat f, SelectedDate d) { | |
226 | + //return f.format(new Date(d.year - 1900, d.month, d.dayOfMonth)); | |
227 | + Calendar c = Calendar.getInstance(); | |
228 | + c.set(d.year, d.month, d.dayOfMonth); | |
229 | + return f.format(c.getTime()); | |
230 | + } | |
231 | + | |
232 | + /** | |
233 | + * 現在の日付の選択範囲に従い、コメント一覧を更新 | |
234 | + */ | |
235 | + private void updateCommentList() { | |
236 | + List<Comment> comments = new ArrayList<Comment>(); | |
237 | + | |
238 | + // 日付をbeginからendまで走査する | |
239 | + // 開始日と終了日を完全に含めたいので、終了日を+1日する | |
240 | + Calendar dateBegin = Calendar.getInstance(); | |
241 | + dateBegin.set(mSelectedDateBegin.year, mSelectedDateBegin.month, mSelectedDateBegin.dayOfMonth); | |
242 | + setToBeginningOfTheDay(dateBegin); | |
243 | + Calendar dateEnd = Calendar.getInstance(); | |
244 | + dateEnd.set(mSelectedDateEnd.year, mSelectedDateEnd.month, mSelectedDateEnd.dayOfMonth); | |
245 | + setToBeginningOfTheDay(dateEnd); | |
246 | + dateEnd.add(Calendar.DAY_OF_MONTH, 1); | |
247 | + | |
248 | + Calendar date = (Calendar) dateBegin.clone(); | |
249 | + // dateが表す日付にコメントがあれば、それをcommentsに追加する | |
250 | + for (; date.compareTo(dateEnd) <= 0; date.add(Calendar.DAY_OF_MONTH, 1)) { | |
251 | + List<Comment> commentsOfDay = mCommentMap.get(mFormat.format(date.getTime())); | |
252 | + if (commentsOfDay != null) { | |
253 | + comments.addAll(commentsOfDay); | |
254 | + } | |
186 | 255 | } |
187 | 256 | |
188 | - @Override | |
189 | - public void onNothingSelected(AdapterView<?> arg0) { | |
257 | + for (int i = 0; i < mPagerAdapter.getCount(); ++i) { | |
258 | + Fragment f = mPagerAdapter.getCachedItem(i); | |
259 | + if (f != null) { | |
260 | + if (f instanceof UnderstandabilityChartFragment) { | |
261 | + UnderstandabilityChartFragment ucf = (UnderstandabilityChartFragment) f; | |
262 | + | |
263 | + long beginToEnd = dateEnd.getTimeInMillis() - dateBegin.getTimeInMillis(); | |
264 | + long diffInSecond = beginToEnd / 1000; | |
265 | + long diffInMinute = diffInSecond / 60; | |
266 | + long diffInHour = diffInMinute / 60; | |
267 | + long diffInDay = diffInHour / 24; | |
268 | + long diffInMonth = diffInDay / 30; | |
269 | + | |
270 | + | |
271 | + int numDivision = 1; | |
272 | + String dateFormatString = "yyyy-MM-dd HH-mm"; | |
273 | + if (diffInDay <= 1) { // 1日以下 | |
274 | + numDivision = (int) (beginToEnd / (1000L * 60 * 60)); // 1時間ごと | |
275 | + dateFormatString = "HH"; | |
276 | + } else if (diffInDay <= 30) { | |
277 | + numDivision = (int) (beginToEnd / (1000L * 60 * 60 * 24)); | |
278 | + dateFormatString = "dd"; | |
279 | + } else if (diffInDay <= 60) { | |
280 | + numDivision = (int) (beginToEnd / (1000L * 60 * 60 * 24 * 7)); | |
281 | + dateFormatString = "dd"; | |
282 | + } else if (diffInMonth <= 12) { | |
283 | + numDivision = (int) (beginToEnd / (1000L * 60 * 60 * 24 * 30)); | |
284 | + dateFormatString = "MM"; | |
285 | + } | |
286 | + if (numDivision > 0) { | |
287 | + Log.d("obsv", "setDivision: " + beginToEnd + "msec / " + numDivision); | |
288 | + ucf.setDivision(beginToEnd / numDivision, numDivision); | |
289 | + } else { | |
290 | + Log.d("obsv", "setDivision: default: " + beginToEnd + "msec / " + 1); | |
291 | + ucf.setDivision(beginToEnd, 1); | |
292 | + } | |
293 | + ucf.setDateFormat(new SimpleDateFormat(dateFormatString)); | |
294 | + | |
295 | + ucf.update(comments, dateEnd.getTimeInMillis()); | |
296 | + } else if (f instanceof CommentListFragment) { | |
297 | + ((CommentListFragment) f).update(comments); | |
298 | + } | |
299 | + } | |
190 | 300 | } |
301 | + } | |
191 | 302 | |
303 | + /** | |
304 | + * カレンダーを0時ちょうどに修正する | |
305 | + * @param c | |
306 | + */ | |
307 | + private void setToBeginningOfTheDay(Calendar c) { | |
308 | + c.set(Calendar.HOUR_OF_DAY, 0); | |
309 | + c.set(Calendar.MINUTE, 0); | |
310 | + c.set(Calendar.SECOND, 0); | |
311 | + c.set(Calendar.MILLISECOND, 0); | |
192 | 312 | } |
193 | - | |
194 | 313 | } |
@@ -1,5 +1,6 @@ | ||
1 | 1 | package jp.sourceforge.observoice; |
2 | 2 | |
3 | +import java.text.SimpleDateFormat; | |
3 | 4 | import java.util.List; |
4 | 5 | |
5 | 6 | import jp.sourceforge.observoice.fragment.CommentListFragment; |
@@ -126,7 +127,9 @@ | ||
126 | 127 | Fragment f = null; |
127 | 128 | switch (position) { |
128 | 129 | case 0: |
129 | - f = new UnderstandabilityChartFragment(); | |
130 | + UnderstandabilityChartFragment ucf = new UnderstandabilityChartFragment(); | |
131 | + ucf.setDateFormat(new SimpleDateFormat("ss")); | |
132 | + f = ucf; | |
130 | 133 | break; |
131 | 134 | case 1: |
132 | 135 | f = new CommentListFragment(); |
@@ -47,6 +47,11 @@ | ||
47 | 47 | private XYMultipleSeriesRenderer mChartRenderer = null; |
48 | 48 | private LinearLayout mLayout = null; |
49 | 49 | |
50 | + private long mDateDivision = 1 * 1000; // データの区切り時間 | |
51 | + private int mNumDivision = 10; // グラフに表示するデータ数 | |
52 | + | |
53 | + private DateFormat mDateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM); | |
54 | + | |
50 | 55 | @Override |
51 | 56 | public void onCreate(Bundle savedInstanceState) { |
52 | 57 | Log.d("chart", "UCF.onCreate"); |
@@ -90,6 +95,7 @@ | ||
90 | 95 | renderer.setChartTitleTextSize(20); |
91 | 96 | renderer.setLabelsTextSize(15); |
92 | 97 | renderer.setLegendTextSize(15); |
98 | + renderer.setPanEnabled(false, false); | |
93 | 99 | for (int i = 0; i < colors.length; i++) { |
94 | 100 | SimpleSeriesRenderer r = new SimpleSeriesRenderer(); |
95 | 101 | r.setColor(colors[i]); |
@@ -102,7 +108,7 @@ | ||
102 | 108 | renderer.setXTitle("時刻"); |
103 | 109 | renderer.setYTitle("理解度"); |
104 | 110 | renderer.setXAxisMin(0.5); |
105 | - renderer.setXAxisMax(10.5); | |
111 | + renderer.setXAxisMax(mNumDivision + 0.5); | |
106 | 112 | renderer.setYAxisMin(-2); |
107 | 113 | renderer.setYAxisMax(2); |
108 | 114 | renderer.setAxesColor(Color.GRAY); |
@@ -129,10 +135,7 @@ | ||
129 | 135 | public void update(List<Comment> comments, long currentTime) { |
130 | 136 | Log.d("chart", "UCF.update"); |
131 | 137 | |
132 | - final DateFormat dateFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM); | |
133 | - final long dateBegin = currentTime - 10 * 1000; // グラフに表示したいデータの開始時刻 | |
134 | - final long dateDivision = 1000; // グラフに表示したいデータの間隔 | |
135 | - final int numDivision = 10; // グラフに表示するデータの数 | |
138 | + final long dateBegin = currentTime - mDateDivision * mNumDivision; // グラフに表示したいデータの開始時刻 | |
136 | 139 | |
137 | 140 | for (Comment c : comments) { |
138 | 141 | mChartManager.addReaction(new Reaction( |
@@ -143,14 +146,15 @@ | ||
143 | 146 | |
144 | 147 | // 指定した時刻範囲のデータからチャートデータを生成 |
145 | 148 | XYMultipleSeriesDataset dataset = |
146 | - mChartManager.buildDataset(dateBegin, dateDivision, numDivision, true); | |
149 | + mChartManager.buildDataset(dateBegin, mDateDivision, mNumDivision, true); | |
147 | 150 | |
148 | 151 | // X軸のラベルを設定 |
149 | 152 | mChartRenderer.clearXTextLabels(); |
150 | - for (int i = 0; i < numDivision; ++i) { | |
153 | + for (int i = 0; i < mNumDivision; ++i) { | |
151 | 154 | mChartRenderer.addXTextLabel(i + 1, |
152 | - dateFormat.format(new Date(dateBegin + dateDivision * i))); | |
155 | + mDateFormat.format(new Date(dateBegin + mDateDivision * i))); | |
153 | 156 | } |
157 | + mChartRenderer.setXAxisMax(mNumDivision + 0.5); | |
154 | 158 | |
155 | 159 | // Y軸の表示範囲を設定 |
156 | 160 | double ymax = 0; |
@@ -163,4 +167,22 @@ | ||
163 | 167 | // 再描画を指示 |
164 | 168 | mLayout.invalidate(); |
165 | 169 | } |
170 | + | |
171 | + /** | |
172 | + * データの分割方法を設定する | |
173 | + * @param dateDivision データ1つの時間間隔 | |
174 | + * @param numDivision データの分割個数 | |
175 | + */ | |
176 | + public void setDivision(long dateDivision, int numDivision) { | |
177 | + this.mDateDivision = dateDivision; | |
178 | + this.mNumDivision = numDivision; | |
179 | + } | |
180 | + | |
181 | + /** | |
182 | + * X軸のラベル描画に用いる時刻フォーマットをセットする | |
183 | + * @param dateFormat | |
184 | + */ | |
185 | + public void setDateFormat(DateFormat dateFormat) { | |
186 | + this.mDateFormat = dateFormat; | |
187 | + } | |
166 | 188 | } |
@@ -72,6 +72,8 @@ | ||
72 | 72 | <string name="get_watching_courses">ウォッチ一覧取得</string> |
73 | 73 | <string name="debug_please_select_from_option">他のデバッグメニューは右上のメニューから選べます</string> |
74 | 74 | <string name="review_day_selecter_label_string">日付:</string> |
75 | + <string name="review_day_begin">から</string> | |
76 | + <string name="review_day_end">まで</string> | |
75 | 77 | <string name="get_account">アカウント情報取得><</string> |
76 | 78 | |
77 | 79 | </resources> |
\ No newline at end of file |
@@ -10,18 +10,26 @@ | ||
10 | 10 | android:layout_weight="1" |
11 | 11 | android:orientation="vertical" > |
12 | 12 | |
13 | + <Button | |
14 | + android:id="@+id/day_begin_select_button" | |
15 | + android:layout_width="wrap_content" | |
16 | + android:layout_height="wrap_content" /> | |
17 | + | |
13 | 18 | <TextView |
14 | - android1:id="@+id/review_day_selecter_label" | |
15 | 19 | android1:layout_width="fill_parent" |
16 | 20 | android1:layout_height="wrap_content" |
17 | - android1:text="@string/review_day_selecter_label_string" | |
18 | - android1:textAppearance="?android:attr/textAppearanceLarge" /> | |
21 | + android1:text="@string/review_day_begin" /> | |
19 | 22 | |
20 | - <Spinner | |
21 | - android:id="@+id/review_lecture_day_selecter" | |
22 | - android:layout_width="fill_parent" | |
23 | - android:layout_height="wrap_content" /> | |
23 | + <Button | |
24 | + android:id="@+id/day_end_select_button" | |
25 | + android:layout_width="wrap_content" | |
26 | + android:layout_height="wrap_content" /> | |
24 | 27 | |
28 | + <TextView | |
29 | + android1:layout_width="fill_parent" | |
30 | + android1:layout_height="wrap_content" | |
31 | + android1:text="@string/review_day_end" /> | |
32 | + | |
25 | 33 | </LinearLayout> |
26 | 34 | |
27 | 35 | <android.support.v4.view.ViewPager |