Skip to content

Commit

Permalink
Closes #706
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamantcheese committed Mar 7, 2020
1 parent 147bd79 commit 30f6b97
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public PostImage getCurrentPostImage() {
return images.get(selectedPosition);
}

@Override
public Loadable getLoadable() {
return loadable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public ImageViewerAdapter(
public View getView(int position, ViewGroup parent) {
PostImage postImage = images.get(position);
MultiImageView view = new MultiImageView(parent.getContext());
view.bindPostImage(postImage, multiImageViewCallback);
view.bindPostImage(postImage, multiImageViewCallback, images.get(0) == postImage); // hacky but good enough

loadedViews.add(view);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public enum Mode {

private PostImage postImage;
private Callback callback;
private boolean op;

private Mode mode = Mode.UNLOADED;
private ImageContainer thumbnailRequest;
private CancelableDownload bigImageRequest;
Expand Down Expand Up @@ -160,9 +162,10 @@ public void onPause() {
}
}

public void bindPostImage(PostImage postImage, Callback callback) {
public void bindPostImage(PostImage postImage, Callback callback, boolean op) {
this.postImage = postImage;
this.callback = callback;
this.op = op;
}

public PostImage getPostImage() {
Expand Down Expand Up @@ -678,11 +681,16 @@ private void setOther(Loadable loadable, PostImage image) {

public void toggleTransparency() {
transparentBackground = !transparentBackground;
final int BACKGROUND_COLOR = Color.argb(255, 211, 217, 241);
final int BACKGROUND_COLOR_SFW = Color.argb(255, 211, 217, 241);
final int BACKGROUND_COLOR_NSFW = Color.argb(255, 240, 224, 214);
final int BACKGROUND_COLOR_NSFW_OP = Color.argb(255, 255, 255, 238);
int boardColor = callback.getLoadable().board.workSafe
? BACKGROUND_COLOR_SFW
: (op ? BACKGROUND_COLOR_NSFW_OP : BACKGROUND_COLOR_NSFW);
View activeView = getActiveView();
if (!(activeView instanceof CustomScaleImageView || activeView instanceof GifImageView)) return;
boolean isImage = activeView instanceof CustomScaleImageView;
int backgroundColor = !transparentBackground ? Color.TRANSPARENT : BACKGROUND_COLOR;
int backgroundColor = !transparentBackground ? Color.TRANSPARENT : boardColor;
if (isImage) {
((CustomScaleImageView) activeView).setTileBackgroundColor(backgroundColor);
} else {
Expand Down Expand Up @@ -885,5 +893,7 @@ public interface Callback {
void onAudioLoaded(MultiImageView multiImageView);

void hideProgress(MultiImageView multiImageView);

Loadable getLoadable();
}
}

0 comments on commit 30f6b97

Please sign in to comment.