|
@@ -7,6 +7,7 @@ import android.content.DialogInterface;
|
|
|
import android.content.Intent;
|
|
|
import android.net.Uri;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.Environment;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.DisplayMetrics;
|
|
|
import android.util.Log;
|
|
@@ -61,7 +62,12 @@ import org.apache.http.Header;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileNotFoundException;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
import de.greenrobot.event.Subscribe;
|
|
@@ -198,10 +204,10 @@ public class RegisterUserBasicInfoActivity extends BaseActivity implements View.
|
|
|
// 窗口的宽度
|
|
|
int screenWidth = dm.widthPixels;
|
|
|
// 设置头像宽高
|
|
|
- LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) mAvatarImg.getLayoutParams();
|
|
|
- linearParams.width = screenWidth;
|
|
|
- linearParams.height = screenWidth;
|
|
|
- mAvatarImg.setLayoutParams(linearParams);
|
|
|
+// LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) mAvatarImg.getLayoutParams();
|
|
|
+// linearParams.width = screenWidth;
|
|
|
+// linearParams.height = screenWidth;
|
|
|
+// mAvatarImg.setLayoutParams(linearParams);
|
|
|
|
|
|
mAvatarImg.setOnClickListener(this);
|
|
|
findViewById(R.id.sex_select_rl).setOnClickListener(this);
|
|
@@ -419,10 +425,10 @@ public class RegisterUserBasicInfoActivity extends BaseActivity implements View.
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (!isSelectAvatar) {
|
|
|
- DialogHelper.tip(this, getString(R.string.must_select_avatar_can_register));
|
|
|
- return;
|
|
|
- }
|
|
|
+// if (!isSelectAvatar) {
|
|
|
+// DialogHelper.tip(this, getString(R.string.must_select_avatar_can_register));
|
|
|
+// return;
|
|
|
+// }
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
// 前面页面传递的信息
|
|
@@ -493,9 +499,11 @@ public class RegisterUserBasicInfoActivity extends BaseActivity implements View.
|
|
|
if (success) {
|
|
|
// 新注册的账号没有支付密码,
|
|
|
MyApplication.getInstance().initPayPassword(result.getData().getUserId(), 0);
|
|
|
+ mCurrentFile = getDefaultAvatarFile();
|
|
|
+ uploadAvatar(result.getData().getIsupdate(), mCurrentFile);
|
|
|
if (mCurrentFile != null && mCurrentFile.exists()) {
|
|
|
// 选择了头像,那么先上传头像
|
|
|
- uploadAvatar(result.getData().getIsupdate(), mCurrentFile);
|
|
|
+
|
|
|
return;
|
|
|
} else {
|
|
|
// 没有选择头像,直接进入程序主页
|
|
@@ -618,6 +626,35 @@ public class RegisterUserBasicInfoActivity extends BaseActivity implements View.
|
|
|
});
|
|
|
tipDialog.show();
|
|
|
}
|
|
|
+ private File getDefaultAvatarFile(){
|
|
|
+ try {
|
|
|
+
|
|
|
+ InputStream inputStream = getAssets().open("default_avatar.png");
|
|
|
+
|
|
|
+ File appDir = new File(Environment.getExternalStorageDirectory(), "image");
|
|
|
+ if (!appDir.exists()) {
|
|
|
+ appDir.mkdir();
|
|
|
+ }
|
|
|
+ String avatarFileName = "default_avatar.png";
|
|
|
+ File avatarFile = new File(appDir.getAbsolutePath(),avatarFileName);
|
|
|
+ if (avatarFile.exists()){
|
|
|
+ return avatarFile;
|
|
|
+ }
|
|
|
+ OutputStream outputStream = new FileOutputStream(avatarFile);
|
|
|
+ byte buffer[] = new byte[1024];
|
|
|
+ int length = 0;
|
|
|
+ while((length=inputStream.read(buffer)) > 0) {
|
|
|
+ outputStream.write(buffer,0,length);
|
|
|
+ }
|
|
|
+ outputStream.close();
|
|
|
+ inputStream.close();
|
|
|
+ return appDir;
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
private void uploadAvatar(int isupdate, File file) {
|
|
|
if (!file.exists()) {
|