Skip to content

Commit

Permalink
Working on Layouts
Browse files Browse the repository at this point in the history
Also extracted text-button-click interface from a Card and placed it its own file
  • Loading branch information
dexafree committed Jul 24, 2014
1 parent c9d841e commit de56d5d
Show file tree
Hide file tree
Showing 21 changed files with 464 additions and 376 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import android.widget.Toast;

import com.dexafree.materiallistviewexample.controller.OnButtonPressListener;
import com.dexafree.materiallistviewexample.model.BasicCard;
import com.dexafree.materiallistviewexample.model.BasicImageButtonsCard;
import com.dexafree.materiallistviewexample.model.BigImageButtonsCard;
import com.dexafree.materiallistviewexample.model.BigImageCard;
import com.dexafree.materiallistviewexample.model.Card;
import com.dexafree.materiallistviewexample.model.CardList;
import com.dexafree.materiallistviewexample.model.ImageButtonsCard;
import com.dexafree.materiallistviewexample.view.MaterialListView;


public class MainActivity extends ActionBarActivity {
Expand Down Expand Up @@ -42,7 +44,7 @@ protected void onCreate(Bundle savedInstanceState) {
}

private void fillArray(){
for(int i=0;i<15;i++){
for(int i=0;i<20;i++){
Card card = getRandomCard(i);
cardsList.add(card);
}
Expand All @@ -51,36 +53,60 @@ private void fillArray(){
private Card getRandomCard(final int position){
String title = "Card number "+(position+1);
String description = "Lorem ipsum dolor sit amet";
Drawable icon = getResources().getDrawable(R.drawable.photo);

int type = position % 3;
int type = position % 4;

Card card;
Drawable icon;

switch (type){

case 0:
card = new BasicCard();
card.setDescription(description);
card.setTitle(title);
icon = getResources().getDrawable(R.drawable.ic_launcher);
card.setBitmap(icon);
return card;

case 1:
card = new BigImageCard();
card.setDescription(description);
card.setTitle(title);
icon = getResources().getDrawable(R.drawable.photo);
card.setBitmap(icon);
return card;

case 2:
card = new BasicImageButtonsCard();
card.setDescription(description);
card.setTitle(title);
icon = getResources().getDrawable(R.drawable.dog);
card.setBitmap(icon);
((BasicImageButtonsCard)card).setLeftButtonText("IZQUIERDA");
((BasicImageButtonsCard)card).setRightButtonText("DERECHA");
((BasicImageButtonsCard)card).setOnButtonPressListener(new OnButtonPressListener() {
@Override
public void onLeftTextPressed(TextView textView) {
Toast.makeText(mContext, "PULSADA IZQUIERDA EN NUMERO "+(position+1), Toast.LENGTH_SHORT).show();
}

@Override
public void onRightTextPressed(TextView textView) {
Toast.makeText(mContext, "PULSADA DERECHA EN NUMERO "+(position+1), Toast.LENGTH_SHORT).show();
}
});
return card;

default:
card = new ImageButtonsCard();
card = new BigImageButtonsCard();
card.setDescription(description);
card.setTitle(title);
icon = getResources().getDrawable(R.drawable.photo);
card.setBitmap(icon);
((ImageButtonsCard)card).setLeftButtonText("IZQUIERDA");
((ImageButtonsCard)card).setRightButtonText("DERECHA");
((ImageButtonsCard)card).setOnButtonPressListener(new ImageButtonsCard.OnButtonPressListener() {
((BigImageButtonsCard)card).setLeftButtonText("IZQUIERDA");
((BigImageButtonsCard)card).setRightButtonText("DERECHA");
((BigImageButtonsCard)card).setOnButtonPressListener(new OnButtonPressListener() {
@Override
public void onLeftTextPressed(TextView textView) {
Toast.makeText(mContext, "PULSADA IZQUIERDA EN NUMERO "+(position+1), Toast.LENGTH_SHORT).show();
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.dexafree.materiallistviewexample.controller;

import android.widget.TextView;

public interface OnButtonPressListener{
void onLeftTextPressed(TextView textView);
void onRightTextPressed(TextView textView);
}
Loading

0 comments on commit de56d5d

Please sign in to comment.