Created
February 21, 2017 11:32
-
-
Save zserge/0c066cfa7039632da8e2b530dc69f765 to your computer and use it in GitHub Desktop.
Reproducing Anvil issue #83
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package trikita.foo; | |
import android.content.Context; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.widget.LinearLayout; | |
import trikita.anvil.RenderableView; | |
import static trikita.anvil.DSL.*; | |
public class MainActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(new OuterView(this)); | |
} | |
public static class OuterView extends RenderableView { | |
private int mode = 0; | |
public OuterView(Context c) { super(c); } | |
public void view() { | |
linearLayout(() -> { | |
orientation(LinearLayout.VERTICAL); | |
button(() -> { | |
text("change mode ("+mode+")"); | |
onClick(v -> mode++); | |
}); | |
v(InnerView.class, () -> {}); | |
if (mode % 2 == 0) { | |
v(InnerView.class, () -> { | |
}); | |
} | |
v(InnerView.class, () -> {}); | |
}); | |
} | |
} | |
public static class InnerView extends RenderableView { | |
public InnerView(Context context) { super(context); } | |
public void view() { | |
xml(R.layout.activity_main, () -> { | |
withId(R.id.button, () -> { | |
text("Hello, button"); | |
}); | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment