Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # app/src/main/java/com/gh/gamecenter/SuggestionActivity.java
This commit is contained in:
@ -3,16 +3,15 @@ package com.gh.gamecenter;
|
||||
import android.app.Dialog;
|
||||
import android.content.*;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.*;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.net.Uri;
|
||||
import android.os.*;
|
||||
import android.provider.MediaStore;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.*;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
import android.view.*;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.*;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
@ -21,7 +20,7 @@ import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.*;
|
||||
import com.gh.gamecenter.entity.InstallGameEntity;
|
||||
import com.gh.gamecenter.entity.SuggestionTypeEntity;
|
||||
import com.gh.gamecenter.fragment.WaitingDialogFragment;
|
||||
import com.gh.gamecenter.retrofit.JSONObjectResponse;
|
||||
import com.gh.gamecenter.retrofit.RetrofitManager;
|
||||
import com.gh.gamecenter.suggest.*;
|
||||
@ -40,8 +39,6 @@ import rx.schedulers.Schedulers;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by khy on 2017/3/31.
|
||||
@ -55,13 +52,13 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
@BindView(R.id.suggest_news_link_et)
|
||||
EditText mSuggestNewsLinkEt;
|
||||
@BindView(R.id.suggest_news_link_ll)
|
||||
LinearLayout mSuggestNewsLinkLl;
|
||||
View mSuggestNewsLinkLl;
|
||||
@BindView(R.id.suggest_email_et)
|
||||
EditText mSuggestEmailEt;
|
||||
@BindView(R.id.suggest_post_btn)
|
||||
TextView mSuggestPostBtn;
|
||||
@BindView(R.id.suggest_post_ll)
|
||||
LinearLayout suggestPostLl;
|
||||
View suggestPostLl;
|
||||
@BindView(R.id.suggest_type_rv)
|
||||
RecyclerView mTypeRv;
|
||||
@BindView(R.id.suggest_select_game)
|
||||
@ -69,14 +66,14 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
@BindView(R.id.suggest_game_text)
|
||||
TextView mSuggestGameText;
|
||||
@BindView(R.id.suggest_game_ll)
|
||||
LinearLayout mSuggestGameLl;
|
||||
View mSuggestGameLl;
|
||||
@BindView(R.id.suggest_scrollview)
|
||||
ScrollView mScrollView;
|
||||
|
||||
private SuggestPicAdapter mAdapter;
|
||||
|
||||
private Dialog selectGameDialog;
|
||||
private Dialog postDialog;
|
||||
private WaitingDialogFragment postDialog;
|
||||
|
||||
private String[] arrType = {"普通反馈", "功能建议", "发生闪退", "游戏问题", "游戏收录", "文章投稿"};
|
||||
|
||||
@ -166,7 +163,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
decorView.getWindowVisibleDisplayFrame(rect);
|
||||
int screenHeight = decorView.getRootView().getHeight();
|
||||
int heightDifference = screenHeight - rect.bottom;//计算软键盘占有的高度 = 屏幕高度 - 视图可见高度
|
||||
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mScrollView.getLayoutParams();
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mScrollView.getLayoutParams();
|
||||
layoutParams.setMargins(0, 0, 0, heightDifference);//设置ScrollView的marginBottom的值为软键盘占有的高度即可
|
||||
mScrollView.requestLayout();
|
||||
}
|
||||
@ -264,7 +261,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
String email = mSuggestEmailEt.getText().toString().trim();
|
||||
String url = mSuggestNewsLinkEt.getText().toString().trim();
|
||||
|
||||
if (!TextUtils.isEmpty(url) && !isUrlAddress(url)) {
|
||||
if (!TextUtils.isEmpty(url) && !PatternUtils.isUrlAddress(url)) {
|
||||
Utils.toast(SuggestionActivity.this, "请输入正确的链接");
|
||||
return;
|
||||
}
|
||||
@ -272,16 +269,8 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
if (TextUtils.isEmpty(email)) {
|
||||
showConfirmDialog(email);
|
||||
} else {
|
||||
postDialog = new Dialog(SuggestionActivity.this);
|
||||
View content = View.inflate(SuggestionActivity.this, R.layout.set_wait_dialog, null);
|
||||
TextView message = (TextView) content
|
||||
.findViewById(R.id.set_wait_message);
|
||||
message.setText("正在反馈...");
|
||||
postDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
postDialog.setContentView(content);
|
||||
postDialog.setCanceledOnTouchOutside(false);
|
||||
postDialog.setCancelable(false);
|
||||
postDialog.show();
|
||||
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
|
||||
postDialog.show(getSupportFragmentManager(), null);
|
||||
|
||||
List<String> fileList = mAdapter.getFileList();
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
@ -310,34 +299,19 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
mSuggestEmailEt.requestFocus();
|
||||
new Thread() {
|
||||
mSuggestEmailEt.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(mSuggestEmailEt, 0);
|
||||
Util_System_Keyboard.showSoftKeyboard(getApplicationContext(), mSuggestEmailEt);
|
||||
}
|
||||
}.start();
|
||||
}, 300);
|
||||
}
|
||||
},
|
||||
new DialogUtils.CancelListener() {
|
||||
@Override
|
||||
public void onCancel() {
|
||||
postDialog = new Dialog(SuggestionActivity.this);
|
||||
View view = View.inflate(SuggestionActivity.this,
|
||||
R.layout.set_wait_dialog, null);
|
||||
TextView message = (TextView) view
|
||||
.findViewById(R.id.set_wait_message);
|
||||
message.setText("正在反馈...");
|
||||
postDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
postDialog.setContentView(view);
|
||||
postDialog.setCanceledOnTouchOutside(false);
|
||||
postDialog.setCancelable(false);
|
||||
postDialog.show();
|
||||
postDialog = WaitingDialogFragment.newInstance(getString(R.string.dialog_feedback_doing));
|
||||
postDialog.show(getSupportFragmentManager(), null);
|
||||
|
||||
List<String> fileList = mAdapter.getFileList();
|
||||
if (fileList != null && fileList.size() > 0) {
|
||||
@ -349,33 +323,6 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
});
|
||||
}
|
||||
|
||||
public boolean savePicture(String newPath, String filePath) {
|
||||
BitmapFactory.Options options = new BitmapFactory.Options();
|
||||
// options.inSampleSize = 2;
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(filePath, options);
|
||||
|
||||
File file = new File(newPath);
|
||||
int quality = 80;
|
||||
do {
|
||||
try {
|
||||
BufferedOutputStream bos = new BufferedOutputStream(
|
||||
new FileOutputStream(file));
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, bos);
|
||||
bos.flush();
|
||||
bos.close();
|
||||
} catch (IOException e) {
|
||||
file.delete();
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
quality -= 10;
|
||||
if (quality < 10) {
|
||||
quality = 10;
|
||||
}
|
||||
} while (file.length() > 81920 && quality > 10);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void postPic(final String email) {
|
||||
|
||||
final JSONArray picArray = new JSONArray();
|
||||
@ -386,7 +333,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
int index = 0;
|
||||
for (String s : mAdapter.getFileList()) {
|
||||
path = getCacheDir() + File.separator + System.currentTimeMillis() + index + ".jpg";
|
||||
if (savePicture(path, s)) {
|
||||
if (BitmapUtils.savePicture(path, s)) {
|
||||
subscriber.onNext(FileUtils.uploadFile(Config.HOST + "support/user/suggestion/img", path, null));
|
||||
index++;
|
||||
} else {
|
||||
@ -406,7 +353,9 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
postDialog.dismiss();
|
||||
if (postDialog != null) {
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
}
|
||||
Utils.toast(SuggestionActivity.this, "上传失败");
|
||||
Utils.log("=========上传失败" + e.toString());
|
||||
}
|
||||
@ -438,9 +387,9 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
params.put("sdk", String.valueOf(android.os.Build.VERSION.SDK_INT));
|
||||
params.put("version", android.os.Build.VERSION.RELEASE);
|
||||
params.put("source", "光环助手");
|
||||
params.put("imei", ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId());
|
||||
params.put("imei", Util_System_Phone_State.getDeviceId(this));
|
||||
|
||||
if ((curType == 6 || curType == 5)&& !TextUtils.isEmpty(mSuggestNewsLinkEt.getText().toString())) {
|
||||
if ((curType == 6 || curType == 5) && !TextUtils.isEmpty(mSuggestNewsLinkEt.getText().toString())) {
|
||||
params.put("url", mSuggestNewsLinkEt.getText().toString().trim());
|
||||
}
|
||||
if (curType > 0) {
|
||||
@ -482,7 +431,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
if (postDialog != null) {
|
||||
postDialog.dismiss();
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
}
|
||||
if (response.length() != 0) {
|
||||
try {
|
||||
@ -526,7 +475,7 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
return;
|
||||
} else {
|
||||
if (postDialog != null) {
|
||||
postDialog.dismiss();
|
||||
postDialog.dismissAllowingStateLoss();
|
||||
}
|
||||
|
||||
toast("提交失败,请检查网络状态");
|
||||
@ -666,17 +615,5 @@ public class SuggestionActivity extends BaseActivity implements SuggestTypeAdapt
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isEmailAddress(String email) {
|
||||
Pattern p = Pattern
|
||||
.compile("^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
|
||||
Matcher m = p.matcher(email);
|
||||
return m.matches();
|
||||
}
|
||||
|
||||
private boolean isUrlAddress(String url) {
|
||||
Pattern p = Pattern
|
||||
.compile("((http://|ftp://|https://|www.))(([a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6})|([0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\\&%_\\./-~-]*)?");
|
||||
Matcher m = p.matcher(url);
|
||||
return m.matches();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user