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());
}
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();
}
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();
}
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);
}
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;
}
Aggregations