Guest User

Untitled

a guest
Aug 8th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.98 KB | None | 0 0
  1. abstract class Layout[TL <: TypedLayout[_], TVHF <: TypedViewHolderFactory[TL]]( layout: Witness.Lt[TL] )(
  2.         implicit
  3.         val tvhf: TVHF
  4. ) extends Activity {
  5.     private var holder: TVHF#VH = _
  6.  
  7.     @inline
  8.     final def view: TVHF#VH = holder
  9.  
  10.     override def onCreate( state: Option[Bundle] ) = {
  11.         super.onCreate( state )
  12.  
  13.         val content = getWindow.getDecorView
  14.             .findViewById( android.R.id.content )
  15.             .asInstanceOf[ViewGroup]
  16.  
  17.         holder = tvhf.create {
  18.             getLayoutInflater.inflate( layout.value.id, content, false )
  19.                 .asInstanceOf[tvhf.V]
  20.         }
  21.  
  22.         setContentView( holder.rootView, holder.rootView.getLayoutParams )
  23.     }
  24. }
  25.  
  26. class Activity extends Layout( TR.layout.screen_control_center ) {
  27.     override def onCreate( state: Option[Bundle] ) = {
  28.         super.onCreate( state )
  29.  
  30.         view.recycler.setLayoutManager( new LinearLayoutManager( context, VERTICAL, false ) )
  31.     }
  32. }
Add Comment
Please, Sign In to add comment