Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SectionFragment : Fragment() {
- override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?,
- savedInstanceState: Bundle?): View? {
- val view = inflater!!.inflate(R.layout.fragment_section, container, false)
- val bundle = arguments
- val myLayout = view.findViewById(R.id.mylayout) as RelativeLayout
- val id = bundle.getInt("ID")
- val displayMetrics = DisplayMetrics()
- activity.windowManager.defaultDisplay.getMetrics(displayMetrics)
- val phoneHeight = displayMetrics.heightPixels
- val phoneWidth = displayMetrics.widthPixels
- doAsync {
- val tables = SqlHelper.fetchAll(Table::class.java, "SectionID = " + id.toLong())
- uiThread {
- tables!!.forEach {
- val tableShape = SqlHelper.fetch(TableShape::class.java, "ID = " + it.TableShapeID)
- val imageViewTable = ImageView(context)
- val imageFile = SqlHelper.fetch(File::class.java, "ID = " + tableShape!!.ImageFileID)
- imageViewTable.adjustViewBounds = true
- imageViewTable.setBackgroundFromLocalServer(imageFile!!.Source!!)
- val params = RelativeLayout.LayoutParams(
- (tableShape.Width * it.SizeMultiplier*phoneWidth/855).toInt(),
- RelativeLayout.LayoutParams.WRAP_CONTENT)//boyut
- params.leftMargin = (it.PosX*phoneWidth/855).toInt() //x
- params.topMargin = (it.PosY*phoneHeight/638-(100*phoneHeight/638)).toInt() //y
- imageViewTable.rotation = it.Angle
- myLayout.addView(imageViewTable, params)
- val table = it
- imageViewTable.setOnClickListener({
- Toast.makeText(context, "" + table.ID + "\n" +
- table.Name + "\n" +
- table.Capacity + "\n" +
- table.Angle + "\n" +
- table.PosX + "\n" +
- table.PosY + "\n" +
- table.SizeMultiplier + "\n" +
- table.TableShapeID,
- Toast.LENGTH_SHORT).show()
- })
- }
- }
- }
- return view
- }
- }
Add Comment
Please, Sign In to add comment