1
1
package com .dvinfosys .WidgetsExample ;
2
2
3
3
import android .content .Context ;
4
+ import android .graphics .Color ;
4
5
import android .graphics .Typeface ;
5
6
import android .graphics .drawable .Drawable ;
6
7
import android .net .Uri ;
9
10
import android .text .Spannable ;
10
11
import android .text .SpannableStringBuilder ;
11
12
import android .text .style .StyleSpan ;
13
+ import android .util .Log ;
12
14
import android .view .View ;
13
15
import android .widget .Button ;
16
+ import android .widget .Toast ;
14
17
18
+ import com .dvinfosys .widgets .Button .NormalButton ;
19
+ import com .dvinfosys .widgets .ColorPicker .ColorPickerDialog ;
20
+ import com .dvinfosys .widgets .ColorPicker .ColorPickerDialogListener ;
15
21
import com .dvinfosys .widgets .ToastView .ToastView ;
16
22
import com .dvinfosys .widgets .VideoPlayer .VPVideoPlayer ;
17
23
import com .dvinfosys .widgets .VideoPlayer .VPVideoPlayerStandard ;
18
24
19
25
import static android .graphics .Typeface .BOLD_ITALIC ;
20
26
21
- public class MainActivity extends AppCompatActivity {
27
+ public class MainActivity extends AppCompatActivity implements ColorPickerDialogListener {
22
28
29
+ private static final int DIALOG_ID = 0 ;
23
30
private Context context ;
24
31
private Button btnErrorToastView , btnSuccessToastView , btnInfoToastView , btnWarringToastView ;
32
+ private NormalButton btnColorPicker ;
25
33
26
34
@ Override
27
35
protected void onCreate (Bundle savedInstanceState ) {
28
36
super .onCreate (savedInstanceState );
29
37
setContentView (R .layout .activity_main );
30
- context = this ;
38
+ context = this ;
31
39
btnErrorToastView = findViewById (R .id .button_error_toast );
32
40
btnSuccessToastView = findViewById (R .id .button_success_toast );
33
41
btnInfoToastView = findViewById (R .id .button_info_toast );
34
42
btnWarringToastView = findViewById (R .id .button_warning_toast );
43
+ btnColorPicker = findViewById (R .id .btn_color_picker );
35
44
36
45
VPVideoPlayerStandard videoPlayerStandard = findViewById (R .id .vp_videoplayer );
37
46
videoPlayerStandard .setUp ("http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" , VPVideoPlayerStandard .SCREEN_LAYOUT_NORMAL , "Elephant Dream" );
@@ -40,26 +49,26 @@ protected void onCreate(Bundle savedInstanceState) {
40
49
btnErrorToastView .setOnClickListener (new View .OnClickListener () {
41
50
@ Override
42
51
public void onClick (View v ) {
43
- ToastView .error (context ,"This is error ToastView" ,ToastView .LENGTH_SHORT ).show ();
52
+ ToastView .error (context , "This is error ToastView" , ToastView .LENGTH_SHORT ).show ();
44
53
}
45
54
});
46
55
btnWarringToastView .setOnClickListener (new View .OnClickListener () {
47
56
@ Override
48
57
public void onClick (View v ) {
49
- ToastView .warning (context ,"This is warring ToastView" ,ToastView .LENGTH_SHORT ).show ();
58
+ ToastView .warning (context , "This is warring ToastView" , ToastView .LENGTH_SHORT ).show ();
50
59
}
51
60
});
52
61
btnInfoToastView .setOnClickListener (new View .OnClickListener () {
53
62
@ Override
54
63
public void onClick (View v ) {
55
- ToastView .info (context ,"This is info ToastView" ,ToastView .LENGTH_SHORT ).show ();
64
+ ToastView .info (context , "This is info ToastView" , ToastView .LENGTH_SHORT ).show ();
56
65
}
57
66
});
58
67
59
68
btnSuccessToastView .setOnClickListener (new View .OnClickListener () {
60
69
@ Override
61
70
public void onClick (View v ) {
62
- ToastView .success (context ,"This is success ToastView" ,ToastView .LENGTH_SHORT ).show ();
71
+ ToastView .success (context , "This is success ToastView" , ToastView .LENGTH_SHORT ).show ();
63
72
}
64
73
});
65
74
@@ -94,6 +103,20 @@ public void onClick(View view) {
94
103
ToastView .Config .reset (); // Use this if you want to use the configuration above only once
95
104
}
96
105
});
106
+
107
+ btnColorPicker .setOnClickListener (new View .OnClickListener () {
108
+ @ Override
109
+ public void onClick (View v ) {
110
+ ColorPickerDialog .newBuilder ()
111
+ .setDialogType (ColorPickerDialog .TYPE_CUSTOM )
112
+ .setAllowPresets (false )
113
+ .setDialogId (DIALOG_ID )
114
+ .setColor (Color .BLACK )
115
+ .setShowAlphaSlider (true )
116
+ .show (MainActivity .this );
117
+
118
+ }
119
+ });
97
120
}
98
121
99
122
private CharSequence getFormattedMessage () {
@@ -120,4 +143,18 @@ protected void onPause() {
120
143
super .onPause ();
121
144
VPVideoPlayer .releaseAllVideos ();
122
145
}
146
+
147
+ @ Override
148
+ public void onColorSelected (int dialogId , int color ) {
149
+ switch (dialogId ) {
150
+ case DIALOG_ID :
151
+ Toast .makeText (MainActivity .this , "Selected Color: #" + Integer .toHexString (color ), Toast .LENGTH_SHORT ).show ();
152
+ break ;
153
+ }
154
+ }
155
+
156
+ @ Override
157
+ public void onDialogDismissed (int dialogId ) {
158
+ Log .d ("ColorPicker" , "onDialogDismissed() called with: dialogId = [" + dialogId + "]" );
159
+ }
123
160
}
0 commit comments