diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 13f625a..8a35274 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,9 +1,9 @@ - + - + + + - + + diff --git a/app/src/main/java/com/example/testes/ImageGridAdapter.kt b/app/src/main/java/com/example/testes/ImageGridAdapter.kt deleted file mode 100644 index 1332952..0000000 --- a/app/src/main/java/com/example/testes/ImageGridAdapter.kt +++ /dev/null @@ -1,40 +0,0 @@ -package com.example.testes - -import android.content.Context -import android.util.Log -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.ImageView -import android.widget.TextView -import androidx.core.content.ContextCompat.getDrawable -import androidx.recyclerview.widget.RecyclerView -import com.bumptech.glide.Glide - -class ImageGridAdapter(val imageList: List) : - RecyclerView.Adapter() { - - lateinit var context: Context; - - /* Creates and inflates view and return FlowerViewHolder. */ - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { - context = parent.context; - val view = LayoutInflater.from(parent.context) - .inflate(R.layout.image_grid_item, parent, false) - return ViewHolder(view) - } - - /* Gets current flower and uses it to bind view. */ - override fun onBindViewHolder(holder: ViewHolder, position: Int) { - Glide.with(context) - .load(imageList[position].preview_url) - .placeholder(getDrawable(context, R.drawable.ic_launcher_foreground)) - .into(holder.imageview) - } - - inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { - var imageview: ImageView = itemView.findViewById(R.id.image) - } - - override fun getItemCount(): Int = imageList.size -} \ No newline at end of file diff --git a/app/src/main/java/com/example/testes/ImageGridFragment.kt b/app/src/main/java/com/example/testes/ImageGridFragment.kt index 780d2c1..6906712 100644 --- a/app/src/main/java/com/example/testes/ImageGridFragment.kt +++ b/app/src/main/java/com/example/testes/ImageGridFragment.kt @@ -1,12 +1,16 @@ package com.example.testes +import android.content.Context import android.os.Bundle import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.widget.ImageView +import androidx.core.content.ContextCompat import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide class ImageGridFragment(val images: List) : Fragment() { @@ -27,4 +31,32 @@ class ImageGridFragment(val images: List) : Fragment() { return layoutView } + + inner class ImageGridAdapter(val imageList: List) : + RecyclerView.Adapter() { + + lateinit var context: Context; + + /* Creates and inflates view and return FlowerViewHolder. */ + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + context = parent.context; + val view = LayoutInflater.from(parent.context) + .inflate(R.layout.image_grid_item, parent, false) + return ViewHolder(view) + } + + /* Gets current flower and uses it to bind view. */ + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + Glide.with(context) + .load(imageList[position].preview_url) + .placeholder(ContextCompat.getDrawable(context, R.drawable.ic_launcher_foreground)) + .into(holder.imageview) + } + + inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + var imageview: ImageView = itemView.findViewById(R.id.image) + } + + override fun getItemCount(): Int = imageList.size + } } \ No newline at end of file diff --git a/app/src/main/java/com/example/testes/ImageViewerActivity.kt b/app/src/main/java/com/example/testes/ImageViewerActivity.kt new file mode 100644 index 0000000..514945d --- /dev/null +++ b/app/src/main/java/com/example/testes/ImageViewerActivity.kt @@ -0,0 +1,11 @@ +package com.example.testes + +import androidx.appcompat.app.AppCompatActivity +import android.os.Bundle + +class ImageViewerActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_image_viewer) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/testes/MainActivity.kt b/app/src/main/java/com/example/testes/MainActivity.kt index 45d7633..0999033 100644 --- a/app/src/main/java/com/example/testes/MainActivity.kt +++ b/app/src/main/java/com/example/testes/MainActivity.kt @@ -1,12 +1,9 @@ package com.example.testes -import android.app.SearchManager import androidx.appcompat.app.AppCompatActivity import android.os.Bundle import android.util.Log -import android.widget.TextView import androidx.appcompat.widget.SearchView -import androidx.fragment.app.Fragment import com.example.testes.databinding.ActivityMainBinding import org.json.JSONArray import org.json.JSONException @@ -39,7 +36,7 @@ class MainActivity : AppCompatActivity() { search("") binding.search.setOnQueryTextListener(object : - android.widget.SearchView.OnQueryTextListener { + SearchView.OnQueryTextListener { override fun onQueryTextChange(newText: String): Boolean { return false } diff --git a/app/src/main/res/layout/activity_image_viewer.xml b/app/src/main/res/layout/activity_image_viewer.xml new file mode 100644 index 0000000..9c848c4 --- /dev/null +++ b/app/src/main/res/layout/activity_image_viewer.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 6004eef..92ced03 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -7,26 +7,20 @@ android:orientation="vertical" tools:context=".MainActivity"> - + app:contentInsetStart="0dp"> + app:cardCornerRadius="7.5dp"> - - - +