[apps/calculation] Additional outputs: Clean cells when the pop-up

disappears to avoid uselessly overloading the Poincare pool
This commit is contained in:
Émilie Feral
2020-02-20 10:24:43 +01:00
committed by LeaNumworks
parent 94daf465c4
commit 99e88df284
5 changed files with 19 additions and 1 deletions

View File

@@ -24,6 +24,13 @@ int ExpressionsListController::reusableCellCount(int type) {
return k_maxNumberOfCells;
}
void ExpressionsListController::viewDidDisappear() {
// Reset cell memoization to avoid taking extra space in the pool
for (int i = 0; i < k_maxNumberOfCells; i++) {
m_cells[i].setLayout(Layout());
}
}
HighlightCell * ExpressionsListController::reusableCell(int index, int type) {
return &m_cells[index];
}

View File

@@ -13,6 +13,7 @@ public:
ExpressionsListController(Responder * parentResponder, EditExpressionController * editExpressionController);
// Responder
void viewDidDisappear() override;
void didEnterResponderChain(Responder * previousFirstResponder) override;
//ListViewDataSource

View File

@@ -42,6 +42,10 @@ void IllustratedListController::viewDidDisappear() {
Poincare::Symbol s = Poincare::Symbol::Builder(expressionSymbol());
context->setExpressionForSymbolAbstract(m_savedExpression, s);
}
// Reset cell memoization to avoid taking extra space in the pool
for (int i = 0; i < k_maxNumberOfAdditionalCalculations; i++) {
m_additionalCalculationCells[i].resetMemoization();
}
}
int IllustratedListController::numberOfRows() const {

View File

@@ -4,11 +4,15 @@
namespace Calculation {
void ScrollableThreeExpressionsView::resetMemoization() {
setLayouts(Poincare::Layout(), Poincare::Layout(), Poincare::Layout());
}
void ScrollableThreeExpressionsView::setCalculation(Calculation * calculation) {
Poincare::Context * context = App::app()->localContext();
// Clean the layouts to make room in the pool
setLayouts(Poincare::Layout(), Poincare::Layout(), Poincare::Layout());
resetMemoization();
// Create the input layout
Poincare::Layout inputLayout = calculation->createInputLayout();

View File

@@ -14,6 +14,7 @@ public:
setMargins(Metric::CommonSmallMargin, Metric::CommonSmallMargin, Metric::CommonSmallMargin, Metric::CommonSmallMargin); // Left Right margins are already added by TableCell
setBackgroundColor(KDColorWhite);
}
void resetMemoization();
void setCalculation(Calculation * calculation);
private:
class ContentCell : public Shared::AbstractScrollableMultipleExpressionsView::ContentCell {
@@ -50,6 +51,7 @@ public:
View * labelView() const override { return (View *)&m_view; }
void setHighlighted(bool highlight) override { m_view.evenOddCell()->setHighlighted(highlight); }
void resetMemoization() { m_view.resetMemoization(); }
void setCalculation(Calculation * calculation);
void setDisplayCenter(bool display);
ScrollableThreeExpressionsView::SubviewPosition selectedSubviewPosition() { return m_view.selectedSubviewPosition(); }