1.完善手机拍照上传照片

2.令牌过期重新跳到登陆界面
3.优化部分代码
0515
panqihua 5 years ago
parent 7d6b1d47ac
commit 057cd6309e
  1. 4
      app/build.gradle
  2. 13
      app/src/main/AndroidManifest.xml
  3. 4
      app/src/main/java/com/community/pocket/ui/BaseFragment.java
  4. 5
      app/src/main/java/com/community/pocket/ui/login/LoginActivity.java
  5. 13
      app/src/main/java/com/community/pocket/ui/main/MainFragment.java
  6. 1
      app/src/main/java/com/community/pocket/ui/main/ui/forum/ForumPost.java
  7. 84
      app/src/main/java/com/community/pocket/ui/main/ui/forum/data/ForumDataActivity.java
  8. 24
      app/src/main/java/com/community/pocket/ui/main/ui/forum/hot/ForumHotFragment.java
  9. 9
      app/src/main/java/com/community/pocket/ui/main/ui/forum/main/ForumFragment.java
  10. 7
      app/src/main/java/com/community/pocket/ui/main/ui/forum/post/ForumPostFragment.java
  11. 2
      app/src/main/java/com/community/pocket/ui/main/ui/garbage/GarbageFragment.java
  12. 19
      app/src/main/java/com/community/pocket/ui/main/ui/garbage/sorting/GarbageSortingFragment.java
  13. 40
      app/src/main/java/com/community/pocket/ui/main/ui/garbage/waste/GarbageWasteFragment.java
  14. 162
      app/src/main/java/com/community/pocket/ui/main/ui/info/InfoFragment.java
  15. 1
      app/src/main/java/com/community/pocket/ui/main/ui/share/MyAutoCompleteTextView.java
  16. 11
      app/src/main/java/com/community/pocket/ui/main/ui/share/Response.java
  17. 11
      app/src/main/java/com/community/pocket/ui/main/ui/share/ShowWordCount.java
  18. 2
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorFragment.java
  19. 18
      app/src/main/java/com/community/pocket/ui/main/ui/visitor/VisitorMyVisitor.java
  20. 1
      app/src/main/java/com/community/pocket/ui/register/RegisterResponse.java
  21. 2
      app/src/main/java/com/community/pocket/ui/resetpwd/ResetPwdViewModel.java
  22. 6
      app/src/main/java/com/community/pocket/util/HttpFileResponse.java
  23. 10
      app/src/main/java/com/community/pocket/util/HttpJSONResponse.java
  24. 29
      app/src/main/java/com/community/pocket/util/HttpUtil.java
  25. 21
      app/src/main/java/com/community/pocket/util/PermissionsUtils.java
  26. 12
      app/src/main/java/com/community/pocket/util/PropertiesUtil.java
  27. 23
      app/src/main/java/com/community/pocket/util/ValidUtil.java
  28. 10
      app/src/main/res/layout/main/layout/info/layout/info_fragment.xml
  29. 1
      app/src/main/res/values-en-rUS/strings.xml
  30. 1
      app/src/main/res/values-zh-rCN/strings.xml
  31. 1
      app/src/main/res/values/integers.xml
  32. 1
      app/src/main/res/values/strings.xml
  33. 6
      app/src/main/res/xml/provider_paths.xml

