[go: nahoru, domu]

Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
bassaer committed Feb 19, 2017
1 parent 4c21228 commit eefb634
Show file tree
Hide file tree
Showing 17 changed files with 696 additions and 40 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# MaterialDesignColors
An Android library which provides Google Material Design Colors
Android library which provides [Google Material Design Colors](https://material.io/guidelines/style/color.html)


3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile project(':materialdesigncolorlib')
//compile project(':materialdesigncolorlib')
compile project(':library')
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,43 @@
package com.github.bassaer.materialdesigncolors;

/**
* Color label data
* Created by nakayama on 2017/02/19.
*/
public class ColorEntry {
/**
* Name of color
*/
private String mLabel;

/**
* Color value
*/
private int color;

/**
* Constructor
* @param label Name of color
* @param color Color value
*/
public ColorEntry(String label, int color) {
mLabel = label;
this.color = color;
}

public String getLabel() {
return mLabel;
}

public void setLabel(String label) {
mLabel = label;
}

public int getColor() {
return color;
}

public void setColor(int color) {
this.color = color;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
package com.github.bassaer.materialdesigncolors;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

/**
* List adapter for color list view
* Created by nakayama on 2017/02/19.
*/
public class ColorListAdapter {
public class ColorListAdapter extends ArrayAdapter<ColorEntry> {
private LayoutInflater mLayoutInflater;

public ColorListAdapter(Context context, int resource, List<ColorEntry> objects) {
super(context, resource, objects);
mLayoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mLayoutInflater.inflate(R.layout.color_row, null);
holder = new ViewHolder();
holder.colorLabel = (TextView)convertView.findViewById(R.id.color_row_label);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
ColorEntry colorEntry = getItem(position);
holder.colorLabel.setText(colorEntry.getLabel());
holder.colorLabel.setBackgroundColor(colorEntry.getColor());

return convertView;
}

class ViewHolder {
TextView colorLabel;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,41 @@

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;

import com.github.bassaer.MDColor;
import com.github.bassaer.library.MDColor;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView textView = (TextView)findViewById(R.id.text_view);
textView.setBackgroundColor(MDColor.BLUE_GREY_500);


}

private void setColors(List<ColorEntry> colors) {
if (colors == null) {
colors = new ArrayList<>();
}
//Red
colors.add(new ColorEntry(getString(R.string.red), MDColor.RED_500));
colors.add(new ColorEntry(getString(R.string.v_50), MDColor.RED_50));
colors.add(new ColorEntry(getString(R.string.v_100), MDColor.RED_100));
colors.add(new ColorEntry(getString(R.string.v_200), MDColor.RED_200));
colors.add(new ColorEntry(getString(R.string.v_300), MDColor.RED_300));
colors.add(new ColorEntry(getString(R.string.v_400), MDColor.RED_400));
colors.add(new ColorEntry(getString(R.string.v_500), MDColor.RED_500));
colors.add(new ColorEntry(getString(R.string.v_600), MDColor.RED_600));
colors.add(new ColorEntry(getString(R.string.v_700), MDColor.RED_700));
colors.add(new ColorEntry(getString(R.string.v_800), MDColor.RED_800));
colors.add(new ColorEntry(getString(R.string.v_900), MDColor.RED_900));
colors.add(new ColorEntry(getString(R.string.a_100), MDColor.RED_A_100));
colors.add(new ColorEntry(getString(R.string.a_200), MDColor.RED_A_200));
colors.add(new ColorEntry(getString(R.string.a_400), MDColor.RED_A_400));
colors.add(new ColorEntry(getString(R.string.a_700), MDColor.RED_A_700));
}
}
13 changes: 9 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.github.bassaer.materialdesigncolors.MainActivity">

<TextView
android:id="@+id/text_view"
<!--<ListView-->
<!--android:id="@+id/list_view"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent"/>-->

<TableLayout
android:id="@+id/table_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Hello World!"/>
android:layout_height="match_parent"/>

</RelativeLayout>
11 changes: 10 additions & 1 deletion app/src/main/res/layout/color_row.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">

<TextView
android:id="@+id/color_row_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/red"
android:textColor="@color/white"
android:gravity="center"
android:background="@color/red_500"/>

</LinearLayout>
69 changes: 64 additions & 5 deletions app/src/main/res/layout/table_low_10_pallette.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</LinearLayout>
<View
android:id="@+id/table_row_10_50"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_100"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_200"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_300"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_400"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_500"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_600"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_700"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_800"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

<View
android:id="@+id/table_row_10_900"
android:layout_height="@dimen/cell_height"
android:layout_width="0dp"
android:layout_weight="1"/>

</TableRow>
Loading

0 comments on commit eefb634

Please sign in to comment.