@Override public int compareTo(Barrage another) { if (another.getVideoTime() == getVideoTime()) { return 0; } else { return another.getVideoTime() < getVideoTime() ? 1 : -1; } }
@Override public boolean equals(Object obj) { boolean result = false; if (obj instanceof Barrage) { Barrage tempBarrage = (Barrage) obj; if (tempBarrage.hashCode() == hashCode()) { result = true; } } return result; }
public static Barrage parse(String jsonStr) { Barrage barrage = null; try { JSONObject object = JSON.parseObject(jsonStr); barrage = new Barrage(); barrage.setContent(object.getString("barrage")); barrage.setPostTime(object.getString("posttime")); barrage.setVideoTime(object.getIntValue("videotime")); String colorStr = object.getString("color"); barrage.setColor(colorStr); } catch (Exception e) { e.printStackTrace(); Log.e(TAG, "get exception when parse, cause: " + e.getMessage()); } return barrage; }