Skip to content

Commit

Permalink
Read bytes from input stream directly
Browse files Browse the repository at this point in the history
  • Loading branch information
REAndroid committed Aug 2, 2024
1 parent 803fe7a commit 5c208ac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/main/java/com/reandroid/arsc/base/DirectStreamReader.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright (C) 2022 github.com/REAndroid
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.reandroid.arsc.base;

import java.io.IOException;
import java.io.InputStream;

public interface DirectStreamReader {
int readBytes(InputStream inputStream) throws IOException;
}
2 changes: 1 addition & 1 deletion src/main/java/com/reandroid/arsc/item/BlockItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public int readBytes(InputStream inputStream) throws IOException {
}
onBytesChanged();
super.notifyBlockLoad();
return bytes.length;
return offset;
}
public void setBytes(BlockItem blockItem){
if(blockItem != this) {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/reandroid/arsc/item/IntegerItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
package com.reandroid.arsc.item;

import com.reandroid.arsc.base.Block;
import com.reandroid.arsc.base.DirectStreamReader;
import com.reandroid.arsc.io.BlockReader;
import com.reandroid.utils.HexUtil;

import java.io.IOException;
import java.io.InputStream;

public class IntegerItem extends BlockItem implements ReferenceItem{
public class IntegerItem extends BlockItem implements ReferenceItem, DirectStreamReader {
private int mCache;
public IntegerItem(){
super(4);
Expand Down

0 comments on commit 5c208ac

Please # to comment.