1fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard/* 2fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * Copyright (C) 2013 The Android Open Source Project 3fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * 4fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * Licensed under the Apache License, Version 2.0 (the "License"); 5fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * you may not use this file except in compliance with the License. 6fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * You may obtain a copy of the License at 7fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * 8fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * http://www.apache.org/licenses/LICENSE-2.0 9fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * 10fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * Unless required by applicable law or agreed to in writing, software 11fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * distributed under the License is distributed on an "AS IS" BASIS, 12fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * See the License for the specific language governing permissions and 14fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard * limitations under the License. 15fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard */ 16fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 17fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroardpackage com.android.gallery3d.filtershow.state; 18fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 19ffc6aea8d586de43e246e60155e573fd34d90da2nicolasroardimport com.android.gallery3d.filtershow.filters.FilterFxRepresentation; 20fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroardimport com.android.gallery3d.filtershow.filters.FilterRepresentation; 21fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 22fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroardpublic class State { 23fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard private String mText; 24fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard private int mType; 25fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard private FilterRepresentation mFilterRepresentation; 26fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 27fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard public State(State state) { 28fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard this(state.getText(), state.getType()); 29fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 30fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 31fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard public State(String text) { 32fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard this(text, StateView.DEFAULT); 33fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 34fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 3500259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard public State(String text, int type) { 36fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard mText = text; 37fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard mType = type; 38fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 39fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 4000259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard public boolean equals(State state) { 4100259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard if (mFilterRepresentation.getFilterClass() 4200259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard != state.mFilterRepresentation.getFilterClass()) { 4300259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard return false; 4400259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard } 45ffc6aea8d586de43e246e60155e573fd34d90da2nicolasroard if (mFilterRepresentation instanceof FilterFxRepresentation) { 46ffc6aea8d586de43e246e60155e573fd34d90da2nicolasroard return mFilterRepresentation.equals(state.getFilterRepresentation()); 47ffc6aea8d586de43e246e60155e573fd34d90da2nicolasroard } 4800259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard return true; 4900259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard } 5000259461be82e601b58d3e970afbf0c012c5f3e7nicolasroard 51fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard public boolean isDraggable() { 52fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard return mFilterRepresentation != null; 53fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 54fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 55fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard String getText() { 56fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard return mText; 57fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 58fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 59fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard void setText(String text) { 60fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard mText = text; 61fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 62fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 63fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard int getType() { 64fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard return mType; 65fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 66fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 67fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard void setType(int type) { 68fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard mType = type; 69fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 70fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 71fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard public FilterRepresentation getFilterRepresentation() { 72fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard return mFilterRepresentation; 73fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 74fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard 75fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard public void setFilterRepresentation(FilterRepresentation filterRepresentation) { 76fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard mFilterRepresentation = filterRepresentation; 77fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard } 78fb6a8e166f0a46d2a994a408b1679e3a67fdcb52nicolasroard} 79