-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
100 changed files
with
1,733 additions
and
291 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
46 changes: 46 additions & 0 deletions
46
RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityTMarker.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,46 @@ | ||
package com.tamsiree.rxdemo.activity | ||
|
||
import android.os.Bundle | ||
import androidx.recyclerview.widget.LinearLayoutManager | ||
import com.tamsiree.rxdemo.R | ||
import com.tamsiree.rxdemo.adapter.AdapterTMarker | ||
import com.tamsiree.rxdemo.repository.RepositoryDummySwipe | ||
import com.tamsiree.rxdemo.viewholder.ViewHolderSwipeable | ||
import com.tamsiree.rxui.activity.ActivityBase | ||
import com.tamsiree.rxui.view.mark.TMarker | ||
import kotlinx.android.synthetic.main.activity_tmarker.* | ||
|
||
class ActivityTMarker : ActivityBase() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_tmarker) | ||
} | ||
|
||
override fun initView() { | ||
val tMarker = TMarker.with(covertConfig) | ||
.setIsActiveCallback { | ||
it is ViewHolderSwipeable && repository.isActive(it.adapterPosition) | ||
} | ||
.doOnSwipe { viewHolder, _ -> | ||
repository.toggleActiveState(viewHolder.adapterPosition) | ||
} | ||
.attachTo(recyclerView) | ||
|
||
recyclerView.adapter = AdapterTMarker(tMarker) | ||
recyclerView.layoutManager = LinearLayoutManager(this) | ||
} | ||
|
||
override fun initData() { | ||
|
||
} | ||
|
||
private val covertConfig = TMarker.Config( | ||
iconRes = R.drawable.ic_star_border_black_24dp, | ||
iconDefaultColorRes = android.R.color.black, | ||
actionColorRes = R.color.colorPrimary | ||
) | ||
|
||
private val repository = RepositoryDummySwipe() | ||
|
||
} |
35 changes: 35 additions & 0 deletions
35
RxDemo/src/main/java/com/tamsiree/rxdemo/adapter/AdapterTMarker.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,35 @@ | ||
package com.tamsiree.rxdemo.adapter | ||
|
||
import android.view.LayoutInflater | ||
import android.view.ViewGroup | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.tamsiree.rxdemo.R | ||
import com.tamsiree.rxdemo.viewholder.ViewHolderSwipeable | ||
import com.tamsiree.rxui.view.mark.TMarker | ||
|
||
|
||
class AdapterTMarker( | ||
private val covert: TMarker | ||
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { | ||
|
||
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerView.ViewHolder = | ||
ViewHolderSwipeable( | ||
itemView = LayoutInflater.from(viewGroup.context).inflate(R.layout.viewholder_swipeable, viewGroup, false)) | ||
|
||
|
||
override fun getItemCount(): Int = 50 | ||
|
||
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, index: Int) { | ||
covert.drawCornerFlag(viewHolder) | ||
|
||
(viewHolder as? ViewHolderSwipeable)?.apply(ViewHolderSwipeable::bind) | ||
} | ||
|
||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: List<Any>) { | ||
// The following is an optimisation for Covert, allowing us to skip re-binding of | ||
// ViewHolders if only drawing the child | ||
if (!payloads.contains(TMarker.SKIP_FULL_BIND_PAYLOAD)) { | ||
onBindViewHolder(holder, position) | ||
} | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
RxDemo/src/main/java/com/tamsiree/rxdemo/repository/RepositoryDummySwipe.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,15 @@ | ||
package com.tamsiree.rxdemo.repository | ||
|
||
/** | ||
* Class which acts in place of something which would perform a swipe action | ||
*/ | ||
class RepositoryDummySwipe { | ||
|
||
private val activeStates: MutableMap<Int, Boolean> = hashMapOf() | ||
|
||
fun toggleActiveState(index: Int) { | ||
activeStates[index] = !(activeStates[index] ?: false) | ||
} | ||
|
||
fun isActive(index: Int): Boolean = activeStates[index] ?: false | ||
} |
19 changes: 19 additions & 0 deletions
19
RxDemo/src/main/java/com/tamsiree/rxdemo/viewholder/ViewHolderSwipeable.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,19 @@ | ||
package com.tamsiree.rxdemo.viewholder | ||
|
||
import android.view.View | ||
import androidx.recyclerview.widget.RecyclerView | ||
import com.bumptech.glide.Glide | ||
import com.bumptech.glide.request.RequestOptions | ||
import kotlinx.android.synthetic.main.viewholder_swipeable.view.* | ||
|
||
class ViewHolderSwipeable( | ||
itemView: View | ||
) : RecyclerView.ViewHolder(itemView) { | ||
|
||
fun bind() { | ||
Glide.with(itemView) | ||
.load("http://i.imgur.com/34vQcpZ.png") | ||
.apply(RequestOptions.circleCropTransform()) | ||
.into(itemView.profileImageView) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="24dp" | ||
android:height="24dp" | ||
android:viewportWidth="24.0" | ||
android:viewportHeight="24.0"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M22,9.24l-7.19,-0.62L12,2 9.19,8.63 2,9.24l5.46,4.73L5.82,21 12,17.27 18.18,21l-1.63,-7.03L22,9.24zM12,15.4l-3.76,2.27 1,-4.28 -3.32,-2.88 4.38,-0.38L12,6.1l1.71,4.04 4.38,0.38 -3.32,2.88 1,4.28L12,15.4z" /> | ||
</vector> |
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
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
Oops, something went wrong.