am afca1ddd: Comprehensive memory deallocation

* commit 'afca1ddd233c03d79433931a0b6ba97ed22663ed':
  Comprehensive memory deallocation
main
Tadashi G. Takaoka 2013-12-24 01:42:02 -08:00 committed by Android Git Automerger
commit 5f676a7311
6 changed files with 21 additions and 13 deletions

View File

@ -1228,6 +1228,6 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack
@Override
public void deallocateMemory() {
super.deallocateMemory();
mGestureTrailsDrawingPreview.deallocateMemory();
mDrawingPreviewPlacerView.deallocateMemory();
}
}

View File

@ -50,9 +50,7 @@ public abstract class AbstractDrawingPreview {
// Default implementation is empty.
}
public void onDetachFromWindow() {
// Default implementation is empty.
}
public abstract void onDeallocateMemory();
/**
* Draws the preview

View File

@ -59,13 +59,17 @@ public final class DrawingPreviewPlacerView extends RelativeLayout {
}
}
public void deallocateMemory() {
final int count = mPreviews.size();
for (int i = 0; i < count; i++) {
mPreviews.get(i).onDeallocateMemory();
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
final int count = mPreviews.size();
for (int i = 0; i < count; i++) {
mPreviews.get(i).onDetachFromWindow();
}
deallocateMemory();
}
@Override

View File

@ -105,6 +105,11 @@ public class GestureFloatingTextDrawingPreview extends AbstractDrawingPreview {
mParams = new GesturePreviewTextParams(typedArray);
}
@Override
public void onDeallocateMemory() {
// Nothing to do here.
}
public void setSuggetedWords(final SuggestedWords suggestedWords) {
if (!isPreviewEnabled()) {
return;

View File

@ -103,11 +103,7 @@ public final class GestureTrailsDrawingPreview extends AbstractDrawingPreview {
}
@Override
public void onDetachFromWindow() {
freeOffscreenBuffer();
}
public void deallocateMemory() {
public void onDeallocateMemory() {
freeOffscreenBuffer();
}

View File

@ -62,6 +62,11 @@ public final class SlidingKeyInputDrawingPreview extends AbstractDrawingPreview
mPaint.setColor(previewColor);
}
@Override
public void onDeallocateMemory() {
// Nothing to do here.
}
public void dismissSlidingKeyInputPreview() {
mShowsSlidingKeyInputPreview = false;
getDrawingView().invalidate();