Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

Commit

Permalink
Merge pull request #27 from rey5137/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rey5137 committed Apr 7, 2015
2 parents 1d3c3c7 + 9c949e3 commit ac83d8f
Show file tree
Hide file tree
Showing 53 changed files with 659 additions and 338 deletions.
2 changes: 1 addition & 1 deletion Material.iml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.0.1" type="JAVA_MODULE" version="4">
<module external.linked.project.id="Material" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion app/app.iml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.0.1" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.github.rey5137" external.system.module.version="1.1.0-SNAPSHOT" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -34,6 +34,6 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:cardview-v7:21.0.2'
compile project(':lib')
compile 'com.squareup.picasso:picasso:2.5.0'
compile project(':lib')
}
3 changes: 2 additions & 1 deletion app/src/main/java/com/rey/material/app/ContactEditText.java
Expand Up @@ -24,6 +24,7 @@
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -581,7 +582,7 @@ public int getItemViewType(int position) {
public View getView(int position, View convertView, ViewGroup parent) {
ContactView v = (ContactView)convertView;
if(v == null) {
v = new ContactView(getContext(), null, 0, position == 0 ? R.style.SelectedContactView : R.style.ReplacementContactView);
v = (ContactView)LayoutInflater.from(parent.getContext()).inflate(position == 0 ? R.layout.row_contact_selected : R.layout.row_contact_replace, parent, false);
v.setOnClickListener(this);
}

Expand Down
Expand Up @@ -20,6 +20,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Adapter;
Expand All @@ -28,6 +29,7 @@
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import com.rey.material.demo.R;
import com.rey.material.util.ThemeUtil;
Expand Down Expand Up @@ -86,7 +88,8 @@ protected void onCreate() {
setContentView(v);

FrameLayout fl_mode = (FrameLayout)v.findViewById(R.id.rd_fl_mode);
LinearLayout ll_repeat = (LinearLayout)v.findViewById(R.id.rd_ll_repeat);
final ScrollView sv_repeat = (ScrollView)v.findViewById(R.id.rd_sv_repeat);
final LinearLayout ll_repeat = (LinearLayout)v.findViewById(R.id.rd_ll_repeat);
mModeSpinner = (Spinner)fl_mode.findViewById(R.id.rd_spn_mode);
mEndSpinner = (Spinner)v.findViewById(R.id.rd_spn_end);
mPeriodEditText = (EditText)v.findViewById(R.id.rd_et_period);
Expand All @@ -98,6 +101,13 @@ protected void onCreate() {
mEndDateButton = (Button)v.findViewById(R.id.rd_bt_end_date);
mWeekView = (WeekView)v.findViewById(R.id.rd_wv_week);

sv_repeat.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
showDivider(ll_repeat.getMeasuredHeight() > sv_repeat.getMeasuredHeight());
}
});

mHeaderBackground = new HeaderDrawable(getContext());

fl_mode.setPadding(mContentPadding, 0, mContentPadding, 0);
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/rey/material/demo/ButtonFragment.java
@@ -1,6 +1,8 @@
package com.rey.material.demo;

import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.Fragment;
Expand Down Expand Up @@ -47,7 +49,6 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

@Override
public void onClick(View v) {
Toast.makeText(getActivity(), "Button Clicked!\nEvent's fired when in anim end.", Toast.LENGTH_SHORT).show();
if(v instanceof FloatingActionButton){
FloatingActionButton bt = (FloatingActionButton)v;
bt.setLineMorphingState((bt.getLineMorphingState() + 1) % 2, true);
Expand All @@ -59,7 +60,6 @@ public void onClick(View v) {

@Override
public void onClick(View v) {
Toast.makeText(getActivity(), "Button Clicked!\nEvent's fired when out anim end.", Toast.LENGTH_SHORT).show();
if(v instanceof FloatingActionButton){
FloatingActionButton bt = (FloatingActionButton)v;
bt.setLineMorphingState((bt.getLineMorphingState() + 1) % 2, true);
Expand Down
50 changes: 24 additions & 26 deletions app/src/main/java/com/rey/material/demo/DialogsFragment.java
Expand Up @@ -77,13 +77,13 @@ public void onClick(View v) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Discarded", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Canceled", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -96,13 +96,13 @@ public void onNegativeActionClicked(DialogFragment fragment) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Deleted", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -115,13 +115,13 @@ public void onNegativeActionClicked(DialogFragment fragment) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Agreed", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Disagreed", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -143,13 +143,13 @@ protected Dialog onBuild(Context context, int styleId) {
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Connected", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled", Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -162,15 +162,14 @@ public void onNegativeActionClicked(DialogFragment fragment) {
builder = new SimpleDialog.Builder(R.style.SimpleDialogLight){
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
SimpleDialog dialog = (SimpleDialog)fragment.getDialog();
Toast.makeText(fragment.getDialog().getContext(), "You have selected " + dialog.getSelectedValue() + " as phone ringtone.", Toast.LENGTH_SHORT).show();
fragment.dismiss();
Toast.makeText(fragment.getDialog().getContext(), "You have selected " + getSelectedValue() + " as phone ringtone.", Toast.LENGTH_SHORT).show();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled" , Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -183,8 +182,7 @@ public void onNegativeActionClicked(DialogFragment fragment) {
builder = new SimpleDialog.Builder(R.style.SimpleDialog){
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
SimpleDialog dialog = (SimpleDialog)fragment.getDialog();
CharSequence[] values = dialog.getSelectedValues();
CharSequence[] values = getSelectedValues();
if(values == null)
Toast.makeText(fragment.getDialog().getContext(), "You have selected nothing.", Toast.LENGTH_SHORT).show();
else{
Expand All @@ -194,13 +192,13 @@ public void onPositiveActionClicked(DialogFragment fragment) {
sb.append(values[i]).append(i == values.length - 1? "." : ", ");
Toast.makeText(fragment.getDialog().getContext(), sb.toString(), Toast.LENGTH_SHORT).show();
}
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled" , Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -210,38 +208,38 @@ public void onNegativeActionClicked(DialogFragment fragment) {
.negativeAction("CANCEL");
break;
case R.id.dialog_bt_time_light:
builder = new TimePickerDialog.Builder(R.style.Material_App_Dialog_TimePicker_Light, 6, 00){
builder = new TimePickerDialog.Builder(6, 00){
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
TimePickerDialog dialog = (TimePickerDialog)fragment.getDialog();
Toast.makeText(fragment.getDialog().getContext(), "Time is " + dialog.getFormattedTime(SimpleDateFormat.getTimeInstance()), Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled" , Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

builder.positiveAction("OK")
.negativeAction("CANCEL");
break;
case R.id.dialog_bt_date_light:
builder = new DatePickerDialog.Builder(R.style.Material_App_Dialog_DatePicker_Light){
builder = new DatePickerDialog.Builder(){
@Override
public void onPositiveActionClicked(DialogFragment fragment) {
DatePickerDialog dialog = (DatePickerDialog)fragment.getDialog();
String date = dialog.getFormattedDate(SimpleDateFormat.getDateInstance());
Toast.makeText(fragment.getDialog().getContext(), "Date is " + date, Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled" , Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -254,13 +252,13 @@ public void onNegativeActionClicked(DialogFragment fragment) {
public void onPositiveActionClicked(DialogFragment fragment) {
TimePickerDialog dialog = (TimePickerDialog)fragment.getDialog();
Toast.makeText(fragment.getDialog().getContext(), "Time is " + dialog.getFormattedTime(SimpleDateFormat.getTimeInstance()), Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled" , Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand All @@ -274,13 +272,13 @@ public void onPositiveActionClicked(DialogFragment fragment) {
DatePickerDialog dialog = (DatePickerDialog)fragment.getDialog();
String date = dialog.getFormattedDate(SimpleDateFormat.getDateInstance());
Toast.makeText(fragment.getDialog().getContext(), "Date is " + date, Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onPositiveActionClicked(fragment);
}

@Override
public void onNegativeActionClicked(DialogFragment fragment) {
Toast.makeText(fragment.getDialog().getContext(), "Cancelled" , Toast.LENGTH_SHORT).show();
fragment.dismiss();
super.onNegativeActionClicked(fragment);
}
};

Expand Down
45 changes: 26 additions & 19 deletions app/src/main/java/com/rey/material/demo/MainActivity.java
Expand Up @@ -32,7 +32,7 @@
import java.util.Calendar;
import java.util.Date;

public class MainActivity extends ActionBarActivity implements AdapterView.OnItemClickListener, ToolbarManager.OnToolbarGroupChangedListener {
public class MainActivity extends ActionBarActivity implements ToolbarManager.OnToolbarGroupChangedListener {

private DrawerLayout dl_navigator;
private FrameLayout fl_drawer;
Expand Down Expand Up @@ -87,8 +87,7 @@ protected boolean shouldSyncDrawerSlidingProgress() {
mToolbarManager.registerOnToolbarGroupChangedListener(this);

mDrawerAdapter = new DrawerAdapter();
lv_drawer.setAdapter(mDrawerAdapter);
lv_drawer.setOnItemClickListener(this);
lv_drawer.setAdapter(mDrawerAdapter);

mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), mItems);
vp.setAdapter(mPagerAdapter);
Expand All @@ -109,6 +108,7 @@ public void onPageScrollStateChanged(int state) {}

});

mDrawerAdapter.setSelected(Tab.PROGRESS);
vp.setCurrentItem(0);
}

Expand Down Expand Up @@ -143,12 +143,6 @@ public void onToolbarGroupChanged(int oldGroupId, int groupId) {
mToolbarManager.notifyNavigationStateChanged();
}

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
vp.setCurrentItem(position);
dl_navigator.closeDrawer(fl_drawer);
}

public SnackBar getSnackBar(){
return mSnackBar;
}
Expand Down Expand Up @@ -179,7 +173,7 @@ public String toString(){

}

class DrawerAdapter extends BaseAdapter{
class DrawerAdapter extends BaseAdapter implements View.OnClickListener {

private Tab mSelectedTab;

Expand Down Expand Up @@ -212,21 +206,34 @@ public long getItemId(int position) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if(v == null)
v = LayoutInflater.from(MainActivity.this).inflate(R.layout.row_drawer, null);

if(v == null) {
v = LayoutInflater.from(MainActivity.this).inflate(R.layout.row_drawer, null);
v.setOnClickListener(this);
}

v.setTag(position);
Tab tab = (Tab)getItem(position);
((TextView)v).setText(tab.toString());

if(tab == mSelectedTab)
v.setBackgroundColor(ThemeUtil.colorPrimary(MainActivity.this, 0));
else
v.setBackgroundResource(0);
if(tab == mSelectedTab) {
v.setBackgroundColor(ThemeUtil.colorPrimary(MainActivity.this, 0));
((TextView)v).setTextColor(0xFFFFFFFF);
}
else {
v.setBackgroundResource(0);
((TextView)v).setTextColor(0xFF000000);
}

return v;
}

}

@Override
public void onClick(View v) {
int position = (Integer)v.getTag();
vp.setCurrentItem(position);
dl_navigator.closeDrawer(fl_drawer);
}
}

private static class PagerAdapter extends FragmentStatePagerAdapter {

Expand Down

0 comments on commit ac83d8f

Please sign in to comment.