-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from AlanCheen/feature/mid-autumn
Feature/mid autumn
- Loading branch information
Showing
29 changed files
with
483 additions
and
103 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
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
53 changes: 53 additions & 0 deletions
53
app/src/main/java/me/yifeiyuan/flapdev/components/Banner.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,53 @@ | ||
package me.yifeiyuan.flapdev.components | ||
|
||
import android.widget.ImageView | ||
import androidx.viewpager2.widget.ViewPager2 | ||
import com.bumptech.glide.Glide | ||
import me.yifeiyuan.flap.FlapAdapter | ||
import me.yifeiyuan.flap.dsl.adapterDelegate | ||
import me.yifeiyuan.flapdev.R | ||
|
||
/** | ||
* Created by 程序亦非猿 on 2022/9/11. | ||
*/ | ||
|
||
class BannerModel { | ||
var images: MutableList<BannerImageModel>? = null | ||
} | ||
|
||
class BannerImageModel { | ||
var url: String? = null | ||
var resId: Int = 0 | ||
} | ||
|
||
fun bannerAdapterDelegate() = adapterDelegate<BannerModel>(R.layout.component_banner) { | ||
|
||
swipeEnable = false | ||
dragEnable = false | ||
|
||
val viewPager2 = findViewById<ViewPager2>(R.id.banner) | ||
val bannerAdapter = FlapAdapter().apply { | ||
registerAdapterDelegate(bannerImageDelegate()) | ||
} | ||
|
||
viewPager2.adapter = bannerAdapter | ||
|
||
onBind { model, position, payloads, adapter -> | ||
model.images?.let { | ||
bannerAdapter.setDataAndNotify(it) | ||
} | ||
} | ||
} | ||
|
||
fun bannerImageDelegate() = adapterDelegate<BannerImageModel>(R.layout.component_banner_image) { | ||
|
||
val imageView = findViewById<ImageView>(R.id.logo) | ||
|
||
onBind { model -> | ||
if (model.url?.isNotEmpty() == true) { | ||
Glide.with(context).load(model.url).into(imageView) | ||
} else if (model.resId > 0) { | ||
Glide.with(context).load(model.resId).into(imageView) | ||
} | ||
} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
app/src/main/java/me/yifeiyuan/flapdev/components/TestConfig.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,59 @@ | ||
package me.yifeiyuan.flapdev.components | ||
|
||
import me.yifeiyuan.flap.differ.IDiffer | ||
import me.yifeiyuan.flap.dsl.adapterDelegate | ||
import me.yifeiyuan.flap.ext.bindTextView | ||
import me.yifeiyuan.flapdev.R | ||
|
||
/** | ||
* Created by 程序亦非猿 on 2022/9/13. | ||
*/ | ||
|
||
class TestConfigModel : IDiffer { | ||
|
||
var id: Int = -1 | ||
var title: String? = null | ||
var content: String? = null | ||
|
||
var dragEnable: Boolean = false | ||
var swipeEnable: Boolean = false | ||
|
||
var swipeFlags: Int = 0 | ||
var dragFlags: Int = 0 | ||
|
||
var clickEnable: Boolean = false | ||
var longClickEnable: Boolean = false | ||
|
||
override fun areItemsTheSame(newItem: Any): Boolean { | ||
return false | ||
} | ||
|
||
override fun areContentsTheSame(newItem: Any): Boolean { | ||
return false | ||
} | ||
|
||
override fun getChangePayload(newItem: Any): Any? { | ||
return super.getChangePayload(newItem) | ||
} | ||
} | ||
|
||
fun fullConfigAdapterDelegate() = adapterDelegate<TestConfigModel>(R.layout.component_full_feature) { | ||
|
||
onBind { model, position, payloads, adapter -> | ||
|
||
bindTextView(R.id.title) { | ||
text = model.title | ||
} | ||
|
||
bindTextView(R.id.content) { | ||
text = model.content | ||
} | ||
|
||
swipeEnable = model.swipeEnable | ||
dragEnable = model.dragEnable | ||
swipeFlags = model.swipeFlags | ||
dragFlags = model.dragFlags | ||
clickable = model.clickEnable | ||
longClickable = model.longClickEnable | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" | ||
android:layout_height="wrap_content"> | ||
|
||
<androidx.viewpager2.widget.ViewPager2 | ||
android:id="@+id/banner" | ||
android:layout_width="match_parent" | ||
android:layout_height="120dp" | ||
/> | ||
|
||
</FrameLayout> |
Oops, something went wrong.