de.psdev.licensesdialog.licenses.License Java Examples
The following examples show how to use
de.psdev.licensesdialog.licenses.License.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NoticesXmlParser.java From LicensesDialog with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: NoticesHtmlBuilder.java From LicensesDialog with Apache License 2.0 | 5 votes |
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 ""; }
Example #3
Source File: LicenseResolver.java From LicensesDialog with Apache License 2.0 | 5 votes |
/** * 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)); } }
Example #4
Source File: LicenseResolverTest.java From LicensesDialog with Apache License 2.0 | 5 votes |
@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()); }
Example #5
Source File: MainActivity.java From LicensesDialog with Apache License 2.0 | 5 votes |
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(); }
Example #6
Source File: MainActivity.java From LicensesDialog with Apache License 2.0 | 5 votes |
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); }
Example #7
Source File: NoticesXmlParser.java From LicensesDialog with Apache License 2.0 | 4 votes |
private static License readLicense(final XmlPullParser parser) throws IOException, XmlPullParserException { final String license = readTag(parser, "license"); return LicenseResolver.read(license); }
Example #8
Source File: Notice.java From LicensesDialog with Apache License 2.0 | 4 votes |
public Notice(final String name, final String url, final String copyright, final License license) { mName = name; mUrl = url; mCopyright = copyright; mLicense = license; }
Example #9
Source File: Notice.java From LicensesDialog with Apache License 2.0 | 4 votes |
public void setLicense(final License license) { mLicense = license; }
Example #10
Source File: Notice.java From LicensesDialog with Apache License 2.0 | 4 votes |
public License getLicense() { return mLicense; }
Example #11
Source File: LicenseResolverTest.java From LicensesDialog with Apache License 2.0 | 4 votes |
@Test public void testReadKnownLicense() throws Exception { final License license = LicenseResolver.read("MIT License"); assertNotNull(license); assertEquals("MIT License", license.getName()); }
Example #12
Source File: LicenseResolver.java From LicensesDialog with Apache License 2.0 | 2 votes |
/** * Register an additional license. * * @param license the license to register */ public static void registerLicense(final License license) { sLicenses.put(license.getName(), license); }