Code Monkey home page Code Monkey logo

swipeablecard's Introduction

SwipeableCard

##A simple implementation of swipe card like StreetView!!

Android Arsenal

alt tag

alt tag

alt tag

####Possibility to use SwipeableCard in RecyclerView!!!

alt tag

##USAGE

Swipeable Card is pushed to JCenter, so you just need to add the following dependency to your build.gradle.

compile 'it.michelelacorte.swipeablecard:library:1.0.0'

In alternative you can use AAR repository with:

allprojects {
    repositories {
        maven { url "https://dl.bintray.com/michelelacorte/maven/" }
        jcenter()
        mavenCentral()

    }
}

And add this dependecies

compile 'it.michelelacorte.swipeablecard:library:1.0.0@aar'

#SINGLE CARD

In your Layout.xml

<it.michelelacorte.swipeablecard.SwipeableCard
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/swipeCard">
</it.michelelacorte.swipeablecard.SwipeableCard>

In your MainActivity.java before setContentView()

//Just an example
        Toolbar.OnMenuItemClickListener toolbarListener = new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                int id = item.getItemId();
                if (id == R.id.action_settings) {
                    Toast.makeText(getApplicationContext(), "Settings Menu!", Toast.LENGTH_LONG).show();
                    return true;
                }

                return false;
            }
        };

        OptionView.setOptionView(new OptionView.Builder()
                .image(R.drawable.image)
                .title("TITLE")
                .menuItem(R.menu.menu_main)
                .toolbarListener(toolbarListener)
                //And all you want!
                .build());

Than under setContentView() just add card to view!

SwipeableCard swipeableCard = (SwipeableCard) findViewById(R.id.swipeCard);

#RECYCLER VIEW

In your Layout.xml add RecyclerView

<android.support.v7.widget.RecyclerView
    android:id="@+id/rv"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:cacheColorHint="@android:color/transparent" />

In your MainActivity.java

This as private variable

RecyclerView rv;
LinearLayoutManager llm;

Than under setContentView()

//Just an example

        rv = (RecyclerView) findViewById(R.id.rv);
        llm = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.HORIZONTAL, false);
        rv.setLayoutManager(llm);

        List<OptionView> optionViews = new ArrayList<>();
        Toolbar.OnMenuItemClickListener toolbarListener = new Toolbar.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                int id = item.getItemId();
                if (id == R.id.action_settings) {
                    Toast.makeText(getApplicationContext(), "Settings Menu!", Toast.LENGTH_LONG).show();
                    return true;
                }

                return false;
            }
        };
        optionViews.add(new OptionView.Builder()
                .image(R.drawable.image)
                .title("TITLE")
                .colorTitle(R.color.colorPrimary)
                .menuItem(R.menu.menu_main)
                .toolbarListener(toolbarListener).build());
        optionViews.add(new OptionView.Builder()
                .text("Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text," +
                                " a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text, a lot of Text")
                .title("TITLE")
                .colorTitle(R.color.colorPrimary)
                .menuItem(R.menu.menu_main)
                .toolbarListener(toolbarListener).build());
        optionViews.add(new OptionView.Builder()
                .subTitle("Sub Title!!!")
                .image(R.drawable.image)
                .title("TITLE")
                .colorTitle(R.color.colorPrimary)
                .menuItem(R.menu.menu_main)
                .toolbarListener(toolbarListener).build());

        //Set custom adapter.
        SwipeableCardAdapter adapter = new SwipeableCardAdapter(optionViews, getApplicationContext());
            rv.setAdapter(adapter);

##SYSTEM REQUIREMENT

Android API 21+

##CHANGELOG

Coming Soon Version

  • Support API 14+

v1.0.0

  • Support API 21+
  • Added class SwipeableCard.java for setUp view of Swipeable Card.
  • Added class OptionView.java that contains setter for set-up card with your own options.
  • Added class SwipeableCardAdapter.java an adapter ready to use the Swipeable Card in RecyclerView, its constructor accepts List<OptionView> for each optionsView of card and Context.
  • Added interface AnimationCard with abstract method for animation (for completeness only).
  • Added method setOptionView(OptionView optionViews) called by OptionView class for set-up card with your own options.
  • Added example App.

Method called by OptionView.getOptionView()

  • Added method getDuration()
  • Added method getTitle()
  • Added method getColorTitle()
  • Added method getMenuItem()
  • Added method getImage()
  • Added method getSubTitle()
  • Added method getColorToolbar()
  • Added method getText()
  • Added method getToolbarListener()
  • Added method isSubTitle() check if Sub Title is set
  • Added method isMenuItem() check if menuItem is set
  • Added method isImage() check if Image is set
  • Added method isText() check if Text is set

Method called by OptionView.Builder()

  • Added method setDuration(long duration) default is 500 millis
  • Added method toolbarListener(Toolbar.OnMenuItemClickListener toolbarListener) for set-up the menù item on click
  • Added method title(String title) default is empty
  • Added method colorTitle(int color) default is black
  • Added method menuItem(int menuItem) default there isn't a menu
  • Added method image(int image) for set drawable image
  • Added method subTitle(String subTitle) default isn't set
  • Added method toolbarColor(int color) default is transparent
  • Added method text(String text)for set custom text
  • Added method build() for build swipeable card with custom configuration

##CREDITS

Author: Michele Lacorte ([email protected])

##LICENSE

Copyright 2015 Michele Lacorte

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.

swipeablecard's People

Contributors

michelelacorte avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.