Java源码示例:de.psdev.licensesdialog.licenses.License

示例1
private static Notice readNotice(final XmlPullParser parser) throws IOException,
    XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, "notice");
    String name = null;
    String url = null;
    String copyright = null;
    License license = null;
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        final String element = parser.getName();
        if ("name".equals(element)) {
            name = readName(parser);
        } else if ("url".equals(element)) {
            url = readUrl(parser);
        } else if ("copyright".equals(element)) {
            copyright = readCopyright(parser);
        } else if ("license".equals(element)) {
            license = readLicense(parser);
        } else {
            skip(parser);
        }
    }
    return new Notice(name, url, copyright, license);
}
 
示例2
private String getLicenseText(final License license) {
    if (license != null) {
        if (!mLicenseTextCache.containsKey(license)) {
            mLicenseTextCache.put(license, mShowFullLicenseText ? license.getFullText(mContext) : license.getSummaryText(mContext));
        }
        return mLicenseTextCache.get(license);
    }
    return "";
}
 
示例3
/**
 * Get a license by name
 *
 * @param license license name
 * @return License
 * @throws java.lang.IllegalStateException when unknown license is requested
 */
public static License read(final String license) {
    final String trimmedLicense = license.trim();
    if (sLicenses.containsKey(trimmedLicense)) {
        return sLicenses.get(trimmedLicense);
    } else {
        throw new IllegalStateException(String.format("no such license available: %s, did you forget to register it?", trimmedLicense));
    }
}
 
示例4
@Test
public void testRegisterLicense() throws Exception {
    LicenseResolver.registerLicense(new TestLicense());
    final License license = LicenseResolver.read(TEST_LICENSE_NAME);
    assertNotNull(license);
    assertEquals(TEST_LICENSE_NAME, license.getName());
}
 
示例5
public void onSingleClick(final View view) {
    final String name = "LicensesDialog";
    final String url = "http://psdev.de";
    final String copyright = "Copyright 2013 Philip Schiffer <[email protected]>";
    final License license = new ApacheSoftwareLicense20();
    final Notice notice = new Notice(name, url, copyright, license);
    new LicensesDialog.Builder(this)
        .setNotices(notice)
        .build()
        .show();
}
 
示例6
public void onSingleFragmentClick(final View view) {
    final String name = "LicensesDialog";
    final String url = "http://psdev.de";
    final String copyright = "Copyright 2013 Philip Schiffer <[email protected]>";
    final License license = new ApacheSoftwareLicense20();
    final Notice notice = new Notice(name, url, copyright, license);

    final LicensesDialogFragment fragment = new LicensesDialogFragment.Builder(this)
        .setNotice(notice)
        .setIncludeOwnLicense(false)
        .build();

    fragment.show(getSupportFragmentManager(), null);
}
 
示例7
private static License readLicense(final XmlPullParser parser) throws IOException, XmlPullParserException {
    final String license = readTag(parser, "license");
    return LicenseResolver.read(license);
}
 
示例8
public Notice(final String name, final String url, final String copyright, final License license) {
    mName = name;
    mUrl = url;
    mCopyright = copyright;
    mLicense = license;
}
 
示例9
public void setLicense(final License license) {
    mLicense = license;
}
 
示例10
public License getLicense() {
    return mLicense;
}
 
示例11
@Test
public void testReadKnownLicense() throws Exception {
    final License license = LicenseResolver.read("MIT License");
    assertNotNull(license);
    assertEquals("MIT License", license.getName());
}
 
示例12
/**
 * Register an additional license.
 *
 * @param license the license to register
 */
public static void registerLicense(final License license) {
    sLicenses.put(license.getName(), license);
}