blob: 46465c41c967621ba25f77573c99b4d331711fe7 [file] [log] [blame]
package com.davemorrissey.labs.subscaleview.test.imagedisplay;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.davemorrissey.labs.subscaleview.test.R.id;
import com.davemorrissey.labs.subscaleview.test.R.layout;
public class ImageDisplayRotateFragment extends Fragment {
@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;
}
}