This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 143
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
15 changed files
with
233 additions
and
14 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
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/vicedev/zy_player_android/common/SPKey.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,11 @@ | ||
package com.vicedev.zy_player_android.common | ||
|
||
/** | ||
* @author vicedev | ||
* @email [email protected] | ||
* @date 2020/9/19 17:14 | ||
* @desc sp的key值 | ||
*/ | ||
|
||
//打开福利 | ||
const val SP_OPEN_FL = "sp_open_fl" |
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/vicedev/zy_player_android/event/OpenFLEvent.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,14 @@ | ||
package com.vicedev.zy_player_android.event | ||
|
||
/** | ||
* @author vicedev | ||
* @email [email protected] | ||
* @date 2020/9/19 18:42 | ||
* @desc 开启福利的事件 | ||
*/ | ||
|
||
class OpenFLEvent(val open: Boolean) { | ||
override fun equals(other: Any?): Boolean { | ||
return other is OpenFLEvent | ||
} | ||
} |
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
32 changes: 32 additions & 0 deletions
32
app/src/main/java/com/vicedev/zy_player_android/ui/setting/SettingActivity.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,32 @@ | ||
package com.vicedev.zy_player_android.ui.setting | ||
|
||
import android.app.Activity | ||
import android.content.Intent | ||
import com.vicedev.zy_player_android.R | ||
import com.vicedev.zy_player_android.ui.BaseActivity | ||
|
||
/** | ||
* @author vicedev | ||
* @email [email protected] | ||
* @date 2020/9/13 0:40 | ||
* @desc 设置 | ||
*/ | ||
const val REWARD = "reward" | ||
|
||
class SettingActivity : BaseActivity() { | ||
override fun initView() { | ||
supportFragmentManager | ||
.beginTransaction() | ||
.replace(R.id.container, SettingFragment(), REWARD) | ||
.commitAllowingStateLoss() | ||
} | ||
|
||
override fun getLayoutId(): Int = R.layout.container_layout | ||
|
||
companion object { | ||
fun jump(activity: Activity) { | ||
activity.startActivity(Intent(activity, SettingActivity::class.java)) | ||
} | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
app/src/main/java/com/vicedev/zy_player_android/ui/setting/SettingFragment.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 com.vicedev.zy_player_android.ui.setting | ||
|
||
import com.blankj.utilcode.util.SPUtils | ||
import com.vicedev.zy_player_android.R | ||
import com.vicedev.zy_player_android.common.SP_OPEN_FL | ||
import com.vicedev.zy_player_android.event.OpenFLEvent | ||
import com.vicedev.zy_player_android.ui.BaseFragment | ||
import com.wuhenzhizao.titlebar.widget.CommonTitleBar | ||
import kotlinx.android.synthetic.main.fragment_setting.* | ||
import kotlinx.android.synthetic.main.set_item_view.view.* | ||
import org.greenrobot.eventbus.EventBus | ||
|
||
/** | ||
* @author vicedev | ||
* @email [email protected] | ||
* @date 2020/9/19 16:57 | ||
* @desc 设置页面 | ||
*/ | ||
class SettingFragment : BaseFragment() { | ||
override fun getLayoutId(): Int = R.layout.fragment_setting | ||
|
||
override fun initTitleBar(titleBar: CommonTitleBar?) { | ||
titleBar?.run { | ||
centerTextView.text = "设置" | ||
|
||
setListener { v, action, extra -> | ||
when (action) { | ||
CommonTitleBar.ACTION_LEFT_BUTTON -> { | ||
requireActivity().finish() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
override fun initView() { | ||
super.initView() | ||
//开启福利 | ||
val openFL = SPUtils.getInstance().getBoolean(SP_OPEN_FL) | ||
setOpenFL.switchBtn.isChecked = openFL | ||
} | ||
|
||
override fun initListener() { | ||
super.initListener() | ||
//开启福利开关 | ||
setOpenFL.switchBtn.setOnCheckedChangeListener { view, isChecked -> | ||
SPUtils.getInstance().put(SP_OPEN_FL, isChecked) | ||
EventBus.getDefault().removeStickyEvent(OpenFLEvent(isChecked)) | ||
EventBus.getDefault().postSticky(OpenFLEvent(isChecked)) | ||
} | ||
} | ||
|
||
} |
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,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<com.wuhenzhizao.titlebar.widget.CommonTitleBar | ||
android:id="@id/title_bar" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:centerText="社会" | ||
app:centerType="textView" | ||
app:leftType="imageButton" /> | ||
|
||
<com.vicedev.zy_player_android.widgets.SetItemView | ||
android:id="@+id/setOpenFL" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
app:itemName="开启福利" | ||
app:needRightArrow="false" | ||
app:needSwitchBtn="true" /> | ||
|
||
</LinearLayout> |
Oops, something went wrong.