mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-30 08:25:01 +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;
|
||||
@JsonField(name = "page_url")
|
||||
String page_url;
|
||||
@ParcelableThisPlease
|
||||
@JsonField(name = "open_browser")
|
||||
public boolean open_browser;
|
||||
public static final Creator<ParcelableMedia> CREATOR = new Creator<ParcelableMedia>() {
|
||||
public ParcelableMedia createFromParcel(Parcel source) {
|
||||
ParcelableMedia target = new ParcelableMedia();
|
||||
|
@ -35,6 +35,7 @@ public class InstagramProvider implements Provider {
|
||||
media.url = link;
|
||||
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.open_browser = true;
|
||||
return media;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,6 @@ dependencies {
|
||||
compile 'com.commonsware.cwac:layouts:0.4.2'
|
||||
compile 'com.rengwuxian.materialedittext:library:2.1.4'
|
||||
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 'com.github.johnpersano:supertoasts:1.3.4.1@aar'
|
||||
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 Authorization auth = new BasicAuthorization(username, password);
|
||||
final Twitter twitter = TwitterAPIFactory.getInstance(activity, endpoint, auth, Twitter.class);
|
||||
User user = null;
|
||||
User user;
|
||||
try {
|
||||
user = twitter.verifyCredentials();
|
||||
} catch (TwitterException e) {
|
||||
if (e.getStatusCode() == 401) {
|
||||
throw new WrongBasicCredentialException();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
if (user == null) throw new NullPointerException();
|
||||
final long userId = user.getId();
|
||||
if (userId <= 0) return new SignInResponse(false, false, null);
|
||||
if (isUserLoggedIn(activity, userId)) return new SignInResponse(true, false, null);
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
|
||||
import org.mariotaku.twidere.adapter.iface.IStatusesAdapter;
|
||||
@ -43,9 +42,11 @@ public class StatusAdapterLinkClickHandler<D> extends OnLinkClickHandler {
|
||||
if (extraId == RecyclerView.NO_POSITION) return;
|
||||
final ParcelableStatus status = adapter.getStatus((int) extraId);
|
||||
final ParcelableMedia current = StatusLinkClickHandler.findByLink(status.media, link);
|
||||
//TODO open media animation
|
||||
Bundle options = null;
|
||||
Utils.openMedia(context, status, current, options);
|
||||
if (current != null && current.open_browser) {
|
||||
openLink(link);
|
||||
} else {
|
||||
Utils.openMedia(context, status, current, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
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) {
|
||||
final ParcelableStatus status = mStatus;
|
||||
final ParcelableMedia current = findByLink(status.media, link);
|
||||
//TODO open media animation
|
||||
Bundle options = null;
|
||||
Utils.openMedia(context, status, current, options);
|
||||
if (current.open_browser) {
|
||||
openLink(link);
|
||||
} else {
|
||||
Utils.openMedia(context, status, current, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static ParcelableMedia findByLink(ParcelableMedia[] media, String link) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user