Skip to content

Commit

Permalink
updated sample project
Browse files Browse the repository at this point in the history
  • Loading branch information
zagum committed Jan 12, 2017
1 parent b3e5091 commit 2b2f2d7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ public class SampleActivity extends Activity {

private SwitchIconView switchIcon1;
private SwitchIconView switchIcon2;
private SwitchIconView switchIcon3;
private View button1;
private View button2;
private View button3;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -19,8 +21,10 @@ protected void onCreate(Bundle savedInstanceState) {

switchIcon1 = (SwitchIconView) findViewById(R.id.switchIconView1);
switchIcon2 = (SwitchIconView) findViewById(R.id.switchIconView2);
switchIcon3 = (SwitchIconView) findViewById(R.id.switchIconView3);
button1 = findViewById(R.id.button1);
button2 = findViewById(R.id.button2);
button3 = findViewById(R.id.button3);

button1.setOnClickListener(new View.OnClickListener() {
@Override
Expand All @@ -32,7 +36,12 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
switchIcon2.switchState();
switchIcon1.setIconEnabled(!switchIcon1.isIconEnabled());
}
});
button3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
switchIcon3.switchState();
}
});
}
Expand Down
12 changes: 12 additions & 0 deletions switchicon-sample/src/main/res/drawable/ic_camera.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32dp"
android:height="32dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0"/>
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4L4,4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2L9,2zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z"/>
</vector>
33 changes: 32 additions & 1 deletion switchicon-sample/src/main/res/layout/activity_sample.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
android:padding="8dp"
app:si_animation_duration="500"
app:si_disabled_alpha=".5"
app:si_tint_color="#ff3c00"
app:si_disabled_color="#b7b7b7"
app:si_enabled="false"
app:si_no_dash="true"
app:si_tint_color="#ff3c00"
app:srcCompat="@drawable/ic_cloud"/>

<TextView
Expand Down Expand Up @@ -59,4 +61,33 @@

</LinearLayout>

<LinearLayout
android:id="@+id/button3"
android:orientation="vertical"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginLeft="24dp"
android:background="?selectableItemBackgroundBorderless"
android:gravity="center">

<com.github.zagum.switchicon.SwitchIconView
android:id="@+id/switchIconView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:padding="8dp"
app:si_disabled_alpha=".5"
app:si_disabled_color="#dadada"
app:si_enabled="false"
app:si_tint_color="#ffb700"
app:srcCompat="@drawable/ic_camera"/>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/camera"/>

</LinearLayout>

</LinearLayout>
1 change: 1 addition & 0 deletions switchicon-sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<string name="app_name">SwitchIconView</string>
<string name="sync">Sync</string>
<string name="alarm">Alarm</string>
<string name="camera">Camera</string>
</resources>

0 comments on commit 2b2f2d7

Please sign in to comment.