Commit 8abf92b5 authored by Administrator's avatar Administrator

当前设备出口查询

parent 50ad9037
......@@ -8,6 +8,7 @@ import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
public interface UserApi {
@GET("api/user/userInfo")
......@@ -18,4 +19,8 @@ public interface UserApi {
@POST("api/user/login")
Call<Result<UserInfo>> loginWithUsername(@Field("userName") String userName,
@Field("password") String password);
@GET("api/user/queryClientMapping")
Call<Result<Integer>> getClientMappingPort(@Query("clientId") String clientId);
}
......@@ -13,12 +13,21 @@ import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.virjar.echo.adr.R;
import com.virjar.echo.adr.bean.Result;
import com.virjar.echo.adr.component.LogServices;
import com.virjar.echo.adr.repo.APIServices;
import com.virjar.echo.adr.repo.EchoConfig;
import com.virjar.echo.nat.log.EchoLogger;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LogFragment extends Fragment {
private TextView logView;
private TextView mappingView;
private boolean running = false;
@Nullable
......@@ -28,9 +37,59 @@ public class LogFragment extends Fragment {
logView = view.findViewById(R.id.tv_log);
logView.setText(LogServices.logSnapshot());
mappingView = view.findViewById(R.id.tv_mapping_proxy);
return view;
}
@Override
public void onResume() {
super.onResume();
updateClientId();
}
private void updateClientId() {
APIServices.userApi.getClientMappingPort(
EchoConfig.getClientId()
).enqueue(new Callback<Result<Integer>>() {
@Override
public void onResponse(Call<Result<Integer>> call, Response<Result<Integer>> response) {
final Result<Integer> result = response.body();
if (!result.isOk()) {
new Handler(Looper.getMainLooper())
.postDelayed(new Runnable() {
@Override
public void run() {
updateClientId();
}
}, 3000);
return;
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
mappingView.setText(EchoConfig.getEchoServer() + ":" + result.getData());
}
});
}
@Override
public void onFailure(Call<Result<Integer>> call, Throwable t) {
EchoLogger.getLogger().error("can not get mapping info", t);
new Handler(Looper.getMainLooper())
.postDelayed(new Runnable() {
@Override
public void run() {
updateClientId();
}
}, 3000);
}
});
}
public void start() {
if (running) {
return;
......
package com.virjar.echo.adr.ui;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.virjar.echo.adr.R;
public class MineFragment extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_mine, container, false);
return view;
}
}
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.LogFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_login_account"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<Button
android:id="@+id/btn_login_out"
android:text="@string/logout"
android:paddingLeft="10dp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:text="@string/quota"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/tv_quota"
android:layout_weight="3"
android:layout_width="0dp"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:text="我的在线设备"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TextView>
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......@@ -25,4 +25,8 @@
<string name="attachment_summary_on">Automatically download attachments for incoming emails
</string>
<string name="attachment_summary_off">Only download attachments when manually requested</string>
<string name="logout">退出登录</string>
<string name="quota">容量</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment