From 64ba30a8118d7be2ed08b30a0263c8b5d9aeccfa Mon Sep 17 00:00:00 2001 From: cuu Date: Thu, 28 Oct 2021 17:03:37 +0800 Subject: [PATCH] warehouse update --- .../GameShell/21_Warehouse/ware_house_page.go | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Menu/GameShell/21_Warehouse/ware_house_page.go b/Menu/GameShell/21_Warehouse/ware_house_page.go index b1872f9..acc060a 100644 --- a/Menu/GameShell/21_Warehouse/ware_house_page.go +++ b/Menu/GameShell/21_Warehouse/ware_house_page.go @@ -115,6 +115,7 @@ func (self *WareHouse) GetAria2DownloadingPercent(url string) int { } func (self *WareHouse) UpdateProcessInterval(ms int) { dirty := false +L: for { select { case <- self.RefreshTicker.C: @@ -136,6 +137,10 @@ func (self *WareHouse) UpdateProcessInterval(ms int) { self.Screen.SwapAndShow() } dirty = false + case v:= <- self.Downloading: + if v== false { + break L + } } } } @@ -398,16 +403,25 @@ func (self *WareHouse) Init() { } self.rpcc = rpcc self.Downloader = grab.NewClient() - self.Downloading = make(chan bool) + self.Downloading = make(chan bool,1) self.RefreshTicker = gotime.NewTicker(500 * gotime.Millisecond) //self.RefreshTicker.Stop() + self.SetDownloading(true) go self.UpdateProcessInterval(500) } } +func (self *WareHouse) SetDownloading(v bool) { + for len(self.Downloading) > 0 { + <- self.Downloading + } + + self.Downloading <- v +} + func (self *WareHouse) ResetHouse() { if self.PsIndex > len(self.MyList) -1 { return @@ -755,6 +769,17 @@ func (self *WareHouse) OnKbdReturnBackCb() { } } +func (self *WareHouse) OnExitCb() { + + if self.RefreshTicker != nil { + self.RefreshTicker.Stop() + } + + self.SetDownloading(false) + self.rpcc.Close() + +} + func (self *WareHouse) OnLoadCb() { if self.MyStack.Length() == 1 {