Home | History | Annotate | Download | only in state
      1 /*
      2  * Copyright (C) 2013 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  */
     16 
     17 package com.android.gallery3d.filtershow.state;
     18 
     19 import com.android.gallery3d.filtershow.filters.FilterFxRepresentation;
     20 import com.android.gallery3d.filtershow.filters.FilterRepresentation;
     21 
     22 public class State {
     23     private String mText;
     24     private int mType;
     25     private FilterRepresentation mFilterRepresentation;
     26 
     27     public State(State state) {
     28         this(state.getText(), state.getType());
     29     }
     30 
     31     public State(String text) {
     32        this(text, StateView.DEFAULT);
     33     }
     34 
     35     public State(String text, int type) {
     36         mText = text;
     37         mType = type;
     38     }
     39 
     40     public boolean equals(State state) {
     41         if (mFilterRepresentation.getFilterClass()
     42                 != state.mFilterRepresentation.getFilterClass()) {
     43             return false;
     44         }
     45         if (mFilterRepresentation instanceof FilterFxRepresentation) {
     46             return mFilterRepresentation.equals(state.getFilterRepresentation());
     47         }
     48         return true;
     49     }
     50 
     51     public boolean isDraggable() {
     52         return mFilterRepresentation != null;
     53     }
     54 
     55     String getText() {
     56         return mText;
     57     }
     58 
     59     void setText(String text) {
     60         mText = text;
     61     }
     62 
     63     int getType() {
     64         return mType;
     65     }
     66 
     67     void setType(int type) {
     68         mType = type;
     69     }
     70 
     71     public FilterRepresentation getFilterRepresentation() {
     72         return mFilterRepresentation;
     73     }
     74 
     75     public void setFilterRepresentation(FilterRepresentation filterRepresentation) {
     76         mFilterRepresentation = filterRepresentation;
     77     }
     78 }
     79