Commit c8a5db9f1de6a8867fda108ab49957a06ef6b049
1 parent
dc60ceee
Exists in
yxb_dev
and in
2 other branches
no message
Showing
7 changed files
with
86 additions
and
56 deletions
Show diff stats
app/src/main/java/com/shunzhi/parent/ui/activity/consult/ConsultOneLevelActivity.java
| ... | ... | @@ -3,39 +3,37 @@ package com.shunzhi.parent.ui.activity.consult; |
| 3 | 3 | import android.content.Context; |
| 4 | 4 | import android.content.Intent; |
| 5 | 5 | import android.support.v4.app.FragmentTransaction; |
| 6 | -import android.support.v7.app.AppCompatActivity; | |
| 7 | 6 | import android.os.Bundle; |
| 8 | 7 | import android.view.View; |
| 9 | 8 | import android.widget.EditText; |
| 10 | 9 | import android.widget.FrameLayout; |
| 11 | 10 | import android.widget.ImageView; |
| 12 | -import android.widget.TextView; | |
| 13 | 11 | |
| 14 | 12 | import com.share.mvpsdk.base.activity.BaseCompatActivity; |
| 15 | 13 | import com.share.mvpsdk.utils.ToastUtils; |
| 16 | 14 | import com.shunzhi.parent.R; |
| 17 | 15 | import com.shunzhi.parent.ui.fragment.consult.ConsultOneLevelFragment; |
| 18 | 16 | |
| 19 | -public class ConsultOneLevelActivity extends BaseCompatActivity implements View.OnClickListener{ | |
| 17 | +public class ConsultOneLevelActivity extends BaseCompatActivity implements View.OnClickListener { | |
| 20 | 18 | |
| 21 | - | |
| 22 | - public static void getInstance(Context context,String channel){ | |
| 23 | - Intent intent=new Intent(context,ConsultOneLevelActivity.class); | |
| 24 | - intent.putExtra("channel",channel); | |
| 19 | + public static void getInstance(Context context, String channel) { | |
| 20 | + Intent intent = new Intent(context, ConsultOneLevelActivity.class); | |
| 21 | + intent.putExtra("channel", channel); | |
| 25 | 22 | context.startActivity(intent); |
| 26 | 23 | } |
| 27 | 24 | |
| 28 | 25 | EditText et_search; |
| 29 | 26 | |
| 30 | - ImageView ivSearch,ivBack; | |
| 27 | + ImageView ivSearch, ivBack; | |
| 31 | 28 | |
| 32 | - String channel=""; | |
| 29 | + String channel = ""; | |
| 33 | 30 | |
| 34 | 31 | FrameLayout frame_consult; |
| 35 | 32 | |
| 36 | - FragmentTransaction fragmentTransaction=null; | |
| 33 | + FragmentTransaction fragmentTransaction = null; | |
| 34 | + | |
| 35 | + ConsultOneLevelFragment consultOneLevelFragment = null; | |
| 37 | 36 | |
| 38 | - ConsultOneLevelFragment consultOneLevelFragment=null; | |
| 39 | 37 | @Override |
| 40 | 38 | protected void initView(Bundle savedInstanceState) { |
| 41 | 39 | |
| ... | ... | @@ -45,22 +43,22 @@ public class ConsultOneLevelActivity extends BaseCompatActivity implements View. |
| 45 | 43 | |
| 46 | 44 | private void initViews() { |
| 47 | 45 | |
| 48 | - channel=getIntent().getStringExtra("channel"); | |
| 49 | - consultOneLevelFragment=new ConsultOneLevelFragment(); | |
| 50 | - et_search=findViewById(R.id.et_search); | |
| 51 | - ivSearch=findViewById(R.id.ivSearch); | |
| 52 | - ivBack=findViewById(R.id.ivBack); | |
| 53 | - frame_consult=findViewById(R.id.frame_consult); | |
| 46 | + channel = getIntent().getStringExtra("channel"); | |
| 47 | + consultOneLevelFragment = new ConsultOneLevelFragment(); | |
| 48 | + et_search = findViewById(R.id.et_search); | |
| 49 | + ivSearch = findViewById(R.id.ivSearch); | |
| 50 | + ivBack = findViewById(R.id.ivBack); | |
| 51 | + frame_consult = findViewById(R.id.frame_consult); | |
| 54 | 52 | |
| 55 | 53 | ivSearch.setOnClickListener(this); |
| 56 | 54 | ivBack.setOnClickListener(this); |
| 57 | 55 | |
| 58 | - Bundle bundle=new Bundle(); | |
| 59 | - bundle.putString("channel",channel); | |
| 56 | + Bundle bundle = new Bundle(); | |
| 57 | + bundle.putString("channel", channel); | |
| 60 | 58 | consultOneLevelFragment.setArguments(bundle); |
| 61 | - ToastUtils.showToast("channel="+channel); | |
| 62 | - fragmentTransaction=getSupportFragmentManager().beginTransaction(); | |
| 63 | - fragmentTransaction.add(R.id.frame_consult,consultOneLevelFragment) | |
| 59 | +// ToastUtils.showToast("channel=" + channel); | |
| 60 | + fragmentTransaction = getSupportFragmentManager().beginTransaction(); | |
| 61 | + fragmentTransaction.add(R.id.frame_consult, consultOneLevelFragment) | |
| 64 | 62 | .show(consultOneLevelFragment).commit(); |
| 65 | 63 | } |
| 66 | 64 | |
| ... | ... | @@ -71,9 +69,9 @@ public class ConsultOneLevelActivity extends BaseCompatActivity implements View. |
| 71 | 69 | |
| 72 | 70 | @Override |
| 73 | 71 | public void onClick(View view) { |
| 74 | - switch (view.getId()){ | |
| 72 | + switch (view.getId()) { | |
| 75 | 73 | case R.id.ivSearch: |
| 76 | - | |
| 74 | + consultOneLevelFragment.showSearchContent(et_search.getText().toString()); | |
| 77 | 75 | break; |
| 78 | 76 | case R.id.ivBack: |
| 79 | 77 | finish(); | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/CePingFragment.java
| ... | ... | @@ -70,7 +70,6 @@ public class CePingFragment extends BaseMVPCompatFragment<CepingContract.CePingP |
| 70 | 70 | |
| 71 | 71 | addTools(); |
| 72 | 72 | |
| 73 | - tvLocalAddress.setText(AppContext.getInstance().cityName); | |
| 74 | 73 | textAndImg_xqjc.setTextColor(R.color.white); |
| 75 | 74 | textAndImg_xqjc.setText("学情检测"); |
| 76 | 75 | textAndImg_xqjc.setImgs(R.drawable.xqjc, R.drawable.xqjc); |
| ... | ... | @@ -99,6 +98,10 @@ public class CePingFragment extends BaseMVPCompatFragment<CepingContract.CePingP |
| 99 | 98 | @Override |
| 100 | 99 | public void onResume() { |
| 101 | 100 | super.onResume(); |
| 101 | + if (!tvLocalAddress.getText().toString().equals(AppContext.getInstance().cityName)){ | |
| 102 | + tvLocalAddress.setText(AppContext.getInstance().cityName); | |
| 103 | + addTools(); | |
| 104 | + } | |
| 102 | 105 | } |
| 103 | 106 | |
| 104 | 107 | private void initListeners(View view) { |
| ... | ... | @@ -125,7 +128,6 @@ public class CePingFragment extends BaseMVPCompatFragment<CepingContract.CePingP |
| 125 | 128 | return new CePingPresenter(); |
| 126 | 129 | } |
| 127 | 130 | |
| 128 | - | |
| 129 | 131 | @Override |
| 130 | 132 | public void onClick(View view) { |
| 131 | 133 | switch (view.getId()) { |
| ... | ... | @@ -175,7 +177,6 @@ public class CePingFragment extends BaseMVPCompatFragment<CepingContract.CePingP |
| 175 | 177 | mPresenter.getTools(layout_control, name.split(" ")[2]); |
| 176 | 178 | AppContext.getInstance().cityName=name.split(" ")[1]; |
| 177 | 179 | AppContext.getInstance().district=name.split(" ")[2]; |
| 178 | -// ToastUtils.showToast(name.split(" ")[2]); | |
| 179 | 180 | } |
| 180 | 181 | |
| 181 | 182 | @Override | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/ConsultFragment.java
| ... | ... | @@ -133,6 +133,11 @@ public class ConsultFragment extends BaseMVPCompatFragment<ConsultContract.Consu |
| 133 | 133 | public void onResume() { |
| 134 | 134 | super.onResume(); |
| 135 | 135 | xBanner.startAutoPlay(); |
| 136 | + if (!tvLocalAddress.getText().toString().equals(AppContext.getInstance().cityName)){ | |
| 137 | + tvLocalAddress.setText(AppContext.getInstance().cityName); | |
| 138 | + mPresenter.getBanners("2", AppContext.getInstance().district); | |
| 139 | + mPresenter.getContextChannel(AppContext.getInstance().district, 0, 1, 1); | |
| 140 | + } | |
| 136 | 141 | } |
| 137 | 142 | |
| 138 | 143 | @Override | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/MineFragment.java
| 1 | 1 | package com.shunzhi.parent.ui.fragment; |
| 2 | 2 | |
| 3 | +import android.app.AlertDialog; | |
| 4 | +import android.content.DialogInterface; | |
| 3 | 5 | import android.content.Intent; |
| 4 | 6 | import android.os.Bundle; |
| 5 | 7 | import android.support.annotation.NonNull; |
| ... | ... | @@ -13,6 +15,7 @@ import com.bumptech.glide.Glide; |
| 13 | 15 | import com.makeramen.roundedimageview.RoundedImageView; |
| 14 | 16 | import com.share.mvpsdk.base.BasePresenter; |
| 15 | 17 | import com.share.mvpsdk.base.fragment.BaseMVPCompatFragment; |
| 18 | +import com.share.mvpsdk.utils.CacheUtils; | |
| 16 | 19 | import com.share.mvpsdk.utils.ToastUtils; |
| 17 | 20 | import com.shunzhi.parent.AppConfig; |
| 18 | 21 | import com.shunzhi.parent.AppContext; |
| ... | ... | @@ -26,9 +29,11 @@ import com.shunzhi.parent.ui.activity.PersonInfoActivity; |
| 26 | 29 | import com.shunzhi.parent.ui.activity.mywebview.WebViewActivity; |
| 27 | 30 | import com.shunzhi.parent.ui.activity.orderdetail.OrderDetailActivity; |
| 28 | 31 | |
| 32 | +import static java.util.ResourceBundle.clearCache; | |
| 33 | + | |
| 29 | 34 | public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract.LoginPresenter, LoginAndRegisterContract.ILoginModel> |
| 30 | 35 | implements MineContract.IMineView, View.OnClickListener { |
| 31 | - LinearLayout childlayout, personinfo, layout_orderDetail, layout_order; | |
| 36 | + LinearLayout childlayout, personinfo, layout_orderDetail, layout_order,layout_cache; | |
| 32 | 37 | RoundedImageView user_photo; |
| 33 | 38 | TextView user_name, user_mobile, tvExit,binding_state; |
| 34 | 39 | |
| ... | ... | @@ -49,6 +54,8 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract |
| 49 | 54 | personinfo = view.findViewById(R.id.personinfo); |
| 50 | 55 | layout_order = view.findViewById(R.id.layout_order); |
| 51 | 56 | layout_orderDetail = view.findViewById(R.id.layout_orderDetail); |
| 57 | + layout_cache=view.findViewById(R.id.layout_cache); | |
| 58 | + layout_cache.setOnClickListener(this); | |
| 52 | 59 | childlayout.setOnClickListener(this); |
| 53 | 60 | personinfo.setOnClickListener(this); |
| 54 | 61 | layout_order.setOnClickListener(this); |
| ... | ... | @@ -109,11 +116,42 @@ public class MineFragment extends BaseMVPCompatFragment<LoginAndRegisterContract |
| 109 | 116 | case R.id.tvExit: |
| 110 | 117 | clearUerinfo(); |
| 111 | 118 | break; |
| 119 | + case R.id.layout_cache: | |
| 120 | + clearMyCache(); | |
| 121 | + break; | |
| 112 | 122 | default: |
| 113 | 123 | break; |
| 114 | 124 | } |
| 115 | 125 | } |
| 116 | 126 | |
| 127 | + private void clearMyCache() { | |
| 128 | + | |
| 129 | + AlertDialog.Builder builder=new AlertDialog.Builder(getActivity()); | |
| 130 | + try { | |
| 131 | + builder.setMessage("清理缓存"+CacheUtils.getCacheSize(getActivity())+"") | |
| 132 | + .setPositiveButton("取消", new DialogInterface.OnClickListener() { | |
| 133 | + @Override | |
| 134 | + public void onClick(DialogInterface dialogInterface, int i) { | |
| 135 | + dialogInterface.dismiss(); | |
| 136 | + } | |
| 137 | + }) | |
| 138 | + .setNegativeButton("确定", new DialogInterface.OnClickListener() { | |
| 139 | + @Override | |
| 140 | + public void onClick(DialogInterface dialogInterface, int i) { | |
| 141 | + try { | |
| 142 | + CacheUtils.clearCache(getActivity()); | |
| 143 | + } catch (Exception e) { | |
| 144 | + e.printStackTrace(); | |
| 145 | + } | |
| 146 | + dialogInterface.dismiss(); | |
| 147 | + } | |
| 148 | + }); | |
| 149 | + } catch (Exception e) { | |
| 150 | + e.printStackTrace(); | |
| 151 | + } | |
| 152 | + builder.create().show(); | |
| 153 | + } | |
| 154 | + | |
| 117 | 155 | private void clearUerinfo() { |
| 118 | 156 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.USER_IMAGE, ""); |
| 119 | 157 | AppConfig.getAppConfig(AppContext.getInstance()).set(AppConfig.USER_NAME, ""); | ... | ... |
app/src/main/java/com/shunzhi/parent/ui/fragment/consult/ConsultOneLevelFragment.java
| ... | ... | @@ -49,9 +49,7 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
| 49 | 49 | |
| 50 | 50 | LinearLayout layout_control; |
| 51 | 51 | |
| 52 | - List<MyConsultBean> myConsultBeanList = null; | |
| 53 | - | |
| 54 | - String channel=""; | |
| 52 | + String channel = ""; | |
| 55 | 53 | |
| 56 | 54 | @Override |
| 57 | 55 | public int getLayoutId() { |
| ... | ... | @@ -60,7 +58,7 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
| 60 | 58 | |
| 61 | 59 | @Override |
| 62 | 60 | public void initUI(View view, @Nullable Bundle savedInstanceState) { |
| 63 | - initViews(view); | |
| 61 | + initViews(view); | |
| 64 | 62 | } |
| 65 | 63 | |
| 66 | 64 | private void initRecyclerView(List<GuangGaoBean> guangGaoBeanList) { |
| ... | ... | @@ -83,35 +81,20 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
| 83 | 81 | } |
| 84 | 82 | |
| 85 | 83 | private void initViews(View view) { |
| 86 | - channel=getArguments().getString("channel"); | |
| 84 | + channel = getArguments().getString("channel"); | |
| 87 | 85 | ToastUtils.showToast(channel); |
| 88 | 86 | layout_control = view.findViewById(R.id.layout_control); |
| 89 | 87 | layout_control.measure(0, 0); |
| 90 | -// mPresenter.getTools(layout_control); | |
| 91 | 88 | recyclerViewGrally = view.findViewById(R.id.recyclerViewGrally); |
| 92 | 89 | recyclerViewConsultOne = view.findViewById(R.id.recyclerViewConsultOne); |
| 93 | 90 | |
| 94 | 91 | mPresenter.getBanners("3", AppContext.getInstance().district); |
| 95 | 92 | mPresenter.getConsultContent(AppContext.getInstance().district, Integer.parseInt(channel), 0, 1); |
| 96 | -// initRecyclerViewConsult(); | |
| 97 | 93 | } |
| 98 | 94 | |
| 99 | -// private void initRecyclerViewConsult() { | |
| 100 | -// if (null == myConsultAdapter) myConsultAdapter = new MyConsultAdapter(getActivity()); | |
| 101 | -// if (null == myConsultBeanList) myConsultBeanList = new ArrayList<>(); | |
| 102 | -// else myConsultBeanList.clear(); | |
| 103 | -// for (int i = 0; i < 12; i++) { | |
| 104 | -// MyConsultBean myConsultBean = new MyConsultBean(); | |
| 105 | -// myConsultBean.consultCounts = i + ""; | |
| 106 | -// myConsultBean.consultContent = "咨询内容" + i; | |
| 107 | -// myConsultBean.consultTitle = "咨询标题" + i; | |
| 108 | -// myConsultBean.consultZhuanfaCounts = "转发:" + i; | |
| 109 | -// myConsultBeanList.add(myConsultBean); | |
| 110 | -// } | |
| 111 | -// myConsultAdapter.addAll(myConsultBeanList); | |
| 112 | -// recyclerViewConsultOne.setAdapter(myConsultAdapter); | |
| 113 | -// | |
| 114 | -// } | |
| 95 | + public void showSearchContent(String keyword) { | |
| 96 | + mPresenter.getInformationTopic(keyword, AppContext.getInstance().district, channel, "0", 1); | |
| 97 | + } | |
| 115 | 98 | |
| 116 | 99 | @NonNull |
| 117 | 100 | @Override |
| ... | ... | @@ -148,7 +131,6 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
| 148 | 131 | TextAndImgShowView textAndImgShowView = new TextAndImgShowView(getActivity()); |
| 149 | 132 | textAndImgShowView.setTextColor(R.color.textColor); |
| 150 | 133 | textAndImgShowView.setText(list.get(i).getChannelName()); |
| 151 | -// textAndImgShowView.setImgs(R.drawable.play, Integer.parseInt(list.get(i).getChannelImage())); | |
| 152 | 134 | textAndImgShowView.addImgs(list.get(i).getChannelImage()); |
| 153 | 135 | textAndImgShowView.setSelect(true); |
| 154 | 136 | textAndImgShowView.setWidth(getActivity(), layout_control); |
| ... | ... | @@ -157,8 +139,8 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
| 157 | 139 | textAndImgShowView.setOnClickListener(new View.OnClickListener() { |
| 158 | 140 | @Override |
| 159 | 141 | public void onClick(View view) { |
| 160 | - ChannelBean channelBean= (ChannelBean) view.getTag(); | |
| 161 | - ConsultTwoLevelActivity.getInstance(getActivity(),channelBean.getId()+""); | |
| 142 | + ChannelBean channelBean = (ChannelBean) view.getTag(); | |
| 143 | + ConsultTwoLevelActivity.getInstance(getActivity(), channelBean.getId() + ""); | |
| 162 | 144 | } |
| 163 | 145 | }); |
| 164 | 146 | layout_control.addView(textAndImgShowView); |
| ... | ... | @@ -199,8 +181,8 @@ public class ConsultOneLevelFragment extends BaseMVPCompatFragment<ConsultOneCon |
| 199 | 181 | |
| 200 | 182 | @Override |
| 201 | 183 | public void onBindViewHolder(GuangGaoBean object, int position) { |
| 202 | - Glide.with(getActivity()).load(AppConfig.BASE_URL_IMG+object.fileSrc).error(R.drawable.ic_launcher_foreground).into(iv_grally); | |
| 203 | - tv_grally_title.setText(object.describe+""); | |
| 184 | + Glide.with(getActivity()).load(AppConfig.BASE_URL_IMG + object.fileSrc).error(R.drawable.ic_launcher_foreground).into(iv_grally); | |
| 185 | + tv_grally_title.setText(object.describe + ""); | |
| 204 | 186 | } |
| 205 | 187 | } |
| 206 | 188 | } | ... | ... |
app/src/main/res/layout/fragment_mine.xml
mvpsdk/src/main/java/com/share/mvpsdk/utils/CacheUtils.java
| ... | ... | @@ -96,6 +96,11 @@ public class CacheUtils { |
| 96 | 96 | cleanCustomCache(filepath); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | + public static void clearCache(Context context)throws Exception{ | |
| 100 | + File file=new File("/data/data/"+ context.getPackageName()); | |
| 101 | + cleanCustomCache(file.toString()); | |
| 102 | + } | |
| 103 | + | |
| 99 | 104 | public static String getCacheSize(Context context) throws Exception { |
| 100 | 105 | File file=new File("/data/data/"+ context.getPackageName()); |
| 101 | 106 | return getFormatSize(getFolderSize(file)); | ... | ... |