madshellnpm 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/cli.js +44 -0
  2. package/generator.js +30 -0
  3. package/index.js +5 -0
  4. package/menu/context menu/MainActivity.kt +50 -0
  5. package/menu/context menu/activity_main.xml +18 -0
  6. package/menu/context menu/menu_main.xml +34 -0
  7. package/menu/options menu/MainActivity.kt +52 -0
  8. package/menu/options menu/activity_main.xml +9 -0
  9. package/menu/options menu/menu_main.xml +81 -0
  10. package/menu/popup menu/MainActivity.kt +58 -0
  11. package/menu/popup menu/activity_main.xml +20 -0
  12. package/menu/popup menu/menu_main.xml +39 -0
  13. package/package.json +27 -0
  14. package/templates/alertdialog/MainActivity.kt +47 -0
  15. package/templates/alertdialog/activity_main.xml +39 -0
  16. package/templates/animations/MainActivity.kt +70 -0
  17. package/templates/animations/activity_main.xml +125 -0
  18. package/templates/animations/bounce.xml +24 -0
  19. package/templates/animations/fade_in.xml +11 -0
  20. package/templates/animations/fade_out.xml +12 -0
  21. package/templates/animations/slide_down.xml +9 -0
  22. package/templates/animations/slide_up.xml +9 -0
  23. package/templates/animations/zoom_in.xml +15 -0
  24. package/templates/animations/zoom_out.xml +15 -0
  25. package/templates/autocomplete_textview/MainActivity.kt +40 -0
  26. package/templates/autocomplete_textview/activity_main.xml +34 -0
  27. package/templates/canvas/MainActivity.kt +54 -0
  28. package/templates/canvas/activity_main.xml +19 -0
  29. package/templates/canvas/example2.kt +13 -0
  30. package/templates/checkbox/MainActivity.kt +56 -0
  31. package/templates/checkbox/activity_main.xml +67 -0
  32. package/templates/custom_checkbox/MainActivity.kt +32 -0
  33. package/templates/custom_checkbox/activity_main.xml +43 -0
  34. package/templates/custom_toast/MainActivity.kt +23 -0
  35. package/templates/custom_toast/activity_main.xml +22 -0
  36. package/templates/custom_toast/customtoast.xml +20 -0
  37. package/templates/database/MainActivity.kt +64 -0
  38. package/templates/database/activity_main.xml +77 -0
  39. package/templates/database/dbController.kt +56 -0
  40. package/templates/datepicker_and_timepicker/datepicker/MainActivity.kt +34 -0
  41. package/templates/datepicker_and_timepicker/datepicker/activity_main.xml +24 -0
  42. package/templates/datepicker_and_timepicker/timepicker/MainActivity.kt +37 -0
  43. package/templates/datepicker_and_timepicker/timepicker/activity_main.xml +15 -0
  44. package/templates/explicit_and_implicit_intents/example 1/MainActivity.kt +36 -0
  45. package/templates/explicit_and_implicit_intents/example 1/SecondActivity.kt +12 -0
  46. package/templates/explicit_and_implicit_intents/example 1/activity_main.xml +33 -0
  47. package/templates/explicit_and_implicit_intents/example 1/activity_second.xml +20 -0
  48. package/templates/explicit_and_implicit_intents/example 2/MainActivity.kt +37 -0
  49. package/templates/explicit_and_implicit_intents/example 2/MainActivity2.kt +23 -0
  50. package/templates/explicit_and_implicit_intents/example 2/activity_main.xml +38 -0
  51. package/templates/explicit_and_implicit_intents/example 2/activity_second.xml +18 -0
  52. package/templates/image_view_listener/MainActivity.kt +38 -0
  53. package/templates/image_view_listener/activity_main.xml +89 -0
  54. package/templates/menu/context menu/MainActivity.kt +50 -0
  55. package/templates/menu/context menu/activity_main.xml +18 -0
  56. package/templates/menu/context menu/menu_main.xml +34 -0
  57. package/templates/menu/options menu/MainActivity.kt +52 -0
  58. package/templates/menu/options menu/activity_main.xml +9 -0
  59. package/templates/menu/options menu/menu_main.xml +81 -0
  60. package/templates/menu/popup menu/MainActivity.kt +58 -0
  61. package/templates/menu/popup menu/activity_main.xml +20 -0
  62. package/templates/menu/popup menu/menu_main.xml +39 -0
  63. package/templates/progressbar/MainActivity.kt +60 -0
  64. package/templates/progressbar/activity_main.xml +47 -0
  65. package/templates/radio_button/MainActivity.kt +46 -0
  66. package/templates/radio_button/activity_main.xml +86 -0
  67. package/templates/sharedpreferences/example1/MainActivity.kt +54 -0
  68. package/templates/sharedpreferences/example1/activity_main.xml +69 -0
  69. package/templates/sharedpreferences/example2/MainActivity.kt +45 -0
  70. package/templates/sharedpreferences/example2/activity_main.xml +48 -0
  71. package/templates/spinner/MainActivity.kt +54 -0
  72. package/templates/spinner/activity_main.xml +37 -0
  73. package/templates/spinner/strings.xml +13 -0
  74. package/templates/toggle_button/MainActivity.kt +39 -0
  75. package/templates/toggle_button/activity_main.xml +50 -0
