show percentage of fetched results
This commit is contained in:
@@ -60,7 +60,7 @@ class BrowseManager {
|
|||||||
int results = Integer.parseInt(headers['Count'])
|
int results = Integer.parseInt(headers['Count'])
|
||||||
|
|
||||||
// at this stage, start pulling the results
|
// at this stage, start pulling the results
|
||||||
eventBus.publish(new BrowseStatusEvent(status : BrowseStatus.FETCHING))
|
eventBus.publish(new BrowseStatusEvent(status : BrowseStatus.FETCHING, totalResults : results))
|
||||||
|
|
||||||
JsonSlurper slurper = new JsonSlurper()
|
JsonSlurper slurper = new JsonSlurper()
|
||||||
DataInputStream dis = new DataInputStream(new GZIPInputStream(is))
|
DataInputStream dis = new DataInputStream(new GZIPInputStream(is))
|
||||||
|
@@ -4,4 +4,5 @@ import com.muwire.core.Event
|
|||||||
|
|
||||||
class BrowseStatusEvent extends Event {
|
class BrowseStatusEvent extends Event {
|
||||||
BrowseStatus status
|
BrowseStatus status
|
||||||
|
int totalResults
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@ import javax.annotation.Nonnull
|
|||||||
|
|
||||||
import com.muwire.core.EventBus
|
import com.muwire.core.EventBus
|
||||||
import com.muwire.core.download.UIDownloadEvent
|
import com.muwire.core.download.UIDownloadEvent
|
||||||
|
import com.muwire.core.search.BrowseStatus
|
||||||
import com.muwire.core.search.BrowseStatusEvent
|
import com.muwire.core.search.BrowseStatusEvent
|
||||||
import com.muwire.core.search.UIBrowseEvent
|
import com.muwire.core.search.UIBrowseEvent
|
||||||
import com.muwire.core.search.UIResultEvent
|
import com.muwire.core.search.UIResultEvent
|
||||||
@@ -38,12 +39,15 @@ class BrowseController {
|
|||||||
void onBrowseStatusEvent(BrowseStatusEvent e) {
|
void onBrowseStatusEvent(BrowseStatusEvent e) {
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
model.status = e.status
|
model.status = e.status
|
||||||
|
if (e.status == BrowseStatus.FETCHING)
|
||||||
|
model.totalResults = e.totalResults
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onUIResultEvent(UIResultEvent e) {
|
void onUIResultEvent(UIResultEvent e) {
|
||||||
runInsideUIAsync {
|
runInsideUIAsync {
|
||||||
model.results << e
|
model.results << e
|
||||||
|
model.resultCount = model.results.size()
|
||||||
view.resultsTable.model.fireTableDataChanged()
|
view.resultsTable.model.fireTableDataChanged()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,6 +14,8 @@ class BrowseModel {
|
|||||||
@Observable BrowseStatus status
|
@Observable BrowseStatus status
|
||||||
@Observable boolean downloadActionEnabled
|
@Observable boolean downloadActionEnabled
|
||||||
@Observable boolean viewCommentActionEnabled
|
@Observable boolean viewCommentActionEnabled
|
||||||
|
@Observable int totalResults
|
||||||
|
@Observable int resultCount
|
||||||
|
|
||||||
def results = []
|
def results = []
|
||||||
}
|
}
|
@@ -49,6 +49,7 @@ class BrowseView {
|
|||||||
panel (constraints : BorderLayout.NORTH) {
|
panel (constraints : BorderLayout.NORTH) {
|
||||||
label(text: "Status:")
|
label(text: "Status:")
|
||||||
label(text: bind {model.status.toString()})
|
label(text: bind {model.status.toString()})
|
||||||
|
label(text : bind {model.totalResults == 0 ? "" : (model.resultCount * 100 / model.totalResults)+ "%"})
|
||||||
}
|
}
|
||||||
scrollPane (constraints : BorderLayout.CENTER){
|
scrollPane (constraints : BorderLayout.CENTER){
|
||||||
resultsTable = table(autoCreateRowSorter : true) {
|
resultsTable = table(autoCreateRowSorter : true) {
|
||||||
|
Reference in New Issue
Block a user