ATuin

Untitled

Dec 17th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.63 KB | None | 0 0
  1. import android.view.View
  2. import android.widget.{Toast, TextView, SeekBar, CompoundButton, CheckBox}
  3.  
  4. abstract class SWidget [+T <: View] (view:T, id:Int) {
  5.   def widget = view
  6.   def widgetId = id
  7. }
  8.  
  9. case class SWSeekBar(seekBar:SeekBar, id:Int) extends SWidget[SeekBar](seekBar, id)
  10. case class SWCheckBox(checkBox:CheckBox, id:Int) extends SWidget[CheckBox](checkBox, id)
  11.  
  12. object SWidget {
  13.   implicit def sWidgetToWidget[T <: View](sw:SWidget[T]) : T = sw.widget.asInstanceOf[T]
  14.   implicit def sWidgetToId[T <: View](sw:SWidget[T]) : Int = sw.widgetId
  15.   implicit def sWCheckBoxToCheckBox(sw:SWCheckBox) : CheckBox = sw.widget
  16. }
Advertisement
Add Comment
Please, Sign In to add comment