Skip to content

Commit

Permalink
[f] Add sample app
Browse files Browse the repository at this point in the history
  • Loading branch information
luongvo committed Mar 13, 2017
1 parent bada3e4 commit 97eefc1
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 33 deletions.
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "vn.luongvo.widget.iosswitchview"
minSdkVersion 9
applicationId "vn.luongvo.widget.iosswitchview.sample"
minSdkVersion 11
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -20,11 +22,11 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.2.0'
compile project(':library')

androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
}
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="vn.luongvo.widget.iosswitchview" >
package="vn.luongvo.widget.iosswitchview.sample">

<application
android:allowBackup="true"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package vn.luongvo.widget.iosswitchview.sample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Toast;

import vn.luongvo.widget.iosswitchview.SwitchView;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

final SwitchView switchView = (SwitchView) findViewById(R.id.switchview);
switchView.setOnStateChangedListener(new SwitchView.OnStateChangedListener() {
@Override
public void toggleToOn(View view) {
Toast.makeText(MainActivity.this, "StateChanged: On", Toast.LENGTH_SHORT).show();
}

@Override
public void toggleToOff(View view) {
Toast.makeText(MainActivity.this, "StateChanged: Off", Toast.LENGTH_SHORT).show();
}
});
}
}
23 changes: 10 additions & 13 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="vn.luongvo.android.widgets.ios.switchview.MainActivity">
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="10dp"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<vn.luongvo.widget.iosswitchview.SwitchView
android:id="@+id/switchview"
android:layout_width="50dp"
android:layout_height="wrap_content" />

</android.support.constraint.ConstraintLayout>
</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
Expand Down

0 comments on commit 97eefc1

Please sign in to comment.