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

refactored set functionality #25

Open
wants to merge 1 commit into
base: release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import com.github.angads25.toggle.widget.LabeledSwitch
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity(), View.OnClickListener {

Expand All @@ -29,12 +31,15 @@ class MainActivity : AppCompatActivity(), View.OnClickListener {

findViewById<View>(R.id.switch_labeled).setOnClickListener(this)
findViewById<View>(R.id.switch_day_night).setOnClickListener(this)
findViewById<View>(R.id.btn_test).setOnClickListener(this)

}

override fun onClick(view: View) {
when (view.id) {
R.id.switch_labeled -> startActivity(Intent(this@MainActivity, LabeledSwitchActivity::class.java))
R.id.switch_day_night -> startActivity(Intent(this@MainActivity, DayNightActivity::class.java))
R.id.btn_test -> startActivity(Intent(this@MainActivity, TestActivity::class.java))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.github.angads25.toggledemo

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_test.*

/**
* Created by Angad Singh on 14/07/18.
Expand All @@ -27,5 +28,12 @@ class TestActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test)

text.text = "default:${switch1.isOn}"

switch1.setOnClickListener {
text.text ="onTouch:${switch1.isOn}"
}

}
}
11 changes: 9 additions & 2 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
~ limitations under the License.
-->

<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="?layoutBackground"
android:orientation="vertical"
tools:context="com.github.angads25.toggledemo.MainActivity">
Expand All @@ -35,4 +35,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_day_night_switch"/>

<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/label_test"/>

</android.support.v7.widget.LinearLayoutCompat>
19 changes: 15 additions & 4 deletions app/src/main/res/layout/activity_test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
~ limitations under the License.
-->

<android.support.v7.widget.LinearLayoutCompat
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.github.angads25.toggle.widget.LabeledSwitch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"/>
android:layout_margin="16dp"
android:textSize="14sp"
app:on="true"
app:colorBorder="@color/colorAccent"/>

<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="test"
/>

</android.support.v7.widget.LinearLayoutCompat>
1 change: 1 addition & 0 deletions app/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">Toggle Demo</string>
<string name="label_labeled_switch">Labeled Switch</string>
<string name="label_day_night_switch">Day Night Switch</string>
<string name="label_test">Test Toggle</string>
</resources>
Loading