移除阅读模块、修改数据库为原创
This commit is contained in:
@ -1,102 +0,0 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.FileUtils;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.TokenUtils;
|
||||
import com.gh.common.view.CropImageCustom;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CropImageActivity extends BaseActivity {
|
||||
|
||||
private CropImageCustom cropimage_custom;
|
||||
|
||||
private Handler handler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
if (msg.what == 0) {
|
||||
toast("上传成功");
|
||||
} else if (msg.what == 1) {
|
||||
toast("上传失败");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
View contentView = View
|
||||
.inflate(this, R.layout.activity_cropimage, null);
|
||||
|
||||
init(contentView, "图片裁剪");
|
||||
|
||||
RelativeLayout reuse_actionbar = (RelativeLayout) findViewById(R.id.reuse_actionbar);
|
||||
|
||||
TextView confirm = new TextView(this);
|
||||
confirm.setText("确定");
|
||||
confirm.setTextColor(0xffffffff);
|
||||
confirm.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
int padding = DisplayUtils.dip2px(getApplicationContext(), 10);
|
||||
confirm.setPadding(padding, padding, padding, padding);
|
||||
confirm.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Dialog dialog = DialogUtils.showWaitDialog(
|
||||
CropImageActivity.this, "上传中...");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String path = getCacheDir() + File.separator
|
||||
+ System.currentTimeMillis() + ".jpg";
|
||||
// String path = getExternalCacheDir() + File.separator
|
||||
// + System.currentTimeMillis() + ".jpg";
|
||||
cropimage_custom.savePicture(path);
|
||||
// 上传图片
|
||||
String token = TokenUtils
|
||||
.getToken(CropImageActivity.this);
|
||||
String url = FileUtils.uploadFile(Config.HOST + "v2/user/upload_user_icon", path, token);
|
||||
dialog.dismiss();
|
||||
if (url != null) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("url", url);
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
handler.sendEmptyMessage(0);
|
||||
} else {
|
||||
handler.sendEmptyMessage(1);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
rparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
rparams.addRule(RelativeLayout.CENTER_VERTICAL);
|
||||
confirm.setLayoutParams(rparams);
|
||||
reuse_actionbar.addView(confirm);
|
||||
|
||||
String path = getIntent().getStringExtra("path");
|
||||
|
||||
ImageUtils.getInstance(getApplicationContext()).displayFile(
|
||||
"file://" + path, cropimage_custom.getCropImageZoomView());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user