mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 18:49:17 +01:00
Category improvements
This commit is contained in:
parent
e6b7a79bee
commit
384bc3c690
@ -38,6 +38,11 @@
|
|||||||
android:label="@string/label_settings"
|
android:label="@string/label_settings"
|
||||||
android:parentActivityName=".ui.main.MainActivity" >
|
android:parentActivityName=".ui.main.MainActivity" >
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".ui.library.category.CategoryActivity"
|
||||||
|
android:label="@string/label_categories"
|
||||||
|
android:parentActivityName=".ui.main.MainActivity">
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.setting.SettingsDownloadsFragment$CustomLayoutPickerActivity"
|
android:name=".ui.setting.SettingsDownloadsFragment$CustomLayoutPickerActivity"
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package eu.kanade.mangafeed.ui.base.fab;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.support.design.widget.CoordinatorLayout;
|
||||||
|
import android.support.design.widget.FloatingActionButton;
|
||||||
|
import android.support.v4.view.ViewCompat;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior {
|
||||||
|
public ScrollAwareFABBehavior(Context context, AttributeSet attrs) {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
|
||||||
|
final View directTargetChild, final View target, final int nestedScrollAxes) {
|
||||||
|
// Ensure we react to vertical scrolling
|
||||||
|
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
|
||||||
|
|| super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
|
||||||
|
final View target, final int dxConsumed, final int dyConsumed,
|
||||||
|
final int dxUnconsumed, final int dyUnconsumed) {
|
||||||
|
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
|
||||||
|
if (dyConsumed > 0 && child.getVisibility() == View.VISIBLE) {
|
||||||
|
// User scrolled down and the FAB is currently visible -> hide the FAB
|
||||||
|
child.hide();
|
||||||
|
} else if (dyConsumed < 0 && child.getVisibility() != View.VISIBLE) {
|
||||||
|
// User scrolled up and the FAB is currently not visible -> show the FAB
|
||||||
|
child.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,26 @@
|
|||||||
package eu.kanade.mangafeed.ui.base.fragment;
|
package eu.kanade.mangafeed.ui.base.fragment;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
import de.greenrobot.event.EventBus;
|
||||||
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
||||||
|
import icepick.Icepick;
|
||||||
|
|
||||||
public class BaseFragment extends Fragment {
|
public class BaseFragment extends Fragment {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedState) {
|
||||||
|
super.onCreate(savedState);
|
||||||
|
Icepick.restoreInstanceState(this, savedState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
|
super.onSaveInstanceState(outState);
|
||||||
|
Icepick.saveInstanceState(this, outState);
|
||||||
|
}
|
||||||
|
|
||||||
public void setToolbarTitle(String title) {
|
public void setToolbarTitle(String title) {
|
||||||
getBaseActivity().setToolbarTitle(title);
|
getBaseActivity().setToolbarTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import eu.kanade.mangafeed.ui.main.MainActivity;
|
|||||||
import eu.kanade.mangafeed.ui.manga.MangaActivity;
|
import eu.kanade.mangafeed.ui.manga.MangaActivity;
|
||||||
import eu.kanade.mangafeed.util.ToastUtil;
|
import eu.kanade.mangafeed.util.ToastUtil;
|
||||||
import eu.kanade.mangafeed.widget.EndlessScrollListener;
|
import eu.kanade.mangafeed.widget.EndlessScrollListener;
|
||||||
import icepick.Icepick;
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import nucleus.factory.RequiresPresenter;
|
import nucleus.factory.RequiresPresenter;
|
||||||
import rx.Subscription;
|
import rx.Subscription;
|
||||||
@ -66,7 +65,6 @@ public class CatalogueFragment extends BaseRxFragment<CataloguePresenter> {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedState) {
|
public void onCreate(Bundle savedState) {
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
Icepick.restoreInstanceState(this, savedState);
|
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,12 +166,6 @@ public class CatalogueFragment extends BaseRxFragment<CataloguePresenter> {
|
|||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
|
||||||
Icepick.saveInstanceState(this, outState);
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initializeSearchSubscription() {
|
private void initializeSearchSubscription() {
|
||||||
queryDebouncerSubject = PublishSubject.create();
|
queryDebouncerSubject = PublishSubject.create();
|
||||||
queryDebouncerSubscription = queryDebouncerSubject
|
queryDebouncerSubscription = queryDebouncerSubject
|
||||||
|
@ -24,7 +24,6 @@ import eu.kanade.mangafeed.ui.base.fragment.BaseFragment;
|
|||||||
import eu.kanade.mangafeed.ui.manga.MangaActivity;
|
import eu.kanade.mangafeed.ui.manga.MangaActivity;
|
||||||
import eu.kanade.mangafeed.util.EventBusHook;
|
import eu.kanade.mangafeed.util.EventBusHook;
|
||||||
import eu.kanade.mangafeed.widget.AutofitRecyclerView;
|
import eu.kanade.mangafeed.widget.AutofitRecyclerView;
|
||||||
import icepick.Icepick;
|
|
||||||
import icepick.State;
|
import icepick.State;
|
||||||
import rx.Subscription;
|
import rx.Subscription;
|
||||||
|
|
||||||
@ -49,7 +48,6 @@ public class LibraryCategoryFragment extends BaseFragment
|
|||||||
// Inflate the layout for this fragment
|
// Inflate the layout for this fragment
|
||||||
View view = inflater.inflate(R.layout.fragment_library_category, container, false);
|
View view = inflater.inflate(R.layout.fragment_library_category, container, false);
|
||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
Icepick.restoreInstanceState(this, savedState);
|
|
||||||
|
|
||||||
adapter = new LibraryCategoryAdapter(this);
|
adapter = new LibraryCategoryAdapter(this);
|
||||||
recycler.setHasFixedSize(true);
|
recycler.setHasFixedSize(true);
|
||||||
@ -98,7 +96,6 @@ public class LibraryCategoryFragment extends BaseFragment
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
Icepick.saveInstanceState(this, outState);
|
|
||||||
adapter.onSaveInstanceState(outState);
|
adapter.onSaveInstanceState(outState);
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.design.widget.AppBarLayout;
|
import android.support.design.widget.AppBarLayout;
|
||||||
import android.support.design.widget.TabLayout;
|
import android.support.design.widget.TabLayout;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
@ -31,24 +30,26 @@ import eu.kanade.mangafeed.data.database.models.Category;
|
|||||||
import eu.kanade.mangafeed.data.database.models.Manga;
|
import eu.kanade.mangafeed.data.database.models.Manga;
|
||||||
import eu.kanade.mangafeed.data.sync.LibraryUpdateService;
|
import eu.kanade.mangafeed.data.sync.LibraryUpdateService;
|
||||||
import eu.kanade.mangafeed.event.LibraryMangasEvent;
|
import eu.kanade.mangafeed.event.LibraryMangasEvent;
|
||||||
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
|
||||||
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
|
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
|
||||||
import eu.kanade.mangafeed.ui.library.category.CategoryFragment;
|
import eu.kanade.mangafeed.ui.library.category.CategoryActivity;
|
||||||
import eu.kanade.mangafeed.ui.main.MainActivity;
|
import eu.kanade.mangafeed.ui.main.MainActivity;
|
||||||
|
import icepick.State;
|
||||||
import nucleus.factory.RequiresPresenter;
|
import nucleus.factory.RequiresPresenter;
|
||||||
|
|
||||||
@RequiresPresenter(LibraryPresenter.class)
|
@RequiresPresenter(LibraryPresenter.class)
|
||||||
public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
||||||
implements ActionMode.Callback {
|
implements ActionMode.Callback {
|
||||||
|
|
||||||
TabLayout tabs;
|
|
||||||
AppBarLayout appBar;
|
|
||||||
|
|
||||||
@Bind(R.id.view_pager) ViewPager viewPager;
|
@Bind(R.id.view_pager) ViewPager viewPager;
|
||||||
|
private TabLayout tabs;
|
||||||
|
private AppBarLayout appBar;
|
||||||
|
|
||||||
protected LibraryAdapter adapter;
|
protected LibraryAdapter adapter;
|
||||||
|
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
|
|
||||||
|
@State int activeCategory;
|
||||||
|
|
||||||
public static LibraryFragment newInstance() {
|
public static LibraryFragment newInstance() {
|
||||||
return new LibraryFragment();
|
return new LibraryFragment();
|
||||||
}
|
}
|
||||||
@ -68,12 +69,12 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
ButterKnife.bind(this, view);
|
ButterKnife.bind(this, view);
|
||||||
|
|
||||||
appBar = ((MainActivity) getActivity()).getAppBar();
|
appBar = ((MainActivity) getActivity()).getAppBar();
|
||||||
tabs = (TabLayout) inflater.inflate(R.layout.tab_layout, appBar, false);
|
tabs = (TabLayout) inflater.inflate(R.layout.library_tab_layout, appBar, false);
|
||||||
appBar.addView(tabs);
|
appBar.addView(tabs);
|
||||||
|
|
||||||
|
|
||||||
adapter = new LibraryAdapter(getChildFragmentManager());
|
adapter = new LibraryAdapter(getChildFragmentManager());
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
|
tabs.setupWithViewPager(viewPager);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@ -81,9 +82,16 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
appBar.removeView(tabs);
|
appBar.removeView(tabs);
|
||||||
|
EventBus.getDefault().removeStickyEvent(LibraryMangasEvent.class);
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSaveInstanceState(Bundle bundle) {
|
||||||
|
activeCategory = viewPager.getCurrentItem();
|
||||||
|
super.onSaveInstanceState(bundle);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
inflater.inflate(R.menu.library, menu);
|
inflater.inflate(R.menu.library, menu);
|
||||||
@ -107,8 +115,8 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onEditCategories() {
|
private void onEditCategories() {
|
||||||
Fragment fragment = CategoryFragment.newInstance();
|
Intent intent = CategoryActivity.newIntent(getActivity());
|
||||||
((MainActivity) getActivity()).pushFragment(fragment);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onNextLibraryUpdate(Pair<List<Category>, Map<Integer, List<Manga>>> pair) {
|
public void onNextLibraryUpdate(Pair<List<Category>, Map<Integer, List<Manga>>> pair) {
|
||||||
@ -125,6 +133,10 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
else if (!mangasInDefaultCategory && (!initialized || adapter.hasDefaultCategory())) {
|
else if (!mangasInDefaultCategory && (!initialized || adapter.hasDefaultCategory())) {
|
||||||
setCategories(pair.first);
|
setCategories(pair.first);
|
||||||
}
|
}
|
||||||
|
// Restore active category
|
||||||
|
if (!initialized) {
|
||||||
|
viewPager.setCurrentItem(activeCategory, false);
|
||||||
|
}
|
||||||
// Send the mangas to child fragments after the adapter is updated
|
// Send the mangas to child fragments after the adapter is updated
|
||||||
EventBus.getDefault().postSticky(new LibraryMangasEvent(pair.second));
|
EventBus.getDefault().postSticky(new LibraryMangasEvent(pair.second));
|
||||||
}
|
}
|
||||||
@ -139,8 +151,8 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
|
|
||||||
private void setCategories(List<Category> categories) {
|
private void setCategories(List<Category> categories) {
|
||||||
adapter.setCategories(categories);
|
adapter.setCategories(categories);
|
||||||
tabs.setupWithViewPager(viewPager);
|
tabs.setTabsFromPagerAdapter(adapter);
|
||||||
tabs.setVisibility(categories.size() == 1 ? View.GONE : View.VISIBLE);
|
tabs.setVisibility(categories.size() <= 1 ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setContextTitle(int count) {
|
public void setContextTitle(int count) {
|
||||||
@ -211,7 +223,7 @@ public class LibraryFragment extends BaseRxFragment<LibraryPresenter>
|
|||||||
|
|
||||||
public void createActionModeIfNeeded() {
|
public void createActionModeIfNeeded() {
|
||||||
if (actionMode == null) {
|
if (actionMode == null) {
|
||||||
actionMode = ((BaseActivity) getActivity()).startSupportActionMode(this);
|
actionMode = getBaseActivity().startSupportActionMode(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public class LibraryPresenter extends BasePresenter<LibraryFragment> {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Observable<List<Category>> getCategoriesObservable() {
|
private Observable<List<Category>> getCategoriesObservable() {
|
||||||
return db.getCategories().createObservable()
|
return db.getCategories().createObservable()
|
||||||
.doOnNext(categories -> this.categories = categories);
|
.doOnNext(categories -> this.categories = categories);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package eu.kanade.mangafeed.ui.library.category;
|
package eu.kanade.mangafeed.ui.library.category;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.content.res.ResourcesCompat;
|
import android.support.v4.content.res.ResourcesCompat;
|
||||||
import android.support.v7.view.ActionMode;
|
import android.support.v7.view.ActionMode;
|
||||||
import android.support.v7.widget.LinearLayoutManager;
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
|
||||||
@ -21,19 +21,19 @@ import butterknife.Bind;
|
|||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import eu.kanade.mangafeed.R;
|
import eu.kanade.mangafeed.R;
|
||||||
import eu.kanade.mangafeed.data.database.models.Category;
|
import eu.kanade.mangafeed.data.database.models.Category;
|
||||||
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
import eu.kanade.mangafeed.ui.base.activity.BaseRxActivity;
|
||||||
import eu.kanade.mangafeed.ui.base.adapter.FlexibleViewHolder;
|
import eu.kanade.mangafeed.ui.base.adapter.FlexibleViewHolder;
|
||||||
import eu.kanade.mangafeed.ui.base.adapter.OnStartDragListener;
|
import eu.kanade.mangafeed.ui.base.adapter.OnStartDragListener;
|
||||||
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
|
|
||||||
import eu.kanade.mangafeed.ui.decoration.DividerItemDecoration;
|
import eu.kanade.mangafeed.ui.decoration.DividerItemDecoration;
|
||||||
import eu.kanade.mangafeed.ui.library.LibraryCategoryAdapter;
|
import eu.kanade.mangafeed.ui.library.LibraryCategoryAdapter;
|
||||||
import nucleus.factory.RequiresPresenter;
|
import nucleus.factory.RequiresPresenter;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
|
|
||||||
@RequiresPresenter(CategoryPresenter.class)
|
@RequiresPresenter(CategoryPresenter.class)
|
||||||
public class CategoryFragment extends BaseRxFragment<CategoryPresenter> implements
|
public class CategoryActivity extends BaseRxActivity<CategoryPresenter> implements
|
||||||
ActionMode.Callback, FlexibleViewHolder.OnListItemClickListener, OnStartDragListener {
|
ActionMode.Callback, FlexibleViewHolder.OnListItemClickListener, OnStartDragListener {
|
||||||
|
|
||||||
|
@Bind(R.id.toolbar) Toolbar toolbar;
|
||||||
@Bind(R.id.categories_list) RecyclerView recycler;
|
@Bind(R.id.categories_list) RecyclerView recycler;
|
||||||
@Bind(R.id.fab) FloatingActionButton fab;
|
@Bind(R.id.fab) FloatingActionButton fab;
|
||||||
|
|
||||||
@ -41,19 +41,20 @@ public class CategoryFragment extends BaseRxFragment<CategoryPresenter> implemen
|
|||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
private ItemTouchHelper touchHelper;
|
private ItemTouchHelper touchHelper;
|
||||||
|
|
||||||
public static CategoryFragment newInstance() {
|
public static Intent newIntent(Context context) {
|
||||||
return new CategoryFragment();
|
return new Intent(context, CategoryActivity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
protected void onCreate(Bundle savedState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_edit_categories, container, false);
|
super.onCreate(savedState);
|
||||||
ButterKnife.bind(this, view);
|
setContentView(R.layout.activity_edit_categories);
|
||||||
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
setToolbarTitle(R.string.action_edit_categories);
|
setupToolbar(toolbar);
|
||||||
|
|
||||||
adapter = new CategoryAdapter(this);
|
adapter = new CategoryAdapter(this);
|
||||||
recycler.setLayoutManager(new LinearLayoutManager(getActivity()));
|
recycler.setLayoutManager(new LinearLayoutManager(this));
|
||||||
recycler.setHasFixedSize(true);
|
recycler.setHasFixedSize(true);
|
||||||
recycler.setAdapter(adapter);
|
recycler.setAdapter(adapter);
|
||||||
recycler.addItemDecoration(new DividerItemDecoration(
|
recycler.addItemDecoration(new DividerItemDecoration(
|
||||||
@ -64,15 +65,13 @@ public class CategoryFragment extends BaseRxFragment<CategoryPresenter> implemen
|
|||||||
touchHelper.attachToRecyclerView(recycler);
|
touchHelper.attachToRecyclerView(recycler);
|
||||||
|
|
||||||
fab.setOnClickListener(v -> {
|
fab.setOnClickListener(v -> {
|
||||||
new MaterialDialog.Builder(getActivity())
|
new MaterialDialog.Builder(this)
|
||||||
.title(R.string.action_add_category)
|
.title(R.string.action_add_category)
|
||||||
.input(R.string.name, 0, false, (dialog, input) -> {
|
.input(R.string.name, 0, false, (dialog, input) -> {
|
||||||
getPresenter().createCategory(input.toString());
|
getPresenter().createCategory(input.toString());
|
||||||
})
|
})
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategories(List<Category> categories) {
|
public void setCategories(List<Category> categories) {
|
||||||
@ -99,7 +98,7 @@ public class CategoryFragment extends BaseRxFragment<CategoryPresenter> implemen
|
|||||||
@Override
|
@Override
|
||||||
public void onListItemLongClick(int position) {
|
public void onListItemLongClick(int position) {
|
||||||
if (actionMode == null)
|
if (actionMode == null)
|
||||||
actionMode = ((BaseActivity) getActivity()).startSupportActionMode(this);
|
actionMode = startSupportActionMode(this);
|
||||||
|
|
||||||
toggleSelection(position);
|
toggleSelection(position);
|
||||||
}
|
}
|
||||||
@ -165,7 +164,7 @@ public class CategoryFragment extends BaseRxFragment<CategoryPresenter> implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void editCategory(Category category) {
|
private void editCategory(Category category) {
|
||||||
new MaterialDialog.Builder(getActivity())
|
new MaterialDialog.Builder(this)
|
||||||
.title(R.string.action_rename_category)
|
.title(R.string.action_rename_category)
|
||||||
.input(getString(R.string.name), category.name, false, (dialog, input) -> {
|
.input(getString(R.string.name), category.name, false, (dialog, input) -> {
|
||||||
getPresenter().renameCategory(category, input.toString());
|
getPresenter().renameCategory(category, input.toString());
|
@ -18,11 +18,11 @@ import eu.kanade.mangafeed.ui.base.adapter.ItemTouchHelperAdapter;
|
|||||||
public class CategoryAdapter extends FlexibleAdapter<CategoryHolder, Category> implements
|
public class CategoryAdapter extends FlexibleAdapter<CategoryHolder, Category> implements
|
||||||
ItemTouchHelperAdapter {
|
ItemTouchHelperAdapter {
|
||||||
|
|
||||||
private final CategoryFragment fragment;
|
private final CategoryActivity activity;
|
||||||
private final ColorGenerator generator;
|
private final ColorGenerator generator;
|
||||||
|
|
||||||
public CategoryAdapter(CategoryFragment fragment) {
|
public CategoryAdapter(CategoryActivity activity) {
|
||||||
this.fragment = fragment;
|
this.activity = activity;
|
||||||
generator = ColorGenerator.DEFAULT;
|
generator = ColorGenerator.DEFAULT;
|
||||||
setHasStableIds(true);
|
setHasStableIds(true);
|
||||||
}
|
}
|
||||||
@ -44,9 +44,9 @@ public class CategoryAdapter extends FlexibleAdapter<CategoryHolder, Category> i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CategoryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
public CategoryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
LayoutInflater inflater = LayoutInflater.from(fragment.getActivity());
|
LayoutInflater inflater = activity.getLayoutInflater();
|
||||||
View v = inflater.inflate(R.layout.item_edit_categories, parent, false);
|
View v = inflater.inflate(R.layout.item_edit_categories, parent, false);
|
||||||
return new CategoryHolder(v, this, fragment, fragment);
|
return new CategoryHolder(v, this, activity, activity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +70,7 @@ public class CategoryAdapter extends FlexibleAdapter<CategoryHolder, Category> i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment.getPresenter().reorderCategories(mItems);
|
activity.getPresenter().reorderCategories(mItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -11,7 +11,7 @@ import eu.kanade.mangafeed.data.database.models.Category;
|
|||||||
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
import eu.kanade.mangafeed.ui.base.presenter.BasePresenter;
|
||||||
import rx.android.schedulers.AndroidSchedulers;
|
import rx.android.schedulers.AndroidSchedulers;
|
||||||
|
|
||||||
public class CategoryPresenter extends BasePresenter<CategoryFragment> {
|
public class CategoryPresenter extends BasePresenter<CategoryActivity> {
|
||||||
|
|
||||||
@Inject DatabaseHelper db;
|
@Inject DatabaseHelper db;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ public class CategoryPresenter extends BasePresenter<CategoryFragment> {
|
|||||||
() -> db.getCategories().createObservable()
|
() -> db.getCategories().createObservable()
|
||||||
.doOnNext(categories -> this.categories = categories)
|
.doOnNext(categories -> this.categories = categories)
|
||||||
.observeOn(AndroidSchedulers.mainThread()),
|
.observeOn(AndroidSchedulers.mainThread()),
|
||||||
CategoryFragment::setCategories);
|
CategoryActivity::setCategories);
|
||||||
|
|
||||||
start(GET_CATEGORIES);
|
start(GET_CATEGORIES);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@ import eu.kanade.mangafeed.R;
|
|||||||
import eu.kanade.mangafeed.data.database.models.Chapter;
|
import eu.kanade.mangafeed.data.database.models.Chapter;
|
||||||
import eu.kanade.mangafeed.data.download.DownloadService;
|
import eu.kanade.mangafeed.data.download.DownloadService;
|
||||||
import eu.kanade.mangafeed.data.download.model.Download;
|
import eu.kanade.mangafeed.data.download.model.Download;
|
||||||
import eu.kanade.mangafeed.ui.base.activity.BaseActivity;
|
|
||||||
import eu.kanade.mangafeed.ui.base.adapter.FlexibleViewHolder;
|
import eu.kanade.mangafeed.ui.base.adapter.FlexibleViewHolder;
|
||||||
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
|
import eu.kanade.mangafeed.ui.base.fragment.BaseRxFragment;
|
||||||
import eu.kanade.mangafeed.ui.decoration.DividerItemDecoration;
|
import eu.kanade.mangafeed.ui.decoration.DividerItemDecoration;
|
||||||
@ -329,7 +328,7 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|||||||
@Override
|
@Override
|
||||||
public void onListItemLongClick(int position) {
|
public void onListItemLongClick(int position) {
|
||||||
if (actionMode == null)
|
if (actionMode == null)
|
||||||
actionMode = ((BaseActivity) getActivity()).startSupportActionMode(this);
|
actionMode = getBaseActivity().startSupportActionMode(this);
|
||||||
|
|
||||||
toggleSelection(position);
|
toggleSelection(position);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,16 @@
|
|||||||
<android.support.design.widget.CoordinatorLayout
|
<android.support.design.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center">
|
||||||
|
|
||||||
|
<include layout="@layout/toolbar"/>
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="?attr/actionBarSize"
|
||||||
android:id="@+id/categories_list"
|
android:id="@+id/categories_list"
|
||||||
android:choiceMode="multipleChoice"
|
android:choiceMode="multipleChoice"
|
||||||
android:listSelector="@color/list_choice_pressed_bg_light" />
|
android:listSelector="@color/list_choice_pressed_bg_light" />
|
||||||
@ -17,10 +20,11 @@
|
|||||||
android:id="@+id/fab"
|
android:id="@+id/fab"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_gravity="end|bottom"
|
android:layout_gravity="bottom|right"
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
android:clickable="true"
|
|
||||||
android:src="@drawable/ic_action_add_18dp"
|
android:src="@drawable/ic_action_add_18dp"
|
||||||
app:borderWidth="0dp"/>
|
app:layout_anchor="@id/categories_list"
|
||||||
|
app:layout_anchorGravity="bottom|right|end"
|
||||||
|
app:layout_behavior="eu.kanade.mangafeed.ui.base.fab.ScrollAwareFABBehavior"/>
|
||||||
|
|
||||||
</android.support.design.widget.CoordinatorLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
@ -1,4 +1,6 @@
|
|||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.design.widget.CoordinatorLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center">
|
android:gravity="center">
|
||||||
@ -18,7 +20,7 @@
|
|||||||
android:id="@+id/drawer_container"
|
android:id="@+id/drawer_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@id/appbar">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
|
|
||||||
<!-- the layout which will be the content of the activity (which will be hosted inside the drawer (NOT the list of the drawer)) -->
|
<!-- the layout which will be the content of the activity (which will be hosted inside the drawer (NOT the list of the drawer)) -->
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
@ -28,4 +30,4 @@
|
|||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
</RelativeLayout>
|
</android.support.design.widget.CoordinatorLayout>
|
14
app/src/main/res/layout/library_tab_layout.xml
Normal file
14
app/src/main/res/layout/library_tab_layout.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<android.support.design.widget.TabLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:id="@+id/tabs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:theme="@style/ThemeOverlay.AppTheme.Dark"
|
||||||
|
android:background="@color/colorPrimary"
|
||||||
|
android:elevation="4dp"
|
||||||
|
app:tabGravity="center"
|
||||||
|
app:tabMode="scrollable"
|
||||||
|
app:tabMinWidth="75dp"
|
||||||
|
app:tabIndicatorColor="@color/white"/>
|
@ -7,4 +7,5 @@
|
|||||||
android:background="@color/colorPrimary"
|
android:background="@color/colorPrimary"
|
||||||
android:elevation="4dp"
|
android:elevation="4dp"
|
||||||
android:theme="@style/ThemeOverlay.AppTheme.Dark"
|
android:theme="@style/ThemeOverlay.AppTheme.Dark"
|
||||||
|
app:layout_scrollFlags="scroll|enterAlways"
|
||||||
app:popupTheme="@style/AppTheme.Popup" />
|
app:popupTheme="@style/AppTheme.Popup" />
|
@ -9,6 +9,7 @@
|
|||||||
<string name="label_library">My library</string>
|
<string name="label_library">My library</string>
|
||||||
<string name="label_recent_updates">Recent updates</string>
|
<string name="label_recent_updates">Recent updates</string>
|
||||||
<string name="label_catalogues">Catalogues</string>
|
<string name="label_catalogues">Catalogues</string>
|
||||||
|
<string name="label_categories">Categories</string>
|
||||||
<string name="label_selected">Selected: %1$d</string>
|
<string name="label_selected">Selected: %1$d</string>
|
||||||
|
|
||||||
<!-- Actions -->
|
<!-- Actions -->
|
||||||
|
Loading…
Reference in New Issue
Block a user