Search in sources :

Example 1 with AsyncAddManga

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

Example 2 with AsyncAddManga

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

Example 3 with AsyncAddManga

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

Aggregations

AsyncAddManga (ar.rulosoft.mimanganu.utils.AsyncAddManga)3 AnimatorSet (android.animation.AnimatorSet)1 ObjectAnimator (android.animation.ObjectAnimator)1 ActionBar (android.app.ActionBar)1 ColorStateList (android.content.res.ColorStateList)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 DisplayMetrics (android.util.DisplayMetrics)1 View (android.view.View)1 OnClickListener (android.view.View.OnClickListener)1 Window (android.view.Window)1 Manga (ar.rulosoft.mimanganu.componentes.Manga)1 ImageLoader (com.fedorvlasov.lazylist.ImageLoader)1 List (java.util.List)1