4
4
import android .app .TaskStackBuilder ;
5
5
import android .content .Intent ;
6
6
import android .os .Bundle ;
7
+ import android .provider .MediaStore ;
7
8
import android .support .design .widget .FloatingActionButton ;
8
9
import android .support .design .widget .Snackbar ;
9
10
import android .support .v4 .app .NavUtils ;
10
11
import android .support .v7 .app .AppCompatActivity ;
11
12
import android .support .v7 .app .NotificationCompat ;
12
13
import android .support .v7 .widget .Toolbar ;
13
14
import android .view .View ;
15
+ import android .widget .AdapterView ;
16
+ import android .widget .ListAdapter ;
17
+ import android .widget .ListView ;
14
18
import android .widget .TextView ;
19
+ import android .widget .Toast ;
20
+
21
+ import java .util .ArrayList ;
15
22
16
23
17
24
public class VideoListActivity extends AppCompatActivity {
@@ -20,6 +27,8 @@ public class VideoListActivity extends AppCompatActivity {
20
27
TextView textViewIntent ;
21
28
DBHandler dbHandler ;
22
29
String selectedURL ;
30
+ String currentURL ;
31
+ ArrayList <String > urlList ;
23
32
24
33
@ Override
25
34
protected void onCreate (Bundle savedInstanceState ) {
@@ -42,20 +51,25 @@ protected void onCreate(Bundle savedInstanceState) {
42
51
}
43
52
}
44
53
45
- Intent currentIntent = NavUtils .getParentActivityIntent (this );
46
-
47
- PendingIntent pendingIntent =
48
- TaskStackBuilder .create (this )
49
- // add all of DetailsActivity's parents to the stack,
50
- // followed by DetailsActivity itself
51
- .addNextIntentWithParentStack (currentIntent )
52
- .getPendingIntent (0 , PendingIntent .FLAG_UPDATE_CURRENT );
54
+ // Intent currentIntent = NavUtils.getParentActivityIntent(this);
55
+ //
56
+ // PendingIntent pendingIntent =
57
+ // TaskStackBuilder.create(this)
58
+ // // add all of DetailsActivity's parents to the stack,
59
+ // // followed by DetailsActivity itself
60
+ // .addNextIntentWithParentStack(currentIntent)
61
+ // .getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
62
+ //
63
+ // NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
64
+ // builder.setContentIntent(pendingIntent);
65
+ //
66
+ // System.out.println("here");
53
67
54
- NotificationCompat .Builder builder = new NotificationCompat .Builder (this );
55
- builder .setContentIntent (pendingIntent );
68
+ //urlList = new ArrayList<String>();
56
69
57
- System . out . println ( "here" );
70
+ // urlList = dbHandler.databaseToStringList( );
58
71
72
+ setUpListView ();
59
73
60
74
61
75
printDatabase ();
@@ -84,6 +98,7 @@ public void handleYoutubeURL(Intent intent){
84
98
String url = intent .getStringExtra (Intent .EXTRA_TEXT );
85
99
if (url != null ){
86
100
selectedURL = url ;
101
+ currentURL = url ;
87
102
textViewIntent .setText (url );
88
103
}
89
104
}
@@ -94,9 +109,34 @@ public void printDatabase() {
94
109
testTextView .setText (dbString );
95
110
}
96
111
public void testButtonClicked (View view ){
97
- System . out . println ( "hi0 " );
98
- VideoOption videoOption = new VideoOption ("zdEhHLjtxDA" );
112
+ //VideoOption videoOption = new VideoOption("zdEhHLjtxDA ");
113
+ VideoOption videoOption = new VideoOption (currentURL );
99
114
dbHandler .addVideoOption (videoOption );
100
115
printDatabase ();
116
+ setUpListView ();
117
+ }
118
+ public void clearTable (View view ){
119
+ dbHandler .clearTable ();
120
+ printDatabase ();
121
+ }
122
+
123
+ public void setUpListView (){
124
+ urlList = dbHandler .databaseToStringList ();
125
+
126
+ ListAdapter customListAdapter = new OptionAdapter (this ,urlList );//
127
+ ListView customListView = (ListView ) findViewById (R .id .VideoListView );
128
+ customListView .setAdapter (customListAdapter );
129
+
130
+ customListView .setOnItemClickListener (
131
+ new AdapterView .OnItemClickListener () {
132
+ @ Override
133
+ public void onItemClick (AdapterView <?> parent , View view , int position , long id ) {
134
+ String food = String .valueOf (parent .getItemAtPosition (position ));
135
+ Toast .makeText (VideoListActivity .this , food , Toast .LENGTH_LONG ).show ();
136
+ }
137
+ }
138
+ );
139
+
140
+
101
141
}
102
142
}
0 commit comments