Commit be0e0655 by 霍志良

feat:草稿功能修复

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