@@ -233,26 +233,14 @@ boolean titleInfo(View view, MotionEvent motionEvent) {
233233 if (ViewCompat .getLayoutDirection (getView ()) == ViewCompat .LAYOUT_DIRECTION_LTR ) {
234234 value = titleEdit .getRight () - titleEdit .getCompoundDrawables ()[2 ].getBounds ().width ();
235235 if (motionEvent .getAction () == ACTION_UP && motionEvent .getRawX () >= value ) {
236- new AlertDialog .Builder (getContext ())
237- .setTitle (R .string .media_detail_title )
238- .setMessage (R .string .title_info )
239- .setCancelable (true )
240- .setNeutralButton (android .R .string .ok , (dialog , id ) -> dialog .cancel ())
241- .create ()
242- .show ();
236+ showInfoAlert (R .string .media_detail_title , R .string .title_info );
243237 return true ;
244238 }
245239 }
246240 else {
247241 value = titleEdit .getLeft () + titleEdit .getCompoundDrawables ()[0 ].getBounds ().width ();
248242 if (motionEvent .getAction () == ACTION_UP && motionEvent .getRawX () <= value ) {
249- new AlertDialog .Builder (getContext ())
250- .setTitle (R .string .media_detail_title )
251- .setMessage (R .string .title_info )
252- .setCancelable (true )
253- .setNeutralButton (android .R .string .ok , (dialog , id ) -> dialog .cancel ())
254- .create ()
255- .show ();
243+ showInfoAlert (R .string .media_detail_title , R .string .title_info );
256244 return true ;
257245 }
258246 }
@@ -265,26 +253,14 @@ boolean descriptionInfo(View view, MotionEvent motionEvent) {
265253 if (ViewCompat .getLayoutDirection (getView ()) == ViewCompat .LAYOUT_DIRECTION_LTR ) {
266254 value = descEdit .getRight () - descEdit .getCompoundDrawables ()[2 ].getBounds ().width ();
267255 if (motionEvent .getAction () == ACTION_UP && motionEvent .getRawX () >= value ) {
268- new AlertDialog .Builder (getContext ())
269- .setTitle (R .string .media_detail_description )
270- .setMessage (R .string .description_info )
271- .setCancelable (true )
272- .setNeutralButton (android .R .string .ok , (dialog , id ) -> dialog .cancel ())
273- .create ()
274- .show ();
256+ showInfoAlert (R .string .media_detail_description ,R .string .description_info );
275257 return true ;
276258 }
277259 }
278260 else {
279261 value = descEdit .getLeft () + descEdit .getCompoundDrawables ()[0 ].getBounds ().width ();
280262 if (motionEvent .getAction () == ACTION_UP && motionEvent .getRawX () <= value ) {
281- new AlertDialog .Builder (getContext ())
282- .setTitle (R .string .media_detail_description )
283- .setMessage (R .string .description_info )
284- .setCancelable (true )
285- .setNeutralButton (android .R .string .ok , (dialog , id ) -> dialog .cancel ())
286- .create ()
287- .show ();
263+ showInfoAlert (R .string .media_detail_description ,R .string .description_info );
288264 return true ;
289265 }
290266 }
@@ -351,4 +327,14 @@ public void afterTextChanged(Editable editable) {
351327 }
352328 }
353329 }
330+
331+ private void showInfoAlert (int titleStringID , int messageStringID ){
332+ new AlertDialog .Builder (getContext ())
333+ .setTitle (titleStringID )
334+ .setMessage (messageStringID )
335+ .setCancelable (true )
336+ .setNeutralButton (android .R .string .ok , (dialog , id ) -> dialog .cancel ())
337+ .create ()
338+ .show ();
339+ }
354340}
0 commit comments