Commit be0e0655 by 霍志良

feat:草稿功能修复

parent b68b8cda
package com.yidianling.dynamic.event package com.yidianling.dynamic.event
class DynamicSaveEvent () class DynamicSaveEvent (var saveOrNot:Boolean)
\ No newline at end of file \ No newline at end of file
...@@ -26,6 +26,7 @@ import com.flyco.tablayout.listener.CustomTabEntity; ...@@ -26,6 +26,7 @@ import com.flyco.tablayout.listener.CustomTabEntity;
import com.flyco.tablayout.listener.OnTabSelectListener; import com.flyco.tablayout.listener.OnTabSelectListener;
import com.ydl.ydlcommon.base.BaseActivity; import com.ydl.ydlcommon.base.BaseActivity;
import com.ydl.ydlcommon.base.config.YDLConstants; import com.ydl.ydlcommon.base.config.YDLConstants;
import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.ydl.ydlcommon.utils.SharedPreferencesEditor; import com.ydl.ydlcommon.utils.SharedPreferencesEditor;
import com.ydl.ydlcommon.utils.StatusBarUtils; import com.ydl.ydlcommon.utils.StatusBarUtils;
import com.ydl.ydlcommon.view.NoScrollViewPager; import com.ydl.ydlcommon.view.NoScrollViewPager;
...@@ -36,6 +37,7 @@ import com.yidianling.dynamic.bean.TrendTabEntity; ...@@ -36,6 +37,7 @@ import com.yidianling.dynamic.bean.TrendTabEntity;
import com.yidianling.dynamic.event.DynamicSaveEvent; import com.yidianling.dynamic.event.DynamicSaveEvent;
import com.yidianling.dynamic.publishTrend.fragment.PublishQuestionAndTrendFragment; import com.yidianling.dynamic.publishTrend.fragment.PublishQuestionAndTrendFragment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -67,7 +69,6 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -67,7 +69,6 @@ public class PublishTrendActivity extends BaseActivity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} }
public static Intent newIntent(Activity activity, String url, String cover, String title) { public static Intent newIntent(Activity activity, String url, String cover, String title) {
...@@ -81,6 +82,12 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -81,6 +82,12 @@ public class PublishTrendActivity extends BaseActivity {
} }
@NotNull
@Override
public StatusBarOptions getStatusViewOptions() {
return new StatusBarOptions(true, true);
}
public static Intent newIntentForArticle(Activity activity, String url, String cover, String title) { public static Intent newIntentForArticle(Activity activity, String url, String cover, String title) {
Intent intent = new Intent(activity, PublishTrendActivity.class); Intent intent = new Intent(activity, PublishTrendActivity.class);
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
...@@ -136,7 +143,7 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -136,7 +143,7 @@ public class PublishTrendActivity extends BaseActivity {
mTableLayout = findViewById(R.id.tab_layout); mTableLayout = findViewById(R.id.tab_layout);
mToastView = findViewById(R.id.tv_coustom_toast_view); mToastView = findViewById(R.id.tv_coustom_toast_view);
initData(); initData();
StatusBarUtils.Companion.setCustomStatusView(this,mPublishTrendTitle); // StatusBarUtils.Companion.setCustomStatusView(this,mPublishTrendTitle);
} }
private void SaveOrNotDialog() { private void SaveOrNotDialog() {
...@@ -145,6 +152,7 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -145,6 +152,7 @@ public class PublishTrendActivity extends BaseActivity {
.setLeftOnclick("不保留", new View.OnClickListener() { .setLeftOnclick("不保留", new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
EventBus.getDefault().post(new DynamicSaveEvent(false));
finish(); finish();
} }
}) })
...@@ -152,7 +160,7 @@ public class PublishTrendActivity extends BaseActivity { ...@@ -152,7 +160,7 @@ public class PublishTrendActivity extends BaseActivity {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
//发送通知给Fragment保留此次编辑 //发送通知给Fragment保留此次编辑
EventBus.getDefault().post(new DynamicSaveEvent()); EventBus.getDefault().post(new DynamicSaveEvent(true));
finish(); finish();
} }
}) })
......
...@@ -226,6 +226,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -226,6 +226,7 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
} }
public void onEventMainThread(DynamicSaveEvent event) { public void onEventMainThread(DynamicSaveEvent event) {
if (event.getSaveOrNot()){
//保留草稿数据 标题、内容、话题、是否专家可见、是否匿名、图片 //保留草稿数据 标题、内容、话题、是否专家可见、是否匿名、图片
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(),
...@@ -235,6 +236,12 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -235,6 +236,12 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
is_niming, is_niming,
publishTrendImgs publishTrendImgs
)); ));
}else{
publishTrendImgs.clear();
MMKV.defaultMMKV().encode("dynamic_save",new DynamicDraftBean(
"","","44","今日打卡",2,1,publishTrendImgs));
}
} }
@Override @Override
public void initDataAndEventLazy() { public void initDataAndEventLazy() {
...@@ -256,13 +263,17 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -256,13 +263,17 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
} }
if ("home_publish".equals(publish_type)) {// 从首页进来的发布 if ("home_publish".equals(publish_type)) {// 从首页进来的发布
topic_id = bundle.getString("topic_ic"); topic_id = bundle.getString("topic_ic");
if (TextUtils.isEmpty(topic_title)){
topic_title = bundle.getString("topic_title"); topic_title = bundle.getString("topic_title");
}
publish_trend_bottom_topic_tv.setVisibility(View.VISIBLE); publish_trend_bottom_topic_tv.setVisibility(View.VISIBLE);
publish_trend_bottom_topic_tv.setText("# " + topic_title); publish_trend_bottom_topic_tv.setText("# " + topic_title);
publish_trend_bottom_topic_tv.setTextColor(ContextCompat.getColor(activity, R.color.platform_main_theme)); publish_trend_bottom_topic_tv.setTextColor(ContextCompat.getColor(activity, R.color.platform_main_theme));
} else if ("topic_publish".equals(publish_type)) {// 从话题详情进来的发布 } else if ("topic_publish".equals(publish_type)) {// 从话题详情进来的发布
topic_id = bundle.getString("topic_id"); topic_id = bundle.getString("topic_id");
if (TextUtils.isEmpty(topic_title)){
topic_title = bundle.getString("topic_title"); topic_title = bundle.getString("topic_title");
}
publish_trend_bottom_topic_tv.setVisibility(View.VISIBLE); publish_trend_bottom_topic_tv.setVisibility(View.VISIBLE);
publish_trend_bottom_topic_tv.setText("# " + topic_title); publish_trend_bottom_topic_tv.setText("# " + topic_title);
publish_trend_bottom_topic_tv.setTextColor(ContextCompat.getColor(activity, R.color.platform_main_theme)); publish_trend_bottom_topic_tv.setTextColor(ContextCompat.getColor(activity, R.color.platform_main_theme));
...@@ -443,16 +454,25 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie ...@@ -443,16 +454,25 @@ public class PublishQuestionAndTrendFragment extends BaseFragment implements Vie
} }
if (dynamicDraftBean!=null){ if (dynamicDraftBean!=null){
//展示保留的草稿内容: 内容、话题、是否匿名、图片 //展示保留的草稿内容: 内容、话题、是否匿名、图片
topic_title=dynamicDraftBean.getTopicTitle();
publish_trend_content_editext.setText(dynamicDraftBean.getContent()); publish_trend_content_editext.setText(dynamicDraftBean.getContent());
publish_trend_bottom_topic_tv.setText(dynamicDraftBean.getTopicTitle()); publish_trend_bottom_topic_tv.setText(dynamicDraftBean.getTopicTitle());
if (dynamicDraftBean.getPublishTrendImgs()!=null){
publishTrendImgs= dynamicDraftBean.getPublishTrendImgs(); publishTrendImgs= dynamicDraftBean.getPublishTrendImgs();
}
is_niming=dynamicDraftBean.isUserAnonymous(); is_niming=dynamicDraftBean.isUserAnonymous();
isDoctorShow=dynamicDraftBean.isExpertSeen();
if (is_niming==1){ if (is_niming==1){
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox); publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox);
}else{ }else{
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox_sel); publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox_sel);
} }
if (isDoctorShow==1){
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox_sel);
}else{
publish_anonymity_iv.setImageResource(R.drawable.dynamic_checkbox);
}
} }
trends_publish_question.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { trends_publish_question.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override @Override
......
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