mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
parent
351109440f
commit
38d39e08ac
5 changed files with 40 additions and 16 deletions
|
|
@ -92,4 +92,12 @@ class ContributionViewHolder implements ViewHolder<DisplayableContribution> {
|
|||
actions.deleteUpload();
|
||||
}
|
||||
}
|
||||
|
||||
@OnClick(R.id.contributionImage)
|
||||
public void imageClicked(){
|
||||
DisplayableContribution.ContributionActions actions = contribution.getContributionActions();
|
||||
if (actions != null) {
|
||||
actions.onClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Adapter;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
|
@ -75,12 +74,12 @@ import static fr.free.nrw.commons.utils.LengthUtils.formatDistanceBetween;
|
|||
public class ContributionsFragment
|
||||
extends CommonsDaggerSupportFragment
|
||||
implements LoaderManager.LoaderCallbacks<Cursor>,
|
||||
AdapterView.OnItemClickListener,
|
||||
MediaDetailPagerFragment.MediaDetailProvider,
|
||||
FragmentManager.OnBackStackChangedListener,
|
||||
ContributionsListFragment.SourceRefresher,
|
||||
LocationUpdateListener,
|
||||
ICampaignsView {
|
||||
ICampaignsView,
|
||||
ContributionsListAdapter.EventListener{
|
||||
@Inject @Named("default_preferences") JsonKvStore store;
|
||||
@Inject ContributionDao contributionDao;
|
||||
@Inject MediaWikiApi mediaWikiApi;
|
||||
|
|
@ -302,7 +301,7 @@ public class ContributionsFragment
|
|||
|
||||
if (contributionsListFragment.getAdapter() == null) {
|
||||
contributionsListFragment.setAdapter(new ContributionsListAdapter(getActivity().getApplicationContext(),
|
||||
cursor, 0, contributionDao));
|
||||
cursor, 0, contributionDao, this));
|
||||
} else {
|
||||
((CursorAdapter) contributionsListFragment.getAdapter()).swapCursor(cursor);
|
||||
}
|
||||
|
|
@ -383,20 +382,12 @@ public class ContributionsFragment
|
|||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
||||
// show detail at a position
|
||||
showDetail(i);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace whatever is in the current contributionsFragmentContainer view with
|
||||
* mediaDetailPagerFragment, and preserve previous state in back stack.
|
||||
* Called when user selects a contribution.
|
||||
*/
|
||||
private void showDetail(int i) {
|
||||
public void showDetail(int i) {
|
||||
if (mediaDetailPagerFragment == null || !mediaDetailPagerFragment.isVisible()) {
|
||||
mediaDetailPagerFragment = new MediaDetailPagerFragment();
|
||||
setMediaDetailPagerFragment();
|
||||
|
|
@ -706,5 +697,13 @@ public class ContributionsFragment
|
|||
super.onDestroyView();
|
||||
presenter.onDetachView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(String filename) {
|
||||
for (int i=0;i<getTotalMediaCount();i++){
|
||||
if (getMediaAtPosition(i).getFilename().equals(filename))
|
||||
showDetail(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import androidx.cursoradapter.widget.CursorAdapter;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.model.DisplayableContribution;
|
||||
|
|
@ -26,9 +27,10 @@ class ContributionsListAdapter extends CursorAdapter {
|
|||
public ContributionsListAdapter(Context context,
|
||||
Cursor c,
|
||||
int flags,
|
||||
ContributionDao contributionDao) {
|
||||
ContributionDao contributionDao, EventListener listener) {
|
||||
super(context, c, flags);
|
||||
this.contributionDao = contributionDao;
|
||||
this.listener=listener;
|
||||
}
|
||||
|
||||
public void setUploadService(UploadService uploadService) {
|
||||
|
|
@ -60,6 +62,11 @@ class ContributionsListAdapter extends CursorAdapter {
|
|||
public void deleteUpload() {
|
||||
ContributionsListAdapter.this.deleteUpload(view.getContext(), contribution);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
ContributionsListAdapter.this.openMediaDetail(contribution);
|
||||
}
|
||||
});
|
||||
views.bindModel(context, displayableContribution);
|
||||
}
|
||||
|
|
@ -100,4 +107,14 @@ class ContributionsListAdapter extends CursorAdapter {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private void openMediaDetail(Contribution contribution){
|
||||
listener.onEvent(contribution.getFilename());
|
||||
|
||||
}
|
||||
EventListener listener;
|
||||
|
||||
public interface EventListener {
|
||||
void onEvent(String filename);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,6 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment {
|
|||
View view = inflater.inflate(R.layout.fragment_contributions_list, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
|
||||
contributionsList.setOnItemClickListener((AdapterView.OnItemClickListener) getParentFragment());
|
||||
|
||||
changeProgressBarVisibility(true);
|
||||
return view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,5 +50,7 @@ public class DisplayableContribution extends Contribution {
|
|||
void retryUpload();
|
||||
|
||||
void deleteUpload();
|
||||
|
||||
void onClick();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue