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

Commit

Permalink
Add support changing background drawable dynamically for RippleDrawab…
Browse files Browse the repository at this point in the history
…le class.

Clean up style.
  • Loading branch information
rey5137 committed Apr 7, 2015
1 parent 9251b84 commit b7db9e9
Show file tree
Hide file tree
Showing 33 changed files with 217 additions and 114 deletions.
4 changes: 2 additions & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Material.iml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<facet type="java-gradle" name="Java-Gradle">
<configuration>
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
<option name="BUILDABLE" value="false" />
</configuration>
</facet>
</component>
Expand All @@ -16,4 +15,5 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
</module>

6 changes: 3 additions & 3 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
<option name="COMPILE_JAVA_TEST_TASK_NAME" value="compileDebugTestSources" />
<option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
<option name="TEST_SOURCE_GEN_TASK_NAME" value="generateDebugTestSources" />
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
Expand Down Expand Up @@ -93,4 +92,5 @@
<orderEntry type="library" exported="" name="cardview-v7-21.0.2" level="project" />
<orderEntry type="module" module-name="lib" exported="" />
</component>
</module>
</module>

3 changes: 2 additions & 1 deletion app/src/main/java/com/rey/material/app/ContactEditText.java
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
2 changes: 0 additions & 2 deletions app/src/main/java/com/rey/material/demo/ButtonFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,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 @@ -61,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
45 changes: 26 additions & 19 deletions app/src/main/java/com/rey/material/demo/MainActivity.java
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@
android:layout_gravity="start"
android:paddingTop="?attr/actionBarSize">

<ListView
<com.rey.material.widget.ListView
android:id="@+id/main_lv_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@null"
android:dividerHeight="0dp"
android:background="?android:attr/windowBackground"
android:listSelector="?attr/colorPrimary"/>
android:listSelector="@android:color/transparent"/>

</FrameLayout>

Expand Down
11 changes: 4 additions & 7 deletions app/src/main/res/layout/dialog_recurring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
app:spn_arrowColor="#FFFFFFFF"
app:spn_dividerHeight="0dp"
app:rd_style="@style/Material.Drawable.Ripple.Wave"
app:rd_enable="true"
app:rd_delayClick="true"
android:layout_gravity="center_vertical"/>

</FrameLayout>
Expand Down Expand Up @@ -128,9 +126,7 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:padding="8dp"
app:rd_style="@style/Material.Drawable.Ripple.Wave.Light"
app:rd_enable="true"
app:rd_delayClick="true"/>
app:rd_style="@style/Material.Drawable.Ripple.Wave.Light"/>

<com.rey.material.widget.EditText
style="@style/Material.Widget.EditText.Light"
Expand Down Expand Up @@ -160,15 +156,16 @@
tools:text="@string/rd_event"/>

<com.rey.material.widget.Button
style="@style/Material.Drawable.Ripple.Wave.Light"
android:id="@+id/rd_bt_end_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/rd_spn_end"
android:singleLine="true"
android:ellipsize="end"
android:layout_centerVertical="true"
style="@style/Material.Drawable.Ripple.Wave.Light"
app:rd_delayClick="false"
android:padding="8dp"
android:background="@null"
tools:text="12/01/2015"/>

</RelativeLayout>
Expand Down
Loading

0 comments on commit b7db9e9

Please sign in to comment.