@@ -45,6 +45,36 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
45
45
realmsList = new ArrayList <String >(app .serverStringSet );
46
46
realmsAdapter = new ArrayAdapter <String >(context , android .R .layout .simple_list_item_1 , realmsList );
47
47
listView .setAdapter (realmsAdapter );
48
+ listView .setOnItemClickListener (new AdapterView .OnItemClickListener () {
49
+ @ Override
50
+ public void onItemClick (AdapterView <?> parent , View view , final int position , long id ) {
51
+ new AlertDialog .Builder (context )
52
+ .setTitle (R .string .realm_switch )
53
+ .setMessage (context .getString (R .string .realm_switch_confirm , realmsAdapter .getItem (position )))
54
+ .setPositiveButton (getResources ().getString (android .R .string .yes ), new DialogInterface .OnClickListener () {
55
+ public void onClick (final DialogInterface dialog , int whichButton ) {
56
+ if (position == app .currentRealm ) {
57
+ Toast .makeText (context , R .string .realm_this_is_current , Toast .LENGTH_LONG ).show ();
58
+ return ;
59
+ }
60
+ final ProgressDialog progressDialog = new ProgressDialog (getActivity ());
61
+ progressDialog .setCancelable (false );
62
+ progressDialog .setTitle (app .getString (R .string .realm_switching ));
63
+ progressDialog .setMessage (app .getString (R .string .please_wait ));
64
+ progressDialog .show ();
65
+ ((ZulipActivity ) getActivity ()).switchRealm (progressDialog , position );
66
+ if (RealmDialog .this .getDialog () != null )
67
+ RealmDialog .this .getDialog ().cancel ();
68
+ }
69
+ })
70
+ .setNegativeButton (getResources ().getString (android .R .string .cancel ), new DialogInterface .OnClickListener () {
71
+ public void onClick (DialogInterface dialog , int whichButton ) {
72
+ dialog .dismiss ();
73
+ }
74
+ })
75
+ .show ();
76
+ }
77
+ });
48
78
return builder .create ();
49
79
}
50
80
}
0 commit comments