mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-19 06:27:30 +00:00
68 lines
1.9 KiB
Java
68 lines
1.9 KiB
Java
|
package org.thoughtcrime.securesms.components;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.support.annotation.NonNull;
|
||
|
import android.support.annotation.Nullable;
|
||
|
import android.util.AttributeSet;
|
||
|
import android.view.View;
|
||
|
import android.widget.FrameLayout;
|
||
|
|
||
|
import org.thoughtcrime.securesms.R;
|
||
|
import org.thoughtcrime.securesms.mms.GlideRequests;
|
||
|
import org.thoughtcrime.securesms.mms.Slide;
|
||
|
import org.thoughtcrime.securesms.mms.SlideClickListener;
|
||
|
import org.thoughtcrime.securesms.mms.SlidesClickedListener;
|
||
|
|
||
|
public class StickerView extends FrameLayout {
|
||
|
|
||
|
private ThumbnailView image;
|
||
|
private View missingShade;
|
||
|
|
||
|
public StickerView(@NonNull Context context) {
|
||
|
super(context);
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
public StickerView(@NonNull Context context, @Nullable AttributeSet attrs) {
|
||
|
super(context, attrs);
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
private void init() {
|
||
|
inflate(getContext(), R.layout.sticker_view, this);
|
||
|
|
||
|
this.image = findViewById(R.id.sticker_thumbnail);
|
||
|
this.missingShade = findViewById(R.id.sticker_missing_shade);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void setFocusable(boolean focusable) {
|
||
|
image.setFocusable(focusable);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void setClickable(boolean clickable) {
|
||
|
image.setClickable(clickable);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void setOnLongClickListener(@Nullable OnLongClickListener l) {
|
||
|
image.setOnLongClickListener(l);
|
||
|
}
|
||
|
|
||
|
public void setSticker(@NonNull GlideRequests glideRequests, @NonNull Slide stickerSlide) {
|
||
|
boolean showControls = stickerSlide.asAttachment().getDataUri() == null;
|
||
|
|
||
|
image.setImageResource(glideRequests, stickerSlide, showControls, false);
|
||
|
missingShade.setVisibility(showControls ? View.VISIBLE : View.GONE);
|
||
|
}
|
||
|
|
||
|
public void setThumbnailClickListener(@NonNull SlideClickListener listener) {
|
||
|
image.setThumbnailClickListener(listener);
|
||
|
}
|
||
|
|
||
|
public void setDownloadClickListener(@NonNull SlidesClickedListener listener) {
|
||
|
image.setDownloadClickListener(listener);
|
||
|
}
|
||
|
}
|