2015-01-03 16:16:50 +01:00
|
|
|
/*
|
|
|
|
* Twidere - Twitter client for Android
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.mariotaku.twidere.util;
|
|
|
|
|
2016-01-26 15:05:07 +01:00
|
|
|
import android.os.Bundle;
|
2016-01-14 17:15:11 +01:00
|
|
|
import android.support.annotation.Nullable;
|
2015-01-03 16:16:50 +01:00
|
|
|
import android.support.v4.app.Fragment;
|
|
|
|
|
2016-03-18 17:04:03 +01:00
|
|
|
import org.mariotaku.twidere.fragment.card.CardBrowserFragment;
|
|
|
|
import org.mariotaku.twidere.fragment.card.CardPollFragment;
|
2015-12-31 09:32:27 +01:00
|
|
|
import org.mariotaku.twidere.model.ParcelableCardEntity;
|
2015-12-31 16:44:29 +01:00
|
|
|
import org.mariotaku.twidere.model.ParcelableStatus;
|
2016-02-24 06:07:24 +01:00
|
|
|
import org.mariotaku.twidere.model.util.ParcelableCardEntityUtils;
|
2015-01-03 16:16:50 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by mariotaku on 15/1/1.
|
|
|
|
*/
|
|
|
|
public abstract class TwitterCardFragmentFactory {
|
|
|
|
|
|
|
|
public abstract Fragment createAnimatedGifFragment(ParcelableCardEntity card);
|
|
|
|
|
|
|
|
public abstract Fragment createAudioFragment(ParcelableCardEntity card);
|
|
|
|
|
|
|
|
public abstract Fragment createPlayerFragment(ParcelableCardEntity card);
|
|
|
|
|
|
|
|
public static TwitterCardFragmentFactory getInstance() {
|
|
|
|
return new TwitterCardFragmentFactoryImpl();
|
|
|
|
}
|
|
|
|
|
2016-01-14 17:15:11 +01:00
|
|
|
@Nullable
|
2016-01-26 15:05:07 +01:00
|
|
|
public static Fragment createGenericPlayerFragment(@Nullable ParcelableCardEntity card, Bundle args) {
|
2016-01-14 17:15:11 +01:00
|
|
|
if (card == null) return null;
|
2016-02-24 06:07:24 +01:00
|
|
|
final String playerUrl = ParcelableCardEntityUtils.getString(card, "player_url");
|
2015-12-31 16:44:29 +01:00
|
|
|
if (playerUrl == null) return null;
|
2016-01-26 15:05:07 +01:00
|
|
|
return CardBrowserFragment.show(playerUrl, args);
|
2015-01-03 16:16:50 +01:00
|
|
|
}
|
2015-12-20 12:54:05 +01:00
|
|
|
|
2015-12-27 07:18:16 +01:00
|
|
|
public static Fragment createCardPollFragment(ParcelableStatus status) {
|
|
|
|
return CardPollFragment.show(status);
|
2015-12-20 12:54:05 +01:00
|
|
|
}
|
2015-01-03 16:16:50 +01:00
|
|
|
}
|