ToastBarOperation.java revision 4f9a4c5ccb1370f583639e763b1c529fe6762271
1/******************************************************************************* 2 * Copyright (C) 2011 Google Inc. 3 * Licensed to The Android Open Source Project. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 *******************************************************************************/ 17package com.android.mail; 18 19import android.os.Bundle; 20 21import java.util.Collection; 22 23/** 24 * A simple holder class that stores the information to undo the application of a label. 25 */ 26public class UndoOperation { 27 private static final String ACCOUNT = "undo-account"; 28 private static final String DESCRIPTION = "undo-description"; 29 private static final String CONVERSATIONS = "undo-conversations"; 30 31 public Collection<ConversationInfo> mConversations; 32 public String mDescription; 33 public String mAccount; 34 35 public UndoOperation(String account, Collection<ConversationInfo> conversations, 36 String description) { 37 this(account, conversations, description, true /* undoAction */); 38 } 39 40 /** 41 * Create an UndoOperation 42 * @param account Account that this operation is associated with 43 * @param conversations Collection of ConversationInfo objects that this operation 44 * should be applied to 45 * @param description Desctiption text that should be shown to the user 46 * @param undoAction Boolean indicating whether the operations should be reversed 47 * in order to perform the action. This is only false when un-marshaling a 48 * previously existing UndoOperation 49 */ 50 private UndoOperation(String account, Collection<ConversationInfo> conversations, 51 String description, boolean undoAction) { 52 mAccount = account; 53 mConversations = conversations; 54 mDescription = description; 55 } 56 57 /** 58 * Save this object into an extra object. 59 */ 60 public void saveToExtras(Bundle extras) { 61 extras.putString(ACCOUNT, mAccount); 62 extras.putString(DESCRIPTION, mDescription); 63 extras.putParcelableArray(CONVERSATIONS, 64 mConversations.toArray(new ConversationInfo[mConversations.size()])); 65 } 66} 67