Skip to content

Commit

Permalink
Fixes #3687 : Media needs refactoring to remove code that has been re…
Browse files Browse the repository at this point in the history
…ndered useless (#3693)
  • Loading branch information
kbhardwaj123 authored Apr 22, 2020
1 parent 0f906b2 commit 840e126
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ public static MediaDetailFragment forMedia(int index, boolean editable, boolean
private boolean categoriesPresent = false;
private boolean depictionLoaded = false;
private ViewTreeObserver.OnGlobalLayoutListener layoutListener; // for layout stuff, only used once!
private ViewTreeObserver.OnScrollChangedListener scrollListener;

//Had to make this class variable, to implement various onClicks, which access the media, also I fell why make separate variables when one can serve the purpose
private Media media;
Expand Down Expand Up @@ -211,9 +210,6 @@ && getParentFragment() instanceof MediaDetailPagerFragment) {
authorLayout.setVisibility(GONE);
}

// Progressively darken the image in the background when we scroll detail pane up
scrollListener = this::updateTheDarkness;
view.getViewTreeObserver().addOnScrollChangedListener(scrollListener);
locale = getResources().getConfiguration().locale;
return view;
}
Expand Down Expand Up @@ -313,10 +309,6 @@ public void onDestroyView() {
getView().getViewTreeObserver().removeGlobalOnLayoutListener(layoutListener); // old Android was on crack. CRACK IS WHACK
layoutListener = null;
}
if (scrollListener != null && getView() != null) {
getView().getViewTreeObserver().removeOnScrollChangedListener(scrollListener);
scrollListener = null;
}

compositeDisposable.clear();
super.onDestroyView();
Expand Down Expand Up @@ -583,18 +575,6 @@ private View buildCatLabel(final String catName, ViewGroup categoryContainer) {
return item;
}

private void updateTheDarkness() {
// You must face the darkness alone
int scrollY = scrollView.getScrollY();
int scrollMax = getView().getHeight();
float scrollPercentage = (float) scrollY / (float) scrollMax;
final float transparencyMax = 0.75f;
if (scrollPercentage > transparencyMax) {
scrollPercentage = transparencyMax;
}
image.setAlpha(1.0f - scrollPercentage);
}

/**
* Returns captions for media details
*
Expand Down
19 changes: 0 additions & 19 deletions app/src/main/java/fr/free/nrw/commons/media/MediaDetailSpacer.java

This file was deleted.

0 comments on commit 840e126

Please sign in to comment.