use of ar.rulosoft.mimanganu.utils.AsyncAddManga in project MiMangaNu by raulhaag.
the class SearchResultsFragment method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
if (!mangaAlreadyAdded) {
AsyncAddManga nAsyncAddManga = new AsyncAddManga(longClickedManga, getActivity(), getView(), false, true, false);
nAsyncAddManga.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
Util.getInstance().showFastSnackBar(getString(R.string.already_on_db), getView(), getActivity());
}
mangaAlreadyAdded = false;
longClickedManga = null;
return super.onContextItemSelected(item);
}
use of ar.rulosoft.mimanganu.utils.AsyncAddManga in project MiMangaNu by raulhaag.
the class ServerFilteredNavigationFragment method onContextItemSelected.
@Override
public boolean onContextItemSelected(MenuItem item) {
if (!mangaAlreadyAdded) {
AsyncAddManga nAsyncAddManga = new AsyncAddManga(mAdapter.getItem(lastContextMenuIndex), getActivity(), getView(), false, true, false);
nAsyncAddManga.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} else {
Util.getInstance().showFastSnackBar(getString(R.string.already_on_db), getView(), getActivity());
}
mangaAlreadyAdded = false;
return super.onContextItemSelected(item);
}
use of ar.rulosoft.mimanganu.utils.AsyncAddManga 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();
}
Aggregations