Search in sources :

Example 6 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class SearchBar method init.

private void init(Context context) {
    setBackgroundResource(R.drawable.card_white_no_padding_2dp);
    mSearchDatabase = SearchDatabase.getInstance(getContext());
    LayoutInflater inflater = LayoutInflater.from(context);
    inflater.inflate(R.layout.widget_search_bar, this);
    mMenuButton = (ImageView) ViewUtils.$$(this, R.id.search_menu);
    mTitleTextView = (TextView) ViewUtils.$$(this, R.id.search_title);
    mActionButton = (ImageView) ViewUtils.$$(this, R.id.search_action);
    mEditText = (SearchEditText) ViewUtils.$$(this, R.id.search_edit_text);
    mListContainer = ViewUtils.$$(this, R.id.list_container);
    ListView list = (ListView) ViewUtils.$$(mListContainer, R.id.search_bar_list);
    mListHeader = ViewUtils.$$(mListContainer, R.id.list_header);
    mViewTransition = new ViewTransition(mTitleTextView, mEditText);
    mTitleTextView.setOnClickListener(this);
    mMenuButton.setOnClickListener(this);
    mActionButton.setOnClickListener(this);
    mEditText.setSearchEditTextListener(this);
    mEditText.setOnEditorActionListener(this);
    mEditText.addTextChangedListener(this);
    // Get base height
    ViewUtils.measureView(this, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    mBaseHeight = getMeasuredHeight();
    mSuggestionList = new ArrayList<>();
    mSuggestionAdapter = new ArrayAdapter<>(getContext(), R.layout.item_simple_list, mSuggestionList);
    list.setAdapter(mSuggestionAdapter);
    list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            String suggestion = mSuggestionList.get(MathUtils.clamp(position, 0, mSuggestionList.size() - 1));
            mEditText.setText(suggestion);
            mEditText.setSelection(mEditText.getText().length());
        }
    });
    list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            String suggestion = mSuggestionList.get(MathUtils.clamp(position, 0, mSuggestionList.size() - 1));
            mSearchDatabase.deleteQuery(suggestion);
            updateSuggestions();
            return true;
        }
    });
}
Also used : ViewTransition(com.hippo.view.ViewTransition) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) LayoutInflater(android.view.LayoutInflater) AdapterView(android.widget.AdapterView)

Example 7 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class DownloadsScene method onCreateView3.

@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_download, container, false);
    View content = ViewUtils.$$(view, R.id.content);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(content, R.id.recycler_view);
    FastScroller fastScroller = (FastScroller) ViewUtils.$$(content, R.id.fast_scroller);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(content, tip);
    Context context = getContext2();
    Assert.assertNotNull(content);
    Resources resources = context.getResources();
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_download);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);
    mAdapter = new DownloadAdapter();
    mAdapter.setHasStableIds(true);
    mRecyclerView.setAdapter(mAdapter);
    mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
    mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
    mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
    mRecyclerView.setDrawSelectorOnTop(true);
    mRecyclerView.hasFixedSize();
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setOnItemLongClickListener(this);
    mRecyclerView.setChoiceMode(EasyRecyclerView.CHOICE_MODE_MULTIPLE_CUSTOM);
    mRecyclerView.setCustomCheckedListener(new DownloadChoiceListener());
    // Cancel change animation
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof SimpleItemAnimator) {
        ((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    int interval = resources.getDimensionPixelOffset(R.dimen.gallery_list_interval);
    int paddingH = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_h);
    int paddingV = resources.getDimensionPixelOffset(R.dimen.gallery_list_margin_v);
    MarginItemDecoration decoration = new MarginItemDecoration(interval, paddingH, paddingV, paddingH, paddingV);
    mRecyclerView.addItemDecoration(decoration);
    decoration.applyPaddings(mRecyclerView);
    if (mInitPosition >= 0) {
        mRecyclerView.scrollToPosition(mInitPosition);
        mInitPosition = -1;
    }
    fastScroller.attachToRecyclerView(mRecyclerView);
    HandlerDrawable handlerDrawable = new HandlerDrawable();
    handlerDrawable.setColor(ResourcesUtils.getAttrColor(context, R.attr.colorAccent));
    fastScroller.setHandlerDrawable(handlerDrawable);
    fastScroller.setOnDragHandlerListener(this);
    mFabLayout.setExpanded(false, false);
    mFabLayout.setHidePrimaryFab(true);
    mFabLayout.setAutoCancel(false);
    mFabLayout.setOnClickFabListener(this);
    addAboveSnackView(mFabLayout);
    updateView();
    guide();
    return view;
}
Also used : Context(android.content.Context) SimpleItemAnimator(android.support.v7.widget.SimpleItemAnimator) ViewTransition(com.hippo.view.ViewTransition) HandlerDrawable(com.hippo.easyrecyclerview.HandlerDrawable) Drawable(android.graphics.drawable.Drawable) FastScroller(com.hippo.easyrecyclerview.FastScroller) MarginItemDecoration(com.hippo.easyrecyclerview.MarginItemDecoration) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) ShowcaseView(com.github.amlcurran.showcaseview.ShowcaseView) View(android.view.View) AdapterView(android.widget.AdapterView) SimpleRatingView(com.hippo.ehviewer.widget.SimpleRatingView) LoadImageView(com.hippo.widget.LoadImageView) TextView(android.widget.TextView) ListView(android.widget.ListView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) Point(android.graphics.Point) AutoStaggeredGridLayoutManager(com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager) TextView(android.widget.TextView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) Resources(android.content.res.Resources) HandlerDrawable(com.hippo.easyrecyclerview.HandlerDrawable) Nullable(android.support.annotation.Nullable)

