Skip to content
支付宝商家语音播报
Branch: master
Clone or download
Latest commit befb8cf Apr 20, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea
app
gradle/wrapper Initial commit Jan 12, 2018
image 新图 Jan 18, 2018
voicebroadcast-lib 新图 Jan 18, 2018
.gitignore
README.md Update README.md Apr 20, 2018
build.gradle Initial commit Jan 12, 2018
config.gradle .md更新 Jan 19, 2018
gradle.properties Initial commit Jan 12, 2018
gradlew
gradlew.bat
settings.gradle Initial commit Jan 12, 2018

README.md

PushVoiceBroadcast

支付宝商家语音播报

image

  1. gradle引入
    allprojects {
        repositories {
            ...
            maven { url 'https://jitpack.io' }
        }
    }

    dependencies {
        implementation 'com.github.YzyCoding:PushVoiceBroadcast:1.0.2'
    }
  1. 一行代码
    VoicePlay.with(MainActivity.this).play(amount);
  • 支持顺序播报
  • 支持中文大写
  • 支持全数字
  • 替换音频文件导入源码

容错处理

    /**
     * 提取字符串中的 数字 带小数点 ,没有就返回""
     *
     * @param money
     * @return
     */
    public static String getMoney(String money) {
        Pattern pattern = Pattern.compile("(\\d+\\.\\d+)");
        Matcher m = pattern.matcher(money);
        if (m.find()) {
            money = m.group(1) == null ? "" : m.group(1);
        } else {
            pattern = Pattern.compile("(\\d+)");
            m = pattern.matcher(money);
            if (m.find()) {
                money = m.group(1) == null ? "" : m.group(1);
            } else {
                money = "";
            }
        }

        return money;
    }
    @Test
    public void testMoney() {
        String money = StringUtils.getMoney("");
        System.out.println("money == " + money);

        String money1 = StringUtils.getMoney("收到影秀卡付款0.01元");
        System.out.println("money1 == " + money1);

        String money2 = StringUtils.getMoney("收到测试影秀卡付款1000.00元");
        System.out.println("money1 == " + money2);

        String money3 = StringUtils.getMoney("收到测试影秀卡付款1000元");
        System.out.println("money2 == " + money3);

        String money4 = StringUtils.getMoney("收到测试影秀卡付款999.99元");
        System.out.println("money3 == " + money4);

        String money5 = StringUtils.getMoney("999.99");
        System.out.println("money4 == " + money5);

        String money6 = StringUtils.getMoney("1");
        System.out.println("money5 == " + money6);
    }
    
    
    Log:
    money == 
    money1 == 0.01
    money1 == 1000.00
    money2 == 1000
    money3 == 999.99
    money4 == 999.99
    money5 == 1

APK下载

点我体验

简书

参考:

KTools/Voice

You can’t perform that action at this time.