And if so who occupied Hainan before them and after them?
Yes. Under the Yuan Empire, Hainan Island was administered as part of the Huguang Province. The Mongolians took the island when they conquered the Song Dynasty. Partial Chinese rule stretches back to the Han Dynasty, though native revolts forced the imperial administration off the island. More permanent control was established during the Southern and Northern Dynasties period, under local tribal leader, Lady Xian.
After the Mongols were driven out of China, its successor the Ming Empire took over Hainan's administration.
(Huguan Province under the Yuan Dynasty, in purple.)
Not directly relevant to this question of whether they occupied Hainan but Kublai Khan was in the South China Sea during his second invasion of Dai Viet (1287). I'm going to try to provide a bit more context here because the Mongol Navy is largely unknown (less popular), compared with their armies on the steppes.
After conquering the Song dynasty, Kublai Khan named his Yuan. But during this 15-year war in southern China, they faced many obstacles. Not least of which is the geography, including novel weather, mountains and waterways. It wasn't easy as they fought two more armies -- Pagan (Upper Burma) and Dai Vet (northern Vietnam), in addition to the Song. Since Mongols were originally land-locked people, they had no real ability with the large rivers of Yunnan, and certainly could not navigate Yangtze & Han rivers. But they learnt to, and with help from Song defections (pirates actually), they finally found their footing.
Kublai's invasion of Japan in 1274 & 1281 were both failures (blame it on the weather!). There are many reasons why the Navy failed (historians doing what they do, will always find new, more pertinent info) but it's obvious they failed to conquer Japan. And everyone here know this.
What is less known however, is their campaigns against Dai Viet and Champa. For Kublai's second invasion of Dai Viet in 1287, they sent a huge armada* -- the Yuan Navy --- via the South China Sea (Bien Dong) route. It did not go well, they basically lost control of their logistics (support ships) and starved themselves including the land contingent (Prince Togan attacked south via the land route). As for the Mongol Admiral, General Omar Batur -- he was caught, imprisoned and eventually drowned (long story on this one).
*Huge armada (500 warships) -- here's the full quote (source provided below):
In 1287, Kublai Khan ordered Togan and Alihaya to proceed with a new advance into Đại Việt. For this campaign, the Yuan emperor put great emphasis on the use of a navy. Since the previous year, 1286, Kublai Khan had ordered 300 warships to be built. In 1287, he again ordered 200 more warships. They were to be ready by the eighth moon of the same year.
So, in sum, the Mongol Navy had no significant achievement to speak of, unlike their land-based army. But it did exist:
- First invasion of Japan, 1274 (from Quanzhou, China)
- Second invasion of Japan, 1281 (Koan campaign)
- Third Mongol Invasion of Đại Việt (1287–8) (two campaigns under Kublai Khan in 1285 & 1287, but there was an earlier one in 1257 as part Great Khan Möngke's invasion of Southern China).
Source: Vu Hong Lien, The Mongol Navy: Kublai Khan’s Invasion in Dai Viet and Champa, Nalanda-Sriwijaya Centre Working Paper No 25 (Jun 2017).
For context, this article is also useful: Victor Lieberman; Charter State Collapse in Southeast Asia, ca. 1250–1400, as a Problem in Regional and World History. Am Hist Rev 2011; 116 (4): 937-963. doi: 10.1086/ahr.116.4.937
p.s We still haven't said anything the Mongol invasion of Java