Example 8 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class GalleryCommentsScene method onCreateView3.

@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_gallery_comments, container, false);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mEditPanel = ViewUtils.$$(view, R.id.edit_panel);
    mSendImage = (ImageView) ViewUtils.$$(mEditPanel, R.id.send);
    mEditText = (EditText) ViewUtils.$$(mEditPanel, R.id.edit_text);
    mFabLayout = (FabLayout) ViewUtils.$$(view, R.id.fab_layout);
    mFab = (FloatingActionButton) ViewUtils.$$(view, R.id.fab);
    Context context = getContext2();
    Assert.assertNotNull(context);
    Resources resources = context.getResources();
    int paddingBottomFab = resources.getDimensionPixelOffset(R.dimen.gallery_padding_bottom_fab);
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_weird_face);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);
    mAdapter = new CommentAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
    LinearDividerItemDecoration decoration = new LinearDividerItemDecoration(LinearDividerItemDecoration.VERTICAL, context.getResources().getColor(R.color.divider), LayoutUtils.dp2pix(context, 1));
    decoration.setShowLastDivider(true);
    mRecyclerView.addItemDecoration(decoration);
    mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, false));
    mRecyclerView.setHasFixedSize(true);
    mRecyclerView.setOnItemClickListener(this);
    mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(), mRecyclerView.getPaddingRight(), mRecyclerView.getPaddingBottom() + paddingBottomFab);
    // Cancel change animator
    RecyclerView.ItemAnimator itemAnimator = mRecyclerView.getItemAnimator();
    if (itemAnimator instanceof DefaultItemAnimator) {
        ((DefaultItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
    }
    mSendImage.setOnClickListener(this);
    mFab.setOnClickListener(this);
    addAboveSnackView(mEditPanel);
    addAboveSnackView(mFabLayout);
    mViewTransition = new ViewTransition(mRecyclerView, tip);
    updateView(false);
    return view;
}
Also used : Context(android.content.Context) Drawable(android.graphics.drawable.Drawable) ViewTransition(com.hippo.view.ViewTransition) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) LinearDividerItemDecoration(com.hippo.easyrecyclerview.LinearDividerItemDecoration) LinkifyTextView(com.hippo.widget.LinkifyTextView) ImageView(android.widget.ImageView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) View(android.view.View) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) RecyclerView(android.support.v7.widget.RecyclerView) SuppressLint(android.annotation.SuppressLint) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) LinkifyTextView(com.hippo.widget.LinkifyTextView) TextView(android.widget.TextView) ObservedTextView(com.hippo.widget.ObservedTextView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) Resources(android.content.res.Resources) Nullable(android.support.annotation.Nullable)

Example 9 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class DownloadLabelsScene method onCreateView3.

