use of ar.rulosoft.mimanganu.servers.ServerBase 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;
}
use of ar.rulosoft.mimanganu.servers.ServerBase in project MiMangaNu by raulhaag.
the class MangasRecAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
final Manga m = mangas.get(position);
MangasHolder mHolder = (MangasHolder) holder;
mHolder.serie.setText(m.getTitle());
((MangasHolder) holder).serie.setImageBitmap(null);
imageLoader.displayImg(m.getImages(), mHolder.serie);
mHolder.v.setTag(position);
mHolder.v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mangaClickListener != null) {
mangaClickListener.onMangaClick(m);
}
}
});
ServerBase server = ServerBase.getServer(m.getServerId(), context);
mHolder.server.setImageResource(server.getIcon());
if (m.getNews() > 0) {
mHolder.notif.setVisibility(ImageView.VISIBLE);
} else {
mHolder.notif.setVisibility(ImageView.INVISIBLE);
}
if (position == getItemCount() - 1 && lastItemListener != null)
lastItemListener.onRequestedLastItem();
}
use of ar.rulosoft.mimanganu.servers.ServerBase in project MiMangaNu by raulhaag.
the class ServerRecAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ServerViewHolder sHolder, final int pos) {
final ServerBase server = servers[pos];
sHolder.flag.setImageResource(server.getFlag());
sHolder.icon.setImageResource(server.getIcon());
sHolder.title.setText(server.getServerName());
sHolder.v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (actionMode == null) {
if (onServerClickListener != null)
onServerClickListener.onServerClick(server);
} else {
toggleSelection(pos);
}
}
});
RecyclerView.LayoutParams param = (RecyclerView.LayoutParams) sHolder.v.getLayoutParams();
if (!unused_servers.contains(server.getServerID()) || actionMode != null) {
param.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
param.width = RelativeLayout.LayoutParams.MATCH_PARENT;
sHolder.v.setVisibility(View.VISIBLE);
if (actionMode != null && selectedItems.get(pos)) {
sHolder.title.setAlpha(0.3f);
sHolder.icon.setAlpha(0.3f);
sHolder.flag.setAlpha(0.3f);
} else {
sHolder.title.setAlpha(1f);
sHolder.icon.setAlpha(1f);
sHolder.flag.setAlpha(1f);
}
} else {
sHolder.v.setVisibility(View.GONE);
param.height = 0;
param.width = 0;
}
sHolder.v.setLayoutParams(param);
sHolder.v.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return startActionMode();
}
});
}
use of ar.rulosoft.mimanganu.servers.ServerBase in project MiMangaNu by raulhaag.
the class Chapter method deleteImages.
public void deleteImages(Context context) {
Manga manga = Database.getManga(context, getMangaID());
ServerBase s = ServerBase.getServer(manga.getServerId(), context);
deleteImages(context, manga, s);
}
use of ar.rulosoft.mimanganu.servers.ServerBase in project MiMangaNu by raulhaag.
the class Chapter method reset.
public void reset(Context context) {
Manga manga = Database.getManga(context, getMangaID());
ServerBase s = ServerBase.getServer(manga.getServerId(), context);
reset(context, manga, s);
}
Aggregations