matrix tests added
This commit is contained in:
parent
26fd4dee77
commit
d5ae136054
@ -72,7 +72,11 @@
|
||||
<activity android:name=".CalculatorDialogActivity" android:theme="@style/cpp_metro_blue_dialog_theme"/>
|
||||
|
||||
<!-- todo serso: strings-->
|
||||
<activity android:label="@string/c_plot_graph" android:name=".matrix.CalculatorMatrixActivity"/>
|
||||
<activity android:label="@string/c_plot_graph" android:name=".matrix.CalculatorMatrixActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".widget.CalculatorWidgetConfigurationActivity" android:theme="@style/cpp_metro_blue_theme">
|
||||
<intent-filter>
|
||||
|
@ -24,17 +24,14 @@ package org.solovyev.android.calculator.matrix;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.solovyev.android.calculator.CalculatorFragment;
|
||||
import org.solovyev.android.calculator.CalculatorFragmentType;
|
||||
import org.solovyev.android.calculator.R;
|
||||
import org.solovyev.android.view.IntegerRange;
|
||||
import org.solovyev.android.view.Picker;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* User: Solovyev_S
|
||||
@ -91,11 +88,11 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
final Picker<Integer> matrixColsCountPicker = (Picker<Integer>) root.findViewById(R.id.matrix_cols_count_picker);
|
||||
initPicker(matrixColsCountPicker);
|
||||
|
||||
Matrix matrix = null;
|
||||
MatrixUi matrix = null;
|
||||
if (in != null) {
|
||||
final Object matrixObject = in.getSerializable(MATRIX);
|
||||
if (matrixObject instanceof Matrix) {
|
||||
matrix = (Matrix) matrixObject;
|
||||
if (matrixObject instanceof MatrixUi) {
|
||||
matrix = (MatrixUi) matrixObject;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +100,7 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
if (matrix == null) {
|
||||
matrixView.setMatrixDimensions(DEFAULT_ROWS, DEFAULT_COLS);
|
||||
} else {
|
||||
matrixView.setMatrix(matrix.bakingArray);
|
||||
matrixView.setMatrix(matrix.getBakingArray());
|
||||
}
|
||||
matrixRowsCountPicker.setCurrent(matrixView.getRows());
|
||||
matrixColsCountPicker.setCurrent(matrixView.getCols());
|
||||
@ -113,7 +110,7 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
public void onSaveInstanceState(@Nonnull Bundle out) {
|
||||
super.onSaveInstanceState(out);
|
||||
|
||||
out.putSerializable(MATRIX, new Matrix(getMatrixView(getView()).toMatrix()));
|
||||
out.putSerializable(MATRIX, new MatrixUi(getMatrixView(getView()).toMatrix()));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -146,16 +143,4 @@ public class CalculatorMatrixEditFragment extends CalculatorFragment implements
|
||||
getMatrixView(getView()).setMatrixRows(newRows);
|
||||
}
|
||||
|
||||
public static class Matrix implements Serializable {
|
||||
|
||||
@Nonnull
|
||||
private String[][] bakingArray;
|
||||
|
||||
public Matrix() {
|
||||
}
|
||||
|
||||
public Matrix(@Nonnull String[][] bakingArray) {
|
||||
this.bakingArray = bakingArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package org.solovyev.android.calculator.matrix;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 7/11/13
|
||||
* Time: 4:54 PM
|
||||
*/
|
||||
class MatrixUi implements Serializable {
|
||||
|
||||
@Nonnull
|
||||
private String[][] bakingArray;
|
||||
|
||||
public MatrixUi() {
|
||||
}
|
||||
|
||||
public MatrixUi(@Nonnull String[][] bakingArray) {
|
||||
this.bakingArray = bakingArray;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
String[][] getBakingArray() {
|
||||
return bakingArray;
|
||||
}
|
||||
}
|
@ -118,8 +118,8 @@ public class MatrixView extends TableLayout {
|
||||
throw new IllegalArgumentException("Number of columns must be more than 1: " + newCols);
|
||||
}
|
||||
|
||||
boolean rowsChanged = this.rows != newRows;
|
||||
boolean colsChanged = this.cols != newCols;
|
||||
final boolean rowsChanged = this.rows != newRows;
|
||||
final boolean colsChanged = this.cols != newCols;
|
||||
|
||||
if (rowsChanged || colsChanged) {
|
||||
if (!initialized) {
|
||||
|
@ -0,0 +1,9 @@
|
||||
package org.solovyev.android.calculator.matrix;
|
||||
|
||||
/**
|
||||
* User: serso
|
||||
* Date: 7/11/13
|
||||
* Time: 4:56 PM
|
||||
*/
|
||||
public class MatrixViewTest {
|
||||
}
|
Loading…
Reference in New Issue
Block a user