// Path: app/src/main/java/it/skarafaz/mercury/fragment/ServerFragment.java
// public class ServerFragment extends ListFragment {
//     public static final String SERVER_ARG = "SERVER_ARG";
//     private Server server;
// 
//     public static ServerFragment newInstance(Server server) {
//         ServerFragment fragment = new ServerFragment();
//         Bundle args = new Bundle();
//         args.putSerializable(SERVER_ARG, server);
//         fragment.setArguments(args);
//         return fragment;
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         server = getArguments() != null ? (Server) getArguments().getSerializable(SERVER_ARG) : null;
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         return inflater.inflate(R.layout.fragment_server, container, false);
//     }
// 
//     @Override
//     public void onActivityCreated(Bundle savedInstanceState) {
//         super.onActivityCreated(savedInstanceState);
// 
//         setListAdapter(new CommandListAdapter(getActivity(), server.getCommands()));
//     }
// }
// 
// Path: app/src/main/java/it/skarafaz/mercury/model/config/Server.java
// @SuppressWarnings("unused")
// public class Server implements Serializable, Comparable<Server> {
//     private static final long serialVersionUID = 7247694914871605048L;
//     private String name;
//     private String host;
//     private Integer port;
//     private String user;
//     private String password;
//     private Boolean sudoNoPasswd;
//     private String sudoPath;
//     private String nohupPath;
//     private List<Command> commands;
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getHost() {
//         return host;
//     }
// 
//     public void setHost(String host) {
//         this.host = host;
//     }
// 
//     public Integer getPort() {
//         return port;
//     }
// 
//     public void setPort(Integer port) {
//         this.port = port;
//     }
// 
//     public String getUser() {
//         return user;
//     }
// 
//     public void setUser(String user) {
//         this.user = user;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public Boolean getSudoNoPasswd() {
//         return sudoNoPasswd;
//     }
// 
//     public void setSudoNoPasswd(Boolean sudoNoPasswd) {
//         this.sudoNoPasswd = sudoNoPasswd;
//     }
// 
//     public String getSudoPath() {
//         return sudoPath;
//     }
// 
//     public void setSudoPath(String sudoPath) {
//         this.sudoPath = sudoPath;
//     }
// 
//     public String getNohupPath() {
//         return nohupPath;
//     }
// 
//     public void setNohupPath(String nohupPath) {
//         this.nohupPath = nohupPath;
//     }
// 
//     @JsonManagedReference
//     public List<Command> getCommands() {
//         return commands;
//     }
// 
//     public void setCommands(List<Command> commands) {
//         this.commands = commands;
//     }
// 
//     @Override
//     public int compareTo(@NonNull Server another) {
//         return name.toLowerCase().compareTo(another.getName().toLowerCase());
//     }
// }


import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import it.skarafaz.mercury.fragment.ServerFragment;
import it.skarafaz.mercury.model.config.Server;
import java.util.ArrayList;
import java.util.List;
/*
 * Mercury-SSH
 * Copyright (C) 2017 Skarafaz
 *
 * This file is part of Mercury-SSH.
 *
 * Mercury-SSH 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 2 of the License, or
 * (at your option) any later version.
 *
 * Mercury-SSH 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 Mercury-SSH.  If not, see <http://www.gnu.org/licenses/>.
 */

package it.skarafaz.mercury.adapter;



public class ServerPagerAdapter extends FragmentStatePagerAdapter {
    private List<Server> servers;

    public ServerPagerAdapter(FragmentManager fm) {
        super(fm);

        servers = new ArrayList<>();
    }

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

    @Override
    public Fragment getItem(int i) {
        return ServerFragment.newInstance(servers.get(i));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return servers.get(position).getName();
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

// Path: app/src/main/java/it/skarafaz/mercury/fragment/ServerFragment.java
// public class ServerFragment extends ListFragment {
//     public static final String SERVER_ARG = "SERVER_ARG";
//     private Server server;
// 
//     public static ServerFragment newInstance(Server server) {
//         ServerFragment fragment = new ServerFragment();
//         Bundle args = new Bundle();
//         args.putSerializable(SERVER_ARG, server);
//         fragment.setArguments(args);
//         return fragment;
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         server = getArguments() != null ? (Server) getArguments().getSerializable(SERVER_ARG) : null;
//     }
// 
//     @Override
//     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//         return inflater.inflate(R.layout.fragment_server, container, false);
//     }
// 
//     @Override
//     public void onActivityCreated(Bundle savedInstanceState) {
//         super.onActivityCreated(savedInstanceState);
// 
//         setListAdapter(new CommandListAdapter(getActivity(), server.getCommands()));
//     }
// }
// 
// Path: app/src/main/java/it/skarafaz/mercury/model/config/Server.java
// @SuppressWarnings("unused")
// public class Server implements Serializable, Comparable<Server> {
//     private static final long serialVersionUID = 7247694914871605048L;
//     private String name;
//     private String host;
//     private Integer port;
//     private String user;
//     private String password;
//     private Boolean sudoNoPasswd;
//     private String sudoPath;
//     private String nohupPath;
//     private List<Command> commands;
// 
//     public String getName() {
//         return name;
//     }
// 
//     public void setName(String name) {
//         this.name = name;
//     }
// 
//     public String getHost() {
//         return host;
//     }
// 
//     public void setHost(String host) {
//         this.host = host;
//     }
// 
//     public Integer getPort() {
//         return port;
//     }
// 
//     public void setPort(Integer port) {
//         this.port = port;
//     }
// 
//     public String getUser() {
//         return user;
//     }
// 
//     public void setUser(String user) {
//         this.user = user;
//     }
// 
//     public String getPassword() {
//         return password;
//     }
// 
//     public void setPassword(String password) {
//         this.password = password;
//     }
// 
//     public Boolean getSudoNoPasswd() {
//         return sudoNoPasswd;
//     }
// 
//     public void setSudoNoPasswd(Boolean sudoNoPasswd) {
//         this.sudoNoPasswd = sudoNoPasswd;
//     }
// 
//     public String getSudoPath() {
//         return sudoPath;
//     }
// 
//     public void setSudoPath(String sudoPath) {
//         this.sudoPath = sudoPath;
//     }
// 
//     public String getNohupPath() {
//         return nohupPath;
//     }
// 
//     public void setNohupPath(String nohupPath) {
//         this.nohupPath = nohupPath;
//     }
// 
//     @JsonManagedReference
//     public List<Command> getCommands() {
//         return commands;
//     }
// 
//     public void setCommands(List<Command> commands) {
//         this.commands = commands;
//     }
// 
//     @Override
//     public int compareTo(@NonNull Server another) {
//         return name.toLowerCase().compareTo(another.getName().toLowerCase());
//     }
// }


// Path: app/src/main/java/it/skarafaz/mercury/adapter/ServerPagerAdapter.java
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import it.skarafaz.mercury.fragment.ServerFragment;
import it.skarafaz.mercury.model.config.Server;
import java.util.ArrayList;
import java.util.List;

/*
 * Mercury-SSH
 * Copyright (C) 2017 Skarafaz
 *
 * This file is part of Mercury-SSH.
 *
 * Mercury-SSH 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 2 of the License, or
 * (at your option) any later version.
 *
 * Mercury-SSH 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 Mercury-SSH.  If not, see <http://www.gnu.org/licenses/>.
 */

package it.skarafaz.mercury.adapter;



public class ServerPagerAdapter extends FragmentStatePagerAdapter {
    private List<Server> servers;

    public ServerPagerAdapter(FragmentManager fm) {
        super(fm);

        servers = new ArrayList<>();
    }

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

    @Override
    public Fragment getItem(int i) {
        return ServerFragment.newInstance(servers.get(i));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return servers.get(position).getName();
    }

    @Override
    public int getItemPosition(Object object) {
        return POSITION_NONE;
    }

    public void updateServers(List<Server> servers) {