Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions app/src/main/java/me/ghui/v2er/network/bean/NodeTopicInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import me.ghui.v2er.network.Constants;
import me.ghui.v2er.util.UriUtils;
import me.ghui.v2er.util.Utils;
import me.ghui.v2er.util.L;

/**
* Created by ghui on 27/05/2017.
Expand All @@ -21,7 +22,7 @@
public class NodeTopicInfo extends BaseInfo {

@Pick("span.topic-count strong")
public String totalStr;
private String totalCountRaw; // Raw topic count string from HTML (may contain thousand separators)
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field totalCountRaw is changed from public to private but there's no corresponding public getter method. This could break existing code that directly accesses the field. Consider adding a getter method or maintaining public visibility if external access is needed.

Copilot uses AI. Check for mistakes.

@Pick(value = "a[href*=favorite/] ", attr = Attrs.HREF)
private String favoriteLink;
@Pick("div.box div.cell:has(table)")
Expand All @@ -32,9 +33,16 @@ public void setItems(List<Item> items) {
}

public int getTotal() {
if (totalCountRaw == null || totalCountRaw.isEmpty()) {
return 0;
}

try {
return Integer.parseInt(totalStr.replaceAll("[^0-9]", ""));
} catch (Exception e) {
// Remove thousand separators (commas) and any other non-numeric characters
String cleanedNumber = totalCountRaw.replaceAll("[^0-9]", "");
Copy link
Preview

Copilot AI Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cleanedNumber becomes an empty string after removing all non-numeric characters, Integer.parseInt() will throw a NumberFormatException. Add a check to ensure the cleaned string is not empty before parsing.

Suggested change
String cleanedNumber = totalCountRaw.replaceAll("[^0-9]", "");
String cleanedNumber = totalCountRaw.replaceAll("[^0-9]", "");
if (cleanedNumber.isEmpty()) {
return 0;
}

Copilot uses AI. Check for mistakes.

return Integer.parseInt(cleanedNumber);
} catch (NumberFormatException e) {
L.e("Failed to parse topic count: " + totalCountRaw + ", error: " + e.getMessage());
return 0;
}
}
Expand Down Expand Up @@ -70,7 +78,7 @@ public String getOnce() {
public String toString() {
return "NodeTopicInfo{" +
"favoriteLink=" + favoriteLink +
",total=" + totalStr +
",total=" + totalCountRaw +
", items=" + items +
'}';
}
Expand Down
Loading