|
|
@ -5,12 +5,12 @@ import android.content.Context; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.DialogInterface; |
|
|
|
import android.content.Intent; |
|
|
|
import android.content.Intent; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
import android.graphics.Bitmap; |
|
|
|
|
|
|
|
import android.graphics.ImageDecoder; |
|
|
|
import android.graphics.Paint; |
|
|
|
import android.graphics.Paint; |
|
|
|
import android.graphics.Rect; |
|
|
|
import android.graphics.Rect; |
|
|
|
import android.net.Uri; |
|
|
|
import android.net.Uri; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Environment; |
|
|
|
|
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Handler; |
|
|
|
import android.os.Looper; |
|
|
|
import android.os.Looper; |
|
|
|
import android.os.Message; |
|
|
|
import android.os.Message; |
|
|
@ -30,9 +30,11 @@ import androidx.annotation.NonNull; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.annotation.Nullable; |
|
|
|
import androidx.annotation.RequiresApi; |
|
|
|
import androidx.annotation.RequiresApi; |
|
|
|
import androidx.appcompat.app.AlertDialog; |
|
|
|
import androidx.appcompat.app.AlertDialog; |
|
|
|
|
|
|
|
import androidx.core.content.FileProvider; |
|
|
|
import androidx.lifecycle.MutableLiveData; |
|
|
|
import androidx.lifecycle.MutableLiveData; |
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
import androidx.lifecycle.ViewModelProvider; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.community.pocket.BuildConfig; |
|
|
|
import com.community.pocket.R; |
|
|
|
import com.community.pocket.R; |
|
|
|
import com.community.pocket.data.model.CreditScore; |
|
|
|
import com.community.pocket.data.model.CreditScore; |
|
|
|
import com.community.pocket.data.model.LocalToken; |
|
|
|
import com.community.pocket.data.model.LocalToken; |
|
|
@ -60,11 +62,11 @@ import org.xutils.view.annotation.Event; |
|
|
|
import org.xutils.view.annotation.ViewInject; |
|
|
|
import org.xutils.view.annotation.ViewInject; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.FileOutputStream; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 我的信息框架 |
|
|
|
* 我的信息框架 |
|
|
@ -130,11 +132,18 @@ public class InfoFragment extends BaseFragment { |
|
|
|
//上传头像
|
|
|
|
//上传头像
|
|
|
|
private Handler uploadImgHandler; |
|
|
|
private Handler uploadImgHandler; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//压缩头像
|
|
|
|
|
|
|
|
private Handler compressHandler; |
|
|
|
|
|
|
|
|
|
|
|
//检测是否有读写文件权限
|
|
|
|
//检测是否有读写文件权限
|
|
|
|
private MutableLiveData<Boolean> bool = new MutableLiveData<>(); |
|
|
|
private MutableLiveData<Boolean> bool = new MutableLiveData<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//拍照uri
|
|
|
|
|
|
|
|
private Uri photoUri; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//显示信用分图表要求的最小记录数
|
|
|
|
|
|
|
|
private static final int MIN_HISTORY = 2; |
|
|
|
|
|
|
|
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.KITKAT) |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
|
|
|
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { |
|
|
|
super.onViewCreated(view, savedInstanceState); |
|
|
|
super.onViewCreated(view, savedInstanceState); |
|
|
@ -217,16 +226,18 @@ public class InfoFragment extends BaseFragment { |
|
|
|
if (infoResponse == null) { |
|
|
|
if (infoResponse == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (uploadImgHandler != null) { |
|
|
|
uploadImgHandler.sendEmptyMessage(infoResponse.getResult().ordinal()); |
|
|
|
uploadImgHandler.sendEmptyMessage(infoResponse.getResult().ordinal()); |
|
|
|
|
|
|
|
} |
|
|
|
infoResponse.toast(getContext()); |
|
|
|
infoResponse.toast(getContext()); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//监听获取头像状态
|
|
|
|
//监听获取头像状态
|
|
|
|
viewModel.getGetImg().observe(getViewLifecycleOwner(), bitmap -> headimg.setImageBitmap(bitmap)); |
|
|
|
viewModel.getGetImg().observe(getViewLifecycleOwner(), bitmap -> headimg.setImageBitmap(bitmap)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 加载个人信息 |
|
|
|
* 加载个人信息 |
|
|
|
* |
|
|
|
* |
|
|
@ -243,7 +254,7 @@ public class InfoFragment extends BaseFragment { |
|
|
|
viewModel.getImg(myInfo.getHeadImg()); |
|
|
|
viewModel.getImg(myInfo.getHeadImg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (myInfo.getScoreHistory() != null && myInfo.getScoreHistory().size() >= 2) { |
|
|
|
if (myInfo.getScoreHistory() != null && myInfo.getScoreHistory().size() >= MIN_HISTORY) { |
|
|
|
loadChart(myInfo.getScoreHistory()); |
|
|
|
loadChart(myInfo.getScoreHistory()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -269,10 +280,13 @@ public class InfoFragment extends BaseFragment { |
|
|
|
if (file.exists()) { |
|
|
|
if (file.exists()) { |
|
|
|
bool.postValue(true); |
|
|
|
bool.postValue(true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
bool.postValue(false); |
|
|
|
boolean mkdirs = file.mkdirs(); |
|
|
|
String msg = "无法创建照片目录"; |
|
|
|
bool.postValue(mkdirs); |
|
|
|
Log.e(InfoFragment.class.getName(), msg); |
|
|
|
if (!mkdirs) { |
|
|
|
throw new RuntimeException(msg); |
|
|
|
String msg = "无法创建照片目录"; |
|
|
|
|
|
|
|
Log.e(InfoFragment.class.getName(), msg); |
|
|
|
|
|
|
|
throw new RuntimeException(msg); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -284,14 +298,13 @@ public class InfoFragment extends BaseFragment { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 点击头像操作 |
|
|
|
* 点击头像操作 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void clickHeadImg() { |
|
|
|
private void clickHeadImg() { |
|
|
|
bool.observe(getViewLifecycleOwner(), aBoolean -> { |
|
|
|
bool.observe(getViewLifecycleOwner(), aBoolean -> { |
|
|
|
if (aBoolean) { |
|
|
|
if (aBoolean) { |
|
|
|
headimg.setOnClickListener(v -> new AlertDialog.Builder(Objects.requireNonNull(getContext())) |
|
|
|
headimg.setOnClickListener(v -> new AlertDialog.Builder(requireContext()) |
|
|
|
.setNegativeButton(R.string.open_photo_album, (dialog, which) -> { |
|
|
|
.setNegativeButton(R.string.open_photo_album, (dialog, which) -> { |
|
|
|
// 打开相册
|
|
|
|
// 打开相册
|
|
|
|
Intent intent = new Intent(Intent.ACTION_PICK); |
|
|
|
Intent intent = new Intent(Intent.ACTION_PICK); |
|
|
@ -303,12 +316,20 @@ public class InfoFragment extends BaseFragment { |
|
|
|
|
|
|
|
|
|
|
|
File file = getPhotoDir(); |
|
|
|
File file = getPhotoDir(); |
|
|
|
File photoFile = new File(file, System.currentTimeMillis() + "origin.png"); |
|
|
|
File photoFile = new File(file, System.currentTimeMillis() + "origin.png"); |
|
|
|
Log.i(InfoFragment.class.getName(), "图片存储到" + photoFile.getAbsolutePath()); |
|
|
|
Log.i(InfoFragment.class.getName(), "图片存储到:" + photoFile.getAbsolutePath()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) { |
|
|
|
|
|
|
|
photoUri = Uri.fromFile(photoFile); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
photoUri = FileProvider.getUriForFile( |
|
|
|
|
|
|
|
requireContext(), |
|
|
|
|
|
|
|
BuildConfig.APPLICATION_ID + ".fileprovider", |
|
|
|
|
|
|
|
photoFile); |
|
|
|
|
|
|
|
} |
|
|
|
// 隐式意图打开系统界面 --要求回传
|
|
|
|
// 隐式意图打开系统界面 --要求回传
|
|
|
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
|
|
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); |
|
|
|
// 存到什么位置
|
|
|
|
// 存到什么位置
|
|
|
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); |
|
|
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri); |
|
|
|
intent.putExtra(Action.OPEN_CAMERA.name(), photoFile); |
|
|
|
|
|
|
|
startActivityForResult(intent, Action.OPEN_CAMERA.ordinal()); |
|
|
|
startActivityForResult(intent, Action.OPEN_CAMERA.ordinal()); |
|
|
|
}) |
|
|
|
}) |
|
|
|
.setPositiveButton(R.string.action_close, (dialog, which) -> dialog.dismiss()).show()); |
|
|
|
.setPositiveButton(R.string.action_close, (dialog, which) -> dialog.dismiss()).show()); |
|
|
@ -320,7 +341,7 @@ public class InfoFragment extends BaseFragment { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private File getPhotoDir() { |
|
|
|
private File getPhotoDir() { |
|
|
|
return new File(Environment.getExternalStorageDirectory(), |
|
|
|
return new File(requireContext().getExternalCacheDir(), |
|
|
|
getString(R.string.app_name)); |
|
|
|
getString(R.string.app_name)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -331,38 +352,72 @@ public class InfoFragment extends BaseFragment { |
|
|
|
|
|
|
|
|
|
|
|
//判断是否有裁剪应用
|
|
|
|
//判断是否有裁剪应用
|
|
|
|
private boolean hasCrop() { |
|
|
|
private boolean hasCrop() { |
|
|
|
Context context = getContext(); |
|
|
|
return getCropIntent().resolveActivity(requireContext().getPackageManager()) != null; |
|
|
|
return context != null && getCropIntent().resolveActivity(getContext().getPackageManager()) != null; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//设置头像
|
|
|
|
//设置头像
|
|
|
|
private void setHeadImg(Bitmap bitmap) { |
|
|
|
private void setHeadImg(Uri uri) { |
|
|
|
File picFile = new File(getPhotoDir(), System.currentTimeMillis() + ".png"); |
|
|
|
File picFile = new File(getPhotoDir(), System.currentTimeMillis() + ".png"); |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (picFile.createNewFile()) { |
|
|
|
if (picFile.createNewFile()) { |
|
|
|
bitmap.compress(Bitmap.CompressFormat.PNG, 100, new FileOutputStream( |
|
|
|
|
|
|
|
picFile)); |
|
|
|
|
|
|
|
Context context = Objects.requireNonNull(getContext()); |
|
|
|
Bitmap bitmap; |
|
|
|
TextView textView = new TextView(context); |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { |
|
|
|
|
|
|
|
bitmap = ImageDecoder.decodeBitmap(ImageDecoder.createSource(requireContext().getContentResolver(), uri)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
bitmap = MediaStore.Images.Media.getBitmap(requireContext().getContentResolver(), uri); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Context context = requireContext(); |
|
|
|
|
|
|
|
TextView textView = new TextView(getContext()); |
|
|
|
textView.setTextSize(18); |
|
|
|
textView.setTextSize(18); |
|
|
|
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); |
|
|
|
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL); |
|
|
|
textView.setText(R.string.upload_img); |
|
|
|
textView.setText(R.string.compress_img); |
|
|
|
AlertDialog alertDialog = new AlertDialog.Builder(context) |
|
|
|
|
|
|
|
.setView(textView).show(); |
|
|
|
AlertDialog uploadDialog = new AlertDialog.Builder(context) |
|
|
|
uploadImgHandler = new Handler(Looper.getMainLooper()) { |
|
|
|
.setView(textView).setCancelable(false).show(); |
|
|
|
|
|
|
|
compressHandler = new Handler(Looper.getMainLooper()) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void handleMessage(@NonNull Message msg) { |
|
|
|
public void handleMessage(@NonNull Message msg) { |
|
|
|
alertDialog.dismiss(); |
|
|
|
|
|
|
|
if (msg.what == Response.Result.OK.ordinal()) { |
|
|
|
if (msg.what == Response.Result.OK.ordinal()) { |
|
|
|
headimg.setImageBitmap(bitmap); |
|
|
|
Log.i(InfoFragment.class.getName(), "位图大小:" + bitmap.getByteCount() / 1024 + "KB" + ",压缩大小" + picFile.length() / 1024 + "KB"); |
|
|
|
|
|
|
|
uploadImgHandler = new Handler(Looper.getMainLooper()) { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void handleMessage(@NonNull Message msg) { |
|
|
|
|
|
|
|
uploadDialog.dismiss(); |
|
|
|
|
|
|
|
if (msg.what == Response.Result.OK.ordinal()) { |
|
|
|
|
|
|
|
headimg.setImageBitmap(bitmap); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
textView.setText(R.string.upload_img); |
|
|
|
|
|
|
|
viewModel.uploadImg(picFile); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
uploadDialog.dismiss(); |
|
|
|
|
|
|
|
Toast.makeText(context, R.string.unknow_error, Toast.LENGTH_LONG).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
viewModel.uploadImg(picFile); |
|
|
|
|
|
|
|
|
|
|
|
new Thread(() -> { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
bitmap.compress(Bitmap.CompressFormat.PNG, getResources().getInteger(R.integer.photo_quality), new FileOutputStream( |
|
|
|
|
|
|
|
picFile)); |
|
|
|
|
|
|
|
compressHandler.sendEmptyMessage(Response.Result.OK.ordinal()); |
|
|
|
|
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
Log.e(InfoFragment.class.getName(), e.toString()); |
|
|
|
|
|
|
|
compressHandler.sendEmptyMessage(Response.Result.FAIL.ordinal()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}).start(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
|
Log.e(InfoFragment.class.getName(), e.toString()); |
|
|
|
Log.e(InfoFragment.class.getName(), e.toString()); |
|
|
|
|
|
|
|
Toast.makeText(getContext(), R.string.unknow_error, Toast.LENGTH_LONG).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -394,35 +449,12 @@ public class InfoFragment extends BaseFragment { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
|
|
|
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { |
|
|
|
Log.i(InfoFragment.class.getName(), "requestCode:" + requestCode + ",resultCode:" + resultCode); |
|
|
|
Log.i(InfoFragment.class.getName(), "requestCode:" + requestCode + ",resultCode:" + resultCode); |
|
|
|
|
|
|
|
//获取图片路径
|
|
|
|
if (data != null) { |
|
|
|
if (requestCode == Action.OPEN_GALLERY.ordinal() && data != null && data.getData() != null) { |
|
|
|
//获取路径
|
|
|
|
setHeadImg(data.getData()); |
|
|
|
if (requestCode == Action.OPEN_GALLERY.ordinal() || requestCode == Action.OPEN_CAMERA.ordinal()) { |
|
|
|
} else if (requestCode == Action.OPEN_CAMERA.ordinal() && photoUri != null) { |
|
|
|
if (hasCrop()) { |
|
|
|
setHeadImg(photoUri); |
|
|
|
crop(data.getData()); |
|
|
|
photoUri = null; |
|
|
|
} else { |
|
|
|
|
|
|
|
Context context = getContext(); |
|
|
|
|
|
|
|
if (context != null) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContext().getContentResolver(), data.getData()); |
|
|
|
|
|
|
|
setHeadImg(bitmap); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
Log.e(InfoFragment.class.getName(), e.toString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Log.e(InfoFragment.class.getName(), "无法获取Context"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (requestCode == Action.CROP.ordinal()) { |
|
|
|
|
|
|
|
//直接拿到一张图片
|
|
|
|
|
|
|
|
Bitmap bitmap = data.getParcelableExtra("data"); |
|
|
|
|
|
|
|
if (bitmap != null) { |
|
|
|
|
|
|
|
setHeadImg(bitmap); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Log.e(InfoFragment.class.getName(), "无法获取裁剪图片"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -450,7 +482,7 @@ public class InfoFragment extends BaseFragment { |
|
|
|
newPwd.addTextChangedListener(textWatcher); |
|
|
|
newPwd.addTextChangedListener(textWatcher); |
|
|
|
confirmNewPwd.addTextChangedListener(textWatcher); |
|
|
|
confirmNewPwd.addTextChangedListener(textWatcher); |
|
|
|
|
|
|
|
|
|
|
|
AlertDialog.Builder alert = new AlertDialog.Builder(Objects.requireNonNull(getContext())); |
|
|
|
AlertDialog.Builder alert = new AlertDialog.Builder(requireContext()); |
|
|
|
final AlertDialog alertDialog = alert.setTitle(R.string.modify_password).setView(view) |
|
|
|
final AlertDialog alertDialog = alert.setTitle(R.string.modify_password).setView(view) |
|
|
|
.setNegativeButton(R.string.modify_password, (dialog, which) -> { |
|
|
|
.setNegativeButton(R.string.modify_password, (dialog, which) -> { |
|
|
|
viewModel.modifyPwd(oldPwd.getText().toString(), newPwd.getText().toString()); |
|
|
|
viewModel.modifyPwd(oldPwd.getText().toString(), newPwd.getText().toString()); |
|
|
@ -494,7 +526,7 @@ public class InfoFragment extends BaseFragment { |
|
|
|
return Utils.convertPixelsToDp(rect.left + rect.right); |
|
|
|
return Utils.convertPixelsToDp(rect.left + rect.right); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//折线图添加数据源
|
|
|
|
private LineDataSet addChart(List<CreditScore> values) { |
|
|
|
private LineDataSet addChart(List<CreditScore> values) { |
|
|
|
List<Entry> entryList = new ArrayList<>(); |
|
|
|
List<Entry> entryList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
@ -537,8 +569,8 @@ public class InfoFragment extends BaseFragment { |
|
|
|
xAxis.setDrawGridLines(false); |
|
|
|
xAxis.setDrawGridLines(false); |
|
|
|
|
|
|
|
|
|
|
|
//设置Y轴数据格式
|
|
|
|
//设置Y轴数据格式
|
|
|
|
initYAxis(lineChart.getAxisLeft(), textSize); |
|
|
|
inityaxis(lineChart.getAxisLeft(), textSize); |
|
|
|
initYAxis(lineChart.getAxisRight(), textSize); |
|
|
|
inityaxis(lineChart.getAxisRight(), textSize); |
|
|
|
|
|
|
|
|
|
|
|
//设置x轴0刻度和最后刻度的左右偏移,保证日期显示完整
|
|
|
|
//设置x轴0刻度和最后刻度的左右偏移,保证日期显示完整
|
|
|
|
float offset = computeTextWidth(getString(R.string.dateformat), textSize) + 3; |
|
|
|
float offset = computeTextWidth(getString(R.string.dateformat), textSize) + 3; |
|
|
@ -558,7 +590,7 @@ public class InfoFragment extends BaseFragment { |
|
|
|
legend.setEnabled(false); |
|
|
|
legend.setEnabled(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initYAxis(YAxis yAxis, int textSize) { |
|
|
|
private void inityaxis(YAxis yAxis, int textSize) { |
|
|
|
//轴细分粒度最小单位长度
|
|
|
|
//轴细分粒度最小单位长度
|
|
|
|
yAxis.setAxisMinimum(1); |
|
|
|
yAxis.setAxisMinimum(1); |
|
|
|
//轴间隔最小单位长度
|
|
|
|
//轴间隔最小单位长度
|
|
|
|