Commit b68b8cda by 霍志良

feat:草稿功能实现

parent e7c637e5
...@@ -153,6 +153,7 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -153,6 +153,7 @@ public class PublishTrendActivity extends BaseActivity {
public void onClick(View view) { public void onClick(View view) {
//发送通知给Fragment保留此次编辑 //发送通知给Fragment保留此次编辑
EventBus.getDefault().post(new DynamicSaveEvent()); EventBus.getDefault().post(new DynamicSaveEvent());
finish();
} }
}) })
.setCancelAble(false) .setCancelAble(false)
...@@ -160,12 +161,20 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -160,12 +161,20 @@ public class PublishTrendActivity extends BaseActivity {
} }
private void initData() { private void initData() {
// titleList.add(new TrendTabEntity("发动态", 0, 0)); Integer dynamic_question = 1;
Bundle bundle = getIntent().getBundleExtra("bundle");
if (null != bundle) {
dynamic_question= bundle.getInt("dynamic_question", 1);
}
if (dynamic_question==1){
titleList.add(new TrendTabEntity("发动态", 0, 0));
fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_TREND));
}else{
titleList.add(new TrendTabEntity("提问", 0, 0)); titleList.add(new TrendTabEntity("提问", 0, 0));
fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_QUESTION));
}
mTableLayout.setTabData(titleList); mTableLayout.setTabData(titleList);
// fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_TREND));
fragmentList.add(PublishQuestionAndTrendFragment.getInstance(PublishQuestionAndTrendFragment.TYPE_QUESTION));
FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) { FragmentPagerAdapter adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
@Override @Override
...@@ -210,7 +219,7 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -210,7 +219,7 @@ public class PublishTrendActivity extends BaseActivity {
} }
}); });
handler.postDelayed(() -> showNoticeView(), 300); // handler.postDelayed(() -> showNoticeView(), 300);
} }
/** /**
...@@ -222,7 +231,7 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -222,7 +231,7 @@ public class PublishTrendActivity extends BaseActivity {
return; return;
} }
TextView textView = mTableLayout.getTitleView(1); TextView textView = mTableLayout.getTitleView(0);
textView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); textView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int textViewWidth = textView.getMeasuredWidth(); int textViewWidth = textView.getMeasuredWidth();
View view = LayoutInflater.from(this).inflate(R.layout.dynamic_popup_notice, null); View view = LayoutInflater.from(this).inflate(R.layout.dynamic_popup_notice, null);
......
...@@ -179,6 +179,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -179,6 +179,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
private View dialogContentView; private View dialogContentView;
private Activity activity; private Activity activity;
private int isCanlayout=0; private int isCanlayout=0;
DynamicDraftBean dynamicDraftBean;
public static Fragment getInstance(String type) { public static Fragment getInstance(String type) {
PublishQuestionAndTrendFragment fragment = new PublishQuestionAndTrendFragment(); PublishQuestionAndTrendFragment fragment = new PublishQuestionAndTrendFragment();
fragment.type = type; fragment.type = type;
...@@ -226,7 +227,6 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -226,7 +227,6 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
public void onEventMainThread(DynamicSaveEvent event) { public void onEventMainThread(DynamicSaveEvent event) {
//保留草稿数据 标题、内容、话题、是否专家可见、是否匿名、图片 //保留草稿数据 标题、内容、话题、是否专家可见、是否匿名、图片
MMKV.defaultMMKV().encode("dynamic_save",new DynamicDraftBean(publish_trend_title_editext.getText().toString(), MMKV.defaultMMKV().encode("dynamic_save",new DynamicDraftBean(publish_trend_title_editext.getText().toString(),
publish_trend_content_editext.getText().toString(), publish_trend_content_editext.getText().toString(),
topic_id, topic_id,
...@@ -240,6 +240,8 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -240,6 +240,8 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
public void initDataAndEventLazy() { public void initDataAndEventLazy() {
rxPermissions = new RxPermissions(getActivity()); rxPermissions = new RxPermissions(getActivity());
imgFiles = new ArrayList<File>(); imgFiles = new ArrayList<File>();
publishTrendImgs = new ArrayList<>();
dynamicDraftBean=MMKV.defaultMMKV().decodeParcelable("dynamic_save",DynamicDraftBean.class);
initView(); initView();
uiHandler = new Handler(); uiHandler = new Handler();
initEvent(); initEvent();
...@@ -268,7 +270,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -268,7 +270,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
publish_trend_bottom_topic_tv.setVisibility(View.VISIBLE); publish_trend_bottom_topic_tv.setVisibility(View.VISIBLE);
} }
publishTrendImgs = new ArrayList<>();
if (!"".equals(Test_url) && Test_url != null && !"".equals(Test_cover) && Test_cover != null && !"".equals(Test_title) && Test_title != null) { if (!"".equals(Test_url) && Test_url != null && !"".equals(Test_cover) && Test_cover != null && !"".equals(Test_title) && Test_title != null) {
publish_trend_img_rcv.setVisibility(View.GONE); publish_trend_img_rcv.setVisibility(View.GONE);
publish_trend_ad_rel.setVisibility(View.VISIBLE); publish_trend_ad_rel.setVisibility(View.VISIBLE);
...@@ -426,6 +428,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -426,6 +428,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
publish_trend_content_editext.setFilters(new InputFilter[]{new InputFilter.LengthFilter(500)}); publish_trend_content_editext.setFilters(new InputFilter[]{new InputFilter.LengthFilter(500)});
publish_trend_content_num_tv.setText("0/500"); publish_trend_content_num_tv.setText("0/500");
publish_trend_content_editext.setHint("这一刻的想法…"); publish_trend_content_editext.setHint("这一刻的想法…");
} else {//提问 } else {//提问
publish_trend_title_editext.setVisibility(View.VISIBLE); publish_trend_title_editext.setVisibility(View.VISIBLE);
ll_to_expert.setVisibility(View.VISIBLE); ll_to_expert.setVisibility(View.VISIBLE);
...@@ -434,6 +437,22 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -434,6 +437,22 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
publish_trend_content_editext.setHint("1、清晰描述事情的背景及经过\n" + publish_trend_content_editext.setHint("1、清晰描述事情的背景及经过\n" +
"2、你想寻求哪方面的帮助\n" + "2、你想寻求哪方面的帮助\n" +
"这样更容易获得咨询师准确、专业的解答哦~"); "这样更容易获得咨询师准确、专业的解答哦~");
if (dynamicDraftBean!=null){
publish_trend_title_editext.setText(dynamicDraftBean.getTitle());
}
}
if (dynamicDraftBean!=null){
//展示保留的草稿内容: 内容、话题、是否匿名、图片
publish_trend_content_editext.setText(dynamicDraftBean.getContent());
publish_trend_bottom_topic_tv.setText(dynamicDraftBean.getTopicTitle());
publishTrendImgs= dynamicDraftBean.getPublishTrendImgs();
is_niming=dynamicDraftBean.isUserAnonymous();
if (is_niming==1){
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox);
}else{
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox_sel);
}
} }
trends_publish_question.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { trends_publish_question.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override @Override
......
...@@ -368,6 +368,7 @@ public class TrendsHomeFragment extends BaseFragment implements ITrendHomeView, ...@@ -368,6 +368,7 @@ public class TrendsHomeFragment extends BaseFragment implements ITrendHomeView,
bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish"); bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish");
bundle.putString("topic_id", "44"); bundle.putString("topic_id", "44");
bundle.putString("topic_title", "今日打卡"); bundle.putString("topic_title", "今日打卡");
bundle.putInt("dynamic_question", 1);
intent.putExtra("bundle", bundle); intent.putExtra("bundle", bundle);
startActivity(intent); startActivity(intent);
// PublishTrendActivityTrends.Companion.start(requireContext(),"44","今日打卡"); // PublishTrendActivityTrends.Companion.start(requireContext(),"44","今日打卡");
...@@ -375,13 +376,14 @@ public class TrendsHomeFragment extends BaseFragment implements ITrendHomeView, ...@@ -375,13 +376,14 @@ public class TrendsHomeFragment extends BaseFragment implements ITrendHomeView,
@Override @Override
public void publishQuestion() { public void publishQuestion() {
//发布问题 //问题
Intent intent = new Intent(getActivity().getApplicationContext(), PublishTrendActivity.class); Intent intent = new Intent(getActivity().getApplicationContext(), PublishTrendActivity.class);
//默认改为今日打卡 //默认改为今日打卡
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish"); bundle.putString(DynamicConstants.PUBLISH_TYPE, "topic_publish");
bundle.putString("topic_id", "44"); bundle.putString("topic_id", "44");
bundle.putString("topic_title", "今日打卡"); bundle.putString("topic_title", "今日打卡");
bundle.putInt("dynamic_question", 2);
intent.putExtra("bundle", bundle); intent.putExtra("bundle", bundle);
startActivity(intent); startActivity(intent);
} }
......
...@@ -146,7 +146,7 @@ dependencies { ...@@ -146,7 +146,7 @@ dependencies {
api rootProject.ext.dependencies["support-multidex"] api rootProject.ext.dependencies["support-multidex"]
api rootProject.ext.dependencies["tablayout"] api rootProject.ext.dependencies["tablayout"]
api rootProject.ext.dependencies["xrecyclerview"] api rootProject.ext.dependencies["xrecyclerview"]
implementation rootProject.ext.dependencies["mmkv"] api rootProject.ext.dependencies["mmkv"]
api rootProject.ext.dependencies["flowlayout"] api rootProject.ext.dependencies["flowlayout"]
api rootProject.ext.dependencies["androidanimations"] api rootProject.ext.dependencies["androidanimations"]
//====================Tools==================== //====================Tools====================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment