Skip to content

Commit

Permalink
Merge pull request #5 from TanishMoral11/main
Browse files Browse the repository at this point in the history
Complete
  • Loading branch information
TanishMoral11 authored Jul 16, 2024
2 parents 263fd97 + 10237c9 commit d37f08b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ dependencies {
implementation ("com.google.code.gson:gson:2.9.1")
implementation ("com.squareup.retrofit2:retrofit:2.9.0")
implementation("com.squareup.retrofit2:converter-gson:2.9.0")
implementation ("com.github.bumptech.glide:glide:4.16.0")

}
3 changes: 3 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/example/randommemes/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bumptech.glide.Glide
import com.example.randommemes.databinding.ActivityMainBinding
import retrofit2.Call
import retrofit2.Callback
Expand All @@ -27,6 +28,10 @@ class MainActivity : AppCompatActivity() {
insets
}
getData()

binding.btnNewMeme.setOnClickListener {
getData()
}
}

private fun getData() {
Expand All @@ -41,6 +46,11 @@ class MainActivity : AppCompatActivity() {
call: Call<responseDataclass?>,
response: Response<responseDataclass?>
) {

binding.memeAuthor.text = response.body()?.author
binding.memeTitle.text = response.body()?.title
Glide.with(this@MainActivity).load(response.body()?.url).into(binding.memeImage);

progressDialog.dismiss()
}

Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@

<ImageView
android:id="@+id/memeImage"
android:layout_height="350dp"
android:layout_width="match_parent"
android:scaleType="centerCrop"
/>
android:layout_height="370dp"
android:scaleType="fitCenter"
/>

<TextView
android:id="@+id/memeAuthor"
Expand All @@ -35,4 +35,4 @@
android:layout_width="200dp"
android:layout_height="wrap_content"
android:text="New Meme" />
</LinearLayout>
</LinearLayout>

0 comments on commit d37f08b

Please sign in to comment.