42 {
43 View curView = convertView;
44 if (curView == null)
45 {
46 LayoutInflater vi =
47 (LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
48 curView = vi.inflate(R.layout.bookmark_list_item, null);
49 }
50
51 BookmarkBase bookmark = getItem(position);
52 TextView label = curView.findViewById(R.id.bookmark_text1);
53 TextView hostname = curView.findViewById(R.id.bookmark_text2);
54 ImageView star_icon = curView.findViewById(R.id.bookmark_icon2);
55 assert label != null;
56 assert hostname != null;
57
58 label.setText(bookmark.getLabel());
59 star_icon.setVisibility(View.VISIBLE);
60
61 String refStr;
62 if (bookmark.getType() == BookmarkBase.TYPE_MANUAL)
63 {
64 hostname.setText(bookmark.<ManualBookmark>get().getHostname());
65 refStr = ConnectionReference.getManualBookmarkReference(bookmark.getId());
66 star_icon.setImageResource(R.drawable.icon_star_on);
67 }
68 else if (bookmark.getType() == BookmarkBase.TYPE_QUICKCONNECT)
69 {
70
71
72 hostname.setText(" ");
73 refStr = ConnectionReference.getHostnameReference(bookmark.getLabel());
74 star_icon.setImageResource(R.drawable.icon_star_off);
75 }
76 else if (bookmark.getType() == BookmarkBase.TYPE_PLACEHOLDER)
77 {
78 hostname.setText(" ");
79 refStr = ConnectionReference.getPlaceholderReference(
80 bookmark.<PlaceholderBookmark>get().getName());
81 star_icon.setVisibility(View.GONE);
82 }
83 else
84 {
85
86 refStr = "";
87 assert false;
88 }
89
90 star_icon.setOnClickListener(new OnClickListener() {
91 @Override public void onClick(View v)
92 {
93
94 Bundle bundle = new Bundle();
95 String refStr = v.getTag().toString();
96 bundle.putString(BookmarkActivity.PARAM_CONNECTION_REFERENCE, refStr);
97
98 Intent bookmarkIntent = new Intent(getContext(), BookmarkActivity.class);
99 bookmarkIntent.putExtras(bundle);
100 getContext().startActivity(bookmarkIntent);
101 }
102 });
103
104 curView.setTag(refStr);
105 star_icon.setTag(refStr);
106
107 return curView;
108 }