mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-01-28 23:49:29 +01:00
crash fixes
This commit is contained in:
parent
5aa3385b1b
commit
660f68c26e
@ -411,7 +411,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
|
||||
updateScaleLimit();
|
||||
}
|
||||
} else {
|
||||
mImageView.setImage(null);
|
||||
mImageView.recycle();
|
||||
mImageView.setTag(null);
|
||||
mImageView.setVisibility(View.GONE);
|
||||
Utils.showErrorMessage(getActivity(), null, data.exception, true);
|
||||
|
@ -160,7 +160,7 @@ public class SupportTabsAdapter extends SupportFixedFragmentStatePagerAdapter im
|
||||
@Override
|
||||
public void onPageSelected(final int position) {
|
||||
Log.d(LOGTAG, "onPageSelected " + position);
|
||||
if (mIndicator == null) return;
|
||||
if (mIndicator == null || position < 0 || position >= getCount()) return;
|
||||
announceForAccessibilityCompat(mContext, (View) mIndicator, getPageTitle(position), getClass());
|
||||
}
|
||||
|
||||
|
@ -749,10 +749,14 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
||||
twitterCard.setCardSize(0, 0);
|
||||
}
|
||||
final Fragment cardFragment = TwitterCardUtils.createCardFragment(status.card);
|
||||
final FragmentManager fm = fragment.getChildFragmentManager();
|
||||
final FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.replace(R.id.twitter_card, cardFragment);
|
||||
ft.commit();
|
||||
if (cardFragment != null) {
|
||||
final FragmentManager fm = fragment.getChildFragmentManager();
|
||||
final FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.replace(R.id.twitter_card, cardFragment);
|
||||
ft.commit();
|
||||
} else {
|
||||
twitterCard.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
twitterCard.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public abstract class TwitterCardFragmentFactory {
|
||||
|
||||
public static Fragment createGenericPlayerFragment(ParcelableCardEntity card) {
|
||||
final ParcelableValueItem player_url = ParcelableCardEntity.getValue(card, "player_url");
|
||||
if (player_url == null) return null;
|
||||
return CardBrowserFragment.show((String) player_url.value);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
package org.mariotaku.twidere.util;
|
||||
|
||||
import android.graphics.Point;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.mariotaku.twidere.model.ParcelableStatus.ParcelableCardEntity;
|
||||
@ -36,6 +37,7 @@ public class TwitterCardUtils {
|
||||
public static final String CARD_NAME_AUDIO = "audio";
|
||||
public static final String CARD_NAME_ANIMATED_GIF = "animated_gif";
|
||||
|
||||
@Nullable
|
||||
public static Fragment createCardFragment(ParcelableCardEntity card) {
|
||||
if (CARD_NAME_PLAYER.equals(card.name)) {
|
||||
final Fragment playerFragment = sFactory.createPlayerFragment(card);
|
||||
|
@ -3557,17 +3557,15 @@ public final class Utils implements Constants, TwitterConstants {
|
||||
scrollListToPosition(list, 0);
|
||||
}
|
||||
|
||||
public static void setMenuForStatus(final Context context, final Menu menu,
|
||||
final ParcelableStatus status) {
|
||||
final ParcelableCredentials account
|
||||
= ParcelableAccount.getCredentials(context, status.account_id);
|
||||
public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status) {
|
||||
if (status == null) return;
|
||||
final ParcelableCredentials account = ParcelableAccount.getCredentials(context, status.account_id);
|
||||
setMenuForStatus(context, menu, status, account);
|
||||
}
|
||||
|
||||
public static void setMenuForStatus(final Context context, final Menu menu,
|
||||
final ParcelableStatus status,
|
||||
public static void setMenuForStatus(final Context context, final Menu menu, final ParcelableStatus status,
|
||||
final ParcelableCredentials account) {
|
||||
if (context == null || menu == null || status == null) return;
|
||||
if (context == null || menu == null || status == null || account == null) return;
|
||||
final Resources resources = context.getResources();
|
||||
final int retweetHighlight = resources.getColor(R.color.highlight_retweet);
|
||||
final int favoriteHighlight = resources.getColor(R.color.highlight_favorite);
|
||||
|
@ -326,12 +326,12 @@ public class TabPagerIndicator extends RecyclerView implements PagerIndicator {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
indicator.dispatchTabClick(getAdapterPosition());
|
||||
indicator.dispatchTabClick(getLayoutPosition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
final int position = getAdapterPosition();
|
||||
final int position = getLayoutPosition();
|
||||
if (position == RecyclerView.NO_POSITION) return false;
|
||||
return indicator.dispatchTabLongClick(position);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user