1/*
2 * Copyright (C) 2010 The Android Open Source Project
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 */
16package com.android.gallery3d.util;
17
18import com.android.gallery3d.common.Utils;
19
20public class UpdateHelper {
21
22    private boolean mUpdated = false;
23
24    public int update(int original, int update) {
25        if (original != update) {
26            mUpdated = true;
27            original = update;
28        }
29        return original;
30    }
31
32    public long update(long original, long update) {
33        if (original != update) {
34            mUpdated = true;
35            original = update;
36        }
37        return original;
38    }
39
40    public double update(double original, double update) {
41        if (original != update) {
42            mUpdated = true;
43            original = update;
44        }
45        return original;
46    }
47
48    public <T> T update(T original, T update) {
49        if (!Utils.equals(original, update)) {
50            mUpdated = true;
51            original = update;
52        }
53        return original;
54    }
55
56    public boolean isUpdated() {
57        return mUpdated;
58    }
59}
60