mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Fix vector placeholder images in API <21.
This commit is contained in:
parent
040789ca2e
commit
5ab060567a
7 changed files with 35 additions and 10 deletions
|
|
@ -3,9 +3,11 @@ package fr.free.nrw.commons;
|
|||
import android.content.Context;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
public class MediaWikiImageView extends SimpleDraweeView {
|
||||
|
|
@ -13,14 +15,17 @@ public class MediaWikiImageView extends SimpleDraweeView {
|
|||
|
||||
public MediaWikiImageView(Context context) {
|
||||
this(context, null);
|
||||
init();
|
||||
}
|
||||
|
||||
public MediaWikiImageView(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
init();
|
||||
}
|
||||
|
||||
public MediaWikiImageView(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
init();
|
||||
}
|
||||
|
||||
public void setMedia(Media media) {
|
||||
|
|
@ -48,6 +53,16 @@ public class MediaWikiImageView extends SimpleDraweeView {
|
|||
super.onDetachedFromWindow();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setHierarchy(GenericDraweeHierarchyBuilder
|
||||
.newInstance(getResources())
|
||||
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
||||
R.drawable.ic_image_black_24dp, getContext().getTheme()))
|
||||
.setFailureImage(VectorDrawableCompat.create(getResources(),
|
||||
R.drawable.ic_image_black_24dp, getContext().getTheme()))
|
||||
.build());
|
||||
}
|
||||
|
||||
private void setImageUrl(@Nullable String url) {
|
||||
setImageURI(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ import android.content.Context;
|
|||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
|
|
@ -24,6 +26,7 @@ import android.widget.GridView;
|
|||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
|
|
@ -82,7 +85,13 @@ public class MultipleUploadListFragment extends Fragment {
|
|||
holder.overlay = (RelativeLayout) view.findViewById(R.id.uploadOverlay);
|
||||
|
||||
holder.image.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, photoSize.y));
|
||||
|
||||
holder.image.setHierarchy(GenericDraweeHierarchyBuilder
|
||||
.newInstance(getResources())
|
||||
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
||||
R.drawable.ic_image_black_24dp, getContext().getTheme()))
|
||||
.setFailureImage(VectorDrawableCompat.create(getResources(),
|
||||
R.drawable.ic_error_outline_black_24dp, getContext().getTheme()))
|
||||
.build());
|
||||
view.setTag(holder);
|
||||
} else {
|
||||
holder = (UploadHolderView)view.getTag();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.support.graphics.drawable.VectorDrawableCompat;
|
||||
import android.support.v4.app.ActivityCompat;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.MenuItem;
|
||||
|
|
@ -16,6 +17,7 @@ import android.view.View;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.facebook.drawee.generic.GenericDraweeHierarchyBuilder;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -219,6 +221,13 @@ public class ShareActivity
|
|||
initBack();
|
||||
app = CommonsApplication.getInstance();
|
||||
backgroundImageView = (SimpleDraweeView)findViewById(R.id.backgroundImage);
|
||||
backgroundImageView.setHierarchy(GenericDraweeHierarchyBuilder
|
||||
.newInstance(getResources())
|
||||
.setPlaceholderImage(VectorDrawableCompat.create(getResources(),
|
||||
R.drawable.ic_image_black_24dp, getTheme()))
|
||||
.setFailureImage(VectorDrawableCompat.create(getResources(),
|
||||
R.drawable.ic_error_outline_black_24dp, getTheme()))
|
||||
.build());
|
||||
|
||||
//Receive intent from ContributionController.java when user selects picture to upload
|
||||
Intent intent = getIntent();
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@
|
|||
android:id="@+id/backgroundImage"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:actualImageScaleType="centerCrop"
|
||||
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||
app:failureImage="@drawable/ic_error_outline_black_24dp" />
|
||||
app:actualImageScaleType="centerCrop" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/single_upload_fragment_container"
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:actualImageScaleType="fitCenter"
|
||||
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||
app:failureImage="@drawable/ic_image_black_24dp"
|
||||
/>
|
||||
|
||||
<ScrollView
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="240dp"
|
||||
app:actualImageScaleType="centerCrop"
|
||||
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||
app:failureImage="@drawable/ic_image_black_24dp"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="192dp"
|
||||
app:actualImageScaleType="centerCrop"
|
||||
app:placeholderImage="@drawable/ic_image_black_24dp"
|
||||
app:failureImage="@drawable/ic_error_outline_black_24dp"
|
||||
android:scaleType="centerCrop"
|
||||
android:contentDescription="@string/upload_image"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue