File tree Expand file tree Collapse file tree
src/main/java/com/rarchives/ripme Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,6 +108,9 @@ public int getPendingThreadCount() {
108108 return threadPool .getQueue ().size ();
109109 }
110110
111+ /**
112+ * @return The approximate active thread count
113+ */
111114 public int getActiveThreadCount () {
112115 return threadPool .getActiveCount ();
113116 }
Original file line number Diff line number Diff line change @@ -1703,6 +1703,8 @@ public void run() {
17031703 }
17041704 }
17051705
1706+ private long lastStatusUpdate = 0 ;
1707+
17061708 private synchronized void handleEvent (StatusEvent evt ) {
17071709 RipStatusMessage msg = evt .msg ;
17081710 RipStatusMessage .STATUS status = msg .getStatus ();
@@ -1711,7 +1713,15 @@ private synchronized void handleEvent(StatusEvent evt) {
17111713 if (status == RipStatusMessage .STATUS .CHUNK_BYTES ) {
17121714 transferRate .addChunk ((Long ) msg .getObject ());
17131715 transferRateValue .setText (transferRate .formatHumanTransferRate ());
1714- return ;
1716+
1717+ // Quick hack: ripper.getActiveCount() and dependent values are approximate and the value can be outdated (too large) when it is called when the ripper notifies COMPLETE,
1718+ // so allow the status info to update too, but throttle it a little.
1719+ long now = System .currentTimeMillis ();
1720+ boolean allowStatusUpdate = now > lastStatusUpdate + 200 ;
1721+ if (!allowStatusUpdate ) {
1722+ return ;
1723+ }
1724+ lastStatusUpdate = now ;
17151725 }
17161726
17171727 if (evt .ripper .useByteProgessBar ()) {
@@ -1735,6 +1745,11 @@ private synchronized void handleEvent(StatusEvent evt) {
17351745 currentlyRippingProgress .setValue (evt .ripper .getCompletionPercentage ());
17361746 }
17371747
1748+ // Quick hack finish:
1749+ if (status == RipStatusMessage .STATUS .CHUNK_BYTES ) {
1750+ return ;
1751+ }
1752+
17381753 switch (status ) {
17391754 case LOADING_RESOURCE :
17401755 case DOWNLOAD_STARTED :
Original file line number Diff line number Diff line change 22
33import javax .swing .JLabel ;
44import java .awt .Dimension ;
5+ import java .util .Objects ;
56
67/**
78 * GridBagLayout does not respect minimum size, only preferred size.
89 * In order to set a minimum width, we need to override getPreferredSize.
910 */
1011public class MinimumWidthLabel extends JLabel {
1112 private String minimumWidthText ;
13+ private String currentText ;
1214
1315 public MinimumWidthLabel (String minimumWidthText , String defaultText ) {
1416 this .minimumWidthText = minimumWidthText ;
@@ -30,4 +32,14 @@ public Dimension getPreferredSize() {
3032 public void setMinimumWidthText (String minimumWidthText ) {
3133 this .minimumWidthText = minimumWidthText ;
3234 }
35+
36+ @ Override
37+ public void setText (String text ) {
38+ // Cache the last text to save cycles,
39+ // because this may be called with the same value very often
40+ if (!Objects .equals (currentText , text )) {
41+ currentText = text ;
42+ super .setText (text );
43+ }
44+ }
3345}
You can’t perform that action at this time.
0 commit comments