Remove useless interfaces

This commit is contained in:
Matthieu 2020-12-20 18:39:50 +01:00
parent 7d78b03ff2
commit 77e30cf04c
8 changed files with 21 additions and 55 deletions

View File

@ -32,8 +32,6 @@ import com.google.android.material.tabs.TabLayout
import com.h.pixeldroid.adapters.EditPhotoViewPagerAdapter import com.h.pixeldroid.adapters.EditPhotoViewPagerAdapter
import com.h.pixeldroid.fragments.EditImageFragment import com.h.pixeldroid.fragments.EditImageFragment
import com.h.pixeldroid.fragments.FilterListFragment import com.h.pixeldroid.fragments.FilterListFragment
import com.h.pixeldroid.interfaces.EditImageFragmentListener
import com.h.pixeldroid.interfaces.FilterListFragmentListener
import com.h.pixeldroid.utils.NonSwipeableViewPager import com.h.pixeldroid.utils.NonSwipeableViewPager
import com.yalantis.ucrop.UCrop import com.yalantis.ucrop.UCrop
import com.zomato.photofilters.imageprocessors.Filter import com.zomato.photofilters.imageprocessors.Filter
@ -58,7 +56,7 @@ private const val REQUEST_CODE_PERMISSIONS_SEND_PHOTO = 7
private val REQUIRED_PERMISSIONS = arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE, private val REQUIRED_PERMISSIONS = arrayOf(android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE) android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
class PhotoEditActivity : BaseActivity(), FilterListFragmentListener, EditImageFragmentListener { class PhotoEditActivity : BaseActivity() {
internal var saving: Boolean = false internal var saving: Boolean = false
private val BITMAP_CONFIG = Bitmap.Config.ARGB_8888 private val BITMAP_CONFIG = Bitmap.Config.ARGB_8888
@ -189,7 +187,7 @@ class PhotoEditActivity : BaseActivity(), FilterListFragmentListener, EditImageF
} }
//</editor-fold> //</editor-fold>
override fun onFilterSelected(filter: Filter) { fun onFilterSelected(filter: Filter) {
resetControls() resetControls()
filteredImage = compressedOriginalImage!!.copy(BITMAP_CONFIG, true) filteredImage = compressedOriginalImage!!.copy(BITMAP_CONFIG, true)
image_preview.setImageBitmap(filter.processFilter(filteredImage)) image_preview.setImageBitmap(filter.processFilter(filteredImage))
@ -219,21 +217,21 @@ class PhotoEditActivity : BaseActivity(), FilterListFragmentListener, EditImageF
} }
} }
override fun onBrightnessChange(brightness: Int) { fun onBrightnessChange(brightness: Int) {
brightnessFinal = brightness brightnessFinal = brightness
val myFilter = Filter() val myFilter = Filter()
myFilter.addEditFilters(brightness, saturationFinal, contrastFinal) myFilter.addEditFilters(brightness, saturationFinal, contrastFinal)
applyFilterAndShowImage(myFilter, filteredImage) applyFilterAndShowImage(myFilter, filteredImage)
} }
override fun onSaturationChange(saturation: Float) { fun onSaturationChange(saturation: Float) {
saturationFinal = saturation saturationFinal = saturation
val myFilter = Filter() val myFilter = Filter()
myFilter.addEditFilters(brightnessFinal, saturation, contrastFinal) myFilter.addEditFilters(brightnessFinal, saturation, contrastFinal)
applyFilterAndShowImage(myFilter, filteredImage) applyFilterAndShowImage(myFilter, filteredImage)
} }
override fun onContrastChange(contrast: Float) { fun onContrastChange(contrast: Float) {
contrastFinal = contrast contrastFinal = contrast
val myFilter = Filter() val myFilter = Filter()
myFilter.addEditFilters(brightnessFinal, saturationFinal, contrast) myFilter.addEditFilters(brightnessFinal, saturationFinal, contrast)
@ -247,10 +245,10 @@ class PhotoEditActivity : BaseActivity(), FilterListFragmentListener, EditImageF
return this return this
} }
override fun onEditStarted() { fun onEditStarted() {
} }
override fun onEditCompleted() { fun onEditCompleted() {
val myFilter = Filter() val myFilter = Filter()
myFilter.addEditFilters(brightnessFinal, saturationFinal, contrastFinal) myFilter.addEditFilters(brightnessFinal, saturationFinal, contrastFinal)
val bitmap = filteredImage.copy(BITMAP_CONFIG, true) val bitmap = filteredImage.copy(BITMAP_CONFIG, true)

View File

@ -18,7 +18,6 @@ import com.bumptech.glide.Glide
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
import com.h.pixeldroid.api.PixelfedAPI import com.h.pixeldroid.api.PixelfedAPI
import com.h.pixeldroid.db.entities.UserDatabaseEntity import com.h.pixeldroid.db.entities.UserDatabaseEntity
import com.h.pixeldroid.interfaces.PostCreationListener
import com.h.pixeldroid.objects.Attachment import com.h.pixeldroid.objects.Attachment
import com.h.pixeldroid.objects.Instance import com.h.pixeldroid.objects.Instance
import com.h.pixeldroid.objects.Status import com.h.pixeldroid.objects.Status
@ -37,7 +36,7 @@ private val TAG = "Post Creation Activity"
private val MORE_PICTURES_REQUEST_CODE = 0xffff private val MORE_PICTURES_REQUEST_CODE = 0xffff
class PostCreationActivity : BaseActivity(), PostCreationListener { class PostCreationActivity : BaseActivity() {
private lateinit var recycler : RecyclerView private lateinit var recycler : RecyclerView
private lateinit var adapter : PostCreationAdapter private lateinit var adapter : PostCreationAdapter
@ -95,7 +94,6 @@ class PostCreationActivity : BaseActivity(), PostCreationListener {
upload() upload()
adapter = PostCreationAdapter(posts) adapter = PostCreationAdapter(posts)
adapter.listener = this
recycler = findViewById(R.id.image_grid) recycler = findViewById(R.id.image_grid)
recycler.layoutManager = GridLayoutManager(this, 3) recycler.layoutManager = GridLayoutManager(this, 3)
recycler.adapter = adapter recycler.adapter = adapter
@ -252,7 +250,7 @@ class PostCreationActivity : BaseActivity(), PostCreationListener {
} }
override fun onClick(position: Int) { fun onClick(position: Int) {
positionResult = position positionResult = position
val intent = Intent(this, PhotoEditActivity::class.java) val intent = Intent(this, PhotoEditActivity::class.java)
@ -296,7 +294,6 @@ class PostCreationActivity : BaseActivity(), PostCreationListener {
} }
inner class PostCreationAdapter(private val posts: ArrayList<String>): RecyclerView.Adapter<PostCreationAdapter.ViewHolder>() { inner class PostCreationAdapter(private val posts: ArrayList<String>): RecyclerView.Adapter<PostCreationAdapter.ViewHolder>() {
var listener: PostCreationListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val view = val view =
@ -335,7 +332,7 @@ class PostCreationActivity : BaseActivity(), PostCreationListener {
.into(itemView.galleryImage) .into(itemView.galleryImage)
// adding click or tap handler for the image layout // adding click or tap handler for the image layout
itemView.setOnClickListener { itemView.setOnClickListener {
listener?.onClick(adapterPosition) this@PostCreationActivity.onClick(adapterPosition)
} }
} }

View File

@ -8,14 +8,15 @@ import android.widget.ImageView
import android.widget.TextView import android.widget.TextView
import androidx.core.content.ContextCompat import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.h.pixeldroid.PhotoEditActivity
import com.h.pixeldroid.R import com.h.pixeldroid.R
import com.h.pixeldroid.interfaces.FilterListFragmentListener import com.h.pixeldroid.fragments.FilterListFragment
import com.zomato.photofilters.utils.ThumbnailItem import com.zomato.photofilters.utils.ThumbnailItem
import kotlinx.android.synthetic.main.thumbnail_list_item.view.* import kotlinx.android.synthetic.main.thumbnail_list_item.view.*
class ThumbnailAdapter (private val context: Context, class ThumbnailAdapter (private val context: Context,
private val tbItemList: List<ThumbnailItem>, private val tbItemList: List<ThumbnailItem>,
private val listener: FilterListFragmentListener): RecyclerView.Adapter<ThumbnailAdapter.MyViewHolder>() { private val listener: FilterListFragment): RecyclerView.Adapter<ThumbnailAdapter.MyViewHolder>() {
private var selectedIndex = 0 private var selectedIndex = 0

View File

@ -6,12 +6,12 @@ import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.SeekBar import android.widget.SeekBar
import com.h.pixeldroid.PhotoEditActivity
import com.h.pixeldroid.R import com.h.pixeldroid.R
import com.h.pixeldroid.interfaces.EditImageFragmentListener
class EditImageFragment : Fragment(), SeekBar.OnSeekBarChangeListener { class EditImageFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
private var listener: EditImageFragmentListener? = null private var listener: PhotoEditActivity? = null
private lateinit var seekbarBrightness: SeekBar private lateinit var seekbarBrightness: SeekBar
private lateinit var seekbarSaturation: SeekBar private lateinit var seekbarSaturation: SeekBar
@ -86,7 +86,7 @@ class EditImageFragment : Fragment(), SeekBar.OnSeekBarChangeListener {
listener!!.onEditCompleted() listener!!.onEditCompleted()
} }
fun setListener(listener: EditImageFragmentListener) { fun setListener(listener: PhotoEditActivity) {
this.listener = listener this.listener = listener
} }
} }

View File

@ -1,34 +1,29 @@
package com.h.pixeldroid.fragments package com.h.pixeldroid.fragments
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.ImageDecoder
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
import android.util.Log
import android.util.TypedValue import android.util.TypedValue
import androidx.fragment.app.Fragment
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.graphics.decodeBitmap import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.DefaultItemAnimator import androidx.recyclerview.widget.DefaultItemAnimator
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.h.pixeldroid.PhotoEditActivity import com.h.pixeldroid.PhotoEditActivity
import com.h.pixeldroid.R import com.h.pixeldroid.R
import com.h.pixeldroid.adapters.ThumbnailAdapter import com.h.pixeldroid.adapters.ThumbnailAdapter
import com.h.pixeldroid.interfaces.FilterListFragmentListener
import com.h.pixeldroid.utils.SpaceItemDecoration import com.h.pixeldroid.utils.SpaceItemDecoration
import com.zomato.photofilters.FilterPack import com.zomato.photofilters.FilterPack
import com.zomato.photofilters.imageprocessors.Filter import com.zomato.photofilters.imageprocessors.Filter
import com.zomato.photofilters.utils.ThumbnailItem import com.zomato.photofilters.utils.ThumbnailItem
import com.zomato.photofilters.utils.ThumbnailsManager import com.zomato.photofilters.utils.ThumbnailsManager
class FilterListFragment : Fragment(), FilterListFragmentListener { class FilterListFragment : Fragment() {
internal lateinit var recyclerView: RecyclerView internal lateinit var recyclerView: RecyclerView
internal var listener : FilterListFragmentListener? = null internal var listener : PhotoEditActivity? = null
internal lateinit var adapter: ThumbnailAdapter internal lateinit var adapter: ThumbnailAdapter
internal lateinit var tbItemList: MutableList<ThumbnailItem> internal lateinit var tbItemList: MutableList<ThumbnailItem>
@ -107,13 +102,13 @@ class FilterListFragment : Fragment(), FilterListFragmentListener {
} }
} }
override fun onFilterSelected(filter: Filter) { fun onFilterSelected(filter: Filter) {
if(listener != null ){ if(listener != null ){
listener!!.onFilterSelected(filter) listener!!.onFilterSelected(filter)
} }
} }
fun setListener(listFragmentListener: FilterListFragmentListener) { fun setListener(listFragmentListener: PhotoEditActivity) {
this.listener = listFragmentListener this.listener = listFragmentListener
} }
} }

View File

@ -1,13 +0,0 @@
package com.h.pixeldroid.interfaces
interface EditImageFragmentListener {
fun onBrightnessChange(brightness: Int)
fun onSaturationChange(saturation: Float)
fun onContrastChange(contrast: Float)
fun onEditStarted()
fun onEditCompleted()
}

View File

@ -1,7 +0,0 @@
package com.h.pixeldroid.interfaces
import com.zomato.photofilters.imageprocessors.Filter
interface FilterListFragmentListener {
fun onFilterSelected(filter: Filter)
}

View File

@ -1,5 +0,0 @@
package com.h.pixeldroid.interfaces
interface PostCreationListener {
fun onClick(position: Int)
}