Android Open Source - Swipeable-Cards Main Activity






From Project

Back to project page Swipeable-Cards.

License

The source code is released under:

Apache License

If you think the Android project Swipeable-Cards listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * AndTinder v0.1 for Android/*from  w ww. j ava  2 s  . c om*/
 *
 * @Author: Enrique Lpez Maas <eenriquelopez@gmail.com>
 * http://www.lopez-manas.com
 *
 * TAndTinder is a native library for Android that provide a
 * Tinder card like effect. A card can be constructed using an
 * image and displayed with animation effects, dismiss-to-like
 * and dismiss-to-unlike, and use different sorting mechanisms.
 *
 * AndTinder is compatible with API Level 13 and upwards
 *
 * @copyright: Enrique Lpez Maas
 * @license: Apache License 2.0
 */

package com.andtinder.demo;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;

import com.andtinder.model.CardModel;
import com.andtinder.view.CardContainer;
import com.andtinder.view.SimpleCardStackAdapter;

public class MainActivity extends Activity {

    /**
     * This variable is the container that will host our cards
     */
  private CardContainer mCardContainer;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.mainlayout);

    mCardContainer = (CardContainer) findViewById(R.id.layoutview);

    Resources r = getResources();

    SimpleCardStackAdapter adapter = new SimpleCardStackAdapter(this);

    adapter.add(new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title2", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title3", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title4", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title5", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title6", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title2", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title3", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title4", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title5", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title6", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title2", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title3", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title4", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title5", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title6", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title2", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title3", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title4", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title5", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title6", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title2", "Description goes here", r.getDrawable(R.drawable.picture2)));
    adapter.add(new CardModel("Title3", "Description goes here", r.getDrawable(R.drawable.picture3)));
    adapter.add(new CardModel("Title4", "Description goes here", r.getDrawable(R.drawable.picture1)));
    adapter.add(new CardModel("Title5", "Description goes here", r.getDrawable(R.drawable.picture2)));

        CardModel cardModel = new CardModel("Title1", "Description goes here", r.getDrawable(R.drawable.picture1));
        cardModel.setOnClickListener(new CardModel.OnClickListener() {
           @Override
           public void OnClickListener() {
               Log.i("Swipeable Cards","I am pressing the card");
           }
        });

        cardModel.setOnCardDimissedListener(new CardModel.OnCardDimissedListener() {
            @Override
            public void onLike() {
                Log.i("Swipeable Cards","I like the card");
            }

            @Override
            public void onDislike() {
                Log.i("Swipeable Cards","I dislike the card");
            }
        });

        adapter.add(cardModel);

    mCardContainer.setAdapter(adapter);
  }
}




Java Source Code List

com.andtinder.Utils.java
com.andtinder.demo.MainActivity.java
com.andtinder.model.CardModel.java
com.andtinder.model.Likes.java
com.andtinder.model.Orientations.java
com.andtinder.view.BaseCardStackAdapter.java
com.andtinder.view.CardContainer.java
com.andtinder.view.CardStackAdapter.java
com.andtinder.view.SimpleCardStackAdapter.java