#3077 Hide disambiguation items from depiction search - when fetching depictions get the entity instead of the search result (#3741)

This commit is contained in:
Seán Mac Gillicuddy 2020-05-12 11:44:17 +01:00 committed by GitHub
parent 34f02499e4
commit 057d11a0e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 359 additions and 582 deletions

View file

@ -4,7 +4,7 @@ import android.os.Parcelable
import androidx.annotation.WorkerThread
import fr.free.nrw.commons.wikidata.WikidataProperties.DEPICTS
import kotlinx.android.parcel.Parcelize
import org.wikipedia.wikidata.DataValue.DataValueEntityId
import org.wikipedia.wikidata.DataValue.EntityId
import org.wikipedia.wikidata.Entities
import java.util.*
@ -18,7 +18,7 @@ data class Depictions(val depictions: List<IdAndLabel>) : Parcelable {
entities.first?.statements
?.getOrElse(DEPICTS.propertyName, { emptyList() })
?.map { statement ->
(statement.mainSnak.dataValue as DataValueEntityId).value.id
(statement.mainSnak.dataValue as EntityId).value.id
}
?.map { id -> IdAndLabel(id, fetchLabel(mediaClient, id)) }
?: emptyList()

View file

@ -602,10 +602,9 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
textView.setText(depictionName);
if (depictionLoaded) {
item.setOnClickListener(view -> {
DepictedItem depictedItem = new DepictedItem(depictionName, "", "", false, entityId);
Intent intent = new Intent(getContext(), WikidataItemDetailsActivity.class);
intent.putExtra("wikidataItemName", depictedItem.getName());
intent.putExtra("entityId", depictedItem.getId());
intent.putExtra("wikidataItemName", depictionName);
intent.putExtra("entityId", entityId);
getContext().startActivity(intent);
});
}