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