diff --git a/res/layout/get_videos.xml b/res/layout/get_videos.xml
index 4d84223..2256b83 100644
--- a/res/layout/get_videos.xml
+++ b/res/layout/get_videos.xml
@@ -13,5 +13,34 @@
android:id="@+id/time_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/com/annimon/donetskwebcam/VideoGetActivity.java b/src/com/annimon/donetskwebcam/VideoGetActivity.java
index 03a9799..6662250 100644
--- a/src/com/annimon/donetskwebcam/VideoGetActivity.java
+++ b/src/com/annimon/donetskwebcam/VideoGetActivity.java
@@ -1,14 +1,74 @@
package com.annimon.donetskwebcam;
+import java.util.Calendar;
+import android.app.Activity;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.ListView;
+import android.widget.TimePicker;
-public final class VideoGetActivity extends FragmentActivity {
+public final class VideoGetActivity extends Activity {
+
+ private DatePicker datePicker;
+ private TimePicker timePicker;
+ private EditText periodEdit, serverNumberEdit;
+ private ListView resultList;
+ private ArrayAdapter urlsAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
setContentView(R.layout.get_videos);
+
+ datePicker = (DatePicker) findViewById(R.id.date_picker);
+ timePicker = (TimePicker) findViewById(R.id.time_picker);
+ timePicker.setIs24HourView(true);
+ periodEdit = (EditText) findViewById(R.id.period);
+ serverNumberEdit = (EditText) findViewById(R.id.server_number);
+ resultList = (ListView) findViewById(R.id.result);
+
+ urlsAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
+ resultList.setAdapter(urlsAdapter);
+ resultList.setOnItemClickListener(itemClickListener);
+
+ findViewById(R.id.get_videos).setOnClickListener(getVideosClick);
}
+
+ private final OnClickListener getVideosClick = new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ Calendar cal = Calendar.getInstance();
+ cal.set(Calendar.MONTH, datePicker.getMonth());
+ cal.set(Calendar.DAY_OF_MONTH, datePicker.getDayOfMonth());
+ cal.set(Calendar.HOUR_OF_DAY, timePicker.getCurrentHour());
+ cal.set(Calendar.MINUTE, timePicker.getCurrentMinute());
+
+ long startTime = cal.getTimeInMillis() / 1000;
+ long period = Integer.parseInt(periodEdit.getText().toString());
+ long server = Integer.parseInt(serverNumberEdit.getText().toString());
+ long camera = getIntent().getExtras().getInt("camera_id");
+ new VideoSearchTask(urlsAdapter).execute(startTime, period, server, camera);
+ }
+ };
+
+ private final OnItemClickListener itemClickListener = new OnItemClickListener() {
+
+ @Override
+ public void onItemClick(AdapterView> parent, View view, int position, long id) {
+ final String url = urlsAdapter.getItem(position);
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ intent.setDataAndType(Uri.parse(url), "video/mp4");
+ startActivity(intent);
+ }
+
+ };
}