GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SwipeCardView/README.md at master · black4bird/SwipeCardView

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
124 lines (89 loc) · 3.72 KB
/

README.md

Copy path

File metadata and controls

124 lines (89 loc) · 3.72 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

SwipeCardView

Android Arsenal Platform API OSSLab

支持左右滑动操作的卡牌效果,可以实现类似 Tinder、花田、明星空间等应用的喜欢、不喜欢 以及 关注功能,同时支持查看卡牌详细资料。

通过异步加载提高数据处理性能,并使用相同的布局参数作为框架布局(你可以在 xml 文件中使用 android:layout_gravity 定义布局样式)。

SwipeCardView

使用方法

首先,你需要导入模块项目或者添加依赖类库:

dependencies {
    compile 'online.osslab:SwipeCard:1.0.0'
}

核心用法:AdapterView

swipeCardView = (SwipeCardView) findViewById(R.id.swipeCardView);
//swipeCardView.setIsNeedSwipe(true); // 是否开启swipe滑动效果,当不调用此方法设置时,默认开启;
swipeCardView.setSwipeListener(this);
swipeCardView.setOnItemClickListener(this);

样式文件:XML

<online.osslab.SwipeCardView
        android:id="@+id/swipeCardView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        swipe:min_adapter_stack="4"
        swipe:max_visible="4"
        swipe:vertical_offset="28dp"/>

回调方法

  • onSwipeListener
    @Override
    public void removeFirstObjectInAdapter() {
        adapter.remove(0);
    }

    @Override
    public void onLeftCardExit(Object dataObject) {
        // 向左滑动
    }

    @Override
    public void onRightCardExit(Object dataObject) {
        // 向右滑动
    }

    @Override
    public void onAdapterAboutToEmpty(int itemsInAdapter) {
        if (itemsInAdapter == 3) {
            loadData();
        }
    }
  • OnItemClickListener
    @Override
    public void onItemClicked(MotionEvent event, View view, Object dataObject) {
        if (view.getTag() instanceof ViewHolder) {
            int x = (int) event.getRawX();
            int y = (int) event.getRawY();
            ViewHolder vh = (ViewHolder) view.getTag();
            View child = vh.portraitView;
            Rect outRect = new Rect();
            child.getGlobalVisibleRect(outRect);
            if (outRect.contains(x, y)) {
                // 查看详情
            } else {
                outRect.setEmpty();
                child = vh.collectView;
                child.getGlobalVisibleRect(outRect);
                if (outRect.contains(x, y)) {
                    // 关注明星
                }
            }
        }
    }

关于作者

  • [email protected]
  • 开源软件实验室

许可协议

Copyright 2014 Dionysis Lorentzos

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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.