blob: 517948fc611bfb04a8b94292a9dbf1ced54186b5 [file] [log] [blame]
t101d4b482272015-03-04 21:40:32 +08001/*
2Copyright 2014 David Morrissey
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package com.davemorrissey.labs.subscaleview.sample.imagedisplay;
18
19import android.graphics.Rect;
20import android.os.Bundle;
21import android.support.v4.app.Fragment;
22import android.view.LayoutInflater;
23import android.view.View;
t101d4b482272015-03-04 21:40:32 +080024import android.view.ViewGroup;
David Morrissey0df74d72015-03-08 19:59:18 +000025
26import com.davemorrissey.labs.subscaleview.ImageSource;
t101d4b482272015-03-04 21:40:32 +080027import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
28import com.davemorrissey.labs.subscaleview.sample.R.id;
29import com.davemorrissey.labs.subscaleview.sample.R.layout;
30
t101d4b482272015-03-04 21:40:32 +080031public class ImageDisplayRegionFragment extends Fragment {
32
33 @Override
34 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
35 View rootView = inflater.inflate(layout.imagedisplay_region_fragment, container, false);
David Morrisseyc930ef72017-11-02 18:27:22 +000036 final SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView);
David Morrissey0df74d72015-03-08 19:59:18 +000037 imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_90);
David Morrisseyff48afe2015-03-08 21:01:48 +000038 imageView.setImage(ImageSource.asset("card.png").region(new Rect(0, 0, 3778, 2834)));
David Morrisseyc930ef72017-11-02 18:27:22 +000039 rootView.findViewById(id.previous).setOnClickListener(new View.OnClickListener() {
40 @Override public void onClick(View v) { ((ImageDisplayActivity) ImageDisplayRegionFragment.this.getActivity()).previous(); }
t101d4b482272015-03-04 21:40:32 +080041 });
David Morrisseyc930ef72017-11-02 18:27:22 +000042 rootView.findViewById(id.rotate).setOnClickListener(new View.OnClickListener() {
43 @Override public void onClick(View v) { imageView.setOrientation((imageView.getOrientation() + 90) % 360); }
t101d4b482272015-03-04 21:40:32 +080044 });
t101d4b482272015-03-04 21:40:32 +080045 return rootView;
46 }
47
t101d4b482272015-03-04 21:40:32 +080048}