-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Release v1.3.0
- Loading branch information
Showing
34 changed files
with
388 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.fossasia.badgemagic.adapter | ||
|
||
import android.graphics.Bitmap | ||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import android.widget.Toast | ||
import androidx.recyclerview.widget.RecyclerView | ||
import androidx.databinding.DataBindingUtil | ||
import org.fossasia.badgemagic.R | ||
import org.fossasia.badgemagic.databinding.RecyclerItemSavedClipartBinding | ||
import org.fossasia.badgemagic.viewmodels.SavedClipartViewModel | ||
|
||
class SavedClipartsAdapter( | ||
private var clipartList: List<Bitmap>, | ||
private val viewModel: SavedClipartViewModel | ||
) : RecyclerView.Adapter<SavedClipartsViewHolder>() { | ||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SavedClipartsViewHolder { | ||
val binding = DataBindingUtil.inflate<RecyclerItemSavedClipartBinding>(LayoutInflater.from(parent.context), R.layout.recycler_item_saved_clipart, parent, false) | ||
return SavedClipartsViewHolder(binding) | ||
} | ||
|
||
override fun getItemCount(): Int = clipartList.size | ||
|
||
override fun onBindViewHolder(holder: SavedClipartsViewHolder, position: Int) { | ||
holder.bind(clipartList[position]) | ||
holder.getBindingView().setOnClickListener { | ||
viewModel.deleteClipart(position) | ||
Toast.makeText(it.context, "Delete Clipart Successfully", Toast.LENGTH_LONG).show() | ||
} | ||
} | ||
|
||
fun setList(list: List<Bitmap>) { | ||
clipartList = list | ||
notifyDataSetChanged() | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/org/fossasia/badgemagic/adapter/SavedClipartsViewHolder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.fossasia.badgemagic.adapter | ||
|
||
import android.graphics.Bitmap | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.fossasia.badgemagic.databinding.RecyclerItemSavedClipartBinding | ||
|
||
class SavedClipartsViewHolder(private val binding: RecyclerItemSavedClipartBinding) : RecyclerView.ViewHolder(binding.root) { | ||
fun bind(bitmap: Bitmap) { | ||
binding.bitmap = bitmap | ||
} | ||
|
||
fun getBindingView() = binding.root | ||
} |
20 changes: 20 additions & 0 deletions
20
app/src/main/java/org/fossasia/badgemagic/bindings/SavedClipartsViewBindings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.fossasia.badgemagic.bindings | ||
|
||
import android.graphics.Bitmap | ||
import androidx.databinding.BindingAdapter | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import androidx.recyclerview.widget.RecyclerView | ||
import org.fossasia.badgemagic.adapter.SavedClipartsAdapter | ||
import org.fossasia.badgemagic.ui.custom.SquareImageView | ||
import org.fossasia.badgemagic.util.ImageUtils | ||
|
||
@BindingAdapter("setAdapter") | ||
fun setSavedClipRecyclerAdapter(recyclerView: RecyclerView, adapter: SavedClipartsAdapter) { | ||
recyclerView.layoutManager = LinearLayoutManager(recyclerView.context) | ||
recyclerView.adapter = adapter | ||
} | ||
|
||
@BindingAdapter("bindImage") | ||
fun bindImage(imageView: SquareImageView, image: Bitmap) { | ||
imageView.setImageBitmap(ImageUtils.trim(image, 200)) | ||
} |
5 changes: 5 additions & 0 deletions
5
app/src/main/java/org/fossasia/badgemagic/data/SavedClipart.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.fossasia.badgemagic.data | ||
|
||
import android.graphics.Bitmap | ||
|
||
data class SavedClipart(val fileName: String, val bitmap: Bitmap) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/src/main/java/org/fossasia/badgemagic/ui/fragments/SavedClipartFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.fossasia.badgemagic.ui.fragments | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.databinding.DataBindingUtil | ||
import org.fossasia.badgemagic.R | ||
import org.fossasia.badgemagic.databinding.FragmentSavedClipartsBinding | ||
import org.fossasia.badgemagic.ui.base.BaseFragment | ||
import org.fossasia.badgemagic.viewmodels.SavedClipartViewModel | ||
import org.koin.androidx.viewmodel.ext.android.viewModel | ||
|
||
class SavedClipartFragment : BaseFragment() { | ||
|
||
companion object { | ||
@JvmStatic | ||
fun newInstance() = | ||
SavedClipartFragment() | ||
} | ||
|
||
private val viewModel by viewModel<SavedClipartViewModel>() | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
val binding = DataBindingUtil.inflate<FragmentSavedClipartsBinding>(inflater, R.layout.fragment_saved_cliparts, container, false) | ||
binding.viewModel = viewModel | ||
return binding.root | ||
} | ||
} |
Oops, something went wrong.