Search in sources :

Example 6 with ViewDefinition

use of org.apmem.tools.layouts.logic.ViewDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method CreateView.

private ViewDefinition CreateView(int length, int thickness) {
    ViewDefinition view = new ViewDefinition(new ConfigDefinition(), null);
    view.setLength(length);
    view.setThickness(thickness);
    return view;
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition)

Example 7 with ViewDefinition

use of org.apmem.tools.layouts.logic.ViewDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method AddView_IncreaseLineLengthForChildLength.

@Test
public void AddView_IncreaseLineLengthForChildLength() {
    ViewDefinition view1 = CreateView(12, 34);
    ViewDefinition view2 = CreateView(56, 78);
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(100);
    LineDefinition def = new LineDefinition(config);
    def.addView(view1);
    def.addView(view2);
    Assert.assertEquals(68, def.getLineLength());
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) Test(org.junit.Test)

Example 8 with ViewDefinition

use of org.apmem.tools.layouts.logic.ViewDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method CanFit_LengthMoreThenRemainingIsNotOk.

@Test
public void CanFit_LengthMoreThenRemainingIsNotOk() {
    ViewDefinition view1 = CreateView(12, 34);
    ViewDefinition view2 = CreateView(56, 78);
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(100);
    LineDefinition def = new LineDefinition(config);
    def.addView(view1);
    def.addView(view2);
    boolean canFit = def.canFit(view2);
    Assert.assertFalse(canFit);
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) Test(org.junit.Test)

Example 9 with ViewDefinition

use of org.apmem.tools.layouts.logic.ViewDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method AddView_AddViewIntoList.

@Test
public void AddView_AddViewIntoList() {
    ViewDefinition view1 = CreateView(12, 34);
    ViewDefinition view2 = CreateView(56, 78);
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(100);
    LineDefinition def = new LineDefinition(config);
    def.addView(view1);
    def.addView(view2);
    Assert.assertEquals(view1, def.getViews().get(0));
    Assert.assertEquals(view2, def.getViews().get(1));
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) Test(org.junit.Test)

Example 10 with ViewDefinition

use of org.apmem.tools.layouts.logic.ViewDefinition in project android-flowlayout by ApmeM.

the class LineDefinitionTests method AddView_SetThicknessToMaxBetweenThickness.

@Test
public void AddView_SetThicknessToMaxBetweenThickness() {
    ViewDefinition view1 = CreateView(12, 34);
    ViewDefinition view2 = CreateView(56, 78);
    ConfigDefinition config = new ConfigDefinition();
    config.setMaxWidth(100);
    LineDefinition def = new LineDefinition(config);
    def.addView(view1);
    def.addView(view2);
    Assert.assertEquals(78, def.getLineThickness());
}
Also used : ViewDefinition(org.apmem.tools.layouts.logic.ViewDefinition) LineDefinition(org.apmem.tools.layouts.logic.LineDefinition) ConfigDefinition(org.apmem.tools.layouts.logic.ConfigDefinition) Test(org.junit.Test)

Aggregations

ViewDefinition (org.apmem.tools.layouts.logic.ViewDefinition)19 LineDefinition (org.apmem.tools.layouts.logic.LineDefinition)16 ConfigDefinition (org.apmem.tools.layouts.logic.ConfigDefinition)14 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)6 View (android.view.View)5 Paint (android.graphics.Paint)3 RecyclerView (android.support.v7.widget.RecyclerView)2