aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/java/com/davemorrissey/labs/subscaleview/test/configuration/ConfigurationActivity.java
blob: 1f812956fe50268a73bb4df1a401569703005a41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
Copyright 2014 David Morrissey

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.davemorrissey.labs.subscaleview.test.configuration;

import android.graphics.PointF;
import android.os.Bundle;
import android.support.annotation.Nullable;

import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
import com.davemorrissey.labs.subscaleview.test.AbstractPagesActivity;
import com.davemorrissey.labs.subscaleview.test.Page;
import com.davemorrissey.labs.subscaleview.test.R.id;

import java.util.Arrays;

import static com.davemorrissey.labs.subscaleview.test.R.string.*;
import static com.davemorrissey.labs.subscaleview.test.R.layout.*;

public class ConfigurationActivity extends AbstractPagesActivity {

    private SubsamplingScaleImageView view;

    public ConfigurationActivity() {
        super(configuration_title, pages_activity, Arrays.asList(
                new Page(configuration_p1_subtitle, configuration_p1_text),
                new Page(configuration_p2_subtitle, configuration_p2_text),
                new Page(configuration_p3_subtitle, configuration_p3_text),
                new Page(configuration_p4_subtitle, configuration_p4_text),
                new Page(configuration_p5_subtitle, configuration_p5_text),
                new Page(configuration_p6_subtitle, configuration_p6_text),
                new Page(configuration_p7_subtitle, configuration_p7_text),
                new Page(configuration_p8_subtitle, configuration_p8_text),
                new Page(configuration_p9_subtitle, configuration_p9_text),
                new Page(configuration_p10_subtitle, configuration_p10_text)
        ));
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        view = findViewById(id.imageView);
        view.setImage(ImageSource.asset("eagle.jpg"));
    }

    @Override
    protected void onPageChanged(int page) {
        if (page == 0) {
            view.setMinimumDpi(50);
        } else {
            view.setMaxScale(2F);
        }
        if (page == 1) {
            view.setMinimumTileDpi(50);
        } else {
            view.setMinimumTileDpi(500);
        }
        if (page == 4) {
            view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER);
        } else if (page == 5) {
            view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_CENTER_IMMEDIATE);
        } else {
            view.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED);
        }
        if (page == 6) {
            view.setDoubleTapZoomDpi(240);
        } else {
            view.setDoubleTapZoomScale(1F);
        }
        if (page == 7) {
            view.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_CENTER);
        } else if (page == 8) {
            view.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_OUTSIDE);
        } else {
            view.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
        }
        if (page == 9) {
            view.setDebug(true);
        } else {
            view.setDebug(false);
        }
        if (page == 2) {
            view.setScaleAndCenter(0f, new PointF(2456, 1632));
            view.setPanEnabled(false);
        } else {
            view.setPanEnabled(true);
        }
        if (page == 3) {
            view.setScaleAndCenter(1f, new PointF(2456, 1632));
            view.setZoomEnabled(false);
        } else {
            view.setZoomEnabled(true);
        }
    }

}