Search in sources :

Example 1 with QMUICommonListItemView

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

the class SettingActivity method showAddressSettingDialog.

private void showAddressSettingDialog(final QMUICommonListItemView qmuiCommonListItemView, final String key) {
    View view = getLayoutInflater().inflate(R.layout.dialog_setting_address, qmuiCommonListItemView, false);
    final AlertDialog alertDialog = new AlertDialog.Builder(this, R.style.MyDialogTheme).setTitle(getAddressSettingTitle(key)).setView(view).setCancelable(false).show();
    AppCompatButton okAppCompatButton = view.findViewById(R.id.bt_dialog_address_setting_ok);
    AppCompatButton backAppCompatButton = view.findViewById(R.id.bt_dialog_address_setting_back);
    AppCompatButton testAppCompatButton = view.findViewById(R.id.bt_dialog_address_setting_test);
    final AppCompatAutoCompleteTextView autoCompleteTextView = view.findViewById(R.id.atv_dialog_address_setting_address);
    autoCompleteTextView.setText(testBaseUrl);
    if (!TextUtils.isEmpty(testBaseUrl)) {
        autoCompleteTextView.setSelection(testBaseUrl.length());
    }
    final String[] address = { "http://", "https://", "http://www.", "https://www." };
    ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.item_auto_complete_textview, address);
    autoCompleteTextView.setAdapter(adapter);
    okAppCompatButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String address = autoCompleteTextView.getText().toString().trim();
            if (!checkAddress(address)) {
                return;
            }
            testBaseUrl = address;
            alertDialog.dismiss();
            if (isTestSuccess) {
                saveToSpAndUpdateQMUICommonListItemView(key, qmuiCommonListItemView, address);
            } else {
                showConfirmDialog(qmuiCommonListItemView, address, key);
            }
        }
    });
    backAppCompatButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            resetOrUpdateAddress(key, addressHelper);
            alertDialog.dismiss();
        }
    });
    testAppCompatButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            String address = autoCompleteTextView.getText().toString().trim();
            if (!checkAddress(address)) {
                return;
            }
            testBaseUrl = address;
            alertDialog.dismiss();
            beginTestAddress(address, qmuiCommonListItemView, key);
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) 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) AppCompatAutoCompleteTextView(android.support.v7.widget.AppCompatAutoCompleteTextView) ArrayAdapter(android.widget.ArrayAdapter) AppCompatButton(android.support.v7.widget.AppCompatButton)

Example 2 with QMUICommonListItemView

use of com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView 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)

Example 3 with QMUICommonListItemView

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

the class MineFragment method initMineSection.

private void initMineSection() {
    boolean openNightMode = dataManager.isOpenNightMode();
    QMUICommonListItemView openNightModeItemWithSwitch = mineList.createItemView(nightModeStr);
    openNightModeItemWithSwitch.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
    openNightModeItemWithSwitch.getSwitch().setChecked(openNightMode);
    openNightModeItemWithSwitch.getSwitch().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            dataManager.setOpenNightMode(isChecked);
            dataManager.setSettingScrollViewScrollPosition(scrollYPosition);
            AppCompatDelegate.setDefaultNightMode(isChecked ? AppCompatDelegate.MODE_NIGHT_YES : AppCompatDelegate.MODE_NIGHT_NO);
            Intent intent = new Intent(context, MainActivity.class);
            intent.putExtra(Keys.KEY_SELECT_INDEX, 4);
            startActivity(intent);
            activity.finish();
            activity.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
        }
    });
    boolean openProxy = dataManager.isOpenHttpProxy();
    openProxyItemWithSwitch = mineList.createItemView(proxyStr);
    openProxyItemWithSwitch.setOrientation(QMUICommonListItemView.VERTICAL);
    final String proxyHost = dataManager.getProxyIpAddress();
    final int port = dataManager.getProxyPort();
    if (TextUtils.isEmpty(proxyHost) || port == 0) {
        openProxyItemWithSwitch.setDetailText("长按设置");
    } else {
        openProxyItemWithSwitch.setDetailText(proxyHost + " : " + port);
    }
    openProxyItemWithSwitch.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_SWITCH);
    openProxyItemWithSwitch.getSwitch().setChecked(openProxy);
    openProxyItemWithSwitch.getSwitch().setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (TextUtils.isEmpty(proxyHost) || port == 0) {
                buttonView.setChecked(false);
                dataManager.setOpenHttpProxy(false);
                return;
            }
            dataManager.setOpenHttpProxy(isChecked);
        }
    });
    QMUICommonListItemView favoriteItemWithChevron = mineList.createItemView(myFavoriteStr);
    favoriteItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    QMUICommonListItemView downloadItemWithChevron = mineList.createItemView(myDownloadStr);
    downloadItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    QMUICommonListItemView viewHistoryItemWithChevron = mineList.createItemView(viewHistoryStr);
    viewHistoryItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    mineList.setSeparatorStyle(QMUIGroupListView.SEPARATOR_STYLE_NORMAL);
    QMUIGroupListView.newSection(context).addItemView(favoriteItemWithChevron, this).addItemView(downloadItemWithChevron, this).addItemView(viewHistoryItemWithChevron, this).addItemView(openNightModeItemWithSwitch, null).addTo(mineList);
    QMUIGroupListView.newSection(context).addItemView(openProxyItemWithSwitch, null, new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            Intent intent = new Intent(context, ProxySettingActivity.class);
            startActivityWithAnimotion(intent);
            return false;
        }
    }).addTo(mineList);
    QMUICommonListItemView moreSettingItemWithChevron = mineList.createItemView(moreSettingStr);
    moreSettingItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    QMUIGroupListView.newSection(context).addItemView(moreSettingItemWithChevron, this).addTo(mineList);
    QMUICommonListItemView aboutItemWithChevron = mineList.createItemView(aboutMeStr);
    aboutItemWithChevron.setAccessoryType(QMUICommonListItemView.ACCESSORY_TYPE_CHEVRON);
    QMUIGroupListView.newSection(context).addItemView(aboutItemWithChevron, this).addTo(mineList);
}
Also used : Intent(android.content.Intent) MainActivity(com.dante.ui.main.MainActivity) QMUICommonListItemView(com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView) ImageView(android.widget.ImageView) QMUIGroupListView(com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView) BindView(butterknife.BindView) QMUICommonListItemView(com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView) View(android.view.View) TextView(android.widget.TextView) ObservableScrollView(com.dante.widget.ObservableScrollView) CompoundButton(android.widget.CompoundButton) SuppressLint(android.annotation.SuppressLint)

Aggregations

View (android.view.View)3 BindView (butterknife.BindView)3 QMUICommonListItemView (com.qmuiteam.qmui.widget.grouplist.QMUICommonListItemView)3 QMUIGroupListView (com.qmuiteam.qmui.widget.grouplist.QMUIGroupListView)3 AppCompatAutoCompleteTextView (android.support.v7.widget.AppCompatAutoCompleteTextView)2 CompoundButton (android.widget.CompoundButton)2 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 AlertDialog (android.support.v7.app.AlertDialog)1 AppCompatButton (android.support.v7.widget.AppCompatButton)1 ArrayAdapter (android.widget.ArrayAdapter)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 MainActivity (com.dante.ui.main.MainActivity)1 ObservableScrollView (com.dante.widget.ObservableScrollView)1