11package com .tamsiree .rxui .view .dialog ;
22
33import android .app .Activity ;
4+ import android .net .Uri ;
45import android .view .Gravity ;
56import android .view .LayoutInflater ;
67import android .view .View ;
8+ import android .widget .Button ;
79import android .widget .TextView ;
810
911import androidx .fragment .app .Fragment ;
@@ -22,7 +24,9 @@ public class RxDialogChooseImage extends RxDialog {
2224 private LayoutType mLayoutType = LayoutType .TITLE ;
2325 private TextView mTvCamera ;
2426 private TextView mTvFile ;
25- private TextView mTvCancel ;
27+ private Button btnCancel ;
28+ private TextView tvOriginalImage ;
29+ private Uri uriOriginalImage ;
2630
2731 public RxDialogChooseImage (Activity context ) {
2832 super (context );
@@ -34,6 +38,18 @@ public RxDialogChooseImage(Fragment fragment) {
3438 initView (fragment );
3539 }
3640
41+ public RxDialogChooseImage (Activity context , Uri uri ) {
42+ super (context );
43+ uriOriginalImage = uri ;
44+ initView (context );
45+ }
46+
47+ public RxDialogChooseImage (Fragment fragment , Uri uri ) {
48+ super (fragment .getContext ());
49+ uriOriginalImage = uri ;
50+ initView (fragment );
51+ }
52+
3753 public RxDialogChooseImage (Activity context , int themeResId ) {
3854 super (context , themeResId );
3955 initView (context );
@@ -91,23 +107,17 @@ public RxDialogChooseImage(Fragment fragment, float alpha, int gravity, LayoutTy
91107 initView (fragment );
92108 }
93109
94- public TextView getFromCameraView () {
95- return mTvCamera ;
96- }
97-
98- public TextView getFromFileView () {
99- return mTvFile ;
100- }
101-
102- public TextView getCancelView () {
103- return mTvCancel ;
110+ private void initView (final Activity activity ) {
111+ init ();
112+ setClickEvent (activity );
104113 }
105114
106- public LayoutType getLayoutType () {
107- return mLayoutType ;
115+ private void initView (final Fragment fragment ) {
116+ init ();
117+ setClickEvent (fragment );
108118 }
109119
110- private void initView ( final Activity activity ) {
120+ private void init ( ) {
111121 View dialogView = null ;
112122 switch (mLayoutType ) {
113123 case TITLE :
@@ -120,16 +130,35 @@ private void initView(final Activity activity) {
120130 break ;
121131 }
122132
123-
133+ tvOriginalImage = dialogView . findViewById ( R . id . tv_original_image );
124134 mTvCamera = dialogView .findViewById (R .id .tv_camera );
125135 mTvFile = dialogView .findViewById (R .id .tv_file );
126- mTvCancel = dialogView .findViewById (R .id .tv_cancel );
127- mTvCancel .setOnClickListener (new View .OnClickListener () {
136+ btnCancel = dialogView .findViewById (R .id .btnCancel );
137+
138+
139+ tvOriginalImage .setOnClickListener (new View .OnClickListener () {
140+ @ Override
141+ public void onClick (View v ) {
142+ if (uriOriginalImage != null ) {
143+ RxDialogScaleView rxDialogScaleView = new RxDialogScaleView (mContext , uriOriginalImage );
144+ rxDialogScaleView .show ();
145+ }
146+ }
147+ });
148+
149+ btnCancel .setOnClickListener (new View .OnClickListener () {
128150 @ Override
129151 public void onClick (View arg0 ) {
130152 cancel ();
131153 }
132154 });
155+
156+ setContentView (dialogView );
157+ mLayoutParams .gravity = Gravity .BOTTOM ;
158+ mLayoutParams .width = android .view .ViewGroup .LayoutParams .MATCH_PARENT ;
159+ }
160+
161+ private void setClickEvent (Activity activity ) {
133162 mTvCamera .setOnClickListener (new View .OnClickListener () {
134163
135164 @ Override
@@ -146,33 +175,10 @@ public void onClick(View arg0) {
146175 cancel ();
147176 }
148177 });
149- setContentView (dialogView );
150- mLayoutParams .gravity = Gravity .BOTTOM ;
151- mLayoutParams .width = android .view .ViewGroup .LayoutParams .MATCH_PARENT ;
152178 }
153179
154- private void initView (final Fragment fragment ) {
155- View dialogView = null ;
156- switch (mLayoutType ) {
157- case TITLE :
158- dialogView = LayoutInflater .from (getContext ()).inflate (R .layout .dialog_picker_pictrue , null );
159- break ;
160- case NO_TITLE :
161- dialogView = LayoutInflater .from (getContext ()).inflate (R .layout .dialog_camero_show , null );
162- break ;
163- default :
164- break ;
165- }
166180
167- mTvCamera = dialogView .findViewById (R .id .tv_camera );
168- mTvFile = dialogView .findViewById (R .id .tv_file );
169- mTvCancel = dialogView .findViewById (R .id .tv_cancel );
170- mTvCancel .setOnClickListener (new View .OnClickListener () {
171- @ Override
172- public void onClick (View arg0 ) {
173- cancel ();
174- }
175- });
181+ private void setClickEvent (Fragment fragment ) {
176182 mTvCamera .setOnClickListener (new View .OnClickListener () {
177183
178184 @ Override
@@ -190,10 +196,38 @@ public void onClick(View arg0) {
190196 cancel ();
191197 }
192198 });
199+ }
193200
194- setContentView (dialogView );
195- mLayoutParams .gravity = Gravity .BOTTOM ;
196- mLayoutParams .width = android .view .ViewGroup .LayoutParams .MATCH_PARENT ;
201+ public TextView getCancelView () {
202+ return btnCancel ;
203+ }
204+
205+ public TextView getFromCameraView () {
206+ return mTvCamera ;
207+ }
208+
209+ public TextView getFromFileView () {
210+ return mTvFile ;
211+ }
212+
213+ public TextView getTvOriginalImage () {
214+ return tvOriginalImage ;
215+ }
216+
217+ public LayoutType getLayoutType () {
218+ return mLayoutType ;
219+ }
220+
221+ public void setTvOriginalImage (TextView tvOriginalImage ) {
222+ this .tvOriginalImage = tvOriginalImage ;
223+ }
224+
225+ public Uri getUriOriginalImage () {
226+ return uriOriginalImage ;
227+ }
228+
229+ public void setUriOriginalImage (Uri uriOriginalImage ) {
230+ this .uriOriginalImage = uriOriginalImage ;
197231 }
198232
199233 public enum LayoutType {
0 commit comments