Skip to content

Instantly share code, notes, and snippets.

@oilking143
Created April 22, 2016 03:43
Show Gist options
  • Save oilking143/2f399ca33417d74b1cd9041bc4a75d88 to your computer and use it in GitHub Desktop.
Save oilking143/2f399ca33417d74b1cd9041bc4a75d88 to your computer and use it in GitHub Desktop.
package tw.com.acme_soft.mibandscanner.frafment;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.zhaoxiaodan.miband.ActionCallback;
import com.zhaoxiaodan.miband.MiBand;
import com.zhaoxiaodan.miband.listeners.NotifyListener;
import tw.com.acme_soft.mibandscanner.Activity.CarActivity;
import tw.com.acme_soft.mibandscanner.Activity.controlActivity;
import tw.com.acme_soft.mibandscanner.Activity.rotationActivity;
import tw.com.acme_soft.mibandscanner.R;
import tw.com.acme_soft.mibandscanner.TPMSApplication;
import tw.com.acme_soft.mibandscanner.interFace.contentToFragment;
import tw.com.acme_soft.mibandscanner.utility;
/**
* Created by Oil on 2016/4/14.
*/
public class carFragment extends Fragment implements contentToFragment{
private View v;
private utility uti=new utility();
private ImageButton rotation;
/**
* 車胎資料
*
* **/
private String[] LFData=null;
private String[] LBData=null;
private String[] RFData=null;
private String[] RBData=null;
/**
* 參數顯示
*
* **/
private TextView LFID;
private TextView LFPress;
private TextView LFTemp;
private TextView LFBattery;
private TextView RFID;
private TextView RFPress;
private TextView RFTemp;
private TextView RFBattery;
private TextView LBID;
private TextView LBPress;
private TextView LBTemp;
private TextView LBBattery;
private TextView RBID;
private TextView RBPress;
private TextView RBTemp;
private TextView RBBattery;
private Handler mUI_Handler = new Handler();
private Handler mThreadHandler;
private HandlerThread mThread;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
v=inflater.inflate(R.layout.carlayout,null,false);
rotation=(ImageButton)v.findViewById(R.id.rotation);
LFID=(TextView)v.findViewById(R.id.tire_id_FL);
LFPress=(TextView)v.findViewById(R.id.tire_press_FL);
LFTemp=(TextView)v.findViewById(R.id.tire_temp_FL);;
LFBattery=(TextView)v.findViewById(R.id.tire_battery_FL);;
RFID=(TextView)v.findViewById(R.id.tire_id_rf);;
RFPress=(TextView)v.findViewById(R.id.tire_press_rf);;
RFTemp=(TextView)v.findViewById(R.id.tire_temp_rf);;
RFBattery=(TextView)v.findViewById(R.id.tire_battery_rf);;
LBID=(TextView)v.findViewById(R.id.tire_id_lb_car);
LBPress=(TextView)v.findViewById(R.id.tire_press_lb_car);
LBTemp=(TextView)v.findViewById(R.id.tire_temp_lb_car);
LBBattery=(TextView)v.findViewById(R.id.tire_battery_lb_car);
RBID=(TextView)v.findViewById(R.id.tire_id_rb);;
RBPress=(TextView)v.findViewById(R.id.tire_press_rb);;
RBTemp=(TextView)v.findViewById(R.id.tire_temp_rb);;
RBBattery=(TextView)v.findViewById(R.id.tire_battery_rb);;
mThread = new HandlerThread("name");
mThread.start();
mThreadHandler=new Handler(mThread.getLooper());
MiBand mMiband=new MiBand(getActivity());
mMiband.SynchronizeTPMS();
// mThreadHandler.postDelayed(r1, 5000);
rotation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
Bundle bundle = new Bundle();
bundle.putInt("flag", 0);
intent.putExtras(bundle).setClass(getActivity(), rotationActivity.class);
startActivity(intent);
}
});
uti.setcalloutListener(new contentToFragment() {
@Override
public void callOut(String[] data) {
if(data!=null) {
System.out.println("data~~~" + data[0]);
}
}
});
return v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment