/*
 * Copyright 2018 The twicalico authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.moko256.twicalico;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * Created by moko256 on 2017/01/15.
 *
 * @author moko256
 */

public class ShowUserFragmentsPagerAdapter extends FragmentPagerAdapter {
    private Fragment[] mFragments;
    private Context mContext;

    ShowUserFragmentsPagerAdapter(FragmentManager fm, Context context, long userId) {
        super(fm);

        mFragments=new Fragment[]{
                UserInfoFragment.newInstance(userId),
                UserTimelineFragment.newInstance(userId),
                UserLikeFragment.newInstance(userId),
                UserFollowsFragment.newInstance(userId),
                UserFollowersFragment.newInstance(userId)
        };
        mContext=context;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments[position];
    }

    @Override
    public int getCount() {
        return mFragments.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Fragment fragment=mFragments[position];
        if(fragment instanceof ToolbarTitleInterface){
            return mContext.getString(((ToolbarTitleInterface)fragment).getTitleResourceId());
        }
        else return null;
    }
}

/*
 * Copyright 2018 The twicalico authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.moko256.twicalico;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.github.moko256.twicalico.entity.Type;

/**
 * Created by moko256 on 2017/01/15.
 *
 * @author moko256
 */

public class ShowUserFragmentsPagerAdapter extends FragmentPagerAdapter {
    private Fragment[] mFragments;
    private Context mContext;

    ShowUserFragmentsPagerAdapter(FragmentManager fm, Context context, long userId) {
        super(fm);

        if (GlobalApplication.clientType == Type.MASTODON && userId != GlobalApplication.userId){
            mFragments=new Fragment[]{
                    UserInfoFragment.newInstance(userId),
                    UserTimelineFragment.newInstance(userId),
                    UserFollowsFragment.newInstance(userId),
                    UserFollowersFragment.newInstance(userId)
            };
        } else {
            mFragments = new Fragment[]{
                    UserInfoFragment.newInstance(userId),
                    UserTimelineFragment.newInstance(userId),
                    UserLikeFragment.newInstance(userId),
                    UserFollowsFragment.newInstance(userId),
                    UserFollowersFragment.newInstance(userId)
            };
        }

        mContext=context;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments[position];
    }

    @Override
    public int getCount() {
        return mFragments.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        Fragment fragment=mFragments[position];
        if(fragment instanceof ToolbarTitleInterface){
            return mContext.getString(((ToolbarTitleInterface)fragment).getTitleResourceId());
        }
        else return null;
    }
}

remove user likes tab when client type is Mastodon