mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
* optimise width loading * amending as per the reviews * aspect ratio updates after layout completion * MediaDetailFragment: update aspect ratio using onGlobalLayoutListener * remove unnecessary imports
This commit is contained in:
parent
c53fcb53cb
commit
c82283a014
1 changed files with 12 additions and 4 deletions
|
|
@ -9,11 +9,11 @@ import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.util.TypedValue;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.ViewTreeObserver;
|
import android.view.ViewTreeObserver;
|
||||||
|
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
@ -33,7 +33,6 @@ import com.facebook.imagepipeline.request.ImageRequest;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.wikipedia.util.DateUtil;
|
import org.wikipedia.util.DateUtil;
|
||||||
import org.wikipedia.util.StringUtil;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
@ -224,8 +223,16 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||||
.setVisibility(View.GONE);
|
.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
media = detailProvider.getMediaAtPosition(index);
|
media = detailProvider.getMediaAtPosition(index);
|
||||||
|
scrollView.getViewTreeObserver().addOnGlobalLayoutListener(
|
||||||
|
new OnGlobalLayoutListener() {
|
||||||
|
@Override
|
||||||
|
public void onGlobalLayout() {
|
||||||
|
scrollView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||||
displayMediaDetails();
|
displayMediaDetails();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private void displayMediaDetails() {
|
private void displayMediaDetails() {
|
||||||
//Always load image from Internet to allow viewing the desc, license, and cats
|
//Always load image from Internet to allow viewing the desc, license, and cats
|
||||||
|
|
@ -243,7 +250,8 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment {
|
||||||
|
|
||||||
private void updateAspectRatio(ImageInfo imageInfo) {
|
private void updateAspectRatio(ImageInfo imageInfo) {
|
||||||
if (imageInfo != null) {
|
if (imageInfo != null) {
|
||||||
int finalHeight = (scrollView.getWidth()*imageInfo.getHeight()) / imageInfo.getWidth();
|
int screenWidth = scrollView.getWidth();
|
||||||
|
int finalHeight = (screenWidth*imageInfo.getHeight()) / imageInfo.getWidth();
|
||||||
ViewGroup.LayoutParams params = image.getLayoutParams();
|
ViewGroup.LayoutParams params = image.getLayoutParams();
|
||||||
params.height = finalHeight;
|
params.height = finalHeight;
|
||||||
image.setLayoutParams(params);
|
image.setLayoutParams(params);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue