Android Open Source - lildebi Stream Display






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;
/*w w w  .j  av a2s.  c o m*/
import java.io.IOException;
import java.io.InputStream;

import android.os.Handler;
import android.util.Log;
import android.widget.ScrollView;
import android.widget.TextView;

public class StreamDisplay extends Thread {
    InputStream i;
    TextView display;
    ScrollView scrollView;
    Handler handler;

    StreamDisplay(InputStream i, TextView display, ScrollView scrollView, Handler handler) {
        this.i = i;
        this.display = display;
        this.scrollView = scrollView;
        this.handler = handler;
    }

    @Override
    public void run() {
        try {
            byte[] readBuffer = new byte[512];
            int readCount = -1;
            while ((readCount = i.read(readBuffer)) > 0) {
                final String readString = new String(readBuffer, 0, readCount);
                handler.post(new Runnable() {
                    public void run() {
                        CharSequence currentText = display.getText();
                        display.setText(currentText + readString);
                        scrollView.scrollTo(0, display.getHeight() + 100);
                    }
                });
                handler.postDelayed(new Runnable() {
                    public void run() {
                        scrollView.scrollTo(0, display.getHeight());
                    }
                }, 300);
            }
        } catch (IOException e) {
            Log.e(LilDebi.TAG, "", e);
        }
    }
}




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