TreeNodeWrapperView.java 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.unnamed.b.atv.view;
  2. import android.content.Context;
  3. import android.view.ContextThemeWrapper;
  4. import android.view.View;
  5. import android.view.ViewGroup;
  6. import android.widget.LinearLayout;
  7. import android.widget.RelativeLayout;
  8. import com.unnamed.b.atv.R;
  9. /**
  10. * Created by Bogdan Melnychuk on 2/10/15.
  11. */
  12. public class TreeNodeWrapperView extends LinearLayout {
  13. private LinearLayout nodeItemsContainer;
  14. private ViewGroup nodeContainer;
  15. private final int containerStyle;
  16. public TreeNodeWrapperView(Context context, int containerStyle) {
  17. super(context);
  18. this.containerStyle = containerStyle;
  19. init();
  20. }
  21. private void init() {
  22. setOrientation(LinearLayout.VERTICAL);
  23. nodeContainer = new RelativeLayout(getContext());
  24. nodeContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  25. nodeContainer.setId(R.id.node_header);
  26. ContextThemeWrapper newContext = new ContextThemeWrapper(getContext(), containerStyle);
  27. nodeItemsContainer = new LinearLayout(newContext, null, containerStyle);
  28. nodeItemsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
  29. nodeItemsContainer.setId(R.id.node_items);
  30. nodeItemsContainer.setOrientation(LinearLayout.VERTICAL);
  31. nodeItemsContainer.setVisibility(View.GONE);
  32. addView(nodeContainer);
  33. addView(nodeItemsContainer);
  34. }
  35. public void insertNodeView(View nodeView) {
  36. nodeContainer.addView(nodeView);
  37. }
  38. public ViewGroup getNodeContainer() {
  39. return nodeContainer;
  40. }
  41. }