@ -90,8 +90,8 @@ dependencies {
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
implementation 'androidx.navigation:navigation-fragment:2.2.2'
implementation 'androidx.navigation:navigation-ui:2.2.2'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13'

@ -13,7 +13,8 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:largeHeap="true">
<activity
android:name=".ui.main.ui.forum.data.ForumDataActivity"
android:windowSoftInputMode="adjustPan" />
@ -35,6 +36,16 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>
</manifest>

@ -23,7 +23,8 @@ public abstract class BaseFragment extends Fragment {
@NonNull
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return x.view().inject(this, inflater, container);//fragment注解
//fragment注解
return x.view().inject(this, inflater, container);
}
//获取父级Fragment
@ -56,4 +57,5 @@ public abstract class BaseFragment extends Fragment {
protected String formatUnix(Long time) {
return DateFormat.format(getString(R.string.dateformat), time).toString();
}
}

@ -43,6 +43,7 @@ import okhttp3.FormBody;
/**
* 登陆
* @author panqihua
*/
@ContentView(R.layout.activity_login)
@ -76,7 +77,7 @@ public class LoginActivity extends BaseActivity {
/**
* 保存令牌到数据库并跳转到主界面
*/
private void saveTokenToDB(@NotNull final LoginResponse response) {
private void savetokentodb(@NotNull final LoginResponse response) {
new Thread(() -> {
Token token = response.getToken();
sInstance.tokenDao().save(token);
@ -153,7 +154,7 @@ public class LoginActivity extends BaseActivity {
setResult(Activity.RESULT_OK);
if (loginResponse.getResult() == Response.Result.OK) {
saveTokenToDB(loginResponse);
savetokentodb(loginResponse);
} else {
loginResponse.toast(getApplicationContext());
}

@ -5,14 +5,13 @@ import android.view.View;
import android.widget.Button;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import com.community.pocket.R;
import com.community.pocket.ui.BaseFragment;
import java.util.Objects;
/**
* 二级菜单基础框架
*/
@ -41,20 +40,20 @@ public abstract class MainFragment extends BaseFragment {
*/
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
protected void changeColor(View view) {
int color = getResources().getColor(R.color.button_unchecked);
for (int id : button_ids()) {
View v = Objects.requireNonNull(getActivity()).findViewById(id);
int color = ContextCompat.getColor(requireContext(), R.color.button_unchecked);
for (int id : buttonIds()) {
View v = requireActivity().findViewById(id);
v.setBackgroundColor(color);
}
if (view instanceof Button) {
Button button = (Button) view;
button.setBackgroundColor(getResources().getColor(R.color.colorAccent));
button.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.colorAccent));
}
}
/**
* 按钮组id
*/
protected abstract int[] button_ids();
protected abstract int[] buttonIds();
}

@ -64,6 +64,7 @@ public abstract class ForumPost extends BaseFragment {
case uncheck:
status.setText(R.string.forum_status_uncheck);
break;
default:
}
TextView title = childView.findViewById(R.id.post_title);

@ -19,7 +19,6 @@ import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.widget.NestedScrollView;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
@ -95,64 +94,50 @@ public class ForumDataActivity extends BaseActivity {
viewModel.loadData(forumId);
//监听回帖表单状态
viewModel.getForumReplyState().observe(this, new Observer<ForumReplyState>() {
@Override
public void onChanged(ForumReplyState forumReplyState) {
if (forumReplyState == null) {
return;
}
if (forumReplyState.getContentError() != null) {
editText.setError(getString(forumReplyState.getContentError()));
}
viewModel.getForumReplyState().observe(this, forumReplyState -> {
if (forumReplyState == null) {
return;
}
reply.setEnabled(forumReplyState.isDataValid());
if (forumReplyState.getContentError() != null) {
editText.setError(getString(forumReplyState.getContentError()));
}
reply.setEnabled(forumReplyState.isDataValid());
});
//监听回帖状态
viewModel.getReplayResponse().observe(this, new Observer<ForumDataResponse>() {
@Override
public void onChanged(ForumDataResponse forumDataResponse) {
if (forumDataResponse == null) {
return;
}
viewModel.getReplayResponse().observe(this, forumDataResponse -> {
if (forumDataResponse == null) {
return;
}
forumDataResponse.toast(getBaseContext());
forumDataResponse.toast(getBaseContext());
if (forumDataResponse.getResult() == Response.Result.OK) {
handler.sendEmptyMessage(0);
viewModel.loadData(forumId);
}
if (forumDataResponse.getResult() == Response.Result.OK) {
handler.sendEmptyMessage(0);
viewModel.loadData(forumId);
}
});
//监听帖子详情数据
viewModel.getForumContentResponse().observe(this, new Observer<ForumDataResponse>() {
@Override
public void onChanged(ForumDataResponse listForumDataResponse) {
if (listForumDataResponse == null) {
return;
}
viewModel.getForumContentResponse().observe(this, listForumDataResponse -> {
if (listForumDataResponse == null) {
return;
}
listForumDataResponse.toast(getBaseContext());
listForumDataResponse.toast(getBaseContext());
if (listForumDataResponse.getResult() == Response.Result.OK) {
List<ForumContent> forumContents = listForumDataResponse.getForumContentList();
initFirst(forumContents.get(0), listForumDataResponse.getForum());
if (forumContents.size() > 1) {
createReply(forumContents.subList(1, forumContents.size()));
}
if (listForumDataResponse.getResult() == Response.Result.OK) {
List<ForumContent> forumContents = listForumDataResponse.getForumContentList();
initFirst(forumContents.get(0), listForumDataResponse.getForum());
if (forumContents.size() > 1) {
createReply(forumContents.subList(1, forumContents.size()));
}
}
});
openReply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showContent();
}
});
openReply.setOnClickListener(v -> showContent());
}
}
@ -166,12 +151,7 @@ public class ForumDataActivity extends BaseActivity {
//关闭回帖窗口按钮
Button close = alertView.findViewById(R.id.close);
reply = alertView.findViewById(R.id.reply);
reply.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
viewModel.sendReply(forumId, editText.getText().toString());
}
});
reply.setOnClickListener(v -> viewModel.sendReply(forumId, editText.getText().toString()));
editText.addTextChangedListener(new MyTextChange() {
@Override
@ -193,12 +173,7 @@ public class ForumDataActivity extends BaseActivity {
}
};
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
handler.sendEmptyMessage(0);
}
});
close.setOnClickListener(v -> handler.sendEmptyMessage(0));
alertDialog.show();
}
@ -239,6 +214,7 @@ public class ForumDataActivity extends BaseActivity {
$complain.setText(getString(R.string.forum_show_complain, complain.getComplain()));
}
break;
default:
}
if (childView != null) {
otherContent.removeAllViews();

@ -11,7 +11,6 @@ import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
@ -40,18 +39,15 @@ public class ForumHotFragment extends BaseFragment {
viewModel.loadHot();
//加载热门信息
viewModel.getForumHotResponse().observe(getViewLifecycleOwner(), new Observer<ForumHotResponse>() {
@Override
public void onChanged(ForumHotResponse forumHotResponse) {
if (forumHotResponse == null) {
return;
}
forumHotResponse.toast(getContext());
if (forumHotResponse.getResult() == Response.Result.OK) {
loadRank(forumHotResponse.getHot());
}
viewModel.getForumHotResponse().observe(getViewLifecycleOwner(), forumHotResponse -> {
if (forumHotResponse == null) {
return;
}
forumHotResponse.toast(getContext());
if (forumHotResponse.getResult() == Response.Result.OK) {
loadRank(forumHotResponse.getHot());
}
});
}
@ -85,7 +81,7 @@ public class ForumHotFragment extends BaseFragment {
//文本居中
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
//字体大小
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18);
textView.setId(View.generateViewId());
//设置约束
ConstraintLayout.LayoutParams layoutParams = new ConstraintLayout.LayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));

@ -12,6 +12,7 @@ import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModelProvider;
@ -102,6 +103,7 @@ public class ForumFragment extends MainFragment {
case MotionEvent.ACTION_UP:
v.setAlpha(0.1f);
break;
default:
}
return false;
});
@ -142,8 +144,9 @@ public class ForumFragment extends MainFragment {
banner.setAdapter(new NoticeAdpter(notices));
banner.setIndicator(new RectangleIndicator(getContext()));
banner.setIndicatorWidth(100, 200);
banner.setIndicatorNormalColor(getResources().getColor(R.color.colorAccent));
banner.setIndicatorSelectedColor(getResources().getColor(R.color.colorBlack));
banner.setIndicatorNormalColor(ContextCompat.getColor(requireContext(), R.color.colorAccent));
banner.setIndicatorSelectedColor(ContextCompat.getColor(requireContext(), R.color.colorBlack));
if (notices.size() >= 2) {
noticePrev.setVisibility(View.VISIBLE);
@ -204,7 +207,7 @@ public class ForumFragment extends MainFragment {
}
@Override
protected int[] button_ids() {
protected int[] buttonIds() {
return new int[]{R.id.forum_hot, R.id.forum_new, R.id.forum_post, R.id.forum_my};
}
}

@ -18,8 +18,6 @@ import com.community.pocket.ui.BaseFragment;
import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import java.util.Objects;
/**
* 发送帖子
*/
@ -54,7 +52,7 @@ public class ForumPostFragment extends BaseFragment {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (nav == null) {
nav = Navigation.findNavController(Objects.requireNonNull(getView()).findViewById(R.id.post_type_fragment));
nav = Navigation.findNavController(requireView().findViewById(R.id.post_type_fragment));
} else {
switch (position) {
case 0:
@ -68,7 +66,8 @@ public class ForumPostFragment extends BaseFragment {
break;
case 3:
nav.navigate(R.id.forumPostComplainFragment);
break;
default:
}
}
}

@ -36,7 +36,7 @@ public class GarbageFragment extends MainFragment {
}
@Override
protected int[] button_ids() {
protected int[] buttonIds() {
return new int[]{R.id.garbage_sorting, R.id.garbage_waste};
}
}

@ -9,7 +9,6 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
@ -58,18 +57,15 @@ public class GarbageSortingFragment extends BaseFragment {
myAutoCompleteTextView = new MyAutoCompleteTextView(searchSorting, viewModel);
//监听垃圾分类检索状态
viewModel.getGarbageSortingResponse().observe(getViewLifecycleOwner(), new Observer<GarbageSortingResponse>() {
@Override
public void onChanged(GarbageSortingResponse garbageSortingResponse) {
if (garbageSortingResponse == null) {
return;
}
viewModel.getGarbageSortingResponse().observe(getViewLifecycleOwner(), garbageSortingResponse -> {
if (garbageSortingResponse == null) {
return;
}
garbageSortingResponse.toast(getContext());
garbageSortingResponse.toast(getContext());
if (garbageSortingResponse.getResult() == Response.Result.OK) {
initSearch(garbageSortingResponse.getGarbageSortings());
}
if (garbageSortingResponse.getResult() == Response.Result.OK) {
initSearch(garbageSortingResponse.getGarbageSortings());
}
});
@ -111,6 +107,7 @@ public class GarbageSortingFragment extends BaseFragment {
case 4:resId=R.string.garbage_category_4;break;
case 8:resId=R.string.garbage_category_8;break;
case 16:resId=R.string.garbage_category_16;break;
default:
}
sorting.setText(resId);
}

@ -10,8 +10,8 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.gridlayout.widget.GridLayout;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.community.pocket.R;
@ -60,34 +60,28 @@ public class GarbageWasteFragment extends BaseFragment {
viewModel.searchDefault();
//监听默认废品信息请求状态
viewModel.getDefaultList().observe(getViewLifecycleOwner(), new Observer<GarbageWasteResponse>() {
@Override
public void onChanged(GarbageWasteResponse garbageWasteResponse) {
if (garbageWasteResponse == null) {
return;
}
viewModel.getDefaultList().observe(getViewLifecycleOwner(), garbageWasteResponse -> {
if (garbageWasteResponse == null) {
return;
}
garbageWasteResponse.toast(getContext());
garbageWasteResponse.toast(getContext());
if (garbageWasteResponse.getResult() == Response.Result.OK) {
initDefault(garbageWasteResponse.getDefaultList(), garbageWasteResponse.getGarbageWasteManage());
}
if (garbageWasteResponse.getResult() == Response.Result.OK) {
initDefault(garbageWasteResponse.getDefaultList(), garbageWasteResponse.getGarbageWasteManage());
}
});
//监听废品信息请求状态
viewModel.getSearchList().observe(getViewLifecycleOwner(), new Observer<GarbageWasteResponse>() {
@Override
public void onChanged(GarbageWasteResponse garbageWasteResponse) {
if (garbageWasteResponse == null) {
return;
}
viewModel.getSearchList().observe(getViewLifecycleOwner(), garbageWasteResponse -> {
if (garbageWasteResponse == null) {
return;
}
garbageWasteResponse.toast(getContext());
garbageWasteResponse.toast(getContext());
if (garbageWasteResponse.getResult() == Response.Result.OK) {
initSearch(garbageWasteResponse.getSearchList());
}
if (garbageWasteResponse.getResult() == Response.Result.OK) {
initSearch(garbageWasteResponse.getSearchList());
}
});
//检索内容改变触发监听器
@ -150,8 +144,8 @@ public class GarbageWasteFragment extends BaseFragment {
TextView textView = new TextView(getContext());
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
textView.setText(text);
textView.setBackground(getResources().getDrawable(R.drawable.border));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 24);
textView.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.border));
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24);
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
textView.setLayoutParams(layoutParams);

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

@ -32,6 +32,7 @@ public class MyAutoCompleteTextView {
//延时搜索的handler
private Handler searchHandler = new Handler(Looper.getMainLooper()) {
@Override
public void handleMessage(@NotNull Message msg) {
dealSearchHint(msg.getData());
}

@ -1,9 +1,13 @@
package com.community.pocket.ui.main.ui.share;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
import com.community.pocket.R;
import com.community.pocket.data.model.LocalToken;
import com.community.pocket.ui.login.LoginActivity;
import com.community.pocket.util.AppDatabase;
import com.community.pocket.util.CustomMessage;
/**
@ -48,6 +52,13 @@ public abstract class Response<T extends CustomMessage> {
public void toast(Context context) {
if (getMessage() != null) {
Toast.makeText(context, context.getString(getMessage().getMsg(), getArgs()), getResult() == Result.OK ? Toast.LENGTH_SHORT : Toast.LENGTH_LONG).show();
if (getMessage().getMsg() == R.string.invalid_token) {
new Thread(() -> {
AppDatabase.getInstance(context).tokenDao().delete(LocalToken.getTokenInstance());
LocalToken.logout();
context.startActivity(new Intent(context, LoginActivity.class));
}).start();
}
} else {
Toast.makeText(context, R.string.unknow_error, Toast.LENGTH_LONG).show();
}

@ -1,5 +1,6 @@
package com.community.pocket.ui.main.ui.share;
import android.os.Build;
import android.text.Html;
import android.view.View;
import android.widget.EditText;
@ -23,7 +24,7 @@ public class ShowWordCount {
private EditText postContent;
private static final int length = PropertiesUtil.getIntValue("textMultiLine.length");
private static final int LENGTH = PropertiesUtil.getIntValue("textMultiLine.length");
public ShowWordCount(int[] ids, int contentId, View view) {
this.ids = ids;
@ -35,11 +36,15 @@ public class ShowWordCount {
* 设置计数
*/
private void setCount() {
String text = view.getContext().getString(R.string.post_content_count, postContent.length(), length);
String text = view.getContext().getString(R.string.post_content_count, postContent.length(), LENGTH);
for (int id : ids) {
TextView textView = view.findViewById(id);
textView.setText(Html.fromHtml(text));
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {
textView.setText(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY));
} else {
textView.setText(Html.fromHtml(text));
}
}
}

@ -70,7 +70,7 @@ public class VisitorFragment extends MainFragment {
}
@Override
protected int[] button_ids() {
protected int[] buttonIds() {
return new int[]{R.id.visitor_appointment, R.id.visitor_reservation, R.id.visitor_visitor};
}
}

@ -15,6 +15,7 @@ import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.StringRes;
import androidx.appcompat.app.AlertDialog;
import androidx.core.content.ContextCompat;
import androidx.core.widget.NestedScrollView;
import androidx.gridlayout.widget.GridLayout;
@ -27,8 +28,6 @@ import com.community.pocket.util.PropertiesUtil;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;
import java.util.Objects;
/**
* 访客列表通用布局
*/
@ -58,7 +57,7 @@ public abstract class VisitorMyVisitor extends BaseFragment {
/**
* 显示备注最大长度
*/
private static final int maxLength = 5;
private static final int MAX_LENGTH = 5;
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
@ -74,10 +73,10 @@ public abstract class VisitorMyVisitor extends BaseFragment {
if (visitors.getCurrentPage() == 1 && !visitors.isEmpty()) {
gridLayout.removeViews(4, gridLayout.getChildCount() - 4);
}
for (final Visitor visitor : visitors.getList()) {
for (Visitor visitor : visitors.getList()) {
createTextView(visitor.getName());
createTextView(DateFormat.format(getString(R.string.dateformat_visitor), visitor.getTime()));
createTextView(visitor.getNotes().length() <= maxLength ? visitor.getNotes() : visitor.getNotes().substring(0, maxLength));
createTextView(visitor.getNotes().length() <= MAX_LENGTH ? visitor.getNotes() : visitor.getNotes().substring(0, MAX_LENGTH));
switch (visitor.getStatus()) {
case ok:
@ -95,7 +94,7 @@ public abstract class VisitorMyVisitor extends BaseFragment {
case fail:
createTextView(R.string.visitor_check_fail);
break;
default:
}
}
@ -139,11 +138,12 @@ public abstract class VisitorMyVisitor extends BaseFragment {
private void createTextView(TextView textView) {
textView.setGravity(Gravity.CENTER | Gravity.CENTER_HORIZONTAL | Gravity.CENTER_VERTICAL);
textView.setBackground(getResources().getDrawable(R.drawable.border));
textView.setBackground(ContextCompat.getDrawable(requireContext(), R.drawable.border));
GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
layoutParams.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f);
textView.setLayoutParams(layoutParams);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
gridLayout.addView(textView);
}
@ -162,7 +162,7 @@ public abstract class VisitorMyVisitor extends BaseFragment {
TextView admin = view.findViewById(R.id.admin);
admin.setText(getString(R.string.visitor_show_admin, visitor.getManagerName()));
Button button = view.findViewById(R.id.close);
AlertDialog.Builder alert = new AlertDialog.Builder(Objects.requireNonNull(getContext()));
AlertDialog.Builder alert = new AlertDialog.Builder(requireContext());
final AlertDialog alertDialog = alert.setTitle(R.string.visitor_traffic_permit).setView(view).create();
button.setOnClickListener(v -> alertDialog.dismiss());
alertDialog.show();

@ -28,6 +28,7 @@ public class RegisterResponse extends Response<RegisterResponse.Msg> {
this.msg = msg;
}
@Override
@NotNull
public @StringRes
Integer getMsg() {

@ -102,7 +102,7 @@ public class ResetPwdViewModel extends BaseViewModel<ResetPwdRequest> {
//监听重置密码第二步表单触发校验
void resetpwdStep2Changed(String code) {
if (!ValidUtil.CAPTCHAValid(code)) {
if (!ValidUtil.captchavalid(code)) {
resetPwdFormStep2.setValue(new ResetPwdFormState.Step2(R.string.invalid_CAPTCHA));
} else {
resetPwdFormStep2.setValue(new ResetPwdFormState.Step2(true));

@ -17,7 +17,7 @@ import okhttp3.ResponseBody;
public class HttpFileResponse implements Callback {
private static final String header = "Content-Type";
private static final String HEADER = "Content-Type";
private final MutableLiveData<Bitmap> image;
@ -33,7 +33,7 @@ public class HttpFileResponse implements Callback {
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) {
String contentType = response.header(header);
String contentType = response.header(HEADER);
if ("image/png".equals(contentType)) {
ResponseBody responseBody = response.body();
if (responseBody != null) {
@ -41,7 +41,7 @@ public class HttpFileResponse implements Callback {
image.postValue(bitmap);
}
} else {
onParseError(call, response, "接口不是响应图片数据,非法响应头" + header + "=" + contentType);
onParseError(call, response, "接口不是响应图片数据,非法响应头" + HEADER + "=" + contentType);
}
}

@ -25,7 +25,9 @@ public class HttpJSONResponse<T extends com.community.pocket.ui.main.ui.share.Re
private HttpParse<T> httpParse;
private static final String header = "Content-Type";
private static final String HEADER = "Content-Type";
private static final String JSON = "json";
public HttpJSONResponse(Class<T> tClass, HttpParse<T> httpParse) {
this.tClass = tClass;
@ -40,8 +42,8 @@ public class HttpJSONResponse<T extends com.community.pocket.ui.main.ui.share.Re
@Override
public void onResponse(@NotNull Call call, @NotNull Response response) {
String contentType = response.header(header);
if (contentType != null && contentType.contains("json")) {
String contentType = response.header(HEADER);
if (contentType != null && contentType.contains(JSON)) {
ResponseBody body = response.body();
if (body != null) {
Gson gson = new Gson();
@ -61,7 +63,7 @@ public class HttpJSONResponse<T extends com.community.pocket.ui.main.ui.share.Re
onParseError(call, response, "响应体为null");
}
} else {
onParseError(call, response, "接口不是响应json数据,非法响应头" + header + "=" + contentType);
onParseError(call, response, "接口不是响应json数据,非法响应头" + HEADER + "=" + contentType);
}
}

@ -41,7 +41,15 @@ import okhttp3.Response;
public class HttpUtil {
private static final Map<String, HttpRequest> map = new HashMap<>();
private static final Map<String, HttpRequest> MAP = new HashMap<>();
private static final String SPACE = " ";
private static final String COLON = ":";
private static final String PERIOD = "。";
private static final String HTTP = "http";
public static void getRequest(Method method, Callback callback) {
getRequest(method, callback, null);
@ -150,9 +158,10 @@ public class HttpUtil {
testPort.setText(R.string.server_error);
mode.setText(context.getString(R.string.debug_mode, BuildType.serverdebug.getName()));
break;
default:
}
testPort.setSingleLine(false);
testPort.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
testPort.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
testPort.setGravity(error.getGravity());
linearLayout.addView(testPort, index + 1);
@ -160,8 +169,8 @@ public class HttpUtil {
//从其他浏览器打开
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri content_url = Uri.parse(BuildConfig.API_HOST);
intent.setData(content_url);
Uri contentUrl = Uri.parse(BuildConfig.API_HOST);
intent.setData(contentUrl);
Activity activity = (Activity) context;
activity.startActivity(Intent.createChooser(intent, context.getString(R.string.choose_browser)));
@ -180,11 +189,11 @@ public class HttpUtil {
});
} else {
String msg = "\n";
if (BuildConfig.API_HOST.contains(" ")) {
if (BuildConfig.API_HOST.contains(SPACE)) {
msg += context.getString(R.string.server_address_error_1);
} else if (BuildConfig.API_HOST.contains(":") || BuildConfig.API_HOST.contains("。")) {
} else if (BuildConfig.API_HOST.contains(COLON) || BuildConfig.API_HOST.contains(PERIOD)) {
msg += context.getString(R.string.server_address_error_2);
} else if (!BuildConfig.API_HOST.startsWith("http")) {
} else if (!BuildConfig.API_HOST.startsWith(HTTP)) {
msg += context.getString(R.string.server_address_error_3);
} else {
msg += context.getString(R.string.server_address_error_4);
@ -221,7 +230,7 @@ public class HttpUtil {
try {
if (!map.containsKey(className + methodName)) {
if (!MAP.containsKey(className + methodName)) {
Class c = Class.forName(className);
java.lang.reflect.Method[] methods = c.getMethods();
@ -234,14 +243,14 @@ public class HttpUtil {
}
if (matchMethod.size() == 1) {
httpRequest = matchMethod.get(0).getAnnotation(HttpRequest.class);
map.put(matchMethod.get(0).getName(), httpRequest);
MAP.put(matchMethod.get(0).getName(), httpRequest);
} else if (matchMethod.size() > 1) {
runtimeException = new RuntimeException(c.getName() + "包含多个方法名为:" + methodName + "的方法!!!");
} else {
runtimeException = new RuntimeException("类:" + c.getName() + "方法:" + methodName + "缺少注解" + HttpRequest.class + ",无法调用" + HttpUtil.class);
}
} else {
httpRequest = map.get(className + methodName);
httpRequest = MAP.get(className + methodName);
}
if (httpRequest != null) {
return httpRequest.value();

@ -18,8 +18,8 @@ import java.util.ArrayList;
import java.util.List;
public class PermissionsUtils<T> {
private final int mRequestCode = 100;//权限请求码
//权限请求码
private final int mRequestCode = 100;
private PermissionsUtils() {
}
@ -36,8 +36,8 @@ public class PermissionsUtils<T> {
public void checkPermissions(Activity context, String[] permissions, @NonNull IPermissionsResult permissionsResult) {
mPermissionsResult = permissionsResult;
if (Build.VERSION.SDK_INT < 23) {//6.0才用动态权限
//6.0才用动态权限
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
permissionsResult.passPermissons();
return;
}
@ -47,7 +47,8 @@ public class PermissionsUtils<T> {
//逐个判断你要的权限是否已经通过
for (String permission : permissions) {
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
mPermissionList.add(permission);//添加还未授予的权限
//添加还未授予的权限
mPermissionList.add(permission);
}
}
@ -67,7 +68,8 @@ public class PermissionsUtils<T> {
public void onRequestPermissionsResult(Activity context, int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
boolean hasPermissionDismiss = false;//有权限没有通过
//有权限没有通过
boolean hasPermissionDismiss = false;
if (mRequestCode == requestCode) {
for (int grantResult : grantResults) {
if (grantResult == -1) {
@ -78,7 +80,8 @@ public class PermissionsUtils<T> {
//如果有权限没有被允许
if (hasPermissionDismiss) {
if (context.getResources().getBoolean(R.bool.showSystemSetting)) {
showSystemPermissionsSettingDialog(context);//跳转到系统设置权限页面,或者直接关闭页面,不让他继续访问
//跳转到系统设置权限页面,或者直接关闭页面,不让他继续访问
showSystemPermissionsSettingDialog(context);
} else {
mPermissionsResult.forbitPermissons();
}
@ -103,8 +106,8 @@ public class PermissionsUtils<T> {
.setPositiveButton("设置", (dialog, which) -> {
cancelPermissionDialog();
Uri packageURI = Uri.parse("package:" + mPackName);
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageURI);
Uri packageuri = Uri.parse("package:" + mPackName);
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageuri);
context.startActivity(intent);
context.finish();
})

@ -10,15 +10,15 @@ public class PropertiesUtil {
private static Properties properties;
private final static Map<String, String> values = new HashMap<>();
private final static Map<String, String> VALUES = new HashMap<>();
// 文件路径
private static final String filePath = "/assets/config.properties";
private static final String FILE_PATH = "/assets/config.properties";
static {
properties = new Properties();
try {
InputStream is = PropertiesUtil.class.getResourceAsStream(filePath);
InputStream is = PropertiesUtil.class.getResourceAsStream(FILE_PATH);
properties.load(is);
} catch (Exception e) {
e.printStackTrace();
@ -27,11 +27,11 @@ public class PropertiesUtil {
//获取字符串配置
public static String getValue(String key) {
if (values.containsKey(key)) {
return values.get(key);
if (VALUES.containsKey(key)) {
return VALUES.get(key);
} else {
String value = properties.getProperty(key);
values.put(key, value);
VALUES.put(key, value);
return value;
}
}

@ -12,8 +12,16 @@ import java.util.regex.Pattern;
/**
* 表单校验工具类
*/
@SuppressWarnings("AlibabaAvoidPatternCompileInMethod")
public class ValidUtil {
private static final Pattern PHONE = Pattern.compile("^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$");
private static final Pattern CAPTCHA = Pattern.compile("^\\d{6}$");
private static final Pattern DATE = Pattern.compile("^\\d{2}:\\d{2}$");
private static final Pattern NUM = Pattern.compile("^\\d+$");
/**
* 校验邮箱
*/
@ -25,7 +33,7 @@ public class ValidUtil {
* 校验手机号
*/
public static boolean mobilePhoneValid(String mobilePhone) {
return Pattern.compile("^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$").matcher(mobilePhone).matches();
return PHONE.matcher(mobilePhone).matches();
}
/**
@ -45,15 +53,15 @@ public class ValidUtil {
/**
* 校验验证码
*/
public static boolean CAPTCHAValid(String code) {
return Pattern.compile("^\\d{6}$").matcher(code).matches();
public static boolean captchavalid(String code) {
return CAPTCHA.matcher(code).matches();
}
/**
* 校验预约时间
*/
public static boolean timeValid(Object time) {
return time != null && Pattern.compile("^\\d{2}:\\d{2}$").matcher(time.toString()).matches();
return time != null && DATE.matcher(time.toString()).matches();
}
/**
@ -90,11 +98,6 @@ public class ValidUtil {
format.parse(str);
} catch (ParseException e) {
// e.printStackTrace();
// 如果throw java.text.ParseException或者NullPointerException,就说明格式不对
convertSuccess = false;
}
@ -128,7 +131,7 @@ public class ValidUtil {
* 校验信用分
*/
public static boolean scoreValid(String score) {
if (score != null && Pattern.compile("^\\d+$").matcher(score).matches()) {
if (score != null && NUM.matcher(score).matches()) {
int value = Integer.parseInt(score);
return value > 0 && value <= PropertiesUtil.getIntValue("score.max");
} else {

@ -37,7 +37,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="@dimen/size_50"
android:textSize="24sp"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/headimg"
app:layout_constraintTop_toTopOf="parent" />
@ -47,7 +47,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="@dimen/size_50"
android:textSize="24sp"
android:textSize="18sp"
app:layout_constraintStart_toEndOf="@id/headimg"
app:layout_constraintTop_toBottomOf="@id/nickname" />
@ -73,7 +73,7 @@
android:id="@+id/recentPosts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="1.5"
android:background="@drawable/border"
android:gravity="center"
android:textSize="18sp" />
@ -96,7 +96,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="1.5"
android:background="@drawable/border"
android:gravity="center"
android:text="@string/mobie"
@ -120,7 +120,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="1.5"
android:background="@drawable/border"
android:gravity="center"
android:text="@string/email"

@ -236,4 +236,5 @@
<string name="not_permissions">not permissions</string>
<string name="set_headimg">click to set headimg</string>
<string name="upload_img">upload img....</string>
<string name="compress_img">compress img…</string>
</resources>

@ -236,4 +236,5 @@
<string name="not_permissions">你当前没有文件读写权限执行此操作</string>
<string name="set_headimg">点击上方设置头像</string>
<string name="upload_img">上传头像中。。。。</string>
<string name="compress_img">压缩图片中。。。</string>
</resources>

@ -3,4 +3,5 @@
<integer name="post_content">200</integer>
<integer name="post_content_maxLines">10</integer>
<integer name="photo_size">100</integer>
<integer name="photo_quality">50</integer>
</resources>

@ -237,6 +237,7 @@
<string name="not_permissions">not permissions</string>
<string name="set_headimg">click to set headimg</string>
<string name="upload_img">upload img....</string>
<string name="compress_img">compress img…</string>
<!-- Strings used for fragments for navigation -->
<!-- Strings used for fragments for navigation -->

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path
name="external_files"
path="." />
</paths>
Loading…
Cancel
Save