Add QuickSearch
This commit is contained in:
1 parent
3c815bc847
commit
e748229e15
16 files changed
+418
-74
No files matched your search
@@ -198,7 +198,7 @@ public class EhDB {
|
||||
search = search.substring("uploader:".length());
|
||||
}
|
||||
|
||||
quickSearch.setDate((long) cursor.getInt(0));
|
||||
quickSearch.setTime((long) cursor.getInt(0));
|
||||
quickSearch.setName(cursor.getString(1));
|
||||
quickSearch.setMode(mode);
|
||||
quickSearch.setCategory(cursor.getInt(3));
|
||||
@@ -456,4 +456,20 @@ public class EhDB {
|
||||
putLocalFavorites(gi);
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized List<QuickSearch> getAllQuickSearch() {
|
||||
QuickSearchDao dao = sDaoSession.getQuickSearchDao();
|
||||
return dao.queryBuilder().orderAsc(QuickSearchDao.Properties.Time).list();
|
||||
}
|
||||
|
||||
public static synchronized void insertQuickSearch(QuickSearch quickSearch) {
|
||||
QuickSearchDao dao = sDaoSession.getQuickSearchDao();
|
||||
quickSearch.time = System.currentTimeMillis();
|
||||
quickSearch.id = dao.insert(quickSearch);
|
||||
}
|
||||
|
||||
public static synchronized void updateQuickSearch(QuickSearch quickSearch) {
|
||||
QuickSearchDao dao = sDaoSession.getQuickSearchDao();
|
||||
dao.update(quickSearch);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import android.text.TextUtils;
|
||||
import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.dao.QuickSearch;
|
||||
import com.hippo.ehviewer.widget.AdvanceSearchTable;
|
||||
import com.hippo.network.UrlBuilder;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
@@ -147,6 +148,24 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mMinRating = lub.mMinRating;
|
||||
}
|
||||
|
||||
public void set(QuickSearch q) {
|
||||
mMode = q.mode;
|
||||
mCategory = q.category;
|
||||
mKeyword = q.keyword;
|
||||
mAdvanceSearch = q.advanceSearch;
|
||||
mMinRating = q.minRating;
|
||||
}
|
||||
|
||||
public QuickSearch toQuickSearch() {
|
||||
QuickSearch q = new QuickSearch();
|
||||
q.mode = mMode;
|
||||
q.category = mCategory;
|
||||
q.keyword = mKeyword;
|
||||
q.advanceSearch = mAdvanceSearch;
|
||||
q.minRating = mMinRating;
|
||||
return q;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param query xxx=yyy&mmm=nnn
|
||||
*/
|
||||
|
||||
@@ -385,6 +385,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
|
||||
ListView listView = (ListView) view.findViewById(R.id.list_view);
|
||||
|
||||
toolbar.setTitle(R.string.collections);
|
||||
toolbar.inflateMenu(R.menu.drawer_favorites);
|
||||
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
@@ -41,15 +42,21 @@ import android.text.style.ImageSpan;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.hippo.app.EditTextDialogBuilder;
|
||||
import com.hippo.drawable.AddDeleteDrawable;
|
||||
import com.hippo.drawable.DrawerArrowDrawable;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
@@ -59,6 +66,7 @@ import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.ListUrlBuilder;
|
||||
import com.hippo.ehviewer.client.parser.GalleryListParser;
|
||||
import com.hippo.ehviewer.dao.QuickSearch;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.widget.FitPaddingLayout;
|
||||
import com.hippo.ehviewer.widget.SearchBar;
|
||||
@@ -79,6 +87,7 @@ import com.hippo.yorozuya.AnimationUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.SimpleAnimatorListener;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
@@ -111,33 +120,48 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
private static final long ANIMATE_TIME = 300L;
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private EhClient mClient;
|
||||
|
||||
private FitPaddingLayout mFitPaddingLayout;
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
private SearchLayout mSearchLayout;
|
||||
private SearchBar mSearchBar;
|
||||
private FloatingActionButton mFab;
|
||||
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
private GalleryListAdapter mAdapter;
|
||||
private GalleryListHelper mHelper;
|
||||
|
||||
private DrawerArrowDrawable mLeftDrawable;
|
||||
private AddDeleteDrawable mRightDrawable;
|
||||
|
||||
private SearchBarMover mSearchBarMover;
|
||||
|
||||
@Nullable
|
||||
private ListUrlBuilder mUrlBuilder;
|
||||
|
||||
/*---------------
|
||||
View life cycle
|
||||
---------------*/
|
||||
@Nullable
|
||||
private FitPaddingLayout mFitPaddingLayout;
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@Nullable
|
||||
private SearchLayout mSearchLayout;
|
||||
@Nullable
|
||||
private SearchBar mSearchBar;
|
||||
@Nullable
|
||||
private FloatingActionButton mFab;
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
@Nullable
|
||||
private GalleryListAdapter mAdapter;
|
||||
@Nullable
|
||||
private GalleryListHelper mHelper;
|
||||
@Nullable
|
||||
private DrawerArrowDrawable mLeftDrawable;
|
||||
@Nullable
|
||||
private AddDeleteDrawable mRightDrawable;
|
||||
@Nullable
|
||||
private SearchBarMover mSearchBarMover;
|
||||
@Nullable
|
||||
private Animator.AnimatorListener mFabAnimatorListener;
|
||||
|
||||
@State
|
||||
private int mState = STATE_NORMAL;
|
||||
|
||||
// Double click back exit
|
||||
private long mPressBackTime = 0;
|
||||
|
||||
private Animator.AnimatorListener mFabAnimatorListener = null;
|
||||
|
||||
private boolean mHasFirstRefresh = false;
|
||||
|
||||
private int mNavCheckedId = 0;
|
||||
@@ -157,7 +181,7 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
|
||||
private void handleArgs(Bundle args) {
|
||||
if (args == null) {
|
||||
if (null == args || null == mUrlBuilder) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -178,9 +202,13 @@ public final class GalleryListScene extends BaseScene
|
||||
public void onNewArguments(@NonNull Bundle args) {
|
||||
handleArgs(args);
|
||||
onUpdateUrlBuilder();
|
||||
mHelper.refresh();
|
||||
if (null != mHelper) {
|
||||
mHelper.refresh();
|
||||
}
|
||||
setState(STATE_NORMAL);
|
||||
mSearchBarMover.showSearchBar();
|
||||
if (null != mSearchBarMover) {
|
||||
mSearchBarMover.showSearchBar();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,6 +244,14 @@ public final class GalleryListScene extends BaseScene
|
||||
outState.putInt(KEY_STATE, mState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
mClient = null;
|
||||
mUrlBuilder = null;
|
||||
}
|
||||
|
||||
private void setSearchBarHint(Context context, SearchBar searchBar) {
|
||||
Resources resources = context.getResources();
|
||||
Drawable searchImage = DrawableManager.getDrawable(context, R.drawable.v_magnify_x24);
|
||||
@@ -229,28 +265,45 @@ public final class GalleryListScene extends BaseScene
|
||||
searchBar.setEditTextHint(ssb);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getSuitableTitleForUrlBuilder(
|
||||
Resources resources, ListUrlBuilder urlBuilder, boolean appName) {
|
||||
String keyword = urlBuilder.getKeyword();
|
||||
int category = urlBuilder.getCategory();
|
||||
|
||||
if (ListUrlBuilder.MODE_NORMAL == urlBuilder.getMode() &&
|
||||
EhUtils.NONE == category &&
|
||||
TextUtils.isEmpty(keyword)) {
|
||||
return resources.getString(appName ? R.string.app_name : R.string.homepage);
|
||||
} else if (ListUrlBuilder.MODE_WHATS_HOT == urlBuilder.getMode()) {
|
||||
return resources.getString(R.string.whats_hot);
|
||||
} else if (!TextUtils.isEmpty(keyword)) {
|
||||
return keyword;
|
||||
} else if (MathUtils.hammingWeight(category) == 1) {
|
||||
return EhUtils.getCategory(category);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Update search bar title, drawer checked item
|
||||
private void onUpdateUrlBuilder() {
|
||||
ListUrlBuilder builder = mUrlBuilder;
|
||||
if (null == builder) {
|
||||
return;
|
||||
}
|
||||
|
||||
Resources resources = getResources();
|
||||
String keyword = builder.getKeyword();
|
||||
int category = builder.getCategory();
|
||||
|
||||
String title;
|
||||
if (ListUrlBuilder.MODE_NORMAL == builder.getMode() &&
|
||||
EhUtils.NONE == category &&
|
||||
TextUtils.isEmpty(keyword)) {
|
||||
title = resources.getString(R.string.app_name);
|
||||
} else if (ListUrlBuilder.MODE_WHATS_HOT == builder.getMode()) {
|
||||
title = resources.getString(R.string.whats_hot);
|
||||
} else if (!TextUtils.isEmpty(keyword)) {
|
||||
title = keyword;
|
||||
} else if (MathUtils.hammingWeight(category) == 1) {
|
||||
title = EhUtils.getCategory(category);
|
||||
} else {
|
||||
String title = getSuitableTitleForUrlBuilder(getResources(), builder, true);
|
||||
if (null == title) {
|
||||
title = resources.getString(R.string.search);
|
||||
}
|
||||
mSearchBar.setTitle(title);
|
||||
if (mSearchBar != null) {
|
||||
mSearchBar.setTitle(title);
|
||||
}
|
||||
|
||||
int checkedItemId;
|
||||
if (ListUrlBuilder.MODE_NORMAL == builder.getMode() &&
|
||||
@@ -274,12 +327,12 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
Resources resources = getContext().getResources();
|
||||
|
||||
mFitPaddingLayout = (FitPaddingLayout) view.findViewById(R.id.main_layout);
|
||||
ContentLayout contentLayout = (ContentLayout) mFitPaddingLayout.findViewById(R.id.content_layout);
|
||||
mFitPaddingLayout = (FitPaddingLayout) ViewUtils.$$(view, R.id.main_layout);
|
||||
ContentLayout contentLayout = (ContentLayout) ViewUtils.$$(mFitPaddingLayout, R.id.content_layout);
|
||||
mRecyclerView = contentLayout.getRecyclerView();
|
||||
mSearchLayout = (SearchLayout) mFitPaddingLayout.findViewById(R.id.search_layout);
|
||||
mSearchBar = (SearchBar) mFitPaddingLayout.findViewById(R.id.search_bar);
|
||||
mFab = (FloatingActionButton) mFitPaddingLayout.findViewById(R.id.fab);
|
||||
mSearchLayout = (SearchLayout) ViewUtils.$$(mFitPaddingLayout, R.id.search_layout);
|
||||
mSearchBar = (SearchBar) ViewUtils.$$(mFitPaddingLayout, R.id.search_bar);
|
||||
mFab = (FloatingActionButton) ViewUtils.$$(mFitPaddingLayout, R.id.fab);
|
||||
|
||||
mViewTransition = new ViewTransition(contentLayout, mSearchLayout);
|
||||
|
||||
@@ -337,7 +390,9 @@ public final class GalleryListScene extends BaseScene
|
||||
super.onDestroyView();
|
||||
|
||||
// End animation
|
||||
mSearchBarMover.cancelAnimation();
|
||||
if (mSearchBarMover != null) {
|
||||
mSearchBarMover.cancelAnimation();
|
||||
}
|
||||
|
||||
mFitPaddingLayout = null;
|
||||
mRecyclerView = null;
|
||||
@@ -353,10 +408,104 @@ public final class GalleryListScene extends BaseScene
|
||||
mFabAnimatorListener = null;
|
||||
}
|
||||
|
||||
private void showAddQuickSearchDialog(final List<QuickSearch> list,
|
||||
final ArrayAdapter<QuickSearch> adapter, final ListView listView, final TextView tip) {
|
||||
if (null == mUrlBuilder) {
|
||||
return;
|
||||
}
|
||||
|
||||
final EditTextDialogBuilder builder = new EditTextDialogBuilder(getContext(),
|
||||
getSuitableTitleForUrlBuilder(getResources(), mUrlBuilder, false), getString(R.string.quick_search));
|
||||
builder.setTitle(R.string.add_quick_search_dialog_title);
|
||||
builder.setPositiveButton(android.R.string.ok, null);
|
||||
final AlertDialog dialog = builder.show();
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String text = builder.getText().trim();
|
||||
if (TextUtils.isEmpty(text)) {
|
||||
builder.setError(getString(R.string.name_is_empty));
|
||||
} else {
|
||||
builder.setError(null);
|
||||
dialog.dismiss();
|
||||
QuickSearch quickSearch = mUrlBuilder.toQuickSearch();
|
||||
quickSearch.name = text;
|
||||
EhDB.insertQuickSearch(quickSearch);
|
||||
list.add(quickSearch);
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
if (0 == list.size()) {
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
listView.setVisibility(View.GONE);
|
||||
} else {
|
||||
tip.setVisibility(View.GONE);
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateDrawerView(LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.drawer_list, container, false);
|
||||
Toolbar toolbar = (Toolbar) ViewUtils.$$(view, R.id.toolbar);
|
||||
final TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
|
||||
final ListView listView = (ListView) ViewUtils.$$(view, R.id.list_view);
|
||||
|
||||
final List<QuickSearch> list = EhDB.getAllQuickSearch();
|
||||
final ArrayAdapter<QuickSearch> adapter = new ArrayAdapter<>(getContext(), R.layout.item_simple_list, list);
|
||||
listView.setAdapter(adapter);
|
||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (null == mHelper || null == mUrlBuilder) {
|
||||
return;
|
||||
}
|
||||
|
||||
mUrlBuilder.set(list.get(position));
|
||||
mUrlBuilder.setPageIndex(0);
|
||||
onUpdateUrlBuilder();
|
||||
mHelper.refresh();
|
||||
setState(STATE_NORMAL);
|
||||
closeDrawer(Gravity.RIGHT);
|
||||
}
|
||||
});
|
||||
|
||||
tip.setText(R.string.quick_search_tip);
|
||||
toolbar.setTitle(R.string.quick_search);
|
||||
toolbar.inflateMenu(R.menu.drawer_gallery_list);
|
||||
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
int id = item.getItemId();
|
||||
switch (id) {
|
||||
case R.id.action_add:
|
||||
showAddQuickSearchDialog(list, adapter, listView, tip);
|
||||
break;
|
||||
case R.id.action_settings:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
if (0 == list.size()) {
|
||||
tip.setVisibility(View.VISIBLE);
|
||||
listView.setVisibility(View.GONE);
|
||||
} else {
|
||||
tip.setVisibility(View.GONE);
|
||||
listView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mFab == v) {
|
||||
if (mState != STATE_NORMAL) {
|
||||
if (mState != STATE_NORMAL && null != mSearchBar) {
|
||||
mSearchBar.applySearch();
|
||||
}
|
||||
}
|
||||
@@ -439,6 +588,10 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
if (null == mHelper || null == mRecyclerView) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GalleryInfo gi = mHelper.getDataAt(position);
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
@@ -454,6 +607,10 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public boolean onItemLongClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
if (null == mHelper) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final GalleryInfo gi = mHelper.getDataAt(position);
|
||||
new AlertDialog.Builder(getContext())
|
||||
.setTitle(EhUtils.getSuitableTitle(gi))
|
||||
@@ -476,6 +633,10 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
|
||||
private void showFab() {
|
||||
if (null == mFab) {
|
||||
return;
|
||||
}
|
||||
|
||||
mFab.setVisibility(View.VISIBLE);
|
||||
mFab.setScaleX(0.0f);
|
||||
mFab.setScaleY(0.0f);
|
||||
@@ -484,6 +645,10 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
|
||||
private void hideFab() {
|
||||
if (null == mFab) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mFabAnimatorListener == null) {
|
||||
mFabAnimatorListener = new SimpleAnimatorListener() {
|
||||
@Override
|
||||
@@ -501,6 +666,11 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
|
||||
private void setState(@State int state, boolean animation) {
|
||||
if (null == mSearchBar || null == mSearchBarMover ||
|
||||
null == mViewTransition || null == mSearchLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mState != state) {
|
||||
int oldState = mState;
|
||||
mState = state;
|
||||
@@ -585,6 +755,10 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public void onClickLeftIcon() {
|
||||
if (null == mSearchBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSearchBar.getState() == SearchBar.STATE_NORMAL) {
|
||||
toggleDrawer(Gravity.LEFT);
|
||||
} else {
|
||||
@@ -594,6 +768,10 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public void onClickRightIcon() {
|
||||
if (null == mSearchBar) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mSearchBar.getState() == SearchBar.STATE_NORMAL) {
|
||||
setState(STATE_SEARCH);
|
||||
} else {
|
||||
@@ -609,10 +787,12 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onApplySearch(String query) {
|
||||
if (null == mUrlBuilder || null == mHelper || null == mSearchLayout) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mState == STATE_SEARCH || mState == STATE_SEARCH_SHOW_LIST) {
|
||||
if (mSearchLayout.isSpecifyGallery()) {
|
||||
int index = query.indexOf(' ');
|
||||
@@ -665,11 +845,17 @@ public final class GalleryListScene extends BaseScene
|
||||
// Restore right drawer
|
||||
setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.RIGHT);
|
||||
|
||||
mSearchBarMover.returnSearchBarPosition();
|
||||
if (null != mSearchBarMover) {
|
||||
mSearchBarMover.returnSearchBarPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(SearchBar searchBar, int newState, int oldState, boolean animation) {
|
||||
if (null == mFitPaddingLayout || null == mLeftDrawable || null == mRightDrawable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newState == SearchBar.STATE_NORMAL) {
|
||||
mFitPaddingLayout.setEnableUpdatePaddingTop(true);
|
||||
} else {
|
||||
@@ -699,7 +885,9 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public void onChangeSearchMode() {
|
||||
mSearchBarMover.showSearchBar();
|
||||
if (null != mSearchBarMover) {
|
||||
mSearchBarMover.showSearchBar();
|
||||
}
|
||||
}
|
||||
|
||||
// SearchBarMover.Helper
|
||||
@@ -771,6 +959,10 @@ public final class GalleryListScene extends BaseScene
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public void onBindViewHolder(GalleryListHolder holder, int position) {
|
||||
if (null == mHelper) {
|
||||
return;
|
||||
}
|
||||
|
||||
GalleryInfo gi = mHelper.getDataAt(position);
|
||||
holder.thumb.load(EhCacheKeyFactory.getThumbKey(gi.gid), gi.thumb, true);
|
||||
holder.title.setText(EhUtils.getSuitableTitle(gi));
|
||||
@@ -797,7 +989,7 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mHelper.size();
|
||||
return null != mHelper ? mHelper.size() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,8 +997,11 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
protected void getPageData(int taskId, int type, int page) {
|
||||
mUrlBuilder.setPageIndex(page);
|
||||
if (null == mClient || null == mUrlBuilder) {
|
||||
return;
|
||||
}
|
||||
|
||||
mUrlBuilder.setPageIndex(page);
|
||||
if (ListUrlBuilder.MODE_WHATS_HOT == mUrlBuilder.getMode()) {
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_GET_WHATS_HOT);
|
||||
@@ -832,17 +1027,23 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
@Override
|
||||
protected void notifyDataSetChanged() {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
if (null != mAdapter) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyItemRangeRemoved(int positionStart, int itemCount) {
|
||||
mAdapter.notifyItemRangeRemoved(positionStart, itemCount);
|
||||
if (null != mAdapter) {
|
||||
mAdapter.notifyItemRangeRemoved(positionStart, itemCount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void notifyItemRangeInserted(int positionStart, int itemCount) {
|
||||
mAdapter.notifyItemRangeInserted(positionStart, itemCount);
|
||||
if (null != mAdapter) {
|
||||
mAdapter.notifyItemRangeInserted(positionStart, itemCount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.hippo.widget;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -114,6 +115,7 @@ public class ContentLayout extends FrameLayout {
|
||||
mRecyclerViewOriginBottom = mRecyclerView.getPaddingBottom();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public EasyRecyclerView getRecyclerView() {
|
||||
return mRecyclerView;
|
||||
}
|
||||
|
||||
@@ -30,10 +30,22 @@
|
||||
android:elevation="8dp"
|
||||
android:saveEnabled="false"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_view"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
@@ -39,6 +39,13 @@
|
||||
android:layout_height="8dp"
|
||||
android:background="@drawable/shadow_bottom"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/list_view"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@drawable/v_settings_dark_x24"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_default_download_label"
|
||||
android:icon="@drawable/v_download_box_dark_x24"
|
||||
android:title="@string/default_download_label"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@drawable/v_settings_dark_x24"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
@@ -19,16 +19,16 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_info"
|
||||
android:icon="@drawable/v_info_dark_x24"
|
||||
android:title="@string/favorites_info"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_default_favorites_slot"
|
||||
android:icon="@drawable/v_heart_box_dark_x24"
|
||||
android:title="@string/default_favorites_collection"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_info"
|
||||
android:icon="@drawable/v_info_dark_x24"
|
||||
android:title="@string/favorites_info"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2016 Hippo Seven
|
||||
~
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<menu
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_add"
|
||||
android:icon="@drawable/v_plus_dark_x24"
|
||||
android:title="@string/add"
|
||||
app:showAsAction="always"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:icon="@drawable/v_settings_dark_x24"
|
||||
android:title="@string/settings"
|
||||
app:showAsAction="ifRoom"/>
|
||||
|
||||
</menu>
|
||||
@@ -55,6 +55,7 @@
|
||||
<string name="error_509">509</string>
|
||||
<string name="error_invalid_url">无效链接</string>
|
||||
<string name="error_get_ptoken_error">获取 pToken 错误</string>
|
||||
<string name="error_invalid_specify_gallery">指定画廊的关键字应该看起来像 \"618395 0439fa3666\"</string>
|
||||
|
||||
<string name="app_waring">本应用中内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。本应用作者不会对由本应用造成的后果负责。您是否愿意继续使用该应用?</string>
|
||||
<string name="error_username_cannot_empty">用户名不可为空</string>
|
||||
@@ -94,6 +95,11 @@
|
||||
|
||||
<string name="add_to_favourites">收藏</string>
|
||||
|
||||
<string name="quick_search">快速搜索</string>
|
||||
<string name="quick_search_tip">点击“+”来添加快速搜索</string>
|
||||
<string name="add_quick_search_dialog_title">添加快速搜索</string>
|
||||
<string name="name_is_empty">Name is empty</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 星</string>
|
||||
<string name="star_3">3 星</string>
|
||||
@@ -296,6 +302,7 @@
|
||||
<string name="default_favorites_collection">默认收藏夹</string>
|
||||
<string name="let_me_select">让我选择</string>
|
||||
<string name="favorites_info">收藏信息</string>
|
||||
<string name="collections">收藏夹</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">被玩坏了</string>
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<string name="error_509">509</string>
|
||||
<string name="error_invalid_url">無效鏈接</string>
|
||||
<string name="error_get_ptoken_error">獲取 pToken 錯誤</string>
|
||||
<string name="error_invalid_specify_gallery">指定畫廊的關鍵字應該看起來像 \"618395 0439fa3666\"</string>
|
||||
|
||||
<string name="app_waring">本應用中內容來自互聯網,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的後果負責。您是否願意繼續使用該應用?</string>
|
||||
<string name="error_username_cannot_empty">用户名不可為空</string>
|
||||
@@ -94,6 +95,11 @@
|
||||
|
||||
<string name="add_to_favourites">收藏</string>
|
||||
|
||||
<string name="quick_search">快速搜索</string>
|
||||
<string name="quick_search_tip">點擊“+”來添加快速搜索</string>
|
||||
<string name="add_quick_search_dialog_title">添加快速搜索</string>
|
||||
<string name="name_is_empty">Name is empty</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 星</string>
|
||||
<string name="star_3">3 星</string>
|
||||
@@ -296,6 +302,7 @@
|
||||
<string name="default_favorites_collection">默認收藏夾</string>
|
||||
<string name="let_me_select">讓我選擇</string>
|
||||
<string name="favorites_info">收藏信息</string>
|
||||
<string name="collections">收藏夾</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">被玩壞了</string>
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
<string name="error_509">509</string>
|
||||
<string name="error_invalid_url">無效連結</string>
|
||||
<string name="error_get_ptoken_error">獲取 pToken 錯誤</string>
|
||||
<string name="error_invalid_specify_gallery">指定畫廊的關鍵字應該看起來像 \"618395 0439fa3666\"</string>
|
||||
|
||||
<string name="app_waring">本應用中內容來自網際網路,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的後果負責。您是否願意繼續使用該應用?</string>
|
||||
<string name="error_username_cannot_empty">使用者名稱不可為空</string>
|
||||
@@ -94,6 +95,11 @@
|
||||
|
||||
<string name="add_to_favourites">收藏</string>
|
||||
|
||||
<string name="quick_search">快速搜尋</string>
|
||||
<string name="quick_search_tip">點選“+”來新增快速搜尋</string>
|
||||
<string name="add_quick_search_dialog_title">新增快速搜尋</string>
|
||||
<string name="name_is_empty">Name is empty</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 星</string>
|
||||
<string name="star_3">3 星</string>
|
||||
@@ -296,6 +302,7 @@
|
||||
<string name="default_favorites_collection">預設收藏夾</string>
|
||||
<string name="let_me_select">讓我選擇</string>
|
||||
<string name="favorites_info">收藏資訊</string>
|
||||
<string name="collections">收藏夾</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">被玩壞了</string>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<string name="pd_folder_move" translatable="false">M9,18V15H5V11H9V8L14,13M20,6H12L10,4H4C2.89,4 2,4.89 2,6V18A2,2 0 0,0 4,20H20A2,2 0 0,0 22,18V8C22,6.89 21.1,6 20,6Z</string>
|
||||
<string name="pd_label" translatable="false">M17.63,5.84C17.27,5.33 16.67,5 16,5H5A2,2 0 0,0 3,7V17A2,2 0 0,0 5,19H16C16.67,19 17.27,18.66 17.63,18.15L22,12L17.63,5.84Z</string>
|
||||
<string name="pd_settings" translatable="false">M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z</string>
|
||||
<string name="pd_plus" translatable="false">M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z</string>
|
||||
<string name="pd_plus" translatable="false">M21,13H13V21H11V13H3V11H11V3H13V11H21V13Z</string>
|
||||
<string name="pd_download" translatable="false">M5,20H19V18H5M19,9H15V3H9V9H5L12,16L19,9Z</string>
|
||||
<string name="pd_homepage" translatable="false">M10,20V14H14V20H19V12H22L12,3L2,12H5V20H10Z</string>
|
||||
<string name="pd_fire" translatable="false">M11.71,19C9.93,19 8.5,17.59 8.5,15.86C8.5,14.24 9.53,13.1 11.3,12.74C13.07,12.38 14.9,11.53 15.92,10.16C16.31,11.45 16.5,12.81 16.5,14.2C16.5,16.84 14.36,19 11.71,19M13.5,0.67C13.5,0.67 14.24,3.32 14.24,5.47C14.24,7.53 12.89,9.2 10.83,9.2C8.76,9.2 7.2,7.53 7.2,5.47L7.23,5.1C5.21,7.5 4,10.61 4,14A8,8 0 0,0 12,22A8,8 0 0,0 20,14C20,8.6 17.41,3.8 13.5,0.67Z</string>
|
||||
|
||||
@@ -134,6 +134,11 @@
|
||||
|
||||
<string name="add_to_favourites">Add to favourites</string>
|
||||
|
||||
<string name="quick_search">Quick search</string>
|
||||
<string name="quick_search_tip">Click \"+\" to add Quick Search</string>
|
||||
<string name="add_quick_search_dialog_title">Add Quick Search</string>
|
||||
<string name="name_is_empty">Name is empty</string>
|
||||
|
||||
<!-- search_min_rating -->
|
||||
<string name="star_2">2 stars</string>
|
||||
<string name="star_3">3 stars</string>
|
||||
@@ -336,6 +341,7 @@
|
||||
<string name="default_favorites_collection">Default favorites collection</string>
|
||||
<string name="let_me_select">Let me select</string>
|
||||
<string name="favorites_info">Favorites info</string>
|
||||
<string name="collections">Collections</string>
|
||||
|
||||
<!-- Progress Scene -->
|
||||
<string name="error_something_wrong_happened">Something wrong happened</string>
|
||||
|
||||
@@ -36,6 +36,7 @@ public class EhDaoGenerator {
|
||||
|
||||
private static final String DOWNLOAD_INFO_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/DownloadInfo.java";
|
||||
private static final String HISTORY_INFO_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/HistoryInfo.java";
|
||||
private static final String QUICK_SEARCH_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/QuickSearch.java";
|
||||
private static final String LOCAL_FAVORITE_INFO_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/LocalFavoriteInfo.java";
|
||||
private static final String BOOKMARK_INFO_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/BookmarkInfo.java";
|
||||
|
||||
@@ -57,6 +58,7 @@ public class EhDaoGenerator {
|
||||
|
||||
adjustDownloadInfo();
|
||||
adjustHistoryInfo();
|
||||
adjustQuickSearch();
|
||||
adjustLocalFavoriteInfo();
|
||||
adjustBookmarkInfo();
|
||||
}
|
||||
@@ -97,7 +99,7 @@ public class EhDaoGenerator {
|
||||
Entity entity = schema.addEntity("DownloadDirname");
|
||||
entity.setTableName("DOWNLOAD_DIRNAME");
|
||||
entity.setClassNameDao("DownloadDirnameDao");
|
||||
entity.addLongProperty("gid").primaryKey();
|
||||
entity.addLongProperty("gid").primaryKey().notNull();
|
||||
entity.addStringProperty("dirname");
|
||||
}
|
||||
|
||||
@@ -128,12 +130,12 @@ public class EhDaoGenerator {
|
||||
entity.setClassNameDao("QuickSearchDao");
|
||||
entity.addIdProperty();
|
||||
entity.addStringProperty("name");
|
||||
entity.addIntProperty("mode");
|
||||
entity.addIntProperty("category");
|
||||
entity.addIntProperty("mode").notNull();
|
||||
entity.addIntProperty("category").notNull();
|
||||
entity.addStringProperty("keyword");
|
||||
entity.addIntProperty("advanceSearch");
|
||||
entity.addIntProperty("minRating");
|
||||
entity.addLongProperty("date");
|
||||
entity.addIntProperty("advanceSearch").notNull();
|
||||
entity.addIntProperty("minRating").notNull();
|
||||
entity.addLongProperty("time").notNull();
|
||||
}
|
||||
|
||||
private static void addLocalFavorites(Schema schema) {
|
||||
@@ -325,6 +327,29 @@ public class EhDaoGenerator {
|
||||
fileWriter.close();
|
||||
}
|
||||
|
||||
private static void adjustQuickSearch() throws Exception {
|
||||
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(QUICK_SEARCH_PATH));
|
||||
|
||||
// Set all field public
|
||||
javaClass.getField("id").setPublic();
|
||||
javaClass.getField("name").setPublic();
|
||||
javaClass.getField("mode").setPublic();
|
||||
javaClass.getField("category").setPublic();
|
||||
javaClass.getField("keyword").setPublic();
|
||||
javaClass.getField("advanceSearch").setPublic();
|
||||
javaClass.getField("minRating").setPublic();
|
||||
javaClass.getField("time").setPublic();
|
||||
|
||||
javaClass.addMethod("\t@Override\n" +
|
||||
"\tpublic String toString() {\n" +
|
||||
"\t\treturn name;\n" +
|
||||
"\t}");
|
||||
|
||||
FileWriter fileWriter = new FileWriter(QUICK_SEARCH_PATH);
|
||||
fileWriter.write(javaClass.toString());
|
||||
fileWriter.close();
|
||||
}
|
||||
|
||||
private static void adjustLocalFavoriteInfo() throws Exception {
|
||||
JavaClassSource javaClass = Roaster.parse(JavaClassSource.class, new File(LOCAL_FAVORITE_INFO_PATH));
|
||||
// Remove field from GalleryInfo
|
||||
|
||||
Reference in new issue
Block a user