1+ package com .zulip .android .activities ;
2+
3+ import android .app .AlertDialog ;
4+ import android .app .Dialog ;
5+ import android .app .ProgressDialog ;
6+ import android .content .Context ;
7+ import android .content .DialogInterface ;
8+ import android .content .Intent ;
9+ import android .os .Bundle ;
10+ import android .support .annotation .NonNull ;
11+ import android .support .v4 .app .DialogFragment ;
12+ import android .util .Log ;
13+ import android .view .LayoutInflater ;
14+ import android .view .View ;
15+ import android .view .ViewGroup ;
16+ import android .widget .AdapterView ;
17+ import android .widget .ArrayAdapter ;
18+ import android .widget .ListView ;
19+ import android .widget .Toast ;
20+
21+ import com .zulip .android .R ;
22+ import com .zulip .android .ZulipApp ;
23+
24+ import java .util .ArrayList ;
25+ import java .util .Collections ;
26+ import java .util .HashSet ;
27+ import java .util .List ;
28+
29+ public class RealmDialog extends DialogFragment {
30+ private ZulipApp app ;
31+ private ArrayAdapter <String > realmsAdapter ;
32+ private Context context ;
33+
34+ static RealmDialog newInstance () {
35+ return new RealmDialog ();
36+ }
37+
38+ public RealmDialog () {
39+ }
40+
41+ @ NonNull
42+ @ Override
43+ public Dialog onCreateDialog (Bundle savedInstanceState ) {
44+ AlertDialog .Builder builder = new AlertDialog .Builder (getActivity ());
45+ LayoutInflater inflater = getActivity ().getLayoutInflater ();
46+ builder .setTitle (R .string .realm_title );
47+ View rootView = inflater .inflate (R .layout .realm_dialog_list , null );
48+ List <String > realmsList = new ArrayList <>();
49+ context = getActivity ();
50+ app = ZulipApp .get ();
51+ ListView listView = (ListView ) rootView .findViewById (R .id .realmListView );
52+ realmsList = new ArrayList <String >(app .serverStringSet );
53+ realmsAdapter = new ArrayAdapter <String >(context , android .R .layout .simple_list_item_1 , realmsList );
54+ listView .setAdapter (realmsAdapter );
55+ builder .setView (rootView )
56+ .setPositiveButton (R .string .realm_add , new DialogInterface .OnClickListener () {
57+ @ Override
58+ public void onClick (DialogInterface dialog , int id ) {
59+ }
60+ })
61+ .setNegativeButton (android .R .string .cancel , new DialogInterface .OnClickListener () {
62+ public void onClick (DialogInterface dialog , int id ) {
63+ RealmDialog .this .getDialog ().cancel ();
64+ }
65+ });
66+ return builder .create ();
67+ }
68+ }
0 commit comments