下面列出了android.os.Parcel#dataAvail ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private UndoBuffer(Parcel in) {
this();
int len = in.readInt();
while( in.dataAvail() > 0 && len-- > 0){
TextChange item = new TextChange();
item.start = in.readInt();
item.oldtext = in.readString();
item.newtext = in.readString();
if ( item.newtext == null ){
item.newtext = "";
}
if ( item.oldtext == null ){
item.oldtext = "";
}
mBuffer.add(item);
mCurrentSize += item.newtext.length() + item.oldtext.length();
}
}
public Presence(Parcel source) {
mStatus = source.readInt();
mStatusText = source.readString();
mAvatarData = source.createByteArray();
mAvatarType = source.readString();
mClientType = source.readInt();
// TODO - what ClassLoader should be passed to readMap?
// TODO - switch to Bundle
mExtendedInfo = source.readHashMap(null);
//this may not exist for older persisted presence data
if (source.dataAvail() > 0)
mResource = source.readString();
if (source.dataAvail() > 0) {
long timeLastSeen = source.readLong();
if (timeLastSeen != -1)
mLastSeen = new Date(timeLastSeen);
}
}
private UndoBuffer(Parcel in) {
this();
int len = in.readInt();
while( in.dataAvail() > 0 && len-- > 0){
TextChange item = new TextChange();
item.start = in.readInt();
item.oldtext = in.readString();
item.newtext = in.readString();
if ( item.newtext == null ){
item.newtext = "";
}
if ( item.oldtext == null ){
item.oldtext = "";
}
mBuffer.add(item);
mCurrentSize += item.newtext.length() + item.oldtext.length();
}
}
public RevokeMsgInfoImpl(Parcelable o) {
if (o == null) throw new NullPointerException("RevokeMsgInfo == null");
Parcel p = Parcel.obtain();
try {
o.writeToParcel(p, 0);
p.setDataPosition(0);
istroop = p.readInt();
shmsgseq = p.readLong();
friendUin = p.readString();
sendUin = p.readString();
msgUid = p.readLong();
time = p.readLong();
if (p.dataAvail() > 0) authorUin = p.readString();
if (p.dataAvail() > 0) opType = p.readInt();
} catch (Exception e) {
log(e);
}
p.recycle();
String summery = o.toString();
int keyIndex = summery.indexOf("fromuin");
if (keyIndex == -1) {
log("RevokeMsgInfoImpl/E indexOf('fromuin') == -1, leave fromUin null");
return;
}
int valueStart = summery.indexOf('=', keyIndex) + 1;
if (summery.charAt(valueStart) == ' ') valueStart++;
int end1 = summery.indexOf(',', valueStart);
int end2 = summery.indexOf(' ', valueStart);
if (end1 == -1) end1 = summery.length() - 1;
if (end2 == -1) end2 = summery.length() - 1;
int end = Math.min(end1, end2);
String str = summery.substring(valueStart, end);
if (str.equals("null")) {
fromUin = null;
} else {
fromUin = str;
}
}
VisualState(Parcel in) {
super(in);
if (in.dataAvail() > 0) {
int side = in.readInt();
float dockVerticalPositionPercent = in.readFloat();
mSidePosition = new SideDock.SidePosition(side, dockVerticalPositionPercent);
}
if (in.dataAvail() > 0) {
mSelectedSectionId = new HoverMenu.SectionId(in.readString());
}
}
public SdlPacket(Parcel p) {
this.version = p.readInt();
this.encryption = (p.readInt() == 0) ? false : true;
this.frameType = p.readInt();
this.serviceType = p.readInt();
this.frameInfo = p.readInt();
this.sessionId = p.readInt();
this.dataSize = p.readInt();
this.messageId = p.readInt();
if(p.readInt() == 1){ //We should have a payload attached
payload = new byte[dataSize];
p.readByteArray(payload);
}
this.priorityCoefficient = p.readInt();
if(p.dataAvail() > EXTRA_PARCEL_DATA_LENGTH) { //See note on constant for why not 0
try {
messagingVersion = p.readInt();
if (messagingVersion >= 2) {
if (p.readInt() == 1) { //We should have a transport type attached
this.transportRecord = (TransportRecord) p.readParcelable(TransportRecord.class.getClassLoader());
}
}
}catch (RuntimeException e){
DebugTool.logError("Error creating packet from parcel", e);
}
}
}
public SdlPacket(Parcel p) {
this.version = p.readInt();
this.encryption = (p.readInt() == 0) ? false : true;
this.frameType = p.readInt();
this.serviceType = p.readInt();
this.frameInfo = p.readInt();
this.sessionId = p.readInt();
this.dataSize = p.readInt();
this.messageId = p.readInt();
if(p.readInt() == 1){ //We should have a payload attached
payload = new byte[dataSize];
p.readByteArray(payload);
}
this.priorityCoefficient = p.readInt();
if(p.dataAvail() > EXTRA_PARCEL_DATA_LENGTH) { //See note on constant for why not 0
try {
messagingVersion = p.readInt();
if (messagingVersion >= 2) {
if (p.readInt() == 1) { //We should have a transport type attached
this.transportRecord = (TransportRecord) p.readParcelable(TransportRecord.class.getClassLoader());
}
}
}catch (RuntimeException e){
DebugTool.logError("Error creating packet from parcel", e);
}
}
}