Android Open Source - lildebi Stream Thread






From Project

Back to project page lildebi.

License

The source code is released under:

GNU General Public License

If you think the Android project lildebi 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 info.guardianproject.lildebi;
/* ww  w . j  a  va2  s .c  om*/
import java.io.IOException;
import java.io.InputStream;

import android.util.Log;

public class StreamThread extends Thread {
    InputStream i;
    StreamUpdate update;

    StreamThread(InputStream i) {
        this.i = i;
    }

    StreamThread(InputStream i, StreamUpdate update) {
        this.i = i;
        this.update = update;
    }

    @Override
    public void run() {
        try {
            byte[] readBuffer = new byte[512];
            int readCount = -1;
            while ((readCount = i.read(readBuffer)) > 0) {
                String readString = new String(readBuffer, 0, readCount);
                update.update(readString);
            }
        } catch (IOException e) {
            Log.e(LilDebi.TAG, "", e);
        }
    }

    public String dump() {
        if (update instanceof StringBufferStreamUpdate) {
            return ((StringBufferStreamUpdate) update).dump();
        }

        return null;
    }

    public static abstract class StreamUpdate {
        public abstract void update(String val);
    }

    public class StringBufferStreamUpdate extends StreamUpdate {
        StringBuilder sb = new StringBuilder();

        @Override
        public void update(String val) {
            sb.append(val);
        }

        public String dump() {
            return sb.toString();
        }
    }
}




Java Source Code List

info.guardianproject.lildebi.BootCompletedReceiver.java
info.guardianproject.lildebi.InstallActivity.java
info.guardianproject.lildebi.InstallLogViewActivity.java
info.guardianproject.lildebi.InstallService.java
info.guardianproject.lildebi.LilDebiAction.java
info.guardianproject.lildebi.LilDebiApplication.java
info.guardianproject.lildebi.LilDebi.java
info.guardianproject.lildebi.MediaEjectReceiver.java
info.guardianproject.lildebi.MediaMountedReceiver.java
info.guardianproject.lildebi.MediaUnmountedReceiver.java
info.guardianproject.lildebi.NativeHelper.java
info.guardianproject.lildebi.PreferencesActivity.java
info.guardianproject.lildebi.SelectArch.java
info.guardianproject.lildebi.SelectMirror.java
info.guardianproject.lildebi.SelectRelease.java
info.guardianproject.lildebi.StreamDisplay.java
info.guardianproject.lildebi.StreamThread.java
info.guardianproject.lildebi.UnsupportedDeviceActivity.java
org.torproject.android.service.TorServiceConstants.java
org.torproject.android.service.TorServiceUtils.java