光环助手V2.4优化汇总(20170302)

This commit is contained in:
khy
2017-03-07 09:46:54 +08:00
parent d870e68001
commit 9a2f4c984c
37 changed files with 396 additions and 152 deletions

View File

@ -1,11 +1,14 @@
package com.gh.gamecenter;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
@ -28,6 +31,8 @@ import org.json.JSONObject;
import java.io.File;
import java.lang.ref.SoftReference;
import java.net.HttpURLConnection;
import java.text.SimpleDateFormat;
import java.util.Date;
import butterknife.BindView;
import rx.Observable;
@ -42,6 +47,8 @@ public class CropImageActivity extends BaseActivity {
private SoftReference<Bitmap> reference;
private SharedPreferences sp;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
@ -63,6 +70,8 @@ public class CropImageActivity extends BaseActivity {
init(contentView, "图片裁剪");
sp = getSharedPreferences(Config.PREFERENCE, Context.MODE_PRIVATE);
RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
TextView confirm = new TextView(this);
@ -135,11 +144,36 @@ public class CropImageActivity extends BaseActivity {
try {
int statusCode = result.getInt("statusCode");
if (statusCode == HttpURLConnection.HTTP_OK) {
handler.sendEmptyMessage(0);
String iconCount = sp.getString("updateIconCount", null);
long l = System.currentTimeMillis();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String time = format.format(new Date(l));
JSONObject jsonObject = new JSONObject();
jsonObject.put("time", time);
if (TextUtils.isEmpty(iconCount)) {
jsonObject.put("count", 1);
} else {
JSONObject json = new JSONObject(iconCount);
String lastTime = json.getString("time");
if (lastTime.equals(time)) {
jsonObject.put("count", json.getInt("count") + 1);
} else {
jsonObject.put("count", 1);
}
}
sp.edit().putString("updateIconCount", jsonObject.toString()).apply();
Intent data = new Intent();
data.putExtra("url", result.getString("icon"));
setResult(RESULT_OK, data);
finish();
handler.sendEmptyMessage(0);
} else if (statusCode == HttpURLConnection.HTTP_FORBIDDEN
&& "too frequent".equals(result.getString("detail"))) {
handler.sendEmptyMessage(2);