Mercurial > dwindows
comparison android/DWindows.kt @ 2691:e13607b87517
Android: Call notifyDataSetChanged() on ViewPager2 adapters to fix some
initial display issues on notebook widgets.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 31 Oct 2021 21:22:11 +0000 |
parents | 755d9ad07aaf |
children | 231f9489a38a |
comparison
equal
deleted
inserted
replaced
2690:755d9ad07aaf | 2691:e13607b87517 |
---|---|
1184 windowLayout!!.setCurrentItem(0, false) | 1184 windowLayout!!.setCurrentItem(0, false) |
1185 if((windowStyles[0] and 2) != 2) { | 1185 if((windowStyles[0] and 2) != 2) { |
1186 supportActionBar?.hide() | 1186 supportActionBar?.hide() |
1187 } | 1187 } |
1188 } | 1188 } |
1189 adapter.notifyDataSetChanged() | |
1189 } | 1190 } |
1190 } | 1191 } |
1191 return window | 1192 return window |
1192 } | 1193 } |
1193 | 1194 |
1544 if(state == 0) { | 1545 if(state == 0) { |
1545 window.visibility = View.GONE | 1546 window.visibility = View.GONE |
1546 } else { | 1547 } else { |
1547 window.visibility = View.VISIBLE | 1548 window.visibility = View.VISIBLE |
1548 } | 1549 } |
1550 adapter.notifyDataSetChanged() | |
1549 windowSwitchWindow(index) | 1551 windowSwitchWindow(index) |
1550 } | 1552 } |
1551 } | 1553 } |
1552 } | 1554 } |
1553 | 1555 |
1579 windowTitles.removeAt(index) | 1581 windowTitles.removeAt(index) |
1580 windowMenuBars.removeAt(index) | 1582 windowMenuBars.removeAt(index) |
1581 windowStyles.removeAt(index) | 1583 windowStyles.removeAt(index) |
1582 windowDefault.removeAt(index) | 1584 windowDefault.removeAt(index) |
1583 | 1585 |
1586 adapter.notifyDataSetChanged() | |
1587 | |
1584 retval = 0 // DW_ERROR_NONE | 1588 retval = 0 // DW_ERROR_NONE |
1585 } else { | 1589 } else { |
1586 // If we are removing an individual widget, | 1590 // If we are removing an individual widget, |
1587 // find the parent layout and remove it. | 1591 // find the parent layout and remove it. |
1588 if(window.parent is ViewGroup) { | 1592 if(window.parent is ViewGroup) { |
2290 } else { | 2294 } else { |
2291 adapter.viewList.add(placeholder) | 2295 adapter.viewList.add(placeholder) |
2292 adapter.pageList.add(pageID) | 2296 adapter.pageList.add(pageID) |
2293 tabs.addTab(tab) | 2297 tabs.addTab(tab) |
2294 } | 2298 } |
2299 adapter.notifyDataSetChanged() | |
2295 } | 2300 } |
2296 } | 2301 } |
2297 return pageID | 2302 return pageID |
2298 } | 2303 } |
2299 | 2304 |
2332 | 2337 |
2333 if (tab != null) { | 2338 if (tab != null) { |
2334 adapter.viewList.removeAt(index) | 2339 adapter.viewList.removeAt(index) |
2335 adapter.pageList.removeAt(index) | 2340 adapter.pageList.removeAt(index) |
2336 tabs.removeTab(tab) | 2341 tabs.removeTab(tab) |
2342 adapter.notifyDataSetChanged() | |
2337 } | 2343 } |
2338 } | 2344 } |
2339 } | 2345 } |
2340 } | 2346 } |
2341 | 2347 |
2390 LinearLayout.LayoutParams.MATCH_PARENT, | 2396 LinearLayout.LayoutParams.MATCH_PARENT, |
2391 LinearLayout.LayoutParams.MATCH_PARENT | 2397 LinearLayout.LayoutParams.MATCH_PARENT |
2392 ) | 2398 ) |
2393 | 2399 |
2394 adapter.viewList[index] = box | 2400 adapter.viewList[index] = box |
2401 adapter.notifyDataSetChanged() | |
2395 } | 2402 } |
2396 } | 2403 } |
2397 } | 2404 } |
2398 | 2405 |
2399 fun notebookPageGet(notebook: RelativeLayout): Long | 2406 fun notebookPageGet(notebook: RelativeLayout): Long |
2435 } | 2442 } |
2436 | 2443 |
2437 if (pager != null && tabs != null) { | 2444 if (pager != null && tabs != null) { |
2438 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter | 2445 val adapter: DWTabViewPagerAdapter = pager.adapter as DWTabViewPagerAdapter |
2439 val index = adapter.pageList.indexOf(pageID) | 2446 val index = adapter.pageList.indexOf(pageID) |
2440 val tab = tabs.getTabAt(index) | 2447 |
2441 | 2448 if (index > -1 && index < adapter.pageList.count()) { |
2442 tabs.selectTab(tab) | 2449 tabs.setScrollPosition(index, 0F, true) |
2450 pager.setCurrentItem(index, true) | |
2451 } | |
2443 } | 2452 } |
2444 } | 2453 } |
2445 } | 2454 } |
2446 | 2455 |
2447 fun splitBarNew(type: Int, topleft: View?, bottomright: View?, cid: Int): ConstraintLayout? | 2456 fun splitBarNew(type: Int, topleft: View?, bottomright: View?, cid: Int): ConstraintLayout? |