| package com.google.araplox; |
| |
| import java.io.DataInputStream; |
| import java.io.IOException; |
| |
| import android.content.Context; |
| import android.os.Handler; |
| import android.os.Message; |
| import android.util.Log; |
| |
| public class AFE4400Thread extends Thread { |
| private static final String TAG = "AFE4400Thread"; |
| |
| private boolean stopped = false; |
| private DataInputStream dataInputStream; |
| |
| Context mContext; |
| Handler mHandler; |
| |
| public AFE4400Thread(Context context, Handler handler) { |
| mContext = context; |
| mHandler = handler; |
| |
| try { |
| dataInputStream = new DataInputStream(mContext.getAssets().open("plox.dat")); |
| } catch (IOException e) { |
| // TODO Auto-generated catch block |
| e.printStackTrace(); |
| } |
| } |
| |
| public void run() { |
| Log.d(TAG, "AFE4400 thread started"); |
| int x = 0; |
| while (!stopped) { |
| Message msg; |
| try { |
| msg = mHandler.obtainMessage(0, x++, dataInputStream.readInt()); |
| dataInputStream.readInt(); |
| msg.sendToTarget(); |
| } catch (IOException e1) { |
| // TODO Auto-generated catch block |
| e1.printStackTrace(); |
| break; |
| } |
| |
| try { |
| Thread.sleep(10); |
| } catch (InterruptedException e) { |
| // TODO Auto-generated catch block |
| e.printStackTrace(); |
| } |
| } |
| } |
| |
| public void requestStop() { |
| stopped = true; |
| } |
| |
| public boolean isStopped() { |
| return this.stopped; |
| } |
| } |