Search in sources :

Example 1 with QMUIGroupListView

use of com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView in project 91Pop by DanteAndroid.

the class SettingActivity method initSettingSection.

private void initSettingSection() {
    qmuiGroupListView.setSeparatorStyle(QMUIGroupListView.SEPARATOR_STYLE_NORMAL);
    QMUIGroupListView.Section tsec = QMUIGroupListView.newSection(this);
    // 91pron地址
    QMUICommonListItemView addressItemWithChevron = qmuiGroupListView.createItemView(getString(R.string.address_91porn));
    addressItemWithChevron.setId(R.id.setting_item_91_porn_address);
    addressItemWithChevron.setOrientation(QMUICommonListItemView.VERTICAL);
    String video91Address = addressHelper.getVideo91PornAddress();
    addressItemWithChevron.setDetailText(TextUtils.isEmpty(video91Address) ? "未设置" : video91Address);
    addressItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    // 91论坛地址
    QMUICommonListItemView forumAddressItemWithChevron = qmuiGroupListView.createItemView(getString(R.string.address_forum_91porn));
    forumAddressItemWithChevron.setId(R.id.setting_item_t66y_forum_address);
    forumAddressItemWithChevron.setOrientation(QMUICommonListItemView.VERTICAL);
    String forum91Address = addressHelper.getForum91PornAddress();
    forumAddressItemWithChevron.setDetailText(TextUtils.isEmpty(forum91Address) ? "未设置" : forum91Address);
    forumAddressItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    // 朱古力视频地址
    QMUICommonListItemView pigAvAddressItemWithChevron = qmuiGroupListView.createItemView(getString(R.string.address_pig_av));
    pigAvAddressItemWithChevron.setOrientation(QMUICommonListItemView.VERTICAL);
    String pigAvAddress = addressHelper.getPigAvAddress();
    pigAvAddressItemWithChevron.setDetailText(TextUtils.isEmpty(pigAvAddress) ? "未设置" : pigAvAddress);
    pigAvAddressItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    // 草榴地址
    QMUICommonListItemView t66yAddressItemWithChevron = qmuiGroupListView.createItemView(getString(R.string.address_t66y));
    t66yAddressItemWithChevron.setId(R.id.setting_item_t66y_forum_address);
    t66yAddressItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    tsec.addItemView(addressItemWithChevron, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showAddressSettingDialog((QMUICommonListItemView) v, AppPreferencesHelper.KEY_SP_PORN_91_VIDEO_ADDRESS);
        }
    });
    tsec.addItemView(forumAddressItemWithChevron, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showAddressSettingDialog((QMUICommonListItemView) v, AppPreferencesHelper.KEY_SP_FORUM_91_PORN_ADDRESS);
        }
    });
    tsec.addItemView(pigAvAddressItemWithChevron, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            showAddressSettingDialog((QMUICommonListItemView) v, AppPreferencesHelper.KEY_SP_PIG_AV_ADDRESS);
        }
    });
    tsec.addItemView(t66yAddressItemWithChevron, this);
    tsec.addTo(qmuiGroupListView);
    // 播放引擎
    QMUICommonListItemView playEngineItemWithChevron = qmuiGroupListView.createItemView(getString(R.string.playback_engine));
    playEngineItemWithChevron.setId(R.id.setting_item_player_engine_choice);
    playEngineItemWithChevron.setOrientation(QMUICommonListItemView.VERTICAL);
    final int checkedIndex = dataManager.getPlaybackEngine();
    playEngineItemWithChevron.setDetailText(PlaybackEngine.PLAY_ENGINE_ITEMS[checkedIndex]);
    playEngineItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    // 自定义下载路径
    final QMUICommonListItemView customDownloadPathItemWithChevron = qmuiGroupListView.createItemView("自定义视频下载文件夹");
    customDownloadPathItemWithChevron.setOrientation(QMUICommonListItemView.VERTICAL);
    String customDirPath = dataManager.getCustomDownloadVideoDirPath();
    if (SDCardUtils.DOWNLOAD_VIDEO_PATH.equalsIgnoreCase(customDirPath)) {
        customDownloadPathItemWithChevron.setDetailText("需先清空所有未完成下载,建议使用默认");
    } else {
        customDownloadPathItemWithChevron.setDetailText(customDirPath);
    }
    customDownloadPathItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    QMUIGroupListView.newSection(this).addItemView(playEngineItemWithChevron, this).addItemView(customDownloadPathItemWithChevron, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            selectDownloadVideoDir(customDownloadPathItemWithChevron);
        }
    }).addTo(qmuiGroupListView);
    QMUIGroupListView.Section sec = QMUIGroupListView.newSection(this);
    // 禁用自动释放内存功能
    boolean isForbidden = dataManager.isForbiddenAutoReleaseMemory();
    QMUICommonListItemView itemWithSwitchForbidden = qmuiGroupListView.createItemView("禁用自动释放内存功能");
    itemWithSwitchForbidden.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
    itemWithSwitchForbidden.getSwitch().setChecked(isForbidden);
    itemWithSwitchForbidden.getSwitch().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            dataManager.setForbiddenAutoReleaseMemory(isChecked);
            if (isChecked) {
                showForbiddenReleaseMemoryTipInfoDialog();
            }
        }
    });
    // 非Wi-Fi环境下下载视频
    boolean isDownloadNeedWifi = dataManager.isDownloadVideoNeedWifi();
    QMUICommonListItemView itemWithSwitch = qmuiGroupListView.createItemView("非Wi-Fi环境下下载视频");
    itemWithSwitch.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
    itemWithSwitch.getSwitch().setChecked(!isDownloadNeedWifi);
    itemWithSwitch.getSwitch().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            dataManager.setDownloadVideoNeedWifi(!isChecked);
        }
    });
    // 开启91视频跳页功能
    boolean isOpenSkipPage = dataManager.isOpenSkipPage();
    QMUICommonListItemView openSkipPageItemWithSwitch = qmuiGroupListView.createItemView("开启91视频跳页功能");
    openSkipPageItemWithSwitch.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
    openSkipPageItemWithSwitch.getSwitch().setChecked(isOpenSkipPage);
    openSkipPageItemWithSwitch.getSwitch().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            dataManager.setOpenSkipPage(isChecked);
        }
    });
    sec.addItemView(itemWithSwitch, null);
    sec.addItemView(itemWithSwitchForbidden, this);
    sec.addItemView(openSkipPageItemWithSwitch, null);
    sec.addTo(qmuiGroupListView);
}
Also used : QMUIGroupListView(com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView) QMUICommonListItemView(com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView) QMUIGroupListView(com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView) BindView(butterknife.BindView) QMUICommonListItemView(com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView) View(android.view.View) CompoundButton(android.widget.CompoundButton)

Aggregations

AppCompatAutoCompleteTextView (android.support.v7.widget.AppCompatAutoCompleteTextView)1 View (android.view.View)1 CompoundButton (android.widget.CompoundButton)1 BindView (butterknife.BindView)1 QMUICommonListItemView (com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView)1 QMUIGroupListView (com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView)1