Skip to content

Commit 8c3a97e

Browse files
committed
Image Component Updated
1 parent 63d2abb commit 8c3a97e

File tree

13 files changed

+223
-11
lines changed

13 files changed

+223
-11
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
android:roundIcon="@mipmap/ic_launcher_round"
1313
android:supportsRtl="true"
1414
android:theme="@style/AppTheme">
15+
<activity android:name=".Image.ImageSwitcher.ImageswitcherActivity">
16+
</activity>
17+
<activity android:name=".Image.ImageView.ImageViewActivity">
18+
</activity>
19+
<activity android:name=".Image.ImageActivity">
20+
</activity>
21+
<activity android:name=".Image.ImageButton.ImageButtonActivity">
22+
</activity>
1523
<activity android:name=".AlertDialog.EditTextInAlertDialog.EditTextAlertDialogActivity">
1624
</activity>
1725
<activity android:name=".AlertDialog.ListViewInAlertDialog.ListViewAlertDialogActivity">

app/src/main/java/source/open/akash/kotlinexample/AlertDialog/EditTextInAlertDialog/EditTextAlertDialogActivity.kt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,8 @@ import kotlinx.android.synthetic.main.activity_edit_text_alert_dialog.*
1010
import source.open.akash.kotlinexample.R
1111

