Skip to content

Commit

Permalink
Finished Layouts
Browse files Browse the repository at this point in the history
  • Loading branch information
dexafree committed Jul 24, 2014
1 parent 66d0e0e commit c1bb76c
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import com.dexafree.materiallistviewexample.controller.OnButtonPressListener;
import com.dexafree.materiallistviewexample.model.BasicButtonsCard;
import com.dexafree.materiallistviewexample.model.BasicCard;
import com.dexafree.materiallistviewexample.model.SmallImageCard;
import com.dexafree.materiallistviewexample.model.BasicImageButtonsCard;
import com.dexafree.materiallistviewexample.model.BigImageButtonsCard;
import com.dexafree.materiallistviewexample.model.BigImageCard;
Expand Down Expand Up @@ -63,7 +63,7 @@ private Card getRandomCard(final int position){
switch (type){

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

This file was deleted.

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

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;

import com.dexafree.materiallistviewexample.R;

public class SmallImageCard extends Card {

public SmallImageCard(){
super();
this.setLayout(R.layout.material_small_image_card);
}

public SmallImageCard(String title, String description, Bitmap bitmap) {
super(title, description, bitmap);
this.setLayout(R.layout.material_small_image_card);
}

public SmallImageCard(String title, String description, int resourceId) {
super(title, description, resourceId);
this.setLayout(R.layout.material_small_image_card);
}

public SmallImageCard(String title, String description, Drawable drawable) {
super(title, description, drawable);
this.setLayout(R.layout.material_small_image_card);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,36 @@
import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dexafree.materiallistviewexample.R;
import com.dexafree.materiallistviewexample.model.BasicCard;
import com.dexafree.materiallistviewexample.model.SmallImageCard;
import com.dexafree.materiallistviewexample.model.GridItemView;

public class BasicCardItemView extends GridItemView<BasicCard> {
public class SmallImageCardItemView extends GridItemView<SmallImageCard> {

TextView mTitle;

ImageView mImage;

TextView mDescription;

public BasicCardItemView(Context context) {
public SmallImageCardItemView(Context context) {
super(context);
}

public BasicCardItemView(Context context, AttributeSet attrs) {
public SmallImageCardItemView(Context context, AttributeSet attrs) {
super(context, attrs);
}

public BasicCardItemView(Context context, AttributeSet attrs, int defStyle) {
public SmallImageCardItemView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if(mImage != null) {
LayoutParams params = (LayoutParams) mImage.getLayoutParams();
params.height = getMeasuredWidth();
mImage.setLayoutParams(params);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}


@Override
public void configureView(BasicCard card) {
public void configureView(SmallImageCard card) {
setTitle(card.getTitle());
setDescription(card.getDescription());
setImage(card.getBitmap());
Expand Down
53 changes: 0 additions & 53 deletions app/src/main/res/layout/basic_card_layout.xml

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/main/res/layout/image_card_layout.xml

This file was deleted.

74 changes: 0 additions & 74 deletions app/src/main/res/layout/image_card_layout_with_buttons.xml

This file was deleted.

55 changes: 55 additions & 0 deletions app/src/main/res/layout/material_small_image_card.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>

<com.dexafree.materiallistviewexample.view.SmallImageCardItemView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/MainLayout">

<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
card_view:cardCornerRadius="@dimen/card_corner_radius"
style="@style/MainCardView">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="@dimen/big_padding"
android:textSize="@dimen/title_size"
android:id="@+id/titleTextView"
tools:text="Title"/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@id/imageView"
android:layout_alignLeft="@+id/titleTextView"
android:paddingLeft="@dimen/big_padding"
android:paddingBottom="@dimen/big_padding"
android:paddingTop="@dimen/small_padding"
android:paddingRight="@dimen/big_padding"
android:layout_below="@+id/titleTextView"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher"/>

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@id/descriptionTextView"
android:layout_alignTop="@+id/imageView"
android:layout_toRightOf="@+id/imageView"
android:paddingLeft="@dimen/small_padding"
android:paddingRight="@dimen/big_padding"
android:paddingBottom="@dimen/big_padding"
android:textSize="@dimen/description_size"
android:textColor="@color/description_color"
tools:text="Lorem ipsum dolor sit amet"/>

</RelativeLayout>

</android.support.v7.widget.CardView>

</com.dexafree.materiallistviewexample.view.SmallImageCardItemView>
Loading

0 comments on commit c1bb76c

Please sign in to comment.