Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit f01993a

Browse files
Sam1301kunall17
authored andcommitted
Better error checking for StreamSpan.
1 parent 5b1ef64 commit f01993a

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

app/src/main/java/com/zulip/android/util/StreamSpan.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import com.zulip.android.ZulipApp;
99
import com.zulip.android.models.Stream;
1010

11+
import org.apache.commons.lang.StringUtils;
12+
1113
/**
1214
* Custom ClickableSpan to support #stream-name click. The user is taken to the last message read
1315
* in the stream.
@@ -31,15 +33,17 @@ public void onClick(View widget) {
3133

3234
// get stream name from streamId string
3335
String streamName = null;
34-
if (streamId != null) {
36+
if (StringUtils.isNumeric(streamId)) {
3537
Stream stream = Stream.getById(ZulipApp.get(), Integer.parseInt(streamId));
3638
if (stream != null) {
3739
streamName = stream.getName();
3840
}
39-
}
4041

41-
// go to last message read in the stream
42-
(((ZulipApp) context).getZulipActivity()).doNarrowToLastRead(streamName);
42+
// go to last message read in the stream
43+
if (streamName != null) {
44+
(((ZulipApp) context).getZulipActivity()).doNarrowToLastRead(streamName);
45+
}
46+
}
4347
}
4448

4549
/**

0 commit comments

Comments
 (0)