parent
47d4b5b54d
commit
20b09ae809
|
@ -390,6 +390,14 @@ public class ParcelableMedia implements Parcelable {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static ParcelableMedia findByUrl(@Nullable ParcelableMedia[] media, @Nullable String url) {
|
||||
if (media == null || url == null) return null;
|
||||
for (ParcelableMedia item : media) {
|
||||
if (url.equals(item.url)) return item;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@IntDef({Type.TYPE_UNKNOWN, Type.TYPE_IMAGE, Type.TYPE_VIDEO, Type.TYPE_ANIMATED_GIF,
|
||||
Type.TYPE_CARD_ANIMATED_GIF, Type.TYPE_EXTERNAL_PLAYER, Type.TYPE_VARIABLE_TYPE})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
|
|
@ -1392,24 +1392,26 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
@Override
|
||||
public void onLinkClick(String link, String orig, long accountId, long extraId, int type, boolean sensitive, int start, int end) {
|
||||
final ParcelableStatus status = adapter.getStatus();
|
||||
if (status.media != null) {
|
||||
for (final ParcelableMedia media : status.media) {
|
||||
if (link.equals(media.url)) {
|
||||
expandOrOpenMedia();
|
||||
return;
|
||||
}
|
||||
}
|
||||
ParcelableMedia current = null;
|
||||
if ((current = ParcelableMedia.findByUrl(status.media, link)) != null) {
|
||||
expandOrOpenMedia(current);
|
||||
return;
|
||||
}
|
||||
if ((current = ParcelableMedia.findByUrl(status.quoted_media, link)) != null) {
|
||||
expandOrOpenMedia(current);
|
||||
return;
|
||||
}
|
||||
if (type == TwidereLinkify.LINK_TYPE_STATUS && status.id == NumberUtils.toLong(link)) {
|
||||
expandOrOpenMedia();
|
||||
expandOrOpenMedia(current);
|
||||
return;
|
||||
}
|
||||
super.onLinkClick(link, orig, accountId, extraId, type, sensitive, start, end);
|
||||
}
|
||||
|
||||
private void expandOrOpenMedia() {
|
||||
private void expandOrOpenMedia(ParcelableMedia current) {
|
||||
if (adapter.isDetailMediaExpanded()) {
|
||||
//TODO open first media
|
||||
Utils.openMedia(adapter.getContext(), adapter.getStatus(), current, null);
|
||||
return;
|
||||
}
|
||||
adapter.setDetailMediaExpanded(true);
|
||||
|
|
|
@ -63,6 +63,7 @@ import okhttp3.Dns;
|
|||
public class TwidereDns implements Constants, Dns {
|
||||
|
||||
private static final String RESOLVER_LOGTAG = "TwidereDns";
|
||||
private static final boolean CHECK_ADDRESS = Boolean.parseBoolean("false");
|
||||
|
||||
private final SharedPreferences mHostMapping, mPreferences;
|
||||
private final HostCache mHostCache = new HostCache(512);
|
||||
|
@ -217,7 +218,7 @@ public class TwidereDns implements Constants, Dns {
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
if (mConnnectTimeout == 0 || inetAddress.isReachable(TwidereMathUtils.clamp((int) mConnnectTimeout / 2, 1000, 3000))) {
|
||||
if (mConnnectTimeout == 0 || checkAddress(inetAddress)) {
|
||||
resolvedAddresses.add(InetAddress.getByAddress(originalHost, inetAddress.getAddress()));
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +240,11 @@ public class TwidereDns implements Constants, Dns {
|
|||
// return addresses.toArray(new InetAddress[addresses.size()]);
|
||||
}
|
||||
|
||||
private boolean checkAddress(InetAddress inetAddress) throws IOException {
|
||||
if (!CHECK_ADDRESS) return true;
|
||||
return inetAddress.isReachable(TwidereMathUtils.clamp((int) mConnnectTimeout / 2, 1000, 3000));
|
||||
}
|
||||
|
||||
private void putCache(String host, InetAddress[] addresses, long ttl, TimeUnit unit) {
|
||||
if (ArrayUtils.isEmpty(addresses) || ArrayUtils.contains(addresses, null)) return;
|
||||
mHostCache.put(host, addresses, ttl, unit);
|
||||
|
|
Loading…
Reference in New Issue