File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
app/src/main/java/fr/free/nrw/commons/media Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -227,7 +227,13 @@ public void onResume() {
227227 .setVisibility (View .GONE );
228228 }
229229 media = detailProvider .getMediaAtPosition (index );
230- displayMediaDetails ();
230+
231+ scrollView .post (new Runnable () {
232+ @ Override
233+ public void run () {
234+ displayMediaDetails ();
235+ }
236+ });
231237 }
232238
233239 private void displayMediaDetails () {
@@ -246,21 +252,14 @@ private void displayMediaDetails() {
246252
247253 private void updateAspectRatio (ImageInfo imageInfo ) {
248254 if (imageInfo != null ) {
249- int screenWidth = getScreenWidth ( getContext () );
255+ int screenWidth = scrollView . getWidth ( );
250256 int finalHeight = (screenWidth *imageInfo .getHeight ()) / imageInfo .getWidth ();
251257 ViewGroup .LayoutParams params = image .getLayoutParams ();
252258 params .height = finalHeight ;
253259 image .setLayoutParams (params );
254260 }
255261 }
256262
257- private int getScreenWidth (Context context ) {
258- DisplayMetrics dm = new DisplayMetrics ();
259- WindowManager windowManager = (WindowManager ) context .getSystemService (WINDOW_SERVICE );
260- windowManager .getDefaultDisplay ().getMetrics (dm );
261- return dm .widthPixels ;
262- }
263-
264263 private final ControllerListener aspectRatioListener = new BaseControllerListener <ImageInfo >() {
265264 @ Override
266265 public void onIntermediateImageSet (String id , @ Nullable ImageInfo imageInfo ) {
You can’t perform that action at this time.
0 commit comments