修复空头像异常

0515
ZHD 5 years ago
parent 67728a2315
commit c5b58c41e1
  1. 5
      app/src/main/AndroidManifest.xml
  2. 3
      app/src/main/java/com/community/pocket/data/main/info/InfoRequest.java
  3. 6
      app/src/main/java/com/community/pocket/util/HttpUtil.java
  4. 2
      app/src/main/res/values-zh-rCN/strings.xml
  5. 4
      app/src/main/res/xml/network_security_config.xml

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.community.pocket"> package="com.community.pocket">
<!-- 添加网络访问权限--> <!-- 添加网络访问权限-->
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
@ -14,7 +15,9 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:largeHeap="true"> android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
tools:targetApi="n">
<activity <activity
android:name=".ui.main.ui.forum.data.ForumDataActivity" android:name=".ui.main.ui.forum.data.ForumDataActivity"
android:windowSoftInputMode="adjustPan" /> android:windowSoftInputMode="adjustPan" />

@ -63,6 +63,9 @@ public class InfoRequest {
//获取头像 //获取头像
public void getImg(MutableLiveData<Bitmap> liveData, String url) { public void getImg(MutableLiveData<Bitmap> liveData, String url) {
if(url==null){
return;
}
HttpUtil.getRequest(new HttpFileResponse(liveData), url); HttpUtil.getRequest(new HttpFileResponse(liveData), url);
} }
} }

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Looper; import android.os.Looper;
import android.util.Log;
import android.util.Patterns; import android.util.Patterns;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
@ -129,6 +130,8 @@ public class HttpUtil {
@Override @Override
public void onFailure(@NotNull Call call, @NotNull IOException e) { public void onFailure(@NotNull Call call, @NotNull IOException e) {
bool.postValue(false); bool.postValue(false);
Log.e(HttpUtil.class.getName(),e.toString());
try {
if (BuildConfig.DEBUG) { if (BuildConfig.DEBUG) {
Looper.prepare(); Looper.prepare();
AlertDialog.Builder builder = getBuilder(context); AlertDialog.Builder builder = getBuilder(context);
@ -180,6 +183,9 @@ public class HttpUtil {
builder.show(); builder.show();
Looper.loop(); Looper.loop();
} }
} catch (Exception ex) {
Log.e(HttpUtil.class.getName(),ex.toString());
}
} }
@Override @Override

@ -207,7 +207,7 @@
<string name="open_url">尝试使用浏览器打开服务端</string> <string name="open_url">尝试使用浏览器打开服务端</string>
<string name="choose_browser">请选择浏览器</string> <string name="choose_browser">请选择浏览器</string>
<string name="rap2_error">请按照以下步骤检查:\n1.rap2服务端ip地址是否正确\n2.rap2服务是否已启动\n3.浏览器是否能访问rap2的web服务(默认:3000端口)</string> <string name="rap2_error">请按照以下步骤检查:\n1.rap2服务端ip地址是否正确\n2.rap2服务是否已启动\n3.浏览器是否能访问rap2的web服务(默认:3000端口)</string>
<string name="server_error">请按照以下步骤检查:\n1.springboot服务端ip地址是否正确\n2.mongo数据库服务是否已启动\n3.springboot服务端是否已启动</string> <string name="server_error">请按照以下步骤检查:\n1.springboot服务端ip地址是否正确\n2.mongo数据库服务是否已启动\n3.springboot服务端是否已启动\n4.如果是真机调试,请确认手机IP和服务端IP处于同一个网段</string>
<string name="debug_mode">%1s联调模式</string> <string name="debug_mode">%1s联调模式</string>
<string name="exit_app">是否退出应用?</string> <string name="exit_app">是否退出应用?</string>
<string name="YES"></string> <string name="YES"></string>

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config xmlns:android="http://schemas.android.com/apk/res/android">
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
Loading…
Cancel
Save