package/cli.js ADDED
@@ -0,0 +1,44 @@
1
+ import inquirer from "inquirer";
2
+ import chalk from "chalk";
3
+ import figlet from "figlet";
4
+ import { createProject } from "./generator.js";
5
+
6
+ const topics = [
7
+ "progressbar",
8
+ "animations",
9
+ "autocomplete_textview",
10
+ "canvas",
11
+ "checkbox",
12
+ "custom_checkbox",
13
+ "custom_toast",
14
+ "database",
15
+ "datepicker_and_timepicker",
16
+ "explicit_and_implicit_intents",
17
+ "image_view_listener",
18
+ "menu",
19
+ "radio_button",
20
+ "sharedpreferences",
21
+ "spinner",
22
+ "toggle_button",
23
+ "alertdialog"
24
+ ];
25
+
26
+ export async function showMenu() {
27
+
28
+ console.log(
29
+ chalk.green(
30
+ figlet.textSync("MAD LAB")
31
+ )
32
+ );
33
+
34
+ const answer = await inquirer.prompt([
35
+ {
36
+ type: "list",
37
+ name: "topic",
38
+ message: "Select topic:",
39
+ choices: topics
40
+ }
41
+ ]);
42
+
43
+ createProject(answer.topic);
44
+ }
package/generator.js ADDED
@@ -0,0 +1,30 @@
1
+ import fs from "fs-extra";
2
+ import path from "path";
3
+
4
+ export function createProject(topic) {
5
+
6
+ const templatePath = path.join(
7
+ process.cwd(),
8
+ "templates",
9
+ topic
10
+ );
11
+
12
+ const targetPath = path.join(
13
+ process.cwd(),
14
+ topic
15
+ );
16
+
17
+ if (!fs.existsSync(templatePath)) {
18
+ console.log("❌ Template not found!");
19
+ console.log("💀 Bro even the template ran away...");
20
+ return;
21
+ }
22
+
23
+ fs.copySync(templatePath, targetPath);
24
+
25
+ console.log(`\n✅ ${topic} project created successfully!`);
26
+ console.log("🔥 MAD LAB survival chances increased.");
27
+ console.log("🚀 All the best soldier...");
28
+ console.log("🫡 Don't get caught copy-pasting.");
29
+ console.log("😂 And remember: if it works, don't touch it.\n");
30
+ }
package/index.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { showMenu } from "./cli.js";
4
+
5
+ showMenu();
@@ -0,0 +1,50 @@
1
+ package com.example.contextmenu
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.view.ContextMenu
6
+ import android.view.MenuItem
7
+ import android.view.View
8
+ import android.widget.Button
9
+ import android.widget.Toast
10
+
11
+ class MainActivity : AppCompatActivity() {
12
+
13
+ override fun onCreate(savedInstanceState: Bundle?) {
14
+ super.onCreate(savedInstanceState)
15
+ setContentView(R.layout.activity_main)
16
+
17
+ val B1 = findViewById<Button>(R.id.B1)
18
+
19
+ registerForContextMenu(B1)
20
+
21
+ B1.setOnClickListener { v ->
22
+ openContextMenu(v)
23
+ }
24
+ }
25
+
26
+ override fun onCreateContextMenu(
27
+ menu: ContextMenu?,
28
+ v: View?,
29
+ menuInfo: ContextMenu.ContextMenuInfo?
30
+ ) {
31
+ super.onCreateContextMenu(menu, v, menuInfo)
32
+ menuInflater.inflate(R.menu.menu, menu)
33
+ }
34
+
35
+ override fun onContextItemSelected(item: MenuItem): Boolean {
36
+ when (item.itemId) {
37
+
38
+ R.id.item1 ->
39
+ Toast.makeText(this, "Open Selected", Toast.LENGTH_SHORT).show()
40
+
41
+ R.id.item2 ->
42
+ Toast.makeText(this, "Search Selected", Toast.LENGTH_SHORT).show()
43
+
44
+ R.id.item3 ->
45
+ Toast.makeText(this, "Exit Selected", Toast.LENGTH_SHORT).show()
46
+ }
47
+
48
+ return super.onContextItemSelected(item)
49
+ }
50
+ }
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:app="http://schemas.android.com/apk/res-auto"
5
+ xmlns:tools="http://schemas.android.com/tools"
6
+ android:layout_width="match_parent"
7
+ android:layout_height="match_parent"
8
+ tools:context=".MainActivity">
9
+ <Button
10
+ android:id="@+id/B1"
11
+ android:layout_width="wrap_content"
12
+ android:layout_height="wrap_content"
13
+ android:text="Context Menu"
14
+ app:layout_constraintBottom_toBottomOf="parent"
15
+ app:layout_constraintEnd_toEndOf="parent"
16
+ app:layout_constraintStart_toStartOf="parent"
17
+ app:layout_constraintTop_toTopOf="parent" />
18
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1,34 @@
1
+ <!--
2
+ Create a Menu XML File
3
+
4
+ 1. In Android Studio, go to:
5
+ res > menu
6
+
7
+ 2. If the menu folder doesn't exist:
8
+ Right-click res → New → Android Resource Directory
9
+ → Select Resource type = menu
10
+
11
+ 3. Create menu file:
12
+ Right-click menu → New → Menu Resource File
13
+ → Name it menu_main.xml
14
+
15
+ 4. Add menu items inside <menu> tag
16
+
17
+ -->
18
+
19
+ <?xml version="1.0" encoding="utf-8"?>
20
+ <menu xmlns:android="http://schemas.android.com/apk/res/android"
21
+ xmlns:app="http://schemas.android.com/apk/res-auto">
22
+ <item android:id="@+id/item1"
23
+ android:title="Open"
24
+ app:showAsAction="never"
25
+ />
26
+ <item android:id="@+id/item2"
27
+ android:title="Search"
28
+ app:showAsAction="never"
29
+ />
30
+ <item android:id="@+id/item3"
31
+ android:title="Exit"
32
+ app:showAsAction="never"
33
+ />
34
+ </menu>
@@ -0,0 +1,52 @@
1
+ package com.example.menu
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.view.Menu
6
+ import android.view.MenuItem
7
+ import android.widget.Toast
8
+
9
+ class MainActivity : AppCompatActivity() {
10
+
11
+ override fun onCreate(savedInstanceState: Bundle?) {
12
+
13
+ super.onCreate(savedInstanceState)
14
+ setContentView(R.layout.activity_main)
15
+ }
16
+
17
+ override fun onCreateOptionsMenu(menu: Menu?): Boolean {
18
+
19
+ menuInflater.inflate(R.menu.option_menu, menu)
20
+
21
+ return super.onCreateOptionsMenu(menu)
22
+ }
23
+
24
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
25
+
26
+ when (item.itemId) {
27
+
28
+ R.id.about ->
29
+ Toast.makeText(
30
+ this,
31
+ "About Selected",
32
+ Toast.LENGTH_SHORT
33
+ ).show()
34
+
35
+ R.id.settings ->
36
+ Toast.makeText(
37
+ this,
38
+ "Settings Selected",
39
+ Toast.LENGTH_SHORT
40
+ ).show()
41
+
42
+ R.id.exit ->
43
+ Toast.makeText(
44
+ this,
45
+ "Exit Selected",
46
+ Toast.LENGTH_SHORT
47
+ ).show()
48
+ }
49
+
50
+ return super.onOptionsItemSelected(item)
51
+ }
52
+ }
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:app="http://schemas.android.com/apk/res-auto"
5
+ xmlns:tools="http://schemas.android.com/tools"
6
+ android:layout_width="match_parent"
7
+ android:layout_height="match_parent"
8
+ tools:context=".MainActivity">
9
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1,81 @@
1
+ <!--
2
+ Create a Menu XML File
3
+
4
+ 1. In Android Studio, go to:
5
+ res > menu
6
+
7
+ 2. If the menu folder doesn't exist:
8
+ Right-click res → New → Android Resource Directory
9
+ → Select Resource type = menu
10
+
11
+ 3. Create menu file:
12
+ Right-click menu → New → Menu Resource File
13
+ → Name it menu_main.xml
14
+
15
+ 4. Add menu items inside <menu> tag
16
+
17
+
18
+ Create Drawable Icons (Vector Assets)
19
+
20
+ 1. Go to:
21
+ res → drawable
22
+
23
+ 2. Right-click → New → Vector Asset
24
+
25
+ 3. Click "Clip Art" and search:
26
+ - settings
27
+ - label
28
+ - exit_to_app
29
+
30
+ 4. Select icon → Next
31
+
32
+ 5. Set file names EXACTLY:
33
+ - ic_baseline_settings_24
34
+ - ic_baseline_label_24
35
+ - ic_baseline_exit_to_app_24
36
+
37
+ 6. Click Finish
38
+
39
+ These will create XML vector drawable files inside res/drawable.
40
+
41
+ NOTE:
42
+ These drawable files are required because menu items use icons:
43
+ android:icon="@drawable/..."
44
+ -->
45
+
46
+ <?xml version="1.0" encoding="utf-8"?>
47
+ <menu
48
+ xmlns:android="http://schemas.android.com/apk/res/android"
49
+ xmlns:app="http://schemas.android.com/apk/res-auto">
50
+
51
+ <item
52
+ android:id="@+id/overflowMenu"
53
+ android:icon="@drawable/ic_baseline_unfold_less_double_24"
54
+ android:title=""
55
+ app:showAsAction="always">
56
+
57
+ <menu>
58
+
59
+ <item
60
+ android:id="@+id/settings"
61
+ android:icon="@drawable/ic_baseline_settings_24"
62
+ android:title="SETTINGS"
63
+ app:showAsAction="never" />
64
+
65
+ <item
66
+ android:id="@+id/about"
67
+ android:icon="@drawable/ic_baseline_label_24"
68
+ android:title="ABOUT"
69
+ app:showAsAction="never" />
70
+
71
+ <item
72
+ android:id="@+id/exit"
73
+ android:icon="@drawable/ic_baseline_exit_to_app_24"
74
+ android:title="EXIT"
75
+ app:showAsAction="never" />
76
+
77
+ </menu>
78
+
79
+ </item>
80
+
81
+ </menu>
@@ -0,0 +1,58 @@
1
+ package com.example.popmenu
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.widget.Button
6
+ import android.widget.PopupMenu
7
+ import android.widget.Toast
8
+
9
+ class MainActivity : AppCompatActivity() {
10
+
11
+ override fun onCreate(savedInstanceState: Bundle?) {
12
+ super.onCreate(savedInstanceState)
13
+ setContentView(R.layout.activity_main)
14
+
15
+ val B1 = findViewById<Button>(R.id.B1)
16
+
17
+ B1.setOnClickListener {
18
+
19
+ val popupMenu: PopupMenu = PopupMenu(this, B1)
20
+
21
+ popupMenu.menuInflater.inflate(
22
+ R.menu.menu,
23
+ popupMenu.menu
24
+ )
25
+
26
+ popupMenu.setOnMenuItemClickListener { item ->
27
+
28
+ when (item.itemId) {
29
+
30
+ R.id.item1 ->
31
+ Toast.makeText(
32
+ this@MainActivity,
33
+ "You Clicked : " + item.title,
34
+ Toast.LENGTH_SHORT
35
+ ).show()
36
+
37
+ R.id.item2 ->
38
+ Toast.makeText(
39
+ this@MainActivity,
40
+ "You Clicked : " + item.title,
41
+ Toast.LENGTH_SHORT
42
+ ).show()
43
+
44
+ R.id.item3 ->
45
+ Toast.makeText(
46
+ this@MainActivity,
47
+ "You Clicked : " + item.title,
48
+ Toast.LENGTH_SHORT
49
+ ).show()
50
+ }
51
+
52
+ true
53
+ }
54
+
55
+ popupMenu.show()
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,20 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <android.support.constraint.ConstraintLayout
3
+ xmlns:android="http://schemas.android.com/apk/res/android"
4
+ xmlns:app="http://schemas.android.com/apk/res-auto"
5
+ xmlns:tools="http://schemas.android.com/tools"
6
+ android:layout_width="match_parent"
7
+ android:layout_height="match_parent"
8
+ tools:context=".MainActivity">
9
+
10
+ <Button
11
+ android:id="@+id/B1"
12
+ android:layout_width="wrap_content"
13
+ android:layout_height="wrap_content"
14
+ android:text="Popup menu"
15
+ app:layout_constraintTop_toTopOf="parent"
16
+ app:layout_constraintBottom_toBottomOf="parent"
17
+ app:layout_constraintStart_toStartOf="parent"
18
+ app:layout_constraintEnd_toEndOf="parent" />
19
+
20
+ </android.support.constraint.ConstraintLayout>
@@ -0,0 +1,39 @@
1
+ <!--
2
+ Create a Menu XML File
3
+
4
+ 1. In Android Studio, go to:
5
+ res > menu
6
+
7
+ 2. If the menu folder doesn't exist:
8
+ Right-click res → New → Android Resource Directory
9
+ → Select Resource type = menu
10
+
11
+ 3. Create menu file:
12
+ Right-click menu → New → Menu Resource File
13
+ → Name it menu_main.xml
14
+
15
+ 4. Add menu items inside <menu> tag
16
+
17
+ -->
18
+
19
+ <?xml version="1.0" encoding="utf-8"?>
20
+ <menu
21
+ xmlns:android="http://schemas.android.com/apk/res/android"
22
+ xmlns:app="http://schemas.android.com/apk/res-auto">
23
+
24
+ <item
25
+ android:id="@+id/item1"
26
+ android:title="Open"
27
+ app:showAsAction="never" />
28
+
29
+ <item
30
+ android:id="@+id/item2"
31
+ android:title="Search"
32
+ app:showAsAction="never" />
33
+
34
+ <item
35
+ android:id="@+id/item3"
36
+ android:title="Exit"
37
+ app:showAsAction="never" />
38
+
39
+ </menu>
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "madshellnpm",
3
+ "version": "2.0.0",
4
+ "description": "MAD Lab Android Code Generator",
5
+ "main": "index.js",
6
+ "bin": {
7
+ "madlab": "./index.js"
8
+ },
9
+ "type": "module",
10
+ "keywords": [
11
+ "android",
12
+ "kotlin",
13
+ "madlab",
14
+ "generator",
15
+ "bmsce"
16
+ ],
17
+ "author": "KBH",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "chalk": "^5.3.0",
21
+ "figlet": "^1.7.0",
22
+ "fs-extra": "^11.2.0",
23
+ "inquirer": "^9.2.15",
24
+ "madbms": "^1.0.0",
25
+ "madshell": "^1.0.0"
26
+ }
27
+ }
@@ -0,0 +1,47 @@
1
+ package com.example.alertdialog
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.support.v7.app.AlertDialog
6
+ import android.view.View
7
+ import android.widget.Toast
8
+
9
+ class MainActivity : AppCompatActivity() {
10
+
11
+ override fun onCreate(savedInstanceState: Bundle?) {
12
+ super.onCreate(savedInstanceState)
13
+ setContentView(R.layout.activity_main)
14
+ }
15
+
16
+ fun exit(view: View) {
17
+
18
+ val alert = AlertDialog.Builder(this)
19
+
20
+ alert.setTitle("Confirm Exit")
21
+ alert.setIcon(R.drawable.warning)
22
+ alert.setMessage("Are you sure you want to exit?")
23
+ alert.setCancelable(false)
24
+
25
+ alert.setPositiveButton("Yes") { _, _ ->
26
+ finish()
27
+ }
28
+
29
+ alert.setNegativeButton("No") { _, _ ->
30
+ Toast.makeText(
31
+ this,
32
+ "You clicked on No",
33
+ Toast.LENGTH_LONG
34
+ ).show()
35
+ }
36
+
37
+ alert.setNeutralButton("Cancel") { _, _ ->
38
+ Toast.makeText(
39
+ this,
40
+ "You clicked on Cancel",
41
+ Toast.LENGTH_LONG
42
+ ).show()
43
+ }
44
+
45
+ alert.create().show()
46
+ }
47
+ }
@@ -0,0 +1,39 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+
3
+ <RelativeLayout
4
+ xmlns:android="http://schemas.android.com/apk/res/android"
5
+ xmlns:app="http://schemas.android.com/apk/res-auto"
6
+ xmlns:tools="http://schemas.android.com/tools"
7
+ android:layout_width="match_parent"
8
+ android:layout_height="match_parent"
9
+ android:paddingTop="40dp"
10
+ android:paddingBottom="40dp"
11
+ android:paddingLeft="40dp"
12
+ android:paddingRight="40dp"
13
+ tools:context=".MainActivity">
14
+
15
+ <Button
16
+ android:id="@+id/button"
17
+ android:layout_width="wrap_content"
18
+ android:layout_height="wrap_content"
19
+ android:onClick="exit"
20
+ android:textStyle="normal|bold"
21
+ style="@style/Widget.AppCompat.Button.Colored"
22
+ android:layout_alignParentBottom="true"
23
+ android:layout_centerHorizontal="true"
24
+ android:layout_marginBottom="131dp"
25
+ android:text="EXIT" />
26
+
27
+ <TextView
28
+ android:id="@+id/textView"
29
+ android:layout_width="wrap_content"
30
+ android:layout_height="wrap_content"
31
+ android:layout_marginBottom="68dp"
32
+ android:layout_above="@id/button"
33
+ android:layout_centerHorizontal="true"
34
+ android:textSize="18sp"
35
+ android:textStyle="normal|bold"
36
+ android:gravity="center"
37
+ android:text="Click over button to exit" />
38
+
39
+ </RelativeLayout>
@@ -0,0 +1,70 @@
1
+ package com.example.animations
2
+
3
+ import android.support.v7.app.AppCompatActivity
4
+ import android.os.Bundle
5
+ import android.os.Handler
6
+ import android.view.View
7
+ import android.view.animation.AnimationUtils
8
+ import android.widget.Button
9
+ import android.widget.TextView
10
+ import java.util.Collections.rotate
11
+
12
+ class MainActivity : AppCompatActivity() {
13
+
14
+ override fun onCreate(savedInstanceState: Bundle?) {
15
+ super.onCreate(savedInstanceState)
16
+ setContentView(R.layout.activity_main)
17
+
18
+ val image = findViewById<TextView>(R.id.textView)
19
+
20
+ findViewById<Button>(R.id.fade_in).setOnClickListener {
21
+ val animationFadeIn =
22
+ AnimationUtils.loadAnimation(this, R.anim.fade_in)
23
+ image.startAnimation(animationFadeIn)
24
+ }
25
+
26
+ findViewById<Button>(R.id.fade_out).setOnClickListener {
27
+ val animationFadeOut =
28
+ AnimationUtils.loadAnimation(this, R.anim.fade_out)
29
+ image.startAnimation(animationFadeOut)
30
+ }
31
+
32
+ findViewById<Button>(R.id.zoom_in).setOnClickListener {
33
+ val animationZoomIn =
34
+ AnimationUtils.loadAnimation(this, R.anim.zoom_in)
35
+ image.startAnimation(animationZoomIn)
36
+ }
37
+
38
+ findViewById<Button>(R.id.zoom_out).setOnClickListener {
39
+ val animationZoomOut =
40
+ AnimationUtils.loadAnimation(this, R.anim.zoom_out)
41
+ image.startAnimation(animationZoomOut)
42
+ }
43
+
44
+ findViewById<Button>(R.id.slide_up).setOnClickListener {
45
+ val animationZoomIn =
46
+ AnimationUtils.loadAnimation(this, R.anim.slide_up)
47
+ image.startAnimation(animationZoomIn)
48
+ }
49
+
50
+ findViewById<Button>(R.id.slide_down).setOnClickListener {
51
+ val animationZoomIn =
52
+ AnimationUtils.loadAnimation(this, R.anim.slide_down)
53
+ image.startAnimation(animationZoomIn)
54
+ }
55
+
56
+ val bounceAnimation =
57
+ AnimationUtils.loadAnimation(this, R.anim.bounce)
58
+
59
+ findViewById<Button>(R.id.bounce).setOnClickListener {
60
+ image.startAnimation(bounceAnimation)
61
+ }
62
+
63
+ findViewById<Button>(R.id.rotate).setOnClickListener {
64
+ image.animate().apply {
65
+ duration = 1000
66
+ rotationXBy(360f)
67
+ }.start()
68
+ }
69
+ }
70
+ }