diff --git a/app/src/main/java/com/moyv/schoolbbs/config/URLConstant.java b/app/src/main/java/com/moyv/schoolbbs/config/URLConstant.java index bc56e7ff3550036bf8f3b9caf1d157170350af17..a65b577598897e7997b6341ae4a58db290d6c5fb 100644 --- a/app/src/main/java/com/moyv/schoolbbs/config/URLConstant.java +++ b/app/src/main/java/com/moyv/schoolbbs/config/URLConstant.java @@ -5,7 +5,7 @@ package com.moyv.schoolbbs.config; */ public class URLConstant { // tomcat位置 -// public static final String HOST="http://192.168.0.101:8080/bbs_servlet"; + public static final String HOST="http://192.168.0.101:8080/bbs_servlet"; // 服务器位置 public static final String HOST="http://192.168.3.11:8080"; // public static final String HOST="http://192.168.0.101:8080/bbs_servlet"; diff --git a/app/src/main/java/com/moyv/schoolbbs/ui/activity/AddActivity.java b/app/src/main/java/com/moyv/schoolbbs/ui/activity/AddActivity.java index 4f0398a5707ddb5e2ddeb5664bd8716ed27f568e..20f79d0294134ef6f058053dbba82ff2269829d2 100644 --- a/app/src/main/java/com/moyv/schoolbbs/ui/activity/AddActivity.java +++ b/app/src/main/java/com/moyv/schoolbbs/ui/activity/AddActivity.java @@ -258,19 +258,23 @@ public class AddActivity extends AppCompatActivity { // 返回成功 Log.e(TAG, "onResponse: " + resp); if (result.equals("1")) { - okPostId = postId; - List picUrls = new ArrayList<>(); - List files = new ArrayList<>(); - for (int i = 0; i < mPicList.size(); i++) { - String photo = mPicList.get(i); - File file = new File(photo); - files.add(file); - System.out.println(photo); - String url = okPostId + "_" + i + ".jpg"; - picUrls.add(url); + if(mPicList.size()==0){ + handler.sendMessage(handler.obtainMessage(0)); + }else{ +// 发表图片 + okPostId = postId; + List picUrls = new ArrayList<>(); + List files = new ArrayList<>(); + for (int i = 0; i < mPicList.size(); i++) { + String photo = mPicList.get(i); + File file = new File(photo); + files.add(file); + System.out.println(photo); + String url = okPostId + "_" + i + ".jpg"; + picUrls.add(url); + } + uploading(files, picUrls, okPostId, handler1); } - uploading(files, picUrls, okPostId, handler1); - } else { handler.sendMessage(handler.obtainMessage(404)); } diff --git a/app/src/main/java/com/moyv/schoolbbs/ui/activity/BottomTabLayoutActivity.java b/app/src/main/java/com/moyv/schoolbbs/ui/activity/BottomTabLayoutActivity.java index f3ee2d748ccd90e9e90762aa26ebe5e20acf3f1e..db9a6dccc36389a646af27f473594ead9337cf68 100644 --- a/app/src/main/java/com/moyv/schoolbbs/ui/activity/BottomTabLayoutActivity.java +++ b/app/src/main/java/com/moyv/schoolbbs/ui/activity/BottomTabLayoutActivity.java @@ -42,14 +42,12 @@ import static com.moyv.schoolbbs.ui.adapter.DataGenerator.mTabTitle; import static com.moyv.schoolbbs.util.ToastUtils.init; import static com.moyv.schoolbbs.util.ToastUtils.show; import static com.moyv.schoolbbs.util.UIHelper.closeDialog; -import static com.moyv.schoolbbs.util.UIHelper.mLoadingDialog; import static com.moyv.schoolbbs.util.UIHelper.showDialogForLoading; /** * @author moyv */ public class BottomTabLayoutActivity extends AppCompatActivity { - public static String HEAD_SIG="000000"; private TabLayout mTabLayout; private Fragment[] mFragmensts; private Fragment currentFragment; @@ -170,10 +168,9 @@ public class BottomTabLayoutActivity extends AppCompatActivity { // Uri sourceUri = data.getData(); // uCropUtils.startUCrop(sourceUri); // 图片选择器调用 - GlideCacheUtil glideCacheUtil; - glideCacheUtil = GlideCacheUtil.getInstance(); - glideCacheUtil.clearImageAllCache(context); -// HEAD_SIG=String.valueOf(System.currentTimeMillis()); + + + List imageUrl = PictureSelector.obtainMultipleResult(data); upload(imageUrl); } else { @@ -206,8 +203,15 @@ public class BottomTabLayoutActivity extends AppCompatActivity { case 200: show("头像上传成功"); // 刷新用户信息 - closeDialog(context); +// 清除图片缓存 + GlideCacheUtil glideCacheUtil; + glideCacheUtil = GlideCacheUtil.getInstance(); + glideCacheUtil.clearImageAllCache(context); + + mFragmensts[2].onResume(); + closeDialog(context); + break; case 301: show("上传失败"); @@ -227,10 +231,6 @@ public class BottomTabLayoutActivity extends AppCompatActivity { @Override protected void onResume() { super.onResume(); - // 防止内存溢出 - if (mLoadingDialog != null && mLoadingDialog.isShowing()) { - mLoadingDialog.dismiss(); - } // 标题更新 if (LOGIN) { mTabTitle[2] = "我的"; diff --git a/app/src/main/java/com/moyv/schoolbbs/ui/adapter/DataAdapter.java b/app/src/main/java/com/moyv/schoolbbs/ui/adapter/DataAdapter.java index d75f95923f17bf7af5430ce2038e765f0654415c..c0ad6e82985d84177734187957e942e4d369a973 100644 --- a/app/src/main/java/com/moyv/schoolbbs/ui/adapter/DataAdapter.java +++ b/app/src/main/java/com/moyv/schoolbbs/ui/adapter/DataAdapter.java @@ -222,7 +222,7 @@ public class DataAdapter extends RecyclerView.Adapter { String headUrl = IMAGE_URL + "/head/" + postList.get(position).getMain().getPost().getPostAccount() + ".jpg"; Glide.with(context) .load(headUrl) - .skipMemoryCache(true) +// .skipMemoryCache(true) // .signature( new ObjectKey(HEAD_SIG)) .diskCacheStrategy(DiskCacheStrategy.NONE) .placeholder(R.mipmap.ic_launcher) diff --git a/app/src/main/java/com/moyv/schoolbbs/ui/fragment/HomeFragment.java b/app/src/main/java/com/moyv/schoolbbs/ui/fragment/HomeFragment.java index 48f31d4f4b756034cf3c33cc2ffd42b4bda07d68..e329cf848955cc940fe57361ecb29c90c5773d50 100644 --- a/app/src/main/java/com/moyv/schoolbbs/ui/fragment/HomeFragment.java +++ b/app/src/main/java/com/moyv/schoolbbs/ui/fragment/HomeFragment.java @@ -30,6 +30,7 @@ import com.moyv.schoolbbs.pojo.Item; import com.moyv.schoolbbs.service.MainService; import com.moyv.schoolbbs.ui.activity.AddActivity; import com.moyv.schoolbbs.ui.adapter.DataAdapter; +import com.moyv.schoolbbs.util.GlideCacheUtil; import com.moyv.schoolbbs.util.UIHelper; import com.moyv.schoolbbs.ui.listener.EndlessRecyclerOnScrollListener; import com.moyv.schoolbbs.util.ToastUtils; @@ -51,8 +52,7 @@ public class HomeFragment extends Fragment implements DataAdapter.Click { private static final int SUCCESS = 0; private static final int FALL = 404; private DataAdapter adapter; - ; - private FloatingActionButton btnFlt; + public static FloatingActionButton btnFlt; private SwipeRefreshLayout swiperefreshlayout; private Context mContext; private int start, end; @@ -165,11 +165,15 @@ public class HomeFragment extends Fragment implements DataAdapter.Click { List items = new ArrayList<>(); switch (msg.what) { case SUCCESS: + // 清除图片缓存 + GlideCacheUtil glideCacheUtil; + glideCacheUtil = GlideCacheUtil.getInstance(); + glideCacheUtil.clearImageAllCache(mContext); + Toast.makeText(mContext, "成功获取数据", Toast.LENGTH_SHORT).show(); ReModel reModel = (ReModel) msg.obj; lists = reModel.getMain(); count = reModel.getCount(); - System.out.println(count); for (ReModel.Main list : lists) { Item item = new Item(); @@ -208,6 +212,12 @@ public class HomeFragment extends Fragment implements DataAdapter.Click { swiperefreshlayout.setRefreshing(false); switch (msg.what) { case SUCCESS: + // 清除图片缓存 + GlideCacheUtil glideCacheUtil; + glideCacheUtil = GlideCacheUtil.getInstance(); + glideCacheUtil.clearImageAllCache(mContext); + + Toast.makeText(mContext, "成功获取数据", Toast.LENGTH_SHORT).show(); ReModel reModel = (ReModel) msg.obj; lists = reModel.getMain(); diff --git a/app/src/main/java/com/moyv/schoolbbs/ui/fragment/MeFragment.java b/app/src/main/java/com/moyv/schoolbbs/ui/fragment/MeFragment.java index 2e5cf623ca92a068768e4e041298619abca85120..86ca4daa05d892b2c24af9702c0007318f95beda 100644 --- a/app/src/main/java/com/moyv/schoolbbs/ui/fragment/MeFragment.java +++ b/app/src/main/java/com/moyv/schoolbbs/ui/fragment/MeFragment.java @@ -49,7 +49,6 @@ import static com.moyv.schoolbbs.config.PictureSelectorConfig.initCamer; import static com.moyv.schoolbbs.config.URLConstant.HEAD_URL; import static com.moyv.schoolbbs.service.MainService.STAR_POSTS; import static com.moyv.schoolbbs.service.MainService.USER_POSTS; -import static com.moyv.schoolbbs.ui.activity.BottomTabLayoutActivity.HEAD_SIG; import static com.moyv.schoolbbs.util.AnalysisUtils.cleanLoginStatus; import static com.moyv.schoolbbs.util.AnalysisUtils.readLoginStatus; import static com.moyv.schoolbbs.util.ToastUtils.show; @@ -138,11 +137,10 @@ public class MeFragment extends Fragment implements View.OnClickListener { tvName.setVisibility(View.VISIBLE); btnLogin.setVisibility(View.GONE); int account = sharedPreferences.getInt("account", 0); - Log.e("1658", "onResume: hello"+HEAD_SIG ); + // 高斯模糊背景 Glide.with(context).load(HEAD_URL + account + ".jpg") //缓存 - .skipMemoryCache(true) // .signature( new ObjectKey(HEAD_SIG)) .diskCacheStrategy(DiskCacheStrategy.NONE) .apply(ivBackground.setGaussBlur()) @@ -153,11 +151,11 @@ public class MeFragment extends Fragment implements View.OnClickListener { // 圆形头像加载 Glide.with(context).load(HEAD_URL + account + ".jpg") .error(R.drawable.login_head) - .skipMemoryCache(true) // .signature( new ObjectKey(HEAD_SIG)) .diskCacheStrategy(DiskCacheStrategy.NONE) .apply(RequestOptions.bitmapTransform(new CircleCrop())) .into(ivHead); + UserInfoService userInfoService = new UserInfoService(); new AccountConstant(context); userInfoService.getUserInfo(account, handler); diff --git a/app/src/main/java/com/moyv/schoolbbs/util/FormatUtils.java b/app/src/main/java/com/moyv/schoolbbs/util/FormatUtils.java index 84a46e8374241af131b41c18c6169511b2f78e14..2cf2e9cc8c7333aa4c956e4c95e55def3d234746 100644 --- a/app/src/main/java/com/moyv/schoolbbs/util/FormatUtils.java +++ b/app/src/main/java/com/moyv/schoolbbs/util/FormatUtils.java @@ -31,17 +31,17 @@ public final class FormatUtils { String result="0000-00-00"; long timer=now-start; if(timerONE_HOUR_MILLIS){ - SimpleDateFormat formatDay = new SimpleDateFormat("HH小时前", + SimpleDateFormat formatDay = new SimpleDateFormat("H小时前", Locale.getDefault()); Date date = new Date(timer); result=formatDay.format(date); }else if(timerONE_MINUTE_MILLIS){ - SimpleDateFormat formatDay = new SimpleDateFormat("mm分钟前", + SimpleDateFormat formatDay = new SimpleDateFormat("m分钟前", Locale.getDefault()); Date date = new Date(timer); result=formatDay.format(date); }else if (timer0){ - SimpleDateFormat formatDay = new SimpleDateFormat("mm分钟前", + SimpleDateFormat formatDay = new SimpleDateFormat("s秒前", Locale.getDefault()); Date date = new Date(timer); result=formatDay.format(date); diff --git a/app/src/main/java/com/moyv/schoolbbs/util/KeyboardUtils.java b/app/src/main/java/com/moyv/schoolbbs/util/KeyboardUtils.java index 244c9adbd41f9b67608be1be16a4775ff81082e0..990776c3927c5187eabc2fb9cb280000eb2aa4c2 100644 --- a/app/src/main/java/com/moyv/schoolbbs/util/KeyboardUtils.java +++ b/app/src/main/java/com/moyv/schoolbbs/util/KeyboardUtils.java @@ -7,6 +7,8 @@ import android.graphics.Rect; import android.view.View; import android.view.inputmethod.InputMethodManager; +import com.moyv.schoolbbs.ui.fragment.HomeFragment; + /** * /** * 创 建 者:下一页5(轻飞扬) @@ -108,6 +110,7 @@ public class KeyboardUtils { public static void showSoftInput(Context context) { InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); + HomeFragment.btnFlt.setVisibility(View.GONE); inputMethodManager.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS); } @@ -119,6 +122,7 @@ public class KeyboardUtils { public static void hideSoftInput(Activity activity) { InputMethodManager inputMethodManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE); + HomeFragment.btnFlt.setVisibility(View.VISIBLE); inputMethodManager.hideSoftInputFromWindow( activity.getWindow().getDecorView().getWindowToken(), 0); } diff --git a/app/src/main/res/layout/fragment_me.xml b/app/src/main/res/layout/fragment_me.xml index 33e7e93da878431ad114ffae298589fa7ea11e92..42597c775c7c391e288f3ad854cfcf6edca26508 100644 --- a/app/src/main/res/layout/fragment_me.xml +++ b/app/src/main/res/layout/fragment_me.xml @@ -97,8 +97,8 @@ app:icon="@drawable/ic_me_account" app:name="账号" android:background="#fff" - app:show_more="true" - app:show_line="true"/> + app:show_line="true" + app:show_more="true"/>