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
10 changes: 7 additions & 3 deletions app/src/main/java/me/ghui/v2er/network/bean/NodeTopicInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class NodeTopicInfo extends BaseInfo {

@Pick("span.topic-count strong")
private int total;
public String totalStr;
@Pick(value = "a[href*=favorite/] ", attr = Attrs.HREF)
private String favoriteLink;
@Pick("div.box div.cell:has(table)")
Expand All @@ -32,7 +32,11 @@ public void setItems(List<Item> items) {
}

public int getTotal() {
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

This method could throw a NullPointerException if totalStr is null. Add a null check before processing the string.

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

Copilot uses AI. Check for mistakes.
return total;
try {
return Integer.parseInt(totalStr.replaceAll("[^0-9]", ""));
} catch (Exception e) {
Copy link

Copilot AI Sep 13, 2025

Choose a reason for hiding this comment

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

Catching generic Exception is too broad. Catch specific exceptions like NumberFormatException or NullPointerException for better error handling and debugging.

Suggested change
} catch (Exception e) {
} catch (NumberFormatException | NullPointerException e) {

Copilot uses AI. Check for mistakes.
return 0;
}
}

public List<Item> getItems() {
Expand Down Expand Up @@ -66,7 +70,7 @@ public String getOnce() {
public String toString() {
return "NodeTopicInfo{" +
"favoriteLink=" + favoriteLink +
",total=" + total +
",total=" + totalStr +
", items=" + items +
'}';
}
Expand Down