Android Open Source - security-cam Flushed Input Stream






From Project

Back to project page security-cam.

License

The source code is released under:

MIT License

If you think the Android project security-cam listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package berlin.reiche.securitas.util;
/*from w ww  . j a va  2 s. c  om*/
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

import android.graphics.BitmapFactory;

/**
 * There is a bug in the {@link BitmapFactory#decodeStream(InputStream)}
 * implementation. The problem occurs on some JPG files on a slow or hanging
 * connection.
 * 
 * This implementation skips the exact number of bytes provided, unless it
 * reaches EOF.
 * 
 * @see <a href="http://code.google.com/p/android/issues/detail?id=6066">
 *      http://code.google.com/p/android/issues/detail?id=6066</a>
 * 
 * @author Konrad Reiche
 * 
 */
public class FlushedInputStream extends FilterInputStream {

  /**
   * Default constructor.
   * 
   * @param inputStream
   *            the input stream to be wrapped.
   */
  public FlushedInputStream(InputStream inputStream) {
    super(inputStream);
  }

  /**
   * Skips {@code byteCount} bytes in this stream or until EOF is reached.
   * 
   * @see java.io.FilterInputStream#skip(long)
   */
  @Override
  public long skip(long byteCount) throws IOException {
    long totalBytesSkipped = 0L;
    while (totalBytesSkipped < byteCount) {
      long bytesSkipped = in.skip(byteCount - totalBytesSkipped);
      if (bytesSkipped == 0L) {
        int b = read();
        if (b < 0) {
          // reached EOF
          break;
        } else {
          // read one byte
          bytesSkipped = 1;
        }
      }
      totalBytesSkipped += bytesSkipped;
    }
    return totalBytesSkipped;
  }

}




Java Source Code List

berlin.reiche.securitas.Client.java
berlin.reiche.securitas.Settings.java
berlin.reiche.securitas.activities.Action.java
berlin.reiche.securitas.activities.LauncherActivity.java
berlin.reiche.securitas.activities.MainActivity.java
berlin.reiche.securitas.activities.SettingsActivity.java
berlin.reiche.securitas.activities.package-info.java
berlin.reiche.securitas.controller.ClientController.java
berlin.reiche.securitas.controller.Controller.java
berlin.reiche.securitas.controller.GCMIntentService.java
berlin.reiche.securitas.controller.GCMReceiver.java
berlin.reiche.securitas.controller.InboxHandler.java
berlin.reiche.securitas.controller.states.ControllerState.java
berlin.reiche.securitas.controller.states.DetectionState.java
berlin.reiche.securitas.controller.states.IdleState.java
berlin.reiche.securitas.controller.states.package-info.java
berlin.reiche.securitas.controller.tasks.BitmapDownloadTask.java
berlin.reiche.securitas.controller.tasks.DetectionRequest.java
berlin.reiche.securitas.controller.tasks.DeviceRegistration.java
berlin.reiche.securitas.controller.tasks.StatusTask.java
berlin.reiche.securitas.controller.tasks.package-info.java
berlin.reiche.securitas.controller.package-info.java
berlin.reiche.securitas.model.ClientModel.java
berlin.reiche.securitas.model.Model.java
berlin.reiche.securitas.model.Protocol.java
berlin.reiche.securitas.model.package-info.java
berlin.reiche.securitas.util.FlushedInputStream.java
berlin.reiche.securitas.util.HttpUtilities.java
berlin.reiche.securitas.util.NotificationDialog.java
berlin.reiche.securitas.util.package-info.java
berlin.reiche.securitas.package-info.java