20
20
import static org .eclipse .egit .github .core .event .Event .TYPE_COMMIT_COMMENT ;
21
21
import static org .eclipse .egit .github .core .event .Event .TYPE_DOWNLOAD ;
22
22
import static org .eclipse .egit .github .core .event .Event .TYPE_PUSH ;
23
- import android .content .DialogInterface ;
24
- import android .content .DialogInterface .OnClickListener ;
23
+ import android .app .AlertDialog ;
25
24
import android .content .Intent ;
26
25
import android .net .Uri ;
27
26
import android .os .Bundle ;
28
27
import android .text .TextUtils ;
29
28
import android .view .View ;
29
+ import android .view .View .OnClickListener ;
30
30
import android .widget .ListView ;
31
31
32
32
import com .github .kevinsawicki .wishlist .SingleTypeAdapter ;
33
+ import com .github .kevinsawicki .wishlist .ViewFinder ;
34
+ import com .github .mobile .R .id ;
35
+ import com .github .mobile .R .layout ;
33
36
import com .github .mobile .R .string ;
34
37
import com .github .mobile .core .gist .GistEventMatcher ;
35
38
import com .github .mobile .core .issue .IssueEventMatcher ;
@@ -144,7 +147,8 @@ public void onListItemClick(ListView l, View v, int position, long id) {
144
147
}
145
148
146
149
@ Override
147
- public boolean onListItemLongClick (ListView l , View v , int position , long id ) {
150
+ public boolean onListItemLongClick (ListView l , View v , int position ,
151
+ long itemId ) {
148
152
if (!isUsable ())
149
153
return false ;
150
154
@@ -154,26 +158,35 @@ public boolean onListItemLongClick(ListView l, View v, int position, long id) {
154
158
final User user = event .getActor ();
155
159
156
160
if (repo != null && user != null ) {
157
- final CharSequence [] items = { user . getLogin (),
158
- event . getRepo (). getName () } ;
159
-
160
- final LightAlertDialog . Builder builder = LightAlertDialog . Builder
161
- . create ( getActivity ());
162
- builder . setTitle ( string . navigate_to );
163
- builder . setItems ( items , new OnClickListener () {
164
- @ Override
165
- public void onClick ( DialogInterface dialog , int which ) {
166
- switch ( which ) {
167
- case 0 :
168
- viewUser ( user );
169
- break ;
170
- case 1 :
171
- viewRepository ( repo );
172
- break ;
173
- }
161
+ final AlertDialog dialog = LightAlertDialog . create ( getActivity ());
162
+ dialog . setTitle ( string . navigate_to ) ;
163
+ dialog . setCanceledOnTouchOutside ( true );
164
+
165
+ View view = getActivity (). getLayoutInflater (). inflate (
166
+ layout . nav_dialog , null );
167
+ ViewFinder finder = new ViewFinder ( view );
168
+ avatars . bind ( finder . imageView ( id . iv_user_avatar ), user );
169
+ avatars . bind ( finder . imageView ( id . iv_repo_avatar ), repo . getOwner ());
170
+ finder . setText ( id . tv_login , user . getLogin ());
171
+ finder . setText ( id . tv_repo_name , repo . generateId ());
172
+ finder . onClick ( id . ll_user_area , new OnClickListener () {
173
+
174
+ public void onClick ( View v ) {
175
+ dialog . dismiss ( );
176
+
177
+ viewUser ( user );
174
178
}
175
179
});
176
- builder .create ().show ();
180
+ finder .onClick (id .ll_repo_area , new OnClickListener () {
181
+
182
+ public void onClick (View v ) {
183
+ dialog .dismiss ();
184
+
185
+ viewRepository (repo );
186
+ }
187
+ });
188
+ dialog .setView (view );
189
+ dialog .show ();
177
190
178
191
return true ;
179
192
}
0 commit comments