Search in sources :

Example 6 with ServerBase

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;
}
Also used : ServerBase(ar.rulosoft.mimanganu.servers.ServerBase) FromFolder(ar.rulosoft.mimanganu.servers.FromFolder) SharedPreferences(android.content.SharedPreferences) DialogInterface(android.content.DialogInterface) MangaFolderSelect(ar.rulosoft.mimanganu.componentes.MangaFolderSelect) ViewGroup(android.view.ViewGroup) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ServerRecAdapter(ar.rulosoft.mimanganu.adapters.ServerRecAdapter) LoginDialog(ar.rulosoft.mimanganu.componentes.LoginDialog)

Example 7 with ServerBase

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();
}
Also used : ServerBase(ar.rulosoft.mimanganu.servers.ServerBase) OnClickListener(android.view.View.OnClickListener) CardView(android.support.v7.widget.CardView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 8 with ServerBase

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();
        }
    });
}
Also used : ServerBase(ar.rulosoft.mimanganu.servers.ServerBase) OnClickListener(android.view.View.OnClickListener) RecyclerView(android.support.v7.widget.RecyclerView) ImageView(android.widget.ImageView) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) View(android.view.View)

Example 9 with ServerBase

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);
}
Also used : ServerBase(ar.rulosoft.mimanganu.servers.ServerBase)

Example 10 with ServerBase

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);
}
Also used : ServerBase(ar.rulosoft.mimanganu.servers.ServerBase)

Aggregations

ServerBase (ar.rulosoft.mimanganu.servers.ServerBase)10 DialogInterface (android.content.DialogInterface)4 View (android.view.View)4 Manga (ar.rulosoft.mimanganu.componentes.Manga)3 File (java.io.File)3 AlertDialog (android.app.AlertDialog)2 SharedPreferences (android.content.SharedPreferences)2 RecyclerView (android.support.v7.widget.RecyclerView)2 OnClickListener (android.view.View.OnClickListener)2 ImageView (android.widget.ImageView)2 Chapter (ar.rulosoft.mimanganu.componentes.Chapter)2 LoginDialog (ar.rulosoft.mimanganu.componentes.LoginDialog)2 Intent (android.content.Intent)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Bundle (android.os.Bundle)1 PowerManager (android.os.PowerManager)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 ListPreference (android.support.v7.preference.ListPreference)1 Preference (android.support.v7.preference.Preference)1 PreferenceGroup (android.support.v7.preference.PreferenceGroup)1