|
25 | 25 | import android.view.View;
|
26 | 26 | import android.view.ViewGroup;
|
27 | 27 | import android.widget.Adapter;
|
28 |
| -import android.widget.AdapterView; |
29 | 28 | import android.widget.CheckBox;
|
30 | 29 | import android.widget.Toast;
|
31 | 30 |
|
|
75 | 74 | public class ContributionsFragment
|
76 | 75 | extends CommonsDaggerSupportFragment
|
77 | 76 | implements LoaderManager.LoaderCallbacks<Cursor>,
|
78 |
| - AdapterView.OnItemClickListener, |
79 | 77 | MediaDetailPagerFragment.MediaDetailProvider,
|
80 | 78 | FragmentManager.OnBackStackChangedListener,
|
81 | 79 | ContributionsListFragment.SourceRefresher,
|
82 | 80 | LocationUpdateListener,
|
83 |
| - ICampaignsView { |
| 81 | + ICampaignsView, |
| 82 | + ContributionsListAdapter.EventListener{ |
84 | 83 | @Inject @Named("default_preferences") JsonKvStore store;
|
85 | 84 | @Inject ContributionDao contributionDao;
|
86 | 85 | @Inject MediaWikiApi mediaWikiApi;
|
@@ -302,7 +301,7 @@ public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
|
302 | 301 |
|
303 | 302 | if (contributionsListFragment.getAdapter() == null) {
|
304 | 303 | contributionsListFragment.setAdapter(new ContributionsListAdapter(getActivity().getApplicationContext(),
|
305 |
| - cursor, 0, contributionDao)); |
| 304 | + cursor, 0, contributionDao, this)); |
306 | 305 | } else {
|
307 | 306 | ((CursorAdapter) contributionsListFragment.getAdapter()).swapCursor(cursor);
|
308 | 307 | }
|
@@ -383,20 +382,12 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
|
383 | 382 | super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
384 | 383 | }
|
385 | 384 | }
|
386 |
| - |
387 |
| - @Override |
388 |
| - public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { |
389 |
| - // show detail at a position |
390 |
| - showDetail(i); |
391 |
| - } |
392 |
| - |
393 |
| - |
394 | 385 | /**
|
395 | 386 | * Replace whatever is in the current contributionsFragmentContainer view with
|
396 | 387 | * mediaDetailPagerFragment, and preserve previous state in back stack.
|
397 | 388 | * Called when user selects a contribution.
|
398 | 389 | */
|
399 |
| - private void showDetail(int i) { |
| 390 | + public void showDetail(int i) { |
400 | 391 | if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
|
401 | 392 | mediaDetailPagerFragment = new MediaDetailPagerFragment();
|
402 | 393 | setMediaDetailPagerFragment();
|
@@ -706,5 +697,13 @@ private void fetchCampaigns() {
|
706 | 697 | super.onDestroyView();
|
707 | 698 | presenter.onDetachView();
|
708 | 699 | }
|
| 700 | + |
| 701 | + @Override |
| 702 | + public void onEvent(String filename) { |
| 703 | + for (int i=0;i<getTotalMediaCount();i++){ |
| 704 | + if (getMediaAtPosition(i).getFilename().equals(filename)) |
| 705 | + showDetail(i); |
| 706 | + } |
| 707 | + } |
709 | 708 | }
|
710 | 709 |
|
0 commit comments