use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.
the class ImageDisplayRotateFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(layout.imagedisplay_rotate_fragment, container, false);
final SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView);
imageView.setImage(ImageSource.asset("swissroad.jpg"));
imageView.setOrientation(90);
final ImageDisplayActivity activity = (ImageDisplayActivity) getActivity();
if (activity != null) {
rootView.findViewById(id.previous).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.previous();
}
});
rootView.findViewById(id.next).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.next();
}
});
}
rootView.findViewById(id.rotate).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
imageView.setOrientation((imageView.getOrientation() + 90) % 360);
}
});
return rootView;
}
use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.
the class ItemActivity method onSaveInstanceState.
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (albumItem instanceof Photo) {
View itemView = viewPager.findViewWithTag(albumItem.getPath());
if (itemView != null) {
View view = itemView.findViewById(R.id.subsampling);
if (view instanceof SubsamplingScaleImageView) {
SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view;
ImageViewState state = imageView.getState();
if (state != null) {
outState.putSerializable(IMAGE_VIEW_SAVED_STATE, state);
}
}
}
}
// outState.putParcelable(ALBUM, album);
outState.putParcelable(ALBUM_ITEM, albumItem);
outState.putBoolean(WAS_SYSTEM_UI_HIDDEN, !systemUiVisible);
outState.putBoolean(INFO_DIALOG_SHOWN, infoDialog != null);
}
use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.
the class SetWallpaperActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
outState.putSerializable(IMAGE_VIEW_STATE, imageView.getState());
}
use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.
the class SetWallpaperActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_set_wallpaper);
Intent intent = getIntent();
if (intent == null) {
return;
}
final Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("");
actionBar.setDisplayHomeAsUpEnabled(true);
}
imageUri = intent.getData();
if (!MediaType.suitableAsWallpaper(this, imageUri)) {
Toast.makeText(this, R.string.wallpaper_file_format_not_supported, Toast.LENGTH_SHORT).show();
finish();
}
final SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
ImageViewState imageViewState = null;
if (savedInstanceState != null && savedInstanceState.containsKey(IMAGE_VIEW_STATE)) {
imageViewState = (ImageViewState) savedInstanceState.getSerializable(IMAGE_VIEW_STATE);
}
imageView.setMinimumTileDpi(196);
// use custom decoders
imageView.setRegionDecoderClass(CustomRegionDecoder.class);
imageView.setImage(ImageSource.uri(imageUri), imageViewState);
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
if (imageViewState == null) {
imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {
@Override
public void onImageLoaded() {
super.onImageLoaded();
float scale = imageView.getScale();
PointF center = new PointF(imageView.getWidth() / 2, 0.0f);
imageView.setScaleAndCenter(scale, center);
}
});
}
// setting window insets manually
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
toolbar.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {
@Override
@RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
// clear this listener so insets aren't re-applied
toolbar.setOnApplyWindowInsetsListener(null);
toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom());
return insets.consumeSystemWindowInsets();
}
});
} else {
toolbar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
toolbar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
// hacky way of getting window insets on pre-Lollipop
// somewhat works...
int[] screenSize = Util.getScreenSize(SetWallpaperActivity.this);
int[] windowInsets = new int[] { Math.abs(screenSize[0] - toolbar.getLeft()), Math.abs(screenSize[1] - toolbar.getTop()), Math.abs(screenSize[2] - toolbar.getRight()), Math.abs(0) };
toolbar.setPadding(toolbar.getPaddingStart() + windowInsets[0], toolbar.getPaddingTop() + windowInsets[1], toolbar.getPaddingEnd() + windowInsets[2], toolbar.getPaddingBottom());
}
});
}
// needed to achieve transparent navBar
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE);
}
use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project LeafPic by HoraApps.
the class ImageFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (PreferenceUtil.getInstance(getContext()).getBoolean(getString(R.string.preference_sub_scaling), false)) {
SubsamplingScaleImageView imageView = new SubsamplingScaleImageView(getContext());
imageView.setImage(ImageSource.uri(img.getUri()));
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}
});
return imageView;
} else {
PhotoView photoView = new PhotoView(getContext());
displayMedia(photoView, true);
photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}
@Override
public void onOutsidePhotoTap() {
((SingleMediaActivity) getActivity()).toggleSystemUI();
}
});
photoView.setMaximumScale(5.0F);
photoView.setMediumScale(3.0F);
return photoView;
}
}
Aggregations