mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-31 00:45:00 +01:00
fixed NPE during login #354
This commit is contained in:
parent
d8ce5acac1
commit
1abe500982
@ -76,6 +76,9 @@ public class ParcelableMedia implements Parcelable {
|
|||||||
public ParcelableCardEntity card;
|
public ParcelableCardEntity card;
|
||||||
@JsonField(name = "page_url")
|
@JsonField(name = "page_url")
|
||||||
String page_url;
|
String page_url;
|
||||||
|
@ParcelableThisPlease
|
||||||
|
@JsonField(name = "open_browser")
|
||||||
|
public boolean open_browser;
|
||||||
public static final Creator<ParcelableMedia> CREATOR = new Creator<ParcelableMedia>() {
|
public static final Creator<ParcelableMedia> CREATOR = new Creator<ParcelableMedia>() {
|
||||||
public ParcelableMedia createFromParcel(Parcel source) {
|
public ParcelableMedia createFromParcel(Parcel source) {
|
||||||
ParcelableMedia target = new ParcelableMedia();
|
ParcelableMedia target = new ParcelableMedia();
|
||||||
|
@ -35,6 +35,7 @@ public class InstagramProvider implements Provider {
|
|||||||
media.url = link;
|
media.url = link;
|
||||||
media.preview_url = String.format(Locale.ROOT, "https://instagram.com/p/%s/media/?size=m", id);
|
media.preview_url = String.format(Locale.ROOT, "https://instagram.com/p/%s/media/?size=m", id);
|
||||||
media.media_url = String.format(Locale.ROOT, "https://instagram.com/p/%s/media/?size=l", id);
|
media.media_url = String.format(Locale.ROOT, "https://instagram.com/p/%s/media/?size=l", id);
|
||||||
|
media.open_browser = true;
|
||||||
return media;
|
return media;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,6 @@ dependencies {
|
|||||||
compile 'com.commonsware.cwac:layouts:0.4.2'
|
compile 'com.commonsware.cwac:layouts:0.4.2'
|
||||||
compile 'com.rengwuxian.materialedittext:library:2.1.4'
|
compile 'com.rengwuxian.materialedittext:library:2.1.4'
|
||||||
compile 'com.pnikosis:materialish-progress:1.7'
|
compile 'com.pnikosis:materialish-progress:1.7'
|
||||||
compile 'com.squareup.okhttp3:okhttp:3.1.0'
|
|
||||||
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.7'
|
compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.7'
|
||||||
compile 'com.github.johnpersano:supertoasts:1.3.4.1@aar'
|
compile 'com.github.johnpersano:supertoasts:1.3.4.1@aar'
|
||||||
compile 'com.github.mariotaku:MessageBubbleView:1.2'
|
compile 'com.github.mariotaku:MessageBubbleView:1.2'
|
||||||
|
@ -750,15 +750,15 @@ public class SignInActivity extends BaseAppCompatActivity implements OnClickList
|
|||||||
final Endpoint endpoint = new Endpoint(TwitterAPIFactory.getApiUrl(apiUrlFormat, "api", versionSuffix));
|
final Endpoint endpoint = new Endpoint(TwitterAPIFactory.getApiUrl(apiUrlFormat, "api", versionSuffix));
|
||||||
final Authorization auth = new BasicAuthorization(username, password);
|
final Authorization auth = new BasicAuthorization(username, password);
|
||||||
final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class);
|
final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class);
|
||||||
User user = null;
|
User user;
|
||||||
try {
|
try {
|
||||||
user = twitter.verifyCredentials();
|
user = twitter.verifyCredentials();
|
||||||
} catch (TwitterException e) {
|
} catch (TwitterException e) {
|
||||||
if (e.getStatusCode() == 401) {
|
if (e.getStatusCode() == 401) {
|
||||||
throw new WrongBasicCredentialException();
|
throw new WrongBasicCredentialException();
|
||||||
}
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
if (user == null) throw new NullPointerException();
|
|
||||||
final long userId = user.getId();
|
final long userId = user.getId();
|
||||||
if (userId <= 0) return new SignInResponse(false, false, null);
|
if (userId <= 0) return new SignInResponse(false, false, null);
|
||||||
if (isUserLoggedIn(activity, userId)) return new SignInResponse(true, false, null);
|
if (isUserLoggedIn(activity, userId)) return new SignInResponse(true, false, null);
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package org.mariotaku.twidere.util;
|
package org.mariotaku.twidere.util;
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
|
||||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||||
@ -43,9 +42,11 @@ public class StatusAdapterLinkClickHandler<D> extends OnLinkClickHandler {
|
|||||||
if (extraId == RecyclerView.NO_POSITION) return;
|
if (extraId == RecyclerView.NO_POSITION) return;
|
||||||
final ParcelableStatus status = adapter.getStatus((int) extraId);
|
final ParcelableStatus status = adapter.getStatus((int) extraId);
|
||||||
final ParcelableMedia current = StatusLinkClickHandler.findByLink(status.media, link);
|
final ParcelableMedia current = StatusLinkClickHandler.findByLink(status.media, link);
|
||||||
//TODO open media animation
|
if (current != null && current.open_browser) {
|
||||||
Bundle options = null;
|
openLink(link);
|
||||||
Utils.openMedia(context, status, current, options);
|
} else {
|
||||||
|
Utils.openMedia(context, status, current, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
package org.mariotaku.twidere.util;
|
package org.mariotaku.twidere.util;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||||
@ -36,9 +35,11 @@ public class StatusLinkClickHandler extends OnLinkClickHandler {
|
|||||||
protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) {
|
protected void openMedia(long accountId, long extraId, boolean sensitive, String link, int start, int end) {
|
||||||
final ParcelableStatus status = mStatus;
|
final ParcelableStatus status = mStatus;
|
||||||
final ParcelableMedia current = findByLink(status.media, link);
|
final ParcelableMedia current = findByLink(status.media, link);
|
||||||
//TODO open media animation
|
if (current.open_browser) {
|
||||||
Bundle options = null;
|
openLink(link);
|
||||||
Utils.openMedia(context, status, current, options);
|
} else {
|
||||||
|
Utils.openMedia(context, status, current, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ParcelableMedia findByLink(ParcelableMedia[] media, String link) {
|
public static ParcelableMedia findByLink(ParcelableMedia[] media, String link) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user