FileDocCategorySizeDatePackage
History.javaAPI DocAndroid 1.5 API3004Wed May 06 22:42:42 BST 2009com.android.calculator2

History

public class History extends Object

Fields Summary
private static final int
VERSION_1
private static final int
MAX_ENTRIES
Vector
mEntries
int
mPos
android.widget.BaseAdapter
mObserver
Constructors Summary
History()


     
        clear();
    
History(int version, DataInput in)

        if (version >= VERSION_1) {
            int size = in.readInt();
            for (int i = 0; i < size; ++i) {
                mEntries.add(new HistoryEntry(version, in));
            }
            mPos = in.readInt();
        } else {
            throw new IOException("invalid version " + version);
        }
    
Methods Summary
voidclear()

        mEntries.clear();
        mEntries.add(new HistoryEntry(""));
        mPos = 0;
        notifyChanged();
    
HistoryEntrycurrent()

        return mEntries.elementAt(mPos);
    
voidenter(java.lang.String text)

        current().clearEdited();
        if (mEntries.size() >= MAX_ENTRIES) {
            mEntries.remove(0);
        }
        if (mEntries.size() < 2 ||
            !text.equals(mEntries.elementAt(mEntries.size() - 2).getBase())) {
            mEntries.insertElementAt(new HistoryEntry(text), mEntries.size() - 1);
        }
        mPos = mEntries.size() - 1;
        notifyChanged();
    
java.lang.StringgetBase()

        return current().getBase();
    
java.lang.StringgetText()

        return current().getEdited();
    
booleanmoveToNext()

        if (mPos < mEntries.size() - 1) {
            ++mPos;
            return true;
        }
        return false;
    
booleanmoveToPrevious()

        if (mPos > 0) {
            --mPos;
            return true;
        }
        return false;
    
private voidnotifyChanged()

        if (mObserver != null) {
            mObserver.notifyDataSetChanged();
        }
    
voidsetObserver(android.widget.BaseAdapter observer)

        mObserver = observer;
    
voidupdate(java.lang.String text)

        current().setEdited(text);
    
voidwrite(java.io.DataOutput out)

        out.writeInt(mEntries.size());
        for (HistoryEntry entry : mEntries) {
            entry.write(out);
        }
        out.writeInt(mPos);