-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
193 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
demo/src/main/java/com/balysv/materialripple/demo/DemoRecyclerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package com.balysv.materialripple.demo; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.support.v7.widget.LinearLayoutManager; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.TextView; | ||
import android.widget.Toast; | ||
|
||
import com.balysv.materialripple.MaterialRippleLayout; | ||
|
||
import java.util.UUID; | ||
|
||
public class DemoRecyclerActivity extends ActionBarActivity { | ||
|
||
private final static String[] data; | ||
|
||
static { | ||
data = new String[50]; | ||
for (int i = 0; i < data.length; i++) { | ||
data[i] = UUID.randomUUID().toString(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.demo_recycler); | ||
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list); | ||
recyclerView.setLayoutManager(new LinearLayoutManager(this)); | ||
recyclerView.setAdapter(new MyAdapter()); | ||
} | ||
|
||
@Override | ||
public boolean onCreateOptionsMenu(Menu menu) { | ||
getMenuInflater().inflate(R.menu.menu_recycler, menu); | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean onOptionsItemSelected(MenuItem item) { | ||
int id = item.getItemId(); | ||
if (id == R.id.switch_button) { | ||
startActivity(new Intent(this, DemoActivity.class)); | ||
finish(); | ||
return true; | ||
} else if (id == R.id.switch_list) { | ||
startActivity(new Intent(this, DemoListActivity.class)); | ||
finish(); | ||
return true; | ||
} | ||
return super.onOptionsItemSelected(item); | ||
} | ||
|
||
private static class MyAdapter extends RecyclerView.Adapter<MyViewHolder> { | ||
|
||
@Override | ||
public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { | ||
final LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext()); | ||
return new MyViewHolder( | ||
MaterialRippleLayout.on(inflater.inflate(R.layout.demo_recycler_item, viewGroup, false)) | ||
.rippleOverlay(true) | ||
.rippleAlpha(0.2f) | ||
.rippleColor(0xFF585858) | ||
.rippleHover(true) | ||
.create() | ||
); | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(MyViewHolder viewHolder, int i) { | ||
viewHolder.text.setText(data[i]); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return data.length; | ||
} | ||
} | ||
|
||
private static class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, | ||
View.OnLongClickListener { | ||
|
||
TextView text; | ||
|
||
public MyViewHolder(View itemView) { | ||
super(itemView); | ||
text = (TextView) itemView.findViewById(android.R.id.text1); | ||
itemView.setOnClickListener(this); | ||
itemView.setOnLongClickListener(this); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
Toast.makeText(v.getContext(), "Rippled item: " + getAdapterPosition(), Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
@Override | ||
public boolean onLongClick(View v) { | ||
if (getAdapterPosition() % 2 == 0) { | ||
Toast.makeText(v.getContext(), "long item: " + getAdapterPosition() + " and not consumed", | ||
Toast.LENGTH_SHORT) | ||
.show(); | ||
return false; | ||
} | ||
Toast.makeText(v.getContext(), "long item: " + getAdapterPosition() + " and consumed", Toast.LENGTH_SHORT) | ||
.show(); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<com.balysv.materialripple.MaterialRippleLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
<com.balysv.materialripple.MaterialRippleLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="70dp" | ||
app:mrl_rippleOverlay="false" | ||
app:mrl_rippleColor="#585858" | ||
app:mrl_rippleAlpha="0.2" | ||
app:mrl_rippleHover="true"> | ||
app:mrl_rippleColor="#585858" | ||
app:mrl_rippleHover="true" | ||
app:mrl_rippleOverlay="true"> | ||
|
||
<TextView | ||
android:id="@android:id/text1" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:gravity="center_vertical" | ||
android:paddingLeft="8dp" | ||
android:textSize="20sp" | ||
android:paddingRight="8dp" | ||
android:gravity="center_vertical" | ||
android:background="@drawable/selector" | ||
android:singleLine="true" | ||
android:ellipsize="end" | ||
android:paddingRight="8dp" | ||
/> | ||
android:singleLine="true" | ||
android:textSize="20sp" /> | ||
|
||
</com.balysv.materialripple.MaterialRippleLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/list" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@android:id/text1" | ||
android:layout_width="match_parent" | ||
android:layout_height="70dp" | ||
android:minHeight="70dp" | ||
android:paddingLeft="8dp" | ||
android:paddingRight="8dp" | ||
android:gravity="center_vertical" | ||
android:background="@drawable/selector" | ||
android:ellipsize="end" | ||
android:singleLine="true" | ||
android:textSize="20sp" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<menu xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto"> | ||
|
||
<item | ||
android:id="@+id/switch_button" | ||
app:showAsAction="ifRoom|withText" | ||
android:title="@string/switch_button"/> | ||
|
||
<item | ||
android:id="@+id/switch_list" | ||
app:showAsAction="ifRoom|withText" | ||
android:title="@string/switch_list"/> | ||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="app_name">Material Ripple Demo</string> | ||
<string name="switch_list">Switch to ListView</string> | ||
<string name="switch_button">Switch to Buttons</string> | ||
<string name="switch_list">ListView</string> | ||
<string name="switch_button">Buttons</string> | ||
<string name="switch_recycler">RecyclerView</string> | ||
</resources> |