use of ar.rulosoft.mimanganu.adapters.ServerRecAdapter in project MiMangaNu by raulhaag.
the class ServersSelectFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
SharedPreferences pm = PreferenceManager.getDefaultSharedPreferences(getActivity());
ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_add_manga, container, false);
server_list = viewGroup.findViewById(R.id.lista_de_servers);
server_list.setLayoutManager(new LinearLayoutManager(getActivity()));
serverRecAdapter = new ServerRecAdapter(ServerBase.getServers(getContext()), pm, getActivity());
serverRecAdapter.setEndActionModeListener(this);
server_list.setAdapter(serverRecAdapter);
serverRecAdapter.setOnServerClickListener(new ServerRecAdapter.OnServerClickListener() {
@Override
public void onServerClick(final ServerBase server) {
if (!(server instanceof FromFolder)) {
if (server.hasCredentials()) {
if (server.hasFilteredNavigation()) {
ServerFilteredNavigationFragment fragment = new ServerFilteredNavigationFragment();
Bundle b = new Bundle();
b.putInt(MainFragment.SERVER_ID, server.getServerID());
fragment.setArguments(b);
((MainActivity) getActivity()).replaceFragment(fragment, "FilteredNavigation");
} else {
ServerListFragment fragment = new ServerListFragment();
Bundle b = new Bundle();
b.putInt(MainFragment.SERVER_ID, server.getServerID());
fragment.setArguments(b);
((MainActivity) getActivity()).replaceFragment(fragment, "FilteredServerList");
}
} else {
LoginDialog lDialog = new LoginDialog(getContext(), server);
lDialog.getDialog().setCanceledOnTouchOutside(false);
lDialog.getDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (server.hasCredentials())
onServerClick(server);
else
Util.getInstance().showFastSnackBar(getString(R.string.this_server_needs_an_account), getView(), getContext());
}
});
lDialog.show();
}
} else {
MangaFolderSelect mangaFolderSelect = new MangaFolderSelect();
mangaFolderSelect.show(getChildFragmentManager(), "fragment_find_folder");
}
}
});
return viewGroup;
}
Aggregations