lmw
2024-09-04 a3bc6aa4fa3bad787c9fc366d6904f60265eec3b
app/src/main/java/com/lotaai/canguiayw/MainActivity.java
@@ -21,9 +21,15 @@
import com.lotaai.canguiayw.common.HttpLoggerInterceptor;
import com.lotaai.canguiayw.common.HttpUrlDefine;
import com.lotaai.canguiayw.common.SettingConfig;
import com.lotaai.canguiayw.device.CanGuiCommand;
import com.lotaai.canguiayw.device.DeviceMessage;
import com.lotaai.canguiayw.device.DeviceType;
import com.lotaai.canguiayw.device.MessageType;
import com.lotaai.canguiayw.device.service.CanGuiService;
import com.lotaai.canguiayw.mqtt.MyMQTTService;
import com.pranavpandey.android.dynamic.toasts.DynamicToast;
import org.greenrobot.eventbus.EventBus;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
@@ -36,24 +42,49 @@
import okhttp3.RequestBody;
import okhttp3.Response;
/* 262743  员工号*/
public class MainActivity extends AppCompatActivity {
    private Context context;
    private ImageView logoView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        LogUtils.i("VERSION.SDK_INT:" +VERSION.SDK_INT);
        LogUtils.i("VERSION.SDK_INT:" + VERSION.SDK_INT);
        logoView = findViewById(R.id.logo);
        context = MainActivity.this;
        /*new Thread(new Runnable() {
            @Override
            public void run() {
                while (true){
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    CThreadPoolExecutor.runOnMainThread(new Runnable() {
                        @Override
                        public void run() {
                            DynamicToast.makeSuccess(getApplicationContext(), "测试!", 3).show();
                        }
                    });
                }
            }
        }).start();*/
        Intent startIntent = new Intent(context, CanGuiService.class);
        startService(startIntent);
        Intent startMqttIntent = new Intent(context, MyMQTTService.class);
        startService(startMqttIntent);
        login();
        logoView.setOnLongClickListener(new View.OnLongClickListener() {
        /* */
      /*  Intent startMqttIntent = new Intent(context, MyMQTTService.class);
        startService(startMqttIntent);*/
        // login();
       /* logoView.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                Intent intent = new Intent();
@@ -61,7 +92,7 @@
                startActivity(intent);
                return true;
            }
        });
        });*/
//        testData();
    }
@@ -86,22 +117,25 @@
//        LogUtils.i("插入订单数据:" + order.getOrderNo());
//    }
    public void gotoSetting(View view){
    public void gotoSetting(View view) {
//        Intent intent = new Intent();
//        intent.setClass(MainActivity.this, AdminLoginActivity.class);
//        startActivity(intent);
    }
    public void take(View view){
    public void putIn(View view) {
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, TakeActivity.class);
        intent.putExtra("type",1);
        intent.setClass(MainActivity.this, CheckUserIdActivity.class);
        startActivity(intent);
    }
    public void putIn(View view){
    public void take(View view) {
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, ManageActivity.class);
        intent.setClass(MainActivity.this, TakeActivity.class);
        startActivity(intent);
    }
    public void login() {
@@ -133,7 +167,7 @@
            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String result = response.body().string();
                LogUtils.i("获取到的数据:"+result);
                LogUtils.i("获取到的数据:" + result);
                JSONObject obj = JSONObject.parseObject(result);
                if ("0".equals(obj.getString("code"))) {
                    JSONObject dataObj = obj.getJSONObject("data");
@@ -148,7 +182,7 @@
                } else {
                    Message msg = new Message();
                    msg.what = 0;
                    msg.obj = "登录失败:请重新激活!" ;
                    msg.obj = "登录失败:请重新激活!";
                    showHandler.sendMessage(msg);
                }
            }
@@ -168,4 +202,9 @@
        }
    };
    public void toset(View view) {
        Intent intent = new Intent();
        intent.setClass(MainActivity.this, ManageActivity.class);
        startActivity(intent);
    }
}