Search in sources :

Example 1 with Manga

use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.

the class SearchResultsFragment method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
    final Manga manga = (Manga) list.getAdapter().getItem(position);
    longClickedManga = manga;
    Thread t0 = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                List<Manga> mangas = Database.getMangas(getContext(), null, true);
                for (Manga m : mangas) {
                    if (m.getPath().equals(manga.getPath()))
                        mangaAlreadyAdded = true;
                }
            } catch (Exception e) {
                Log.e("SFNF", "Exception", e);
                Util.getInstance().toast(getContext(), Log.getStackTraceString(e));
            }
        }
    });
    t0.start();
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.menu_manga_item_server_nav, menu);
    menu.setHeaderTitle(manga.getTitle());
}
Also used : MenuInflater(android.view.MenuInflater) ArrayList(java.util.ArrayList) List(java.util.List) Manga(ar.rulosoft.mimanganu.componentes.Manga) AsyncAddManga(ar.rulosoft.mimanganu.utils.AsyncAddManga)

Example 2 with Manga

use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.

the class DetailsFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    Thread t0 = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                List<Manga> mangas = Database.getMangas(getContext(), null, true);
                for (Manga m : mangas) {
                    if (m.getPath().equals(manga.getPath())) {
                        mangaAlreadyAdded = true;
                        if (floatingActionButton_add != null)
                            floatingActionButton_add.hide();
                    }
                }
            } catch (Exception e) {
                Log.e(TAG, "Exception", e);
                Util.getInstance().toast(getContext(), Log.getStackTraceString(e));
            }
        }
    });
    t0.start();
    data = (ControlInfo) getView().findViewById(R.id.datos);
    swipeRefreshLayout = (SwipeRefreshLayout) getView().findViewById(R.id.str);
    ActionBar mActBar = getActivity().getActionBar();
    if (mActBar != null) {
        mActBar.setDisplayHomeAsUpEnabled(true);
    }
    floatingActionButton_add = (FloatingActionButton) getView().findViewById(R.id.floatingActionButton_add);
    floatingActionButton_add.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!mangaAlreadyAdded) {
                AsyncAddManga nAsyncAddManga = new AsyncAddManga(manga, getActivity(), getView(), false, false, true);
                nAsyncAddManga.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
                AnimatorSet set = new AnimatorSet();
                ObjectAnimator anim1 = ObjectAnimator.ofFloat(floatingActionButton_add, "alpha", 1.0f, 0.0f);
                anim1.setDuration(0);
                DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
                ObjectAnimator anim2 = ObjectAnimator.ofFloat(floatingActionButton_add, "y", displayMetrics.heightPixels);
                anim2.setDuration(500);
                set.playSequentially(anim2, anim1);
                set.start();
            } else {
                Util.getInstance().showFastSnackBar(getString(R.string.already_on_db), getView(), getContext());
            }
        }
    });
    int[] colors = ThemeColors.getColors(PreferenceManager.getDefaultSharedPreferences(getActivity()));
    floatingActionButton_add.setBackgroundTintList(ColorStateList.valueOf(colors[1]));
    swipeRefreshLayout.setColorSchemeColors(colors[0], colors[1]);
    data.setColor(MainActivity.darkTheme, colors[0]);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getActivity().getWindow();
        window.setNavigationBarColor(colors[0]);
        window.setStatusBarColor(colors[4]);
    }
    if (getActivity() != null) {
        ((MainActivity) getActivity()).setTitle(getResources().getString(R.string.datosde) + " " + title);
    }
    manga = new Manga(id, title, path, false);
    manga.setImages(img);
    data.enableTitleCopy(getActivity(), manga.getTitle());
    serverBase = ServerBase.getServer(id, getContext());
    imageLoader = new ImageLoader(getContext());
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            loadDetailsTask = (LoadDetailsTask) new LoadDetailsTask().execute();
        }
    });
    swipeRefreshLayout.post(new Runnable() {

        @Override
        public void run() {
            swipeRefreshLayout.setRefreshing(true);
        }
    });
    loadDetailsTask = (LoadDetailsTask) new LoadDetailsTask().execute();
}
Also used : Window(android.view.Window) ObjectAnimator(android.animation.ObjectAnimator) AnimatorSet(android.animation.AnimatorSet) View(android.view.View) DisplayMetrics(android.util.DisplayMetrics) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) AsyncAddManga(ar.rulosoft.mimanganu.utils.AsyncAddManga) OnClickListener(android.view.View.OnClickListener) ColorStateList(android.content.res.ColorStateList) List(java.util.List) ImageLoader(com.fedorvlasov.lazylist.ImageLoader) Manga(ar.rulosoft.mimanganu.componentes.Manga) AsyncAddManga(ar.rulosoft.mimanganu.utils.AsyncAddManga) ActionBar(android.app.ActionBar)

Example 3 with Manga

use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.

