/*
 * Copyright 2015 Michael Bel
 *
 * 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 org.app.material.widget;

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

import java.util.ArrayList;
import java.util.List;

public class FragmentsPagerAdapter extends FragmentPagerAdapter {

    private Context context;
    private final List<Fragment> fragments = new ArrayList<>();
    private final List<CharSequence> titles = new ArrayList<>();

    public FragmentsPagerAdapter(Context context, FragmentManager manager) {
        super(manager);

        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    public void addFragment(Fragment fragment, String title) {
        fragments.add(fragment);
        titles.add(title);
    }

    public void addFragment(Fragment fragment, @StringRes int resId) {
        fragments.add(fragment);
        titles.add(context.getResources().getText(resId));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }
}
@@ -1728,27 +1728,483 @@
 .get
-Text(r
+String(resId));%0A    %7D%0A%0A    public void addFragments(FragmentSet... fragmentSet) %7B%0A        for (FragmentSet set : fragmentSet) %7B%0A            fragments.add(set.getFragment());%0A            titles.add(context.getResources().getString(set.getR
 esId
+(
 ))
+)
 ;%0A    
+ 
-%7D
+   %7D%0A    %7D%0A%0A    /*public void addFragments(FragmentSet... fragmentSet) %7B%0A        for (FragmentSet set : fragmentSet) %7B%0A            fragments.add(set.getFragment());%0A            titles.add(set.getTitle());%0A        %7D%0A    %7D*/
 %0A%0A  

Update widget