@SuppressWarnings("deprecation")
@Nullable
@Override
public View onCreateView3(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.scene_label_list, container, false);
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(view, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(view, R.id.tip);
    mViewTransition = new ViewTransition(mRecyclerView, tip);
    Context context = getContext2();
    Assert.assertNotNull(context);
    Drawable drawable = DrawableManager.getDrawable(context, R.drawable.big_label);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);
    tip.setText(R.string.no_download_label);
    // touch guard manager  (this class is required to suppress scrolling while swipe-dismiss animation is running)
    RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
    guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
    guardManager.setEnabled(true);
    // drag & drop manager
    RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager();
    dragDropManager.setDraggingItemShadowDrawable((NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp));
    // swipe manager
    RecyclerViewSwipeManager swipeManager = new RecyclerViewSwipeManager();
    RecyclerView.Adapter adapter = new LabelAdapter();
    adapter.setHasStableIds(true);
    // wrap for dragging
    adapter = dragDropManager.createWrappedAdapter(adapter);
    // wrap for swiping
    adapter = swipeManager.createWrappedAdapter(adapter);
    mAdapter = adapter;
    final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
    animator.setSupportsChangeAnimations(false);
    mRecyclerView.hasFixedSize();
    mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
    mRecyclerView.setAdapter(adapter);
    mRecyclerView.setItemAnimator(animator);
    guardManager.attachRecyclerView(mRecyclerView);
    swipeManager.attachRecyclerView(mRecyclerView);
    dragDropManager.attachRecyclerView(mRecyclerView);
    updateView();
    return view;
}
Also used : Context(android.content.Context) RecyclerViewSwipeManager(com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager) ViewTransition(com.hippo.view.ViewTransition) Drawable(android.graphics.drawable.Drawable) NinePatchDrawable(android.graphics.drawable.NinePatchDrawable) SwipeDismissItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) RecyclerViewTouchActionGuardManager(com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager) TextView(android.widget.TextView) EasyRecyclerView(com.hippo.easyrecyclerview.EasyRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) GeneralItemAnimator(com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator) RecyclerViewDragDropManager(com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager) Nullable(android.support.annotation.Nullable)

Example 10 with ViewTransition

use of com.hippo.view.ViewTransition in project EhViewer by seven332.

the class FilterActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_filter);
    setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
    mFilterList = new FilterList();
    mRecyclerView = (EasyRecyclerView) ViewUtils.$$(this, R.id.recycler_view);
    TextView tip = (TextView) ViewUtils.$$(this, R.id.tip);
    mViewTransition = new ViewTransition(mRecyclerView, tip);
    Drawable drawable = DrawableManager.getDrawable(this, R.drawable.big_filter);
    drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
    tip.setCompoundDrawables(null, drawable, null, null);
    mAdapter = new FilterAdapter();
    mRecyclerView.setAdapter(mAdapter);
    mRecyclerView.setClipToPadding(false);
    mRecyclerView.setClipChildren(false);
    mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
    mRecyclerView.hasFixedSize();
    mRecyclerView.setItemAnimator(null);
    updateView(false);
}
Also used : ViewTransition(com.hippo.view.ViewTransition) Drawable(android.graphics.drawable.Drawable) TextView(android.widget.TextView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Aggregations

TextView (android.widget.TextView)10 ViewTransition (com.hippo.view.ViewTransition)10 View (android.view.View)9 Context (android.content.Context)8 Drawable (android.graphics.drawable.Drawable)8 Nullable (android.support.annotation.Nullable)8 RecyclerView (android.support.v7.widget.RecyclerView)6 EasyRecyclerView (com.hippo.easyrecyclerview.EasyRecyclerView)6 Resources (android.content.res.Resources)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 AdapterView (android.widget.AdapterView)4 ListView (android.widget.ListView)4 ImageView (android.widget.ImageView)3 GeneralItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator)3 SwipeDismissItemAnimator (com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator)3 RecyclerViewSwipeManager (com.h6ah4i.android.widget.advrecyclerview.swipeable.RecyclerViewSwipeManager)3 RecyclerViewTouchActionGuardManager (com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager)3 FastScroller (com.hippo.easyrecyclerview.FastScroller)3 LoadImageView (com.hippo.widget.LoadImageView)3 SuppressLint (android.annotation.SuppressLint)2