the class MainFragment method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    MenuInflater inflater = getActivity().getMenuInflater();
    inflater.inflate(R.menu.gridview_mismangas, menu);
    MenuItem m = menu.findItem(R.id.noupdate);
    Manga manga = mMAdapter.getItem((int) v.getTag());
    if (manga.isFinished()) {
        m.setTitle(getActivity().getResources().getString(R.string.buscarupdates));
    } else {
        m.setTitle(getActivity().getResources().getString(R.string.nobuscarupdate));
    }
    lastContextMenuIndex = (int) v.getTag();
}
Also used : MenuInflater(android.view.MenuInflater) MenuItem(android.view.MenuItem) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 4 with Manga

use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.

the class TestServersCommon method testManga.

private void testManga(ArrayList<Manga> mangas) throws Exception {
    assertNotNull(getContext(), mangas);
    assertFalse(getContext(), mangas.isEmpty());
    // some servers list Manga without chapters - so try to fetch up to 'retries' times
    Manga manga;
    int retries = 5;
    do {
        manga = mangas.get(rand.nextInt(mangas.size()));
        assertNotNull(getContext(), manga);
        testLoadManga(manga);
        try {
            serverBase.loadChapters(manga, false);
        } catch (Exception e) {
            fail(getContext(e.getMessage()));
        }
        if (manga.getChapters().isEmpty()) {
            logMessage("[WRN] no chapters found - will try another Manga.");
        }
    } while (manga.getChapters().isEmpty() && retries-- > 0);
    assertFalse(getContext(), manga.getChapters().isEmpty());
    ArrayList<Chapter> chapters = manga.getChapters();
    Chapter.Comparators.setManga_title(manga.getTitle());
    Collections.sort(chapters, Chapter.Comparators.NUMBERS_ASC);
    assertEquals(getContext("chapters not sorted ascending"), manga.getChapters(), chapters);
    Chapter chapter = manga.getChapter(rand.nextInt(manga.getChapters().size()));
    assertNotNull(getContext(), chapter);
    testInitChapter(chapter);
}
Also used : Chapter(ar.rulosoft.mimanganu.componentes.Chapter) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Example 5 with Manga

use of ar.rulosoft.mimanganu.componentes.Manga in project MiMangaNu by raulhaag.

the class NineManga method getMangasFiltered.

@Override
public ArrayList<Manga> getMangasFiltered(int[][] filters, int pageNumber) throws Exception {
    String includedGenres = "";
    if (filters[0].length > 0) {
        for (int i = 0; i < filters[0].length; i++) {
            // comma
            includedGenres = includedGenres + valGenre[filters[0][i]] + "%2C";
        }
    }
    String excludedGenres = "";
    if (filters[1].length > 0) {
        for (int i = 0; i < filters[1].length; i++) {
            // comma
            excludedGenres = excludedGenres + valGenre[filters[1][i]] + "%2C";
        }
    }
    String web;
    web = HOST + "/search/?name_sel=contain&wd=&author_sel=contain&author=&artist_sel=contain&artist=&category_id=" + includedGenres + "&out_category_id=" + excludedGenres + "&completed_series=" + valStatus[filters[2][0]] + "&page=" + pageNumber + ".html";
    String data = getNavigatorWithNeededHeader().get(web);
    Pattern pattern = Pattern.compile(PATTERN_MANGA_SEARCHED, Pattern.DOTALL);
    Matcher m = pattern.matcher(data);
    ArrayList<Manga> mangas = new ArrayList<>();
    while (m.find()) {
        Manga manga = new Manga(getServerID(), m.group(3), m.group(1), false);
        manga.setImages(m.group(2));
        mangas.add(manga);
    }
    return mangas;
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) ArrayList(java.util.ArrayList) Manga(ar.rulosoft.mimanganu.componentes.Manga)

Aggregations

Manga (ar.rulosoft.mimanganu.componentes.Manga)61 ArrayList (java.util.ArrayList)48 Matcher (java.util.regex.Matcher)40 Pattern (java.util.regex.Pattern)40 JSONObject (org.json.JSONObject)6 View (android.view.View)5 Navigator (ar.rulosoft.navegadores.Navigator)5 Chapter (ar.rulosoft.mimanganu.componentes.Chapter)4 AsyncAddManga (ar.rulosoft.mimanganu.utils.AsyncAddManga)4 JSONArray (org.json.JSONArray)4 MenuInflater (android.view.MenuInflater)3 ServerBase (ar.rulosoft.mimanganu.servers.ServerBase)3 List (java.util.List)3 Bundle (android.os.Bundle)2 RecyclerView (android.support.v7.widget.RecyclerView)2 OnClickListener (android.view.View.OnClickListener)2 AdapterView (android.widget.AdapterView)2 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)2 ListView (android.widget.ListView)2 MangasRecAdapter (ar.rulosoft.mimanganu.adapters.MangasRecAdapter)2