t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | Copyright 2014 David Morrissey |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.davemorrissey.labs.subscaleview.sample.imagedisplay; |
| 18 | |
| 19 | import android.graphics.Rect; |
| 20 | import android.os.Bundle; |
| 21 | import android.support.v4.app.Fragment; |
| 22 | import android.view.LayoutInflater; |
| 23 | import android.view.View; |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 24 | import android.view.ViewGroup; |
David Morrissey | 0df74d7 | 2015-03-08 19:59:18 +0000 | [diff] [blame] | 25 | |
| 26 | import com.davemorrissey.labs.subscaleview.ImageSource; |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 27 | import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; |
| 28 | import com.davemorrissey.labs.subscaleview.sample.R.id; |
| 29 | import com.davemorrissey.labs.subscaleview.sample.R.layout; |
| 30 | |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 31 | public 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 Morrissey | c930ef7 | 2017-11-02 18:27:22 +0000 | [diff] [blame^] | 36 | final SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView); |
David Morrissey | 0df74d7 | 2015-03-08 19:59:18 +0000 | [diff] [blame] | 37 | imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_90); |
David Morrissey | ff48afe | 2015-03-08 21:01:48 +0000 | [diff] [blame] | 38 | imageView.setImage(ImageSource.asset("card.png").region(new Rect(0, 0, 3778, 2834))); |
David Morrissey | c930ef7 | 2017-11-02 18:27:22 +0000 | [diff] [blame^] | 39 | rootView.findViewById(id.previous).setOnClickListener(new View.OnClickListener() { |
| 40 | @Override public void onClick(View v) { ((ImageDisplayActivity) ImageDisplayRegionFragment.this.getActivity()).previous(); } |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 41 | }); |
David Morrissey | c930ef7 | 2017-11-02 18:27:22 +0000 | [diff] [blame^] | 42 | rootView.findViewById(id.rotate).setOnClickListener(new View.OnClickListener() { |
| 43 | @Override public void onClick(View v) { imageView.setOrientation((imageView.getOrientation() + 90) % 360); } |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 44 | }); |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 45 | return rootView; |
| 46 | } |
| 47 | |
t101d | 4b48227 | 2015-03-04 21:40:32 +0800 | [diff] [blame] | 48 | } |