1212
class EditTextAlertDialogActivity : AppCompatActivity() {
13-
val positiveButtonClick = { dialog: DialogInterface, which: Int ->
14-
Toast.makeText(
15-
applicationContext,
16-
"Done", Toast.LENGTH_SHORT
17-
).show()
18-
}
19-
val negativeButtonClick = { dialog: DialogInterface, which: Int ->
13+
14+
val negativeButtonClick = { _: DialogInterface, which: Int ->
2015
finish()
2116
}
2217

@@ -34,10 +29,10 @@ class EditTextAlertDialogActivity : AppCompatActivity() {
3429
setView(view)
3530
setCancelable(false)
3631
setPositiveButton("Login") { _, _ ->
37-
if (edtName.text.isNullOrEmpty()) {
32+
if (edtName.text.isNullOrEmpty() && edtPassword.text.isNullOrEmpty()) {
3833
Toast.makeText(
3934
applicationContext,
40-
"Please Enter Name", Toast.LENGTH_SHORT
35+
"Empty User ID or Password", Toast.LENGTH_SHORT
4136
).show()
4237

4338
} else {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package source.open.akash.kotlinexample.Image
2+
3+
import android.content.Intent
4+
import android.os.Bundle
5+
import androidx.appcompat.app.AppCompatActivity
6+
import kotlinx.android.synthetic.main.activity_image.*
7+
import source.open.akash.kotlinexample.Image.ImageButton.ImageButtonActivity
8+
import source.open.akash.kotlinexample.Image.ImageSwitcher.ImageswitcherActivity
9+
import source.open.akash.kotlinexample.Image.ImageView.ImageViewActivity
10+
import source.open.akash.kotlinexample.R
11+
12+
class ImageActivity : AppCompatActivity() {
13+
14+
override fun onCreate(savedInstanceState: Bundle?) {
15+
super.onCreate(savedInstanceState)
16+
setContentView(R.layout.activity_image)
17+
18+
imageViewDemo.setOnClickListener {
19+
val intent = Intent(this, ImageViewActivity::class.java)
20+
startActivity(intent)
21+
}
22+
imageButtonDemo.setOnClickListener {
23+
val intent = Intent(this, ImageButtonActivity::class.java)
24+
startActivity(intent)
25+
}
26+
imageSwitcherDemo.setOnClickListener {
27+
val intent = Intent(this, ImageswitcherActivity::class.java)
28+
startActivity(intent)
29+
}
30+
31+
}
32+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package source.open.akash.kotlinexample.Image.ImageButton
2+
3+
import android.os.Bundle
4+
import android.widget.Toast
5+
import androidx.appcompat.app.AppCompatActivity
6+
import kotlinx.android.synthetic.main.activity_image_button.*
7+
import source.open.akash.kotlinexample.R
8+
9+
class ImageButtonActivity : AppCompatActivity() {
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_image_button)
14+
imageButton.setOnClickListener {
15+
Toast.makeText(applicationContext, "Image Button Pressed", Toast.LENGTH_SHORT).show()
16+
}
17+
}
18+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package source.open.akash.kotlinexample.Image.ImageSwitcher
2+
3+
import android.os.Bundle
4+
import android.widget.ImageView
5+
import androidx.appcompat.app.AppCompatActivity
6+
import kotlinx.android.synthetic.main.activity_imageswitcher.*
7+
import source.open.akash.kotlinexample.R
8+
9+
class ImageswitcherActivity : AppCompatActivity() {
10+
var index = -1
11+
var arrImage =
12+
intArrayOf(R.drawable.ic_audiotrack, R.drawable.ic_volume_off_black, R.drawable.ic_volume_up_black_24dp)
13+
14+
15+
override fun onCreate(savedInstanceState: Bundle?) {
16+
super.onCreate(savedInstanceState)
17+
setContentView(R.layout.activity_imageswitcher)
18+
imageSwitcher.setFactory {
19+
val imageView = ImageView(applicationContext)
20+
imageView.scaleType = ImageView.ScaleType.FIT_XY
21+
imageView
22+
23+
}
24+
25+
prevImage.setOnClickListener {
26+
if (index > 0) {
27+
index -= 1
28+
imageSwitcher.setImageResource(arrImage[index])
29+
}
30+
}
31+
nextImage.setOnClickListener {
32+
if (index < arrImage.size - 1) {
33+
index += 1
34+
imageSwitcher.setImageResource(arrImage[index])
35+
}
36+
}
37+
38+
39+
}
40+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package source.open.akash.kotlinexample.Image.ImageView
2+
3+
import android.os.Bundle
4+
import android.widget.Toast
5+
import androidx.appcompat.app.AppCompatActivity
6+
import kotlinx.android.synthetic.main.activity_image_view.*
7+
import source.open.akash.kotlinexample.R
8+
9+
class ImageViewActivity : AppCompatActivity() {
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_image_view)
14+
imageView.setOnClickListener {
15+
Toast.makeText(applicationContext, "Image View Pressed", Toast.LENGTH_SHORT).show()
16+
}
17+
}
18+
}

app/src/main/java/source/open/akash/kotlinexample/MainActivity.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import android.os.Bundle
55
import androidx.appcompat.app.AppCompatActivity
66
import kotlinx.android.synthetic.main.activity_main.*
77
import source.open.akash.kotlinexample.AlertDialog.AlertDialogActivity
8+
import source.open.akash.kotlinexample.Image.ImageActivity
89
import source.open.akash.kotlinexample.Toast.ToastActivity
910
import source.open.akash.kotlinexample.Widgets.Widgets
1011

@@ -30,6 +31,10 @@ class MainActivity : AppCompatActivity() {
3031
startActivity(Intent(this@MainActivity, AlertDialogActivity::class.java))
3132

3233
}
34+
ImageActivityDemo.setOnClickListener {
35+
startActivity(Intent(this@MainActivity, ImageActivity::class.java))
36+
37+
}
3338

3439
}
3540
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
android:orientation="vertical"
8+
tools:context=".Image.ImageActivity">
9+
10+
<TextView android:id="@+id/imageViewDemo"
11+
android:layout_height="wrap_content"
12+
android:text="ImageView"
13+
android:padding="10dp"
14+
android:layout_margin="15dp"
15+
android:background="@drawable/rectshape"
16+
android:layout_width="wrap_content"/>
17+
<TextView android:id="@+id/imageButtonDemo"
18+
android:layout_height="wrap_content"
19+
android:text="ImageButton Demo"
20+
android:layout_margin="15dp"
21+
android:padding="10dp"
22+
android:background="@drawable/rectshape"
23+
android:layout_width="wrap_content"/>
24+
<TextView android:id="@+id/imageSwitcherDemo"
25+
android:layout_height="wrap_content"
26+
android:text="ImageSwitcher Demo"
27+
android:layout_margin="15dp"
28+
android:padding="10dp"
29+
android:background="@drawable/rectshape"
30+
android:layout_width="wrap_content"/>
31+
</LinearLayout>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".Image.ImageButton.ImageButtonActivity">
9+
10+
<ImageButton
11+
app:layout_constraintLeft_toLeftOf="parent"
12+
app:layout_constraintRight_toRightOf="parent"
13+
app:layout_constraintBottom_toBottomOf="parent"
14+
app:layout_constraintTop_toTopOf="parent"
15+
android:src="@drawable/ic_audiotrack"
16+
android:layout_width="200dp"
17+
android:layout_height="100dp"
18+
android:id="@+id/imageButton"/>
19+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<androidx.constraintlayout.widget.ConstraintLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
xmlns:app="http://schemas.android.com/apk/res-auto"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent"
8+
tools:context=".Image.ImageView.ImageViewActivity">
9+
<ImageView
10+
app:layout_constraintLeft_toLeftOf="parent"
11+
app:layout_constraintRight_toRightOf="parent"
12+
app:layout_constraintBottom_toBottomOf="parent"
13+
app:layout_constraintTop_toTopOf="parent"
14+
android:src="@drawable/ic_audiotrack"
15+
android:layout_width="200dp"
16+
android:contentDescription="Image Logo"
17+
android:layout_height="100dp"
18+
android:id="@+id/imageView"/>
19+
</androidx.constraintlayout.widget.ConstraintLayout>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".Image.ImageSwitcher.ImageswitcherActivity">
8+
<ImageSwitcher android:id="@+id/imageSwitcher"
9+
android:layout_centerInParent="true"
10+
android:layout_width="match_parent"
11+
android:layout_height="400dp"/>
12+
<TableRow android:layout_height="wrap_content"
13+
android:layout_alignParentBottom="true"
14+
android:layout_width="match_parent">
15+
<Button android:layout_height="wrap_content"
16+
android:layout_weight="1"
17+
android:id="@+id/prevImage"
18+
android:text="Previous"
19+
android:layout_width="0dp"/>
20+
<Button android:layout_height="wrap_content"
21+
android:text="Next"
22+
android:id="@+id/nextImage"
23+
android:layout_weight="1"
24+
android:layout_width="0dp"/>
25+
26+
</TableRow>
27+
</RelativeLayout>

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
android:background="#ffffff"
4848
android:layout_width="10dp"/>
4949
<TextView
50-
50+
android:id="@+id/ImageActivityDemo"
5151
android:text="Image"
5252

5353
android:gravity="center"

0 commit comments

Comments
 (0)