优化代码
This commit is contained in:
@@ -28,6 +28,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private View send;
|
||||
private View fresh;
|
||||
private View fresh2;
|
||||
private TextView content;
|
||||
|
||||
@Override
|
||||
@@ -37,6 +38,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
send = findViewById( R.id.send );
|
||||
fresh = findViewById( R.id.fresh );
|
||||
fresh2 = findViewById( R.id.fresh2 );
|
||||
content = findViewById( R.id.content );
|
||||
|
||||
httpDns = MogoHttpDnsHandler.getHttpDnsApi();
|
||||
@@ -91,6 +93,30 @@ public class MainActivity extends AppCompatActivity {
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
fresh2.setOnClickListener( new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick( View v ) {
|
||||
WorkThreadHandler.getInstance().post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
httpDns.getHttpDnsIp( "dzt-city.zhidaozhixing.com", false, new IHttpDnsCallback() {
|
||||
@Override
|
||||
public void onParsed( @Nullable String ip ) {
|
||||
StringBuilder sb = new StringBuilder( "httpDns ip:\n" );
|
||||
sb.append( ip ).append( "\n" );
|
||||
UiThreadHandler.post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
content.setText( sb.toString() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
private void renderResponse( ResponseBody body ) {
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="发起dns请求" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/fresh2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="发起dns请求2" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user