override public NDEFSmartPosterParsedResult parse(ZXing.Result result) { var bytes = result.RawBytes; if (bytes == null) { return(null); } var headerRecord = NDEFRecord.readRecord(bytes, 0); // Yes, header record starts and ends a message if (headerRecord == null || !headerRecord.MessageBegin || !headerRecord.MessageEnd) { return(null); } if (!headerRecord.Type.Equals(NDEFRecord.SMART_POSTER_WELL_KNOWN_TYPE)) { return(null); } var offset = 0; var recordNumber = 0; NDEFRecord ndefRecord = null; var payload = headerRecord.Payload; var action = NDEFSmartPosterParsedResult.ACTION_UNSPECIFIED; String title = null; String uri = null; while (offset < payload.Length && (ndefRecord = NDEFRecord.readRecord(payload, offset)) != null) { if (recordNumber == 0 && !ndefRecord.MessageBegin) { return(null); } var type = ndefRecord.Type; if (NDEFRecord.TEXT_WELL_KNOWN_TYPE.Equals(type)) { var languageText = NDEFTextResultParser.decodeTextPayload(ndefRecord.Payload); title = languageText[1]; } else if (NDEFRecord.URI_WELL_KNOWN_TYPE.Equals(type)) { uri = NDEFURIResultParser.decodeURIPayload(ndefRecord.Payload); } else if (NDEFRecord.ACTION_WELL_KNOWN_TYPE.Equals(type)) { action = ndefRecord.Payload[0]; } recordNumber++; offset += ndefRecord.TotalRecordLength; } if (recordNumber == 0 || (ndefRecord != null && !ndefRecord.MessageEnd)) { return(null); } return(new NDEFSmartPosterParsedResult(action, uri, title)); }
override public URIParsedResult parse(ZXing.Result result) { var bytes = result.RawBytes; if (bytes == null) { return(null); } var ndefRecord = NDEFRecord.readRecord(bytes, 0); if (ndefRecord == null || !ndefRecord.MessageBegin || !ndefRecord.MessageEnd) { return(null); } if (!ndefRecord.Type.Equals(NDEFRecord.URI_WELL_KNOWN_TYPE)) { return(null); } var fullURI = decodeURIPayload(ndefRecord.Payload); return(new URIParsedResult(fullURI, null)); }
override public TextParsedResult parse(ZXing.Result result) { var bytes = result.RawBytes; if (bytes == null) { return(null); } var ndefRecord = NDEFRecord.readRecord(bytes, 0); if (ndefRecord == null || !ndefRecord.MessageBegin || !ndefRecord.MessageEnd) { return(null); } if (!ndefRecord.Type.Equals(NDEFRecord.TEXT_WELL_KNOWN_TYPE)) { return(null); } var languageText = decodeTextPayload(ndefRecord.Payload); return(new TextParsedResult(languageText[0], languageText[1])); }