Skip to content

Commit f804a50

Browse files
committed
add TMarker.
1 parent 9eaa197 commit f804a50

File tree

100 files changed

+1733
-291
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+1733
-291
lines changed

RxDemo/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
android:supportsRtl="true"
2323
android:theme="@style/AppTheme"
2424
tools:ignore="GoogleAppIndexingWarning">
25+
<activity android:name=".activity.ActivityTMarker"></activity>
2526
<activity android:name=".activity.ActivityTLoadingView" />
2627
<activity android:name=".activity.ActivityTStepperIndicator" />
2728
<activity android:name=".activity.ActivityTCardGallery" />

RxDemo/src/main/java/com/tamsiree/rxdemo/activity/ActivityPopupView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ActivityPopupView : ActivityBase(), TipListener {
7474
mRxPopupViewManager?.findAndDismiss(text_view)
7575
builder = RxPopupView.Builder(this, text_view, parent_layout, text, RxPopupView.POSITION_LEFT_TO)
7676
builder.setBackgroundColor(resources.getColor(R.color.greenyellow))
77-
builder.setTextColor(resources.getColor(R.color.black))
77+
builder.setTextColor(resources.getColor(R.color.Black))
7878
builder.setGravity(RxPopupView.GRAVITY_CENTER)
7979
builder.setTextSize(12)
8080
tipvView = mRxPopupViewManager?.show(builder.build())!!
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.tamsiree.rxdemo.activity
2+
3+
import android.os.Bundle
4+
import androidx.recyclerview.widget.LinearLayoutManager
5+
import com.tamsiree.rxdemo.R
6+
import com.tamsiree.rxdemo.adapter.AdapterTMarker
7+
import com.tamsiree.rxdemo.repository.RepositoryDummySwipe
8+
import com.tamsiree.rxdemo.viewholder.ViewHolderSwipeable
9+
import com.tamsiree.rxui.activity.ActivityBase
10+
import com.tamsiree.rxui.view.mark.TMarker
11+
import kotlinx.android.synthetic.main.activity_tmarker.*
12+
13+
class ActivityTMarker : ActivityBase() {
14+
15+
override fun onCreate(savedInstanceState: Bundle?) {
16+
super.onCreate(savedInstanceState)
17+
setContentView(R.layout.activity_tmarker)
18+
}
19+
20+
override fun initView() {
21+
val tMarker = TMarker.with(covertConfig)
22+
.setIsActiveCallback {
23+
it is ViewHolderSwipeable && repository.isActive(it.adapterPosition)
24+
}
25+
.doOnSwipe { viewHolder, _ ->
26+
repository.toggleActiveState(viewHolder.adapterPosition)
27+
}
28+
.attachTo(recyclerView)
29+
30+
recyclerView.adapter = AdapterTMarker(tMarker)
31+
recyclerView.layoutManager = LinearLayoutManager(this)
32+
}
33+
34+
override fun initData() {
35+
36+
}
37+
38+
private val covertConfig = TMarker.Config(
39+
iconRes = R.drawable.ic_star_border_black_24dp,
40+
iconDefaultColorRes = android.R.color.black,
41+
actionColorRes = R.color.colorPrimary
42+
)
43+
44+
private val repository = RepositoryDummySwipe()
45+
46+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.tamsiree.rxdemo.adapter
2+
3+
import android.view.LayoutInflater
4+
import android.view.ViewGroup
5+
import androidx.recyclerview.widget.RecyclerView
6+
import com.tamsiree.rxdemo.R
7+
import com.tamsiree.rxdemo.viewholder.ViewHolderSwipeable
8+
import com.tamsiree.rxui.view.mark.TMarker
9+
10+
11+
class AdapterTMarker(
12+
private val covert: TMarker
13+
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
14+
15+
override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerView.ViewHolder =
16+
ViewHolderSwipeable(
17+
itemView = LayoutInflater.from(viewGroup.context).inflate(R.layout.viewholder_swipeable, viewGroup, false))
18+
19+
20+
override fun getItemCount(): Int = 50
21+
22+
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, index: Int) {
23+
covert.drawCornerFlag(viewHolder)
24+
25+
(viewHolder as? ViewHolderSwipeable)?.apply(ViewHolderSwipeable::bind)
26+
}
27+
28+
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int, payloads: List<Any>) {
29+
// The following is an optimisation for Covert, allowing us to skip re-binding of
30+
// ViewHolders if only drawing the child
31+
if (!payloads.contains(TMarker.SKIP_FULL_BIND_PAYLOAD)) {
32+
onBindViewHolder(holder, position)
33+
}
34+
}
35+
}

RxDemo/src/main/java/com/tamsiree/rxdemo/fragment/FragmentDemo.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class FragmentDemo : FragmentLazy, OnRefreshListener {
6262
recyclerViewDemo.addItemDecoration(RxRecyclerViewDividerTool(RxImageTool.dp2px(5f)))
6363
mAdapter = AdapterRecyclerViewMain(mDemoList, object : ContentListener {
6464
override fun setListener(position: Int) {
65-
RxActivityTool.skipActivity(mContext, mDemoList!![position].activity)
65+
RxActivityTool.skipActivity(mContext, mDemoList!![position].activity, null, true)
6666
}
6767
})
6868
mAdapter!!.openLoadAnimation(BaseQuickAdapter.SCALEIN)
@@ -144,6 +144,7 @@ class FragmentDemo : FragmentLazy, OnRefreshListener {
144144
mDemoList!!.add(ModelDemo("卡片画廊效果", R.drawable.circle_outlook, ActivityTCardGallery::class.java))
145145
mDemoList!!.add(ModelDemo("步骤指示器", R.drawable.circle_indicator, ActivityTStepperIndicator::class.java))
146146
mDemoList!!.add(ModelDemo("加载中视图", R.drawable.circle_indicator, ActivityTLoadingView::class.java))
147+
mDemoList!!.add(ModelDemo("左滑标记", R.drawable.circle_indicator, ActivityTMarker::class.java))
147148
mDemoList!!.add(ModelDemo("其他界面效果", R.drawable.circle_icecandy, ActivityOtherEffect::class.java))
148149
}
149150

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.tamsiree.rxdemo.repository
2+
3+
/**
4+
* Class which acts in place of something which would perform a swipe action
5+
*/
6+
class RepositoryDummySwipe {
7+
8+
private val activeStates: MutableMap<Int, Boolean> = hashMapOf()
9+
10+
fun toggleActiveState(index: Int) {
11+
activeStates[index] = !(activeStates[index] ?: false)
12+
}
13+
14+
fun isActive(index: Int): Boolean = activeStates[index] ?: false
15+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.tamsiree.rxdemo.viewholder
2+
3+
import android.view.View
4+
import androidx.recyclerview.widget.RecyclerView
5+
import com.bumptech.glide.Glide
6+
import com.bumptech.glide.request.RequestOptions
7+
import kotlinx.android.synthetic.main.viewholder_swipeable.view.*
8+
9+
class ViewHolderSwipeable(
10+
itemView: View
11+
) : RecyclerView.ViewHolder(itemView) {
12+
13+
fun bind() {
14+
Glide.with(itemView)
15+
.load("http://i.imgur.com/34vQcpZ.png")
16+
.apply(RequestOptions.circleCropTransform())
17+
.into(itemView.profileImageView)
18+
}
19+
}

RxDemo/src/main/res/drawable/bg_btn_login_selected.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</shape></item>
77

88
<item android:state_enabled="false"><shape>
9-
<solid android:color="@color/c" />
9+
<solid android:color="@color/C" />
1010
<corners android:radius="6dp" />
1111
</shape></item>
1212

RxDemo/src/main/res/drawable/circle_blue.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
android:width="@dimen/shopping_cart_circle_size"
1010
android:height="@dimen/shopping_cart_circle_size"/>
1111
<stroke
12-
android:color="@color/light_black"
12+
android:color="@color/Gray38"
1313
android:width="5dp"/>
1414
</shape>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24.0"
5+
android:viewportHeight="24.0">
6+
<path
7+
android:fillColor="#FF000000"
8+
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" />
9+
</vector>

0 commit comments

Comments
 (0)