mirror of
https://e.coding.net/mcontext/mContext/sdu.git
synced 2024-09-18 02:24:54 +08:00
final
This commit is contained in:
parent
c355914d84
commit
536ef5a764
@ -22,7 +22,8 @@
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="UnusedAttribute"
|
||||
tools:replace="android:allowBackup">
|
||||
<activity android:name=".ui.baby.AddBabyActivity"></activity>
|
||||
<activity android:name=".ui.grow.AddNewRecordActivity"></activity>
|
||||
<activity android:name=".ui.baby.AddBabyActivity" />
|
||||
<activity android:name=".ui.home.NewPostActivity" />
|
||||
<activity
|
||||
android:name=".ui.account.home.InputCodeActivity"
|
||||
|
@ -4,6 +4,7 @@ public class Const {
|
||||
public static final String BASE_URL = "https://www.yuxihan.com/";
|
||||
public static final String ERROR_CODE_NORMAL = "0";
|
||||
public static boolean NEED_RELOAD_PROFILE = false;
|
||||
public static boolean NEED_RELOAD_HOME = false;
|
||||
|
||||
public static final String LOGIN_STATE = "LoginState";
|
||||
public static final String LOGIN_TOKEN = "LoginToken";
|
||||
|
@ -0,0 +1,244 @@
|
||||
package com.yuxihan.sdu.comm.widget;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Rect;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
|
||||
import com.yuxihan.sdu.R;
|
||||
|
||||
public class InputTextMsgDialog extends AppCompatDialog {
|
||||
private Context mContext;
|
||||
private InputMethodManager imm;
|
||||
private EditText messageTextView;
|
||||
private TextView confirmBtn;
|
||||
private RelativeLayout rlDlg;
|
||||
private int mLastDiff = 0;
|
||||
private TextView tvNumber;
|
||||
private int maxNumber = 200;
|
||||
|
||||
public interface OnTextSendListener {
|
||||
|
||||
void onTextSend(String msg);
|
||||
}
|
||||
|
||||
|
||||
private OnTextSendListener mOnTextSendListener;
|
||||
|
||||
public InputTextMsgDialog(@NonNull Context context, int theme) {
|
||||
super(context, theme);
|
||||
this.mContext = context;
|
||||
this.getWindow().setWindowAnimations(R.style.main_menu_animstyle);
|
||||
init();
|
||||
setLayout();
|
||||
}
|
||||
|
||||
/**
|
||||
* 最大输入字数 默认200
|
||||
*/
|
||||
@SuppressLint("SetTextI18n")
|
||||
public void setMaxNumber(int maxNumber) {
|
||||
this.maxNumber = maxNumber;
|
||||
tvNumber.setText("0/" + maxNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置输入提示文字
|
||||
*/
|
||||
public void setHint(String text) {
|
||||
messageTextView.setHint(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置按钮的文字 默认为:发送
|
||||
*/
|
||||
public void setBtnText(String text) {
|
||||
confirmBtn.setText(text);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setContentView(R.layout.dialog_input_text_msg);
|
||||
messageTextView = (EditText) findViewById(R.id.et_input_message);
|
||||
tvNumber = (TextView) findViewById(R.id.tv_test);
|
||||
final LinearLayout rldlgview = (LinearLayout) findViewById(R.id.rl_inputdlg_view);
|
||||
messageTextView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
tvNumber.setText(editable.length() + "/" + maxNumber);
|
||||
if (editable.length() > maxNumber) {
|
||||
/*dot_hong颜色值:#E73111,text_bottom_comment颜色值:#9B9B9B*/
|
||||
tvNumber.setTextColor(mContext.getResources().getColor(R.color.dot_hong));
|
||||
} else {
|
||||
tvNumber.setTextColor(mContext.getResources().getColor(R.color.text_bottom_comment));
|
||||
}
|
||||
if (editable.length() == 0) {
|
||||
confirmBtn.setBackgroundResource(R.drawable.btn_send_normal);
|
||||
} else {
|
||||
confirmBtn.setBackgroundResource(R.drawable.btn_send_pressed);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
confirmBtn = (TextView) findViewById(R.id.confrim_btn);
|
||||
LinearLayout ll_tv = findViewById(R.id.ll_tv);
|
||||
imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
ll_tv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String msg = messageTextView.getText().toString().trim();
|
||||
if (msg.length() > maxNumber) {
|
||||
Toast.makeText(mContext, "超过最大字数限制", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (!TextUtils.isEmpty(msg)) {
|
||||
mOnTextSendListener.onTextSend(msg);
|
||||
imm.showSoftInput(messageTextView, InputMethodManager.SHOW_FORCED);
|
||||
imm.hideSoftInputFromWindow(messageTextView.getWindowToken(), 0);
|
||||
messageTextView.setText("");
|
||||
dismiss();
|
||||
} else {
|
||||
Toast.makeText(mContext, "请输入文字", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
messageTextView.setText(null);
|
||||
}
|
||||
});
|
||||
|
||||
messageTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
switch (actionId) {
|
||||
case KeyEvent.KEYCODE_ENDCALL:
|
||||
case KeyEvent.KEYCODE_ENTER:
|
||||
if (messageTextView.getText().length() > maxNumber) {
|
||||
Toast.makeText(mContext, "超过最大字数限制", Toast.LENGTH_LONG).show();
|
||||
return true;
|
||||
}
|
||||
if (messageTextView.getText().length() > 0) {
|
||||
imm.hideSoftInputFromWindow(messageTextView.getWindowToken(), 0);
|
||||
dismiss();
|
||||
} else {
|
||||
Toast.makeText(mContext, "请输入文字", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return true;
|
||||
case KeyEvent.KEYCODE_BACK:
|
||||
dismiss();
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
messageTextView.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View view, int i, KeyEvent keyEvent) {
|
||||
Log.d("My test", "onKey " + keyEvent.getCharacters());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
rlDlg = findViewById(R.id.rl_outside_view);
|
||||
rlDlg.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() != R.id.rl_inputdlg_view)
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
rldlgview.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
|
||||
@Override
|
||||
public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5,
|
||||
int i6, int i7) {
|
||||
Rect r = new Rect();
|
||||
//获取当前界面可视部分
|
||||
getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
|
||||
//获取屏幕的高度
|
||||
int screenHeight = getWindow().getDecorView().getRootView().getHeight();
|
||||
//此处就是用来获取键盘的高度的, 在键盘没有弹出的时候 此高度为0 键盘弹出的时候为一个正数
|
||||
int heightDifference = screenHeight - r.bottom;
|
||||
|
||||
if (heightDifference <= 0 && mLastDiff > 0) {
|
||||
dismiss();
|
||||
}
|
||||
mLastDiff = heightDifference;
|
||||
}
|
||||
});
|
||||
rldlgview.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
imm.hideSoftInputFromWindow(messageTextView.getWindowToken(), 0);
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
setOnKeyListener(new OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(DialogInterface dialogInterface, int keyCode, KeyEvent keyEvent) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0)
|
||||
dismiss();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLayout() {
|
||||
getWindow().setGravity(Gravity.BOTTOM);
|
||||
WindowManager m = getWindow().getWindowManager();
|
||||
Display d = m.getDefaultDisplay();
|
||||
WindowManager.LayoutParams p = getWindow().getAttributes();
|
||||
p.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
p.height = WindowManager.LayoutParams.WRAP_CONTENT;
|
||||
getWindow().setAttributes(p);
|
||||
setCancelable(true);
|
||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
|
||||
}
|
||||
|
||||
|
||||
public void setmOnTextSendListener(OnTextSendListener onTextSendListener) {
|
||||
this.mOnTextSendListener = onTextSendListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
//dismiss之前重置mLastDiff值避免下次无法打开
|
||||
mLastDiff = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
}
|
||||
|
||||
}
|
@ -8,10 +8,15 @@ import com.yuxihan.sdu.data.model.RegParams;
|
||||
import com.yuxihan.sdu.data.model.SMSParams;
|
||||
import com.yuxihan.sdu.data.model.UpdateNicknameParams;
|
||||
import com.yuxihan.sdu.data.model.UpdateUserHeadParams;
|
||||
import com.yuxihan.sdu.post.CommentListModel;
|
||||
import com.yuxihan.sdu.post.CommentParams;
|
||||
import com.yuxihan.sdu.ui.account.HomeBean;
|
||||
import com.yuxihan.sdu.ui.account.home.CodeParams;
|
||||
import com.yuxihan.sdu.ui.baby.AddBabyParams;
|
||||
import com.yuxihan.sdu.ui.baby.model.BabyInfoModel;
|
||||
import com.yuxihan.sdu.ui.grow.GrowListParams;
|
||||
import com.yuxihan.sdu.ui.grow.RecordParams;
|
||||
import com.yuxihan.sdu.ui.grow.model.BabyGrowModel;
|
||||
import com.yuxihan.sdu.ui.home.PostModel;
|
||||
import com.yuxihan.sdu.ui.home.PostRequestParams;
|
||||
|
||||
@ -55,6 +60,7 @@ public interface UpdateService {
|
||||
Call<Result<HomeBean>> getFamilyList(
|
||||
@Body BaseRequestParams params
|
||||
);
|
||||
|
||||
@POST("/deleteFamily")
|
||||
Call<Result> deleteFamily(
|
||||
@Body BaseRequestParams params
|
||||
@ -65,30 +71,53 @@ public interface UpdateService {
|
||||
@Body PostRequestParams params
|
||||
);
|
||||
|
||||
@POST("/addBaby")
|
||||
@POST("/saveComment")
|
||||
Call<Result> saveComment(
|
||||
@Body CommentParams params
|
||||
);
|
||||
|
||||
@POST("/addBaby")
|
||||
Call<Result> addBaby(
|
||||
@Body AddBabyParams params
|
||||
);
|
||||
@POST("/updateBaby")
|
||||
|
||||
@POST("/updateBaby")
|
||||
Call<Result> updateBaby(
|
||||
@Body AddBabyParams params
|
||||
);
|
||||
@POST("/deleteBaby")
|
||||
|
||||
@POST("/deleteBaby")
|
||||
Call<Result> deleteBaby(
|
||||
@Body AddBabyParams params
|
||||
);
|
||||
|
||||
@POST("/getBabyList")
|
||||
@POST("/getBabyList")
|
||||
Call<Result<BabyInfoModel>> getBabyList(
|
||||
@Body BaseRequestParams params
|
||||
);
|
||||
@POST("/addFamilyMembers")
|
||||
|
||||
@POST("/saveBabyGroup")
|
||||
Call<Result> saveBabyGroup(
|
||||
@Body RecordParams params
|
||||
);
|
||||
|
||||
@POST("/getBabyGroupList")
|
||||
Call<Result<BabyGrowModel>> getBabyGroupList(
|
||||
@Body GrowListParams params
|
||||
);
|
||||
|
||||
@POST("/addFamilyMembers")
|
||||
Call<Result> addFamilyMembers(
|
||||
@Body CodeParams params
|
||||
);
|
||||
@POST("/getPostDetailList")
|
||||
|
||||
@POST("/getPostDetailList")
|
||||
Call<Result<PostModel>> getPostDetailList(
|
||||
@Body BaseRequestParams params
|
||||
);
|
||||
|
||||
@POST("/getCommentList")
|
||||
Call<Result<CommentListModel>> getCommentList(
|
||||
@Body CommentParams params
|
||||
);
|
||||
}
|
||||
|
92
app/src/main/java/com/yuxihan/sdu/post/CommentListModel.java
Normal file
92
app/src/main/java/com/yuxihan/sdu/post/CommentListModel.java
Normal file
@ -0,0 +1,92 @@
|
||||
package com.yuxihan.sdu.post;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommentListModel {
|
||||
|
||||
private List<CommentBean> commentList;
|
||||
|
||||
public List<CommentBean> getCommentList() {
|
||||
return commentList;
|
||||
}
|
||||
|
||||
public void setCommentList(List<CommentBean> commentList) {
|
||||
this.commentList = commentList;
|
||||
}
|
||||
|
||||
public static class CommentBean {
|
||||
/**
|
||||
* postId : 1
|
||||
* commentContent : 韩大胖是傻子
|
||||
* userId : 13
|
||||
* userName : 15919474525
|
||||
* userHead : null
|
||||
* commentTime : 1591471934000
|
||||
* nickname : 用户1590568596584
|
||||
*/
|
||||
|
||||
private int postId;
|
||||
private String commentContent;
|
||||
private int userId;
|
||||
private String userName;
|
||||
private String userHead;
|
||||
private long commentTime;
|
||||
private String nickname;
|
||||
|
||||
public int getPostId() {
|
||||
return postId;
|
||||
}
|
||||
|
||||
public void setPostId(int postId) {
|
||||
this.postId = postId;
|
||||
}
|
||||
|
||||
public String getCommentContent() {
|
||||
return commentContent;
|
||||
}
|
||||
|
||||
public void setCommentContent(String commentContent) {
|
||||
this.commentContent = commentContent;
|
||||
}
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getUserHead() {
|
||||
return userHead;
|
||||
}
|
||||
|
||||
public void setUserHead(String userHead) {
|
||||
this.userHead = userHead;
|
||||
}
|
||||
|
||||
public long getCommentTime() {
|
||||
return commentTime;
|
||||
}
|
||||
|
||||
public void setCommentTime(long commentTime) {
|
||||
this.commentTime = commentTime;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
}
|
||||
}
|
30
app/src/main/java/com/yuxihan/sdu/post/CommentParams.java
Normal file
30
app/src/main/java/com/yuxihan/sdu/post/CommentParams.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.yuxihan.sdu.post;
|
||||
|
||||
import com.yuxihan.sdu.comm.network.BaseRequestParams;
|
||||
|
||||
public class CommentParams extends BaseRequestParams {
|
||||
|
||||
/**
|
||||
* postId : 1
|
||||
* commentContent : 韩大胖是傻子
|
||||
*/
|
||||
|
||||
private int postId;
|
||||
private String commentContent;
|
||||
|
||||
public int getPostId() {
|
||||
return postId;
|
||||
}
|
||||
|
||||
public void setPostId(int postId) {
|
||||
this.postId = postId;
|
||||
}
|
||||
|
||||
public String getCommentContent() {
|
||||
return commentContent;
|
||||
}
|
||||
|
||||
public void setCommentContent(String commentContent) {
|
||||
this.commentContent = commentContent;
|
||||
}
|
||||
}
|
@ -7,19 +7,31 @@ import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.lzy.ninegrid.ImageInfo;
|
||||
import com.lzy.ninegrid.NineGridView;
|
||||
import com.sackcentury.shinebuttonlib.ShineButton;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.BaseActivity;
|
||||
import com.yuxihan.sdu.comm.util.CommViewHolder;
|
||||
import com.yuxihan.sdu.comm.Const;
|
||||
import com.yuxihan.sdu.comm.util.TimeConvert;
|
||||
import com.yuxihan.sdu.comm.widget.InputTextMsgDialog;
|
||||
import com.yuxihan.sdu.comm.widget.MyScrollView;
|
||||
import com.yuxihan.sdu.data.model.PostDetailBean;
|
||||
import com.yuxihan.sdu.post.adapter.CommentListAdapter;
|
||||
import com.yuxihan.sdu.ui.home.PostModel;
|
||||
import com.yuxihan.sdu.ui.home.adapter.NineGridViewClickAdapter;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 帖子详情页
|
||||
@ -44,12 +56,17 @@ public class PostDetailActivity extends BaseActivity implements MyScrollView.OnS
|
||||
/**
|
||||
* 当前post信息
|
||||
*/
|
||||
private PostDetailBean curPost;
|
||||
private PostModel.PostDetailBean curPost;
|
||||
private InputTextMsgDialog inputTextMsgDialog;
|
||||
private PostDetailViewModel postDetailViewModel;
|
||||
private TextView tvCommentCount;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_post_detail);
|
||||
postDetailViewModel = new ViewModelProvider(this, new PostDetailViewModelFactory())
|
||||
.get(PostDetailViewModel.class);
|
||||
getIntentData();
|
||||
initView();
|
||||
setPostData();
|
||||
@ -61,37 +78,42 @@ public class PostDetailActivity extends BaseActivity implements MyScrollView.OnS
|
||||
return;
|
||||
}
|
||||
ImageView posterHead = findViewById(R.id.poster_head);
|
||||
Glide.with(PostDetailActivity.this).load(curPost.getUserHead()).into(posterHead);
|
||||
Glide.with(this).load(curPost.getUserHead()).placeholder(R.drawable.ic_head_default).into(posterHead);
|
||||
|
||||
TextView posterName = findViewById(R.id.tv_poster_name);
|
||||
posterName.setText(curPost.getUserName());
|
||||
posterName.setText(curPost.getNickname());
|
||||
|
||||
TextView postTime = findViewById(R.id.tv_post_time);
|
||||
postTime.setText(TimeConvert.getTimeElapse(curPost.getPostTime()));
|
||||
postTime.setText(TimeConvert.getTimeElapse(new Date().getTime()));
|
||||
|
||||
TextView postContentText = findViewById(R.id.tv_post_content_text);
|
||||
postContentText.setText(curPost.getPostTextContent());
|
||||
|
||||
TextView tvCommentCount = findViewById(R.id.tv_comment_count);
|
||||
tvCommentCount = findViewById(R.id.tv_comment_count);
|
||||
tvCommentCount.setText(curPost.getCommentCount() + "");
|
||||
|
||||
View rlLike = findViewById( R.id.rl_like);
|
||||
View rlLike = findViewById(R.id.rl_like);
|
||||
rlLike.setOnClickListener(null);
|
||||
|
||||
TextView tvLikeCount = findViewById( R.id.tv_like_count);
|
||||
TextView tvLikeCount = findViewById(R.id.tv_like_count);
|
||||
tvLikeCount.setText(curPost.getPostLikeCount() + "");
|
||||
|
||||
ShineButton shineButton = findViewById( R.id.bt_like);
|
||||
shineButton.setChecked(curPost.isLikedByCurAccount());
|
||||
ImageView baby_head = findViewById(R.id.baby_head);
|
||||
Glide.with(this).load(curPost.getBabyHead()).placeholder(R.drawable.ic_baby_head).into(baby_head);
|
||||
TextView tv_baby_name = findViewById(R.id.tv_baby_name);
|
||||
tv_baby_name.setText(curPost.getBabyName());
|
||||
|
||||
ShineButton shineButton = findViewById(R.id.bt_like);
|
||||
shineButton.setChecked(curPost.getIsLikedByCurAccount() == 1);
|
||||
shineButton.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(View view, boolean checked) {
|
||||
if (checked) {
|
||||
curPost.setLikedByCurAccount(true);
|
||||
curPost.setIsLikedByCurAccount(1);
|
||||
curPost.setPostLikeCount(curPost.getPostLikeCount() + 1);
|
||||
tvLikeCount.setText(curPost.getPostLikeCount() + "");
|
||||
} else {
|
||||
curPost.setLikedByCurAccount(false);
|
||||
curPost.setIsLikedByCurAccount(0);
|
||||
curPost.setPostLikeCount(curPost.getPostLikeCount() - 1);
|
||||
tvLikeCount.setText(curPost.getPostLikeCount() + "");
|
||||
}
|
||||
@ -101,23 +123,26 @@ public class PostDetailActivity extends BaseActivity implements MyScrollView.OnS
|
||||
|
||||
NineGridView ngvPicContainer = findViewById(R.id.ngv_pic_container);
|
||||
ArrayList<ImageInfo> imageInfoList = new ArrayList<>();
|
||||
ArrayList<String> postPicUrls = curPost.getPostPicUrls();
|
||||
if (postPicUrls != null) {
|
||||
for (String picUrl : postPicUrls) {
|
||||
ImageInfo info = new ImageInfo();
|
||||
info.setThumbnailUrl(picUrl);
|
||||
info.setBigImageUrl(picUrl);
|
||||
imageInfoList.add(info);
|
||||
String postPicUrls1 = curPost.getPostPicUrls();
|
||||
if (null != postPicUrls1) {
|
||||
String[] split = postPicUrls1.split(Const.URL_Separator);
|
||||
if (split.length > 0) {
|
||||
for (String picUrl : split) {
|
||||
ImageInfo info = new ImageInfo();
|
||||
info.setThumbnailUrl(picUrl);
|
||||
info.setBigImageUrl(picUrl);
|
||||
imageInfoList.add(info);
|
||||
}
|
||||
}
|
||||
ngvPicContainer.setAdapter(new NineGridViewClickAdapter(this, imageInfoList));
|
||||
}
|
||||
ngvPicContainer.setAdapter(new NineGridViewClickAdapter(PostDetailActivity.this,
|
||||
imageInfoList));
|
||||
|
||||
}
|
||||
|
||||
private void getIntentData() {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (extras != null) {
|
||||
curPost = (PostDetailBean) extras.get("key");
|
||||
curPost = (PostModel.PostDetailBean) extras.get("key");
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,11 +152,35 @@ public class PostDetailActivity extends BaseActivity implements MyScrollView.OnS
|
||||
private void initView() {
|
||||
findViewById(R.id.iv_back).setOnClickListener(this);
|
||||
MyScrollView mMyScrollView = (MyScrollView) findViewById(R.id.my_scrollview);
|
||||
findViewById(R.id.rl_comment).setOnClickListener(this);
|
||||
findViewById(R.id.rl_like).setOnClickListener(this);
|
||||
mTabViewLayout = (LinearLayout) findViewById(R.id.ll_tabView);
|
||||
mTopTabViewLayout = (LinearLayout) findViewById(R.id.ll_tabTopView);
|
||||
mTopView = (LinearLayout) findViewById(R.id.tv_topView);
|
||||
//滑动监听
|
||||
mMyScrollView.setOnScrollListener(this);
|
||||
inputTextMsgDialog = new InputTextMsgDialog(this, R.style.dialog_center);
|
||||
inputTextMsgDialog.setmOnTextSendListener(new InputTextMsgDialog.OnTextSendListener() {
|
||||
@Override
|
||||
public void onTextSend(String msg) {
|
||||
CommentParams commentParams = new CommentParams();
|
||||
commentParams.setPostId(curPost.getPostId());
|
||||
commentParams.setCommentContent(msg);
|
||||
postDetailViewModel.saveComment(commentParams);
|
||||
}
|
||||
});
|
||||
RecyclerView growListRV = findViewById(R.id.recycler);
|
||||
growListRV.setLayoutManager(new LinearLayoutManager(this));
|
||||
growListRV.setHasFixedSize(true);
|
||||
CommentListAdapter listAdapter = new CommentListAdapter(null);
|
||||
growListRV.setAdapter(listAdapter);
|
||||
postDetailViewModel.getCommentListModel().observe(this, new Observer<CommentListModel>() {
|
||||
@Override
|
||||
public void onChanged(CommentListModel commentListModel) {
|
||||
listAdapter.updateData(commentListModel);
|
||||
}
|
||||
});
|
||||
postDetailViewModel.getCommentList(curPost.getPostId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -159,8 +208,34 @@ public class PostDetailActivity extends BaseActivity implements MyScrollView.OnS
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.rl_comment:
|
||||
inputTextMsgDialog.show();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(RefreshCommentListEvent event) {
|
||||
postDetailViewModel.getCommentList(curPost.getPostId());
|
||||
curPost.setCommentCount(curPost.getCommentCount() + 1);
|
||||
tvCommentCount.setText(curPost.getCommentCount() + "");
|
||||
Const.NEED_RELOAD_HOME = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,10 +8,10 @@ import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.yuxihan.sdu.comm.Const;
|
||||
import com.yuxihan.sdu.comm.SDUApp;
|
||||
import com.yuxihan.sdu.data.Result;
|
||||
import com.yuxihan.sdu.data.UpdateService;
|
||||
import com.yuxihan.sdu.data.model.DataBean;
|
||||
import com.yuxihan.sdu.data.model.UpdateNicknameParams;
|
||||
import com.yuxihan.sdu.ui.info.UpdateUserHeadState;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
@ -19,18 +19,18 @@ import retrofit2.Response;
|
||||
|
||||
public class PostDetailViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<UpdateUserHeadState> updateUserHead = new MutableLiveData<>();
|
||||
private MutableLiveData<CommentListModel> commentListModel = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<UpdateUserHeadState> getUpdateUserHead() {
|
||||
return updateUserHead;
|
||||
public MutableLiveData<CommentListModel> getCommentListModel() {
|
||||
return commentListModel;
|
||||
}
|
||||
|
||||
public void updateNickname(String nickname) {
|
||||
public void saveComment(CommentParams params) {
|
||||
UpdateService updateService = SDUApp.getRetrofit().create(UpdateService.class);
|
||||
Call<DataBean> call = updateService.updateNickname(new UpdateNicknameParams(nickname));
|
||||
call.enqueue(new Callback<DataBean>() {
|
||||
Call<Result> call = updateService.saveComment(params);
|
||||
call.enqueue(new Callback<Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<DataBean> call, Response<DataBean> response) {
|
||||
public void onResponse(Call<Result> call, Response<Result> response) {
|
||||
//请求成功,返回是一个封装为DataBean的响应
|
||||
if (null == response.body()) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "Internal Server Error",
|
||||
@ -38,14 +38,46 @@ public class PostDetailViewModel extends ViewModel {
|
||||
return;
|
||||
}
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
// updateNicknameState.setValue(new UpdateNicknameState(nickname));
|
||||
Toast.makeText(SDUApp.getAppContext(), "评论成功!", Toast.LENGTH_LONG).show();
|
||||
EventBus.getDefault().post(new RefreshCommentListEvent());
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), "保存失败,请重新登陆后再试!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<DataBean> call, Throwable t) {
|
||||
public void onFailure(Call<Result> call, Throwable t) {
|
||||
//请求失败
|
||||
Log.e("TAG", "请求失败:" + t.getMessage());
|
||||
Toast.makeText(SDUApp.getAppContext(), "服务器开小差了!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getCommentList(int postID) {
|
||||
UpdateService updateService = SDUApp.getRetrofit().create(UpdateService.class);
|
||||
CommentParams params = new CommentParams();
|
||||
params.setPostId(postID);
|
||||
Call<Result<CommentListModel>> call = updateService.getCommentList(params);
|
||||
call.enqueue(new Callback<Result<CommentListModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<Result<CommentListModel>> call,
|
||||
Response<Result<CommentListModel>> response) {
|
||||
//请求成功,返回是一个封装为DataBean的响应
|
||||
if (null == response.body()) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "Internal Server Error",
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
commentListModel.setValue(response.body().getResult());
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), "保存失败,请重新登陆后再试!", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Result<CommentListModel>> call, Throwable t) {
|
||||
//请求失败
|
||||
Log.e("TAG", "请求失败:" + t.getMessage());
|
||||
Toast.makeText(SDUApp.getAppContext(), "服务器开小差了!", Toast.LENGTH_LONG).show();
|
||||
|
@ -0,0 +1,4 @@
|
||||
package com.yuxihan.sdu.post;
|
||||
|
||||
class RefreshCommentListEvent {
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.yuxihan.sdu.post.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.util.CommViewHolder;
|
||||
import com.yuxihan.sdu.comm.util.TimeConvert;
|
||||
import com.yuxihan.sdu.post.CommentListModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommentListAdapter extends RecyclerView.Adapter {
|
||||
|
||||
private CommentListModel commentListModel;
|
||||
private Context mContext;
|
||||
|
||||
public CommentListAdapter(CommentListModel commentListModel) {
|
||||
this.commentListModel = commentListModel;
|
||||
}
|
||||
|
||||
public static class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
public ViewGroup v;
|
||||
|
||||
public MyViewHolder(ViewGroup v) {
|
||||
super(v);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
ViewGroup v = (ViewGroup) LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_comment_list, parent, false);
|
||||
return new MyViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
List<CommentListModel.CommentBean> commentList = commentListModel.getCommentList();
|
||||
CommentListModel.CommentBean commentBean = commentList.get(position);
|
||||
//findView & setData
|
||||
ImageView iv_commenter_head = CommViewHolder.get(holder.itemView, R.id.iv_commenter_head);
|
||||
Glide.with(mContext).load(commentBean.getUserHead()).placeholder(R.drawable.ic_head_default).into(iv_commenter_head);
|
||||
|
||||
TextView tv_commenter_name = CommViewHolder.get(holder.itemView, R.id.tv_commenter_name);
|
||||
tv_commenter_name.setText(commentBean.getNickname());
|
||||
|
||||
TextView tv_past_time = CommViewHolder.get(holder.itemView, R.id.tv_past_time);
|
||||
tv_past_time.setText(TimeConvert.getTimeElapse(commentBean.getCommentTime()));
|
||||
|
||||
TextView tv_comment_content = CommViewHolder.get(holder.itemView, R.id.tv_comment_content);
|
||||
tv_comment_content.setText(commentBean.getCommentContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (commentListModel == null) {
|
||||
return 0;
|
||||
}
|
||||
List<CommentListModel.CommentBean> commentList = commentListModel.getCommentList();
|
||||
return commentList == null ? 0 : commentList.size();
|
||||
}
|
||||
|
||||
public void updateData(CommentListModel commentListModel) {
|
||||
this.commentListModel = commentListModel;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
@ -1,5 +1,17 @@
|
||||
package com.yuxihan.sdu.ui.baby;
|
||||
|
||||
public class AddBabySuccessEvent {
|
||||
private boolean isNeedRefresh;
|
||||
|
||||
public AddBabySuccessEvent(boolean isNeedRefresh) {
|
||||
this.isNeedRefresh = isNeedRefresh;
|
||||
}
|
||||
|
||||
public boolean isNeedRefresh() {
|
||||
return isNeedRefresh;
|
||||
}
|
||||
|
||||
public void setNeedRefresh(boolean needRefresh) {
|
||||
isNeedRefresh = needRefresh;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class AddBabyViewModel extends ViewModel {
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "宝宝信息添加成功!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
EventBus.getDefault().post(new AddBabySuccessEvent());
|
||||
EventBus.getDefault().post(new AddBabySuccessEvent(true));
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), response.body().getErrMsg(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
@ -83,7 +83,7 @@ public class AddBabyViewModel extends ViewModel {
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "宝宝信息编辑成功!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
EventBus.getDefault().post(new AddBabySuccessEvent());
|
||||
EventBus.getDefault().post(new AddBabySuccessEvent(true));
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), response.body().getErrMsg(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
@ -73,7 +73,7 @@ public class BabyListActivity extends BaseActivity implements View.OnClickListen
|
||||
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(RefreshListEvent event) {
|
||||
public void onMessageEvent(AddBabySuccessEvent event) {
|
||||
babyListViewModel.getBabyList();
|
||||
}
|
||||
|
||||
@ -84,6 +84,15 @@ public class BabyListActivity extends BaseActivity implements View.OnClickListen
|
||||
babyListViewModel.deleteBaby(addBabyParams);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(EditBabyEvent event) {
|
||||
Intent intent = new Intent(this, AddBabyActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("key", event.getBabyBean());
|
||||
intent.putExtras(bundle);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
19
app/src/main/java/com/yuxihan/sdu/ui/baby/EditBabyEvent.java
Normal file
19
app/src/main/java/com/yuxihan/sdu/ui/baby/EditBabyEvent.java
Normal file
@ -0,0 +1,19 @@
|
||||
package com.yuxihan.sdu.ui.baby;
|
||||
|
||||
import com.yuxihan.sdu.ui.baby.model.BabyInfoModel;
|
||||
|
||||
public class EditBabyEvent {
|
||||
BabyInfoModel.BabyBean babyBean;
|
||||
|
||||
public EditBabyEvent(BabyInfoModel.BabyBean babyBean) {
|
||||
this.babyBean = babyBean;
|
||||
}
|
||||
|
||||
public BabyInfoModel.BabyBean getBabyBean() {
|
||||
return babyBean;
|
||||
}
|
||||
|
||||
public void setBabyBean(BabyInfoModel.BabyBean babyBean) {
|
||||
this.babyBean = babyBean;
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.yuxihan.sdu.ui.baby.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -15,8 +13,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.util.CommViewHolder;
|
||||
import com.yuxihan.sdu.ui.baby.AddBabyActivity;
|
||||
import com.yuxihan.sdu.ui.baby.DeleteBabyEvent;
|
||||
import com.yuxihan.sdu.ui.baby.EditBabyEvent;
|
||||
import com.yuxihan.sdu.ui.baby.model.BabyInfoModel;
|
||||
import com.yuxihan.sdu.ui.home.adapter.HomeListAdapter;
|
||||
|
||||
@ -58,11 +56,7 @@ public class BabyListAdapter extends RecyclerView.Adapter {
|
||||
CommViewHolder.get(holder.itemView, R.id.rl_edit_baby).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(mContext, AddBabyActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("key", curBaby);
|
||||
intent.putExtras(bundle);
|
||||
mContext.startActivity(intent);
|
||||
EventBus.getDefault().post(new EditBabyEvent(curBaby));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,201 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.blankj.utilcode.util.TimeUtils;
|
||||
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.BaseActivity;
|
||||
import com.yuxihan.sdu.comm.util.AccountUtils;
|
||||
import com.yuxihan.sdu.comm.widget.ActionSheetDialog;
|
||||
import com.yuxihan.sdu.ui.baby.BabyListViewModel;
|
||||
import com.yuxihan.sdu.ui.baby.model.BabyInfoModel;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class AddNewRecordActivity extends BaseActivity implements View.OnClickListener,
|
||||
DatePickerDialog.OnDateSetListener {
|
||||
|
||||
private AddNewRecordModel addNewRecordModel;
|
||||
private BabyListViewModel babyListViewModel;
|
||||
private BabyInfoModel babyInfoModel = null;
|
||||
private TextView tv_post_to;
|
||||
private EditText tv_height;
|
||||
private EditText tv_head;
|
||||
private EditText tv_weight;
|
||||
private TextView tv_record_time;
|
||||
private TextView tv_baby_selected;
|
||||
private RecordParams recordParams = new RecordParams();
|
||||
private String selectedDate;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_add_new_record);
|
||||
addNewRecordModel = new ViewModelProvider(this).get(AddNewRecordModel.class);
|
||||
babyListViewModel = new ViewModelProvider(this).get(BabyListViewModel.class);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
tv_post_to = findViewById(R.id.tv_post_to);
|
||||
findViewById(R.id.btn_submit).setOnClickListener(this);
|
||||
findViewById(R.id.iv_back).setOnClickListener(this);
|
||||
findViewById(R.id.rl_select_relate_baby).setOnClickListener(this);
|
||||
findViewById(R.id.rl_record_time).setOnClickListener(this);
|
||||
tv_height = findViewById(R.id.tv_height);
|
||||
tv_head = findViewById(R.id.tv_head);
|
||||
tv_weight = findViewById(R.id.tv_weight);
|
||||
tv_record_time = findViewById(R.id.tv_record_time);
|
||||
selectedDate = TimeUtils.millis2String(new Date().getTime(), "yyyy-MM-dd");
|
||||
tv_record_time.setText(selectedDate);
|
||||
recordParams.setBabyMonth(selectedDate);
|
||||
tv_post_to.setText(AccountUtils.getCurFamilyName());
|
||||
tv_baby_selected = findViewById(R.id.tv_baby_selected);
|
||||
babyListViewModel.getBabyInfoModel().observe(this, new Observer<BabyInfoModel>() {
|
||||
@Override
|
||||
public void onChanged(BabyInfoModel babyInfoModelRet) {
|
||||
babyInfoModel = babyInfoModelRet;
|
||||
List<BabyInfoModel.BabyBean> babyList = babyInfoModel.getBabyList();
|
||||
if (null != babyList && babyList.size() > 0) {
|
||||
recordParams.setBabyId(babyList.get(0).getBabyId() + "");
|
||||
tv_baby_selected.setText(babyList.get(0).getBabyName());
|
||||
tv_baby_selected.setTag(babyList.get(0));
|
||||
} else {
|
||||
recordParams.setBabyId("");
|
||||
tv_baby_selected.setText("请添加宝宝信息");
|
||||
tv_baby_selected.setTag(null);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
babyListViewModel.getBabyList();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.rl_record_time:
|
||||
Calendar now = Calendar.getInstance();
|
||||
DatePickerDialog dpd = DatePickerDialog.newInstance(
|
||||
AddNewRecordActivity.this,
|
||||
now.get(Calendar.YEAR),
|
||||
now.get(Calendar.MONTH),
|
||||
now.get(Calendar.DAY_OF_MONTH)
|
||||
);
|
||||
dpd.show(getSupportFragmentManager(), "Datepickerdialog");
|
||||
break;
|
||||
case R.id.rl_select_relate_baby:
|
||||
selectBaby(babyInfoModel);
|
||||
break;
|
||||
case R.id.btn_submit:
|
||||
if (check()) {
|
||||
addNewRecordModel.saveBabyGroup(recordParams);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean check() {
|
||||
recordParams.setBabyMonth(tv_record_time.getText().toString());
|
||||
try {
|
||||
recordParams.setBabyHeadWidth(Double.parseDouble(tv_head.getText().toString()));
|
||||
recordParams.setBabyHeight(Double.parseDouble(tv_height.getText().toString()));
|
||||
recordParams.setBabyWeight(Double.parseDouble(tv_weight.getText().toString()));
|
||||
} catch (NumberFormatException e) {
|
||||
Log.i("NumberFormatException", "NumberFormatException");
|
||||
Toast.makeText(this, "数据输入有误~", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
if (!recordParams.isValid()) {
|
||||
Toast.makeText(this, "数据输入有误~", Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
if (null == tv_baby_selected.getTag()) {
|
||||
Toast.makeText(this, "请先 添加/选择 宝宝~", Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 选择宝宝
|
||||
*/
|
||||
private void selectBaby(BabyInfoModel babyInfoModel) {
|
||||
List<BabyInfoModel.BabyBean> babyList = babyInfoModel.getBabyList();
|
||||
String[] fileFrom = new String[babyList.size()];
|
||||
for (int i = 0; i < babyList.size(); i++) {
|
||||
fileFrom[i] = babyList.get(i).getBabyName();
|
||||
}
|
||||
ActionSheetDialog actionSheetDialog = new ActionSheetDialog(
|
||||
this).builder().setCancelable(false)
|
||||
.setCanceledOnTouchOutside(true);
|
||||
for (String s : fileFrom) {
|
||||
actionSheetDialog.addSheetItem(s,
|
||||
ActionSheetDialog.SheetItemColor.Blue,
|
||||
new ActionSheetDialog.OnSheetItemClickListener() {
|
||||
@Override
|
||||
public void onClick(int which) {
|
||||
BabyInfoModel.BabyBean babyBean = babyList.get(which - 1);
|
||||
tv_baby_selected.setText(babyBean.getBabyName());
|
||||
tv_baby_selected.setTag(babyBean);
|
||||
recordParams.setBabyId(babyBean.getBabyId() + "");
|
||||
}
|
||||
});
|
||||
}
|
||||
actionSheetDialog.show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
|
||||
String date = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
|
||||
long l = TimeUtils.string2Millis(date, "yyyy-MM-dd");
|
||||
selectedDate = TimeUtils.millis2String(l, "yyyy-MM-dd");
|
||||
tv_record_time.setText(selectedDate);
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(AddRecordSuccessEvent event) {
|
||||
setResult(0);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.yuxihan.sdu.comm.Const;
|
||||
import com.yuxihan.sdu.comm.SDUApp;
|
||||
import com.yuxihan.sdu.data.Result;
|
||||
import com.yuxihan.sdu.data.UpdateService;
|
||||
import com.yuxihan.sdu.ui.baby.model.BabyInfoModel;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class AddNewRecordModel extends ViewModel {
|
||||
private MutableLiveData<BabyInfoModel> babyInfoModel = new MutableLiveData<>();
|
||||
|
||||
public MutableLiveData<BabyInfoModel> getBabyInfoModel() {
|
||||
return babyInfoModel;
|
||||
}
|
||||
|
||||
public void saveBabyGroup(RecordParams recordParams) {
|
||||
|
||||
UpdateService updateService = SDUApp.getRetrofit().create(UpdateService.class);
|
||||
Call<Result> call = updateService.saveBabyGroup(recordParams);
|
||||
call.enqueue(new Callback<Result>() {
|
||||
@Override
|
||||
public void onResponse(Call<Result> call, Response<Result> response) {
|
||||
//请求成功,返回是一个封装为DataBean的响应
|
||||
if (null == response.body()) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "Internal Server Error",
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "添加成功",
|
||||
Toast.LENGTH_LONG).show();
|
||||
EventBus.getDefault().post(new AddRecordSuccessEvent());
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), response.body().getErrMsg(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Result> call, Throwable t) {
|
||||
//请求失败
|
||||
Toast.makeText(SDUApp.getAppContext(), "服务器开小差了!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
public class AddRecordSuccessEvent {
|
||||
}
|
@ -1,39 +1,112 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
|
||||
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.BaseFragment;
|
||||
import com.yuxihan.sdu.ui.account.home.RefreshHomeListEvent;
|
||||
import com.yuxihan.sdu.ui.grow.adapter.GrowRecordListAdapter;
|
||||
import com.yuxihan.sdu.ui.grow.model.BabyGrowModel;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
public class GrowFragment extends BaseFragment {
|
||||
public class GrowFragment extends BaseFragment implements View.OnClickListener {
|
||||
|
||||
private GrowViewModel growViewModel;
|
||||
private BabyGrowModel babyGrowModel;
|
||||
private View tv_no_data;
|
||||
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
ViewGroup container, Bundle savedInstanceState) {
|
||||
growViewModel =
|
||||
new ViewModelProvider(this).get(GrowViewModel.class);
|
||||
View root = inflater.inflate(R.layout.fragment_grow, container, false);
|
||||
|
||||
initView(root);
|
||||
return root;
|
||||
}
|
||||
|
||||
private void initView(View root) {
|
||||
root.findViewById(R.id.add_new_post).setOnClickListener(this);
|
||||
tv_no_data = root.findViewById(R.id.tv_no_data);
|
||||
RecyclerView growListRV = root.findViewById(R.id.rv_grow_list);
|
||||
growListRV.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
growListRV.setHasFixedSize(true);
|
||||
GrowRecordListAdapter homeListAdapter = new GrowRecordListAdapter(null);
|
||||
growListRV.setAdapter(homeListAdapter);
|
||||
growViewModel.getBabyGrowModel().observe(getViewLifecycleOwner(),
|
||||
new Observer<BabyGrowModel>() {
|
||||
@Override
|
||||
public void onChanged(BabyGrowModel postModel) {
|
||||
if (postModel == null
|
||||
|| postModel.getBabyGroupList() == null
|
||||
|| postModel.getBabyGroupList().size() == 0) {
|
||||
tv_no_data.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tv_no_data.setVisibility(View.GONE);
|
||||
}
|
||||
homeListAdapter.updateData(postModel);
|
||||
}
|
||||
});
|
||||
growViewModel.getBabyGroupList("");
|
||||
TwinklingRefreshLayout refreshLayout = root.findViewById(R.id.refreshLayout);
|
||||
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
|
||||
@Override
|
||||
public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshLayout.finishRefreshing();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onMessageEvent( event) {
|
||||
//
|
||||
// }
|
||||
@Override
|
||||
public void onLoadMore(final TwinklingRefreshLayout refreshLayout) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
refreshLayout.finishLoadmore();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.add_new_post:
|
||||
crateNewRecord();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void crateNewRecord() {
|
||||
startActivityForResult(new Intent(getContext(), AddNewRecordActivity.class), 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
//TODO 刷新
|
||||
}
|
||||
|
||||
/* @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent( event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
@ -45,5 +118,5 @@ public class GrowFragment extends BaseFragment {
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
import com.yuxihan.sdu.comm.network.BaseRequestParams;
|
||||
|
||||
public class GrowListParams extends BaseRequestParams {
|
||||
public GrowListParams(String babyId) {
|
||||
this.babyId = babyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* babyId : 13
|
||||
*/
|
||||
|
||||
private String babyId;
|
||||
|
||||
public String getBabyId() {
|
||||
return babyId;
|
||||
}
|
||||
|
||||
public void setBabyId(String babyId) {
|
||||
this.babyId = babyId;
|
||||
}
|
||||
}
|
@ -1,19 +1,59 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
import androidx.lifecycle.LiveData;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.yuxihan.sdu.comm.Const;
|
||||
import com.yuxihan.sdu.comm.SDUApp;
|
||||
import com.yuxihan.sdu.data.Result;
|
||||
import com.yuxihan.sdu.data.UpdateService;
|
||||
import com.yuxihan.sdu.ui.grow.model.BabyGrowModel;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class GrowViewModel extends ViewModel {
|
||||
|
||||
private MutableLiveData<String> mText;
|
||||
private MutableLiveData<BabyGrowModel> babyGrowModel = new MutableLiveData<>();
|
||||
|
||||
public GrowViewModel() {
|
||||
mText = new MutableLiveData<>();
|
||||
mText.setValue("This is dashboard fragment");
|
||||
public MutableLiveData<BabyGrowModel> getBabyGrowModel() {
|
||||
return babyGrowModel;
|
||||
}
|
||||
|
||||
public LiveData<String> getText() {
|
||||
return mText;
|
||||
public void getBabyGroupList(String babyId) {
|
||||
|
||||
UpdateService updateService = SDUApp.getRetrofit().create(UpdateService.class);
|
||||
Call<Result<BabyGrowModel>> call =
|
||||
updateService.getBabyGroupList(new GrowListParams(babyId));
|
||||
call.enqueue(new Callback<Result<BabyGrowModel>>() {
|
||||
@Override
|
||||
public void onResponse(Call<Result<BabyGrowModel>> call,
|
||||
Response<Result<BabyGrowModel>> response) {
|
||||
//请求成功,返回是一个封装为DataBean的响应
|
||||
if (null == response.body()) {
|
||||
Toast.makeText(SDUApp.getAppContext(), "Internal Server Error",
|
||||
Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
babyGrowModel.setValue(response.body().getResult());
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), response.body().getErrMsg(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Result<BabyGrowModel>> call, Throwable t) {
|
||||
//请求失败
|
||||
Toast.makeText(SDUApp.getAppContext(), "服务器开小差了!",
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
66
app/src/main/java/com/yuxihan/sdu/ui/grow/RecordParams.java
Normal file
66
app/src/main/java/com/yuxihan/sdu/ui/grow/RecordParams.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.yuxihan.sdu.ui.grow;
|
||||
|
||||
import com.yuxihan.sdu.comm.network.BaseRequestParams;
|
||||
|
||||
public class RecordParams extends BaseRequestParams {
|
||||
|
||||
/**
|
||||
* babyId : 13
|
||||
* babyHeadWidth : 40
|
||||
* babyWeight : 3
|
||||
* babyHeight : 49
|
||||
* babyMonth : 2019-09-14
|
||||
*/
|
||||
|
||||
private String babyId;
|
||||
private double babyHeadWidth;
|
||||
private double babyWeight;
|
||||
private double babyHeight;
|
||||
private String babyMonth;
|
||||
|
||||
public String getBabyId() {
|
||||
return babyId;
|
||||
}
|
||||
|
||||
public void setBabyId(String babyId) {
|
||||
this.babyId = babyId;
|
||||
}
|
||||
|
||||
public double getBabyHeadWidth() {
|
||||
return babyHeadWidth;
|
||||
}
|
||||
|
||||
public void setBabyHeadWidth(double babyHeadWidth) {
|
||||
this.babyHeadWidth = babyHeadWidth;
|
||||
}
|
||||
|
||||
public double getBabyWeight() {
|
||||
return babyWeight;
|
||||
}
|
||||
|
||||
public void setBabyWeight(double babyWeight) {
|
||||
this.babyWeight = babyWeight;
|
||||
}
|
||||
|
||||
public double getBabyHeight() {
|
||||
return babyHeight;
|
||||
}
|
||||
|
||||
public void setBabyHeight(double babyHeight) {
|
||||
this.babyHeight = babyHeight;
|
||||
}
|
||||
|
||||
public String getBabyMonth() {
|
||||
return babyMonth;
|
||||
}
|
||||
|
||||
public void setBabyMonth(String babyMonth) {
|
||||
this.babyMonth = babyMonth;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return babyHeadWidth != 0
|
||||
&& babyWeight != 0
|
||||
&& babyHeight != 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.yuxihan.sdu.ui.grow.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.util.CommViewHolder;
|
||||
import com.yuxihan.sdu.ui.grow.model.BabyGrowModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GrowRecordListAdapter extends RecyclerView.Adapter {
|
||||
|
||||
private BabyGrowModel postModel;
|
||||
private Context mContext;
|
||||
|
||||
public GrowRecordListAdapter(BabyGrowModel postModel) {
|
||||
this.postModel = postModel;
|
||||
}
|
||||
|
||||
public static class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public ViewGroup v;
|
||||
|
||||
public MyViewHolder(ViewGroup v) {
|
||||
super(v);
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
mContext = parent.getContext();
|
||||
ViewGroup v = (ViewGroup) LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_grow_record_list, parent, false);
|
||||
return new MyViewHolder(v);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
BabyGrowModel.BabyGrowBean babyGrowBean = postModel.getBabyGroupList().get(position);
|
||||
ImageView civ_baby_head = CommViewHolder.get(holder.itemView, R.id.civ_baby_head);
|
||||
Glide.with(mContext).load(babyGrowBean.getBabyHead()).placeholder(R.drawable.ic_baby_head).into(civ_baby_head);
|
||||
TextView tv_baby_name = CommViewHolder.get(holder.itemView, R.id.tv_baby_name);
|
||||
tv_baby_name.setText(babyGrowBean.getBabyName());
|
||||
TextView tv_post_time = CommViewHolder.get(holder.itemView, R.id.tv_post_time);
|
||||
tv_post_time.setText(babyGrowBean.getBabyMonth());
|
||||
TextView tv_height = CommViewHolder.get(holder.itemView, R.id.tv_height);
|
||||
tv_height.setText(mContext.getString(R.string.x_cm,
|
||||
doubleTrans(babyGrowBean.getBabyHeight())));
|
||||
TextView tv_head = CommViewHolder.get(holder.itemView, R.id.tv_head);
|
||||
tv_head.setText(mContext.getString(R.string.x_cm,
|
||||
doubleTrans(babyGrowBean.getBabyHeadWidth())));
|
||||
TextView tv_weight = CommViewHolder.get(holder.itemView, R.id.tv_weight);
|
||||
tv_weight.setText(mContext.getString(R.string.x_kg,
|
||||
doubleTrans(babyGrowBean.getBabyWeight())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (postModel == null) {
|
||||
return 0;
|
||||
}
|
||||
List<BabyGrowModel.BabyGrowBean> postDetailList = postModel.getBabyGroupList();
|
||||
return postDetailList == null ? 0 : postDetailList.size();
|
||||
}
|
||||
|
||||
public void updateData(BabyGrowModel postModel) {
|
||||
this.postModel = postModel;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* double为整数时不带.0
|
||||
*/
|
||||
public static String doubleTrans(double d) {
|
||||
if (Math.round(d) - d == 0) {
|
||||
return String.valueOf((long) d);
|
||||
}
|
||||
return String.valueOf(d);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.yuxihan.sdu.ui.grow.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BabyGrowModel {
|
||||
|
||||
private List<BabyGrowBean> babyGroupList;
|
||||
|
||||
public List<BabyGrowBean> getBabyGroupList() {
|
||||
return babyGroupList;
|
||||
}
|
||||
|
||||
public void setBabyGroupList(List<BabyGrowBean> babyGroupList) {
|
||||
this.babyGroupList = babyGroupList;
|
||||
}
|
||||
|
||||
public static class BabyGrowBean {
|
||||
/**
|
||||
* babyId : 13
|
||||
* babyName : 狗胖
|
||||
* babyHead : 45612121545
|
||||
* babyHeight : 49
|
||||
* babyWeight : 3
|
||||
* babyHeadWidth : 40
|
||||
* babyMonth : 2019-09-14
|
||||
*/
|
||||
|
||||
private int babyId;
|
||||
private String babyName;
|
||||
private String babyHead;
|
||||
private double babyHeight;
|
||||
private double babyWeight;
|
||||
private double babyHeadWidth;
|
||||
private String babyMonth;
|
||||
|
||||
public int getBabyId() {
|
||||
return babyId;
|
||||
}
|
||||
|
||||
public void setBabyId(int babyId) {
|
||||
this.babyId = babyId;
|
||||
}
|
||||
|
||||
public String getBabyName() {
|
||||
return babyName;
|
||||
}
|
||||
|
||||
public void setBabyName(String babyName) {
|
||||
this.babyName = babyName;
|
||||
}
|
||||
|
||||
public String getBabyHead() {
|
||||
return babyHead;
|
||||
}
|
||||
|
||||
public void setBabyHead(String babyHead) {
|
||||
this.babyHead = babyHead;
|
||||
}
|
||||
|
||||
public double getBabyHeight() {
|
||||
return babyHeight;
|
||||
}
|
||||
|
||||
public void setBabyHeight(double babyHeight) {
|
||||
this.babyHeight = babyHeight;
|
||||
}
|
||||
|
||||
public double getBabyWeight() {
|
||||
return babyWeight;
|
||||
}
|
||||
|
||||
public void setBabyWeight(double babyWeight) {
|
||||
this.babyWeight = babyWeight;
|
||||
}
|
||||
|
||||
public double getBabyHeadWidth() {
|
||||
return babyHeadWidth;
|
||||
}
|
||||
|
||||
public void setBabyHeadWidth(int babyHeadWidth) {
|
||||
this.babyHeadWidth = babyHeadWidth;
|
||||
}
|
||||
|
||||
public String getBabyMonth() {
|
||||
return babyMonth;
|
||||
}
|
||||
|
||||
public void setBabyMonth(String babyMonth) {
|
||||
this.babyMonth = babyMonth;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter;
|
||||
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout;
|
||||
import com.yuxihan.sdu.R;
|
||||
import com.yuxihan.sdu.comm.BaseFragment;
|
||||
import com.yuxihan.sdu.comm.Const;
|
||||
import com.yuxihan.sdu.comm.util.AccountUtils;
|
||||
import com.yuxihan.sdu.ui.home.adapter.HomeListAdapter;
|
||||
|
||||
@ -113,7 +114,7 @@ public class HomeFragment extends BaseFragment implements View.OnClickListener {
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onMessageEvent(RefreshHomeFragment event) {
|
||||
homeViewModel.getPostDetailList();
|
||||
//homeViewModel.getPostDetailList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -127,4 +128,15 @@ public class HomeFragment extends BaseFragment implements View.OnClickListener {
|
||||
super.onStop();
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (Const.NEED_RELOAD_HOME) {
|
||||
homeViewModel.getPostDetailList();
|
||||
Const.NEED_RELOAD_HOME = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,6 @@ import com.yuxihan.sdu.comm.network.BaseRequestParams;
|
||||
import com.yuxihan.sdu.data.Result;
|
||||
import com.yuxihan.sdu.data.UpdateService;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import retrofit2.Call;
|
||||
import retrofit2.Callback;
|
||||
import retrofit2.Response;
|
||||
@ -41,7 +39,6 @@ public class HomeViewModel extends ViewModel {
|
||||
}
|
||||
if (Const.ERROR_CODE_NORMAL.equals(response.body().getErrCode())) {
|
||||
postListLD.setValue(response.body().getResult());
|
||||
EventBus.getDefault().post(new RefreshHomeFragment());
|
||||
} else {
|
||||
Toast.makeText(SDUApp.getAppContext(), response.body().getErrMsg(),
|
||||
Toast.LENGTH_LONG).show();
|
||||
|
@ -151,7 +151,7 @@ public class NewPostActivity extends BaseActivity implements View.OnClickListene
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择性别
|
||||
* 选择宝宝
|
||||
*/
|
||||
private void selectBaby(BabyInfoModel babyInfoModel) {
|
||||
List<BabyInfoModel.BabyBean> babyList = babyInfoModel.getBabyList();
|
||||
@ -197,7 +197,6 @@ public class NewPostActivity extends BaseActivity implements View.OnClickListene
|
||||
postRequestParams.setPostPicUrls(listToString(mAdapterData));
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private String listToString(List<LocalMedia> mAdapterData) {
|
||||
|
@ -82,6 +82,11 @@ public class HomeListAdapter extends RecyclerView.Adapter {
|
||||
TextView tvLikeCount = CommViewHolder.get(holder.itemView, R.id.tv_like_count);
|
||||
tvLikeCount.setText(curPost.getPostLikeCount() + "");
|
||||
|
||||
ImageView baby_head = CommViewHolder.get(holder.itemView, R.id.baby_head);
|
||||
Glide.with(mContext).load(curPost.getBabyHead()).placeholder(R.drawable.ic_baby_head).into(baby_head);
|
||||
TextView tv_baby_name = CommViewHolder.get(holder.itemView, R.id.tv_baby_name);
|
||||
tv_baby_name.setText(curPost.getBabyName());
|
||||
|
||||
ShineButton shineButton = CommViewHolder.get(holder.itemView, R.id.bt_like);
|
||||
shineButton.setChecked(curPost.getIsLikedByCurAccount() == 1);
|
||||
shineButton.setOnCheckStateChangeListener(new ShineButton.OnCheckedChangeListener() {
|
||||
|
14
app/src/main/res/anim/anim_enter_from_bottom.xml
Normal file
14
app/src/main/res/anim/anim_enter_from_bottom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:fromYDelta="100%"
|
||||
android:toYDelta="0"
|
||||
android:fillAfter="false"
|
||||
android:duration="300" />
|
||||
<alpha
|
||||
android:fromAlpha="0.0"
|
||||
android:toAlpha="1.0"
|
||||
android:duration="300"
|
||||
android:fillAfter="true" />
|
||||
</set>
|
14
app/src/main/res/anim/anim_exit_from_bottom.xml
Normal file
14
app/src/main/res/anim/anim_exit_from_bottom.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate
|
||||
android:duration="300"
|
||||
android:fillAfter="false"
|
||||
android:fromYDelta="0"
|
||||
android:toYDelta="100%" />
|
||||
<alpha
|
||||
android:duration="300"
|
||||
android:fillAfter="true"
|
||||
android:fromAlpha="1.0"
|
||||
android:toAlpha="0.0" />
|
||||
</set>
|
9
app/src/main/res/drawable/btn_send_normal.xml
Normal file
9
app/src/main/res/drawable/btn_send_normal.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="4dp" />
|
||||
|
||||
<solid android:color="#FFD2D2D2" />
|
||||
|
||||
</shape>
|
6
app/src/main/res/drawable/btn_send_pressed.xml
Normal file
6
app/src/main/res/drawable/btn_send_pressed.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners android:radius="4dp" />
|
||||
<solid android:color="#F9780D" />
|
||||
</shape>
|
317
app/src/main/res/layout/activity_add_new_record.xml
Normal file
317
app/src/main/res/layout/activity_add_new_record.xml
Normal file
@ -0,0 +1,317 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.grow.AddNewRecordActivity">
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_account_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="75dp"
|
||||
android:background="@color/white_bg"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="25dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:padding="14dp"
|
||||
android:src="@drawable/ic_arrow_left" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:paddingTop="12dp"
|
||||
android:text="@string/add_grow_record"
|
||||
android:textColor="@color/text_black"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="53dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_margin="14dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:background="@android:color/white"
|
||||
app:cardCornerRadius="22dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_submit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_submit_btn"
|
||||
android:enabled="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/save"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="15sp" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
</RelativeLayout>
|
||||
|
||||
<include layout="@layout/view_divider" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_height"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_height_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/height"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tv_height"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="45dp"
|
||||
android:layout_toEndOf="@+id/tv_height_title"
|
||||
android:background="@null"
|
||||
android:hint="@string/input_height"
|
||||
android:inputType="number"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="42dp"
|
||||
android:text="@string/cm"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_weight"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_weight_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/weight"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tv_weight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="45dp"
|
||||
android:layout_toEndOf="@+id/tv_weight_title"
|
||||
android:background="@null"
|
||||
android:hint="@string/input_weight"
|
||||
android:inputType="number"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="42dp"
|
||||
android:text="@string/kg"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_head"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_head_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/head"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/tv_head"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="45dp"
|
||||
android:layout_toEndOf="@+id/tv_head_title"
|
||||
android:background="@null"
|
||||
android:hint="@string/input_head"
|
||||
android:inputType="number"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="42dp"
|
||||
android:text="@string/cm"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_post_to"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/post_to"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_post_to"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@+id/ic_next"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
tools:text="家庭名称" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ic_next"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:src="@drawable/ic_arrow_right" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_select_relate_baby"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
tools:ignore="RtlSymmetry">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/select_relate_baby"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_baby_selected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="0dp"
|
||||
android:layout_toStartOf="@+id/ic_next_baby"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/loading"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ic_next_baby"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:src="@drawable/ic_arrow_right"
|
||||
android:visibility="visible" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_record_time"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/date"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_record_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toStartOf="@+id/ic_next_time"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="12sp"
|
||||
tools:text="2020-02-02" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ic_next_time"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:src="@drawable/ic_arrow_right" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
</LinearLayout>
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
@ -78,9 +79,9 @@
|
||||
android:background="@null"
|
||||
android:hint="请输入手机号"
|
||||
android:inputType="number"
|
||||
android:text="13262911437"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:text="13262911437" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
@ -119,9 +120,9 @@
|
||||
android:background="@null"
|
||||
android:hint="请输入密码"
|
||||
android:inputType="textPassword"
|
||||
android:text="123456"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="14sp"
|
||||
tools:text="123456" />
|
||||
</LinearLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
@ -119,16 +119,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_contentView"
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1500dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@color/white"
|
||||
android:gravity="top|center_horizontal"
|
||||
android:paddingTop="160dp"
|
||||
android:text="我是评论1111\n\n\n\n\n\n\n\n\n我是评论2222\n\n\n\n\n\n\n\n\n我是评论3333\n\n\n\n\n\n\n\n\n我是评论4444\n\n\n\n\n\n\n\n\n我是评论5555\n\n\n\n\n\n\n\n\n"
|
||||
android:textSize="14sp" />
|
||||
android:layout_height="wrap_content"
|
||||
android:overScrollMode="never" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.yuxihan.sdu.comm.widget.MyScrollView>
|
||||
|
104
app/src/main/res/layout/dialog_input_text_msg.xml
Normal file
104
app/src/main/res/layout/dialog_input_text_msg.xml
Normal file
@ -0,0 +1,104 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/rl_outside_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/rl_inputdlg_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_smile"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_input_message"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/divider_gray"
|
||||
android:gravity="top"
|
||||
android:hint="想说点什么"
|
||||
android:imeOptions="flagNoExtractUi"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:maxLength="2000"
|
||||
android:maxLines="6"
|
||||
android:minHeight="104dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingRight="15dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:scrollbars="vertical"
|
||||
android:textColor="#FF333333"
|
||||
android:textColorHint="@color/text_bottom_comment"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="InvalidImeActionId" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_test"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="0/200"
|
||||
android:textColor="@color/text_bottom_comment" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/confirm_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:paddingRight="10dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_tv"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="right"
|
||||
android:orientation="horizontal"
|
||||
android:paddingRight="15dp">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/confrim_btn"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="28dp"
|
||||
android:background="@drawable/btn_send_normal"
|
||||
android:gravity="center"
|
||||
android:text="发送"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</RelativeLayout>
|
@ -4,6 +4,7 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".ui.grow.GrowFragment">
|
||||
|
||||
|
||||
@ -18,17 +19,17 @@
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/add_new_post_pic"
|
||||
android:visibility="gone"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:src="@drawable/ic_cam" />
|
||||
android:src="@drawable/ic_cam"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/tv_home_title"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:text="@string/grow_record"
|
||||
android:textColor="@color/text_black"
|
||||
android:textSize="20sp" />
|
||||
@ -43,21 +44,35 @@
|
||||
android:src="@drawable/ic_add" />
|
||||
</RelativeLayout>
|
||||
|
||||
<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
|
||||
android:id="@+id/refreshLayout"
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintHeight_percent="0.5"
|
||||
android:background="@color/divider_gray"
|
||||
app:layout_constraintTop_toBottomOf="@+id/rl_grow_title">
|
||||
<!-- app:tr_head_height="100dp"
|
||||
app:tr_wave_height="180dp"-->
|
||||
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_grow_list"
|
||||
|
||||
<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
|
||||
android:id="@+id/refreshLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never" />
|
||||
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
|
||||
app:layout_constraintHeight_percent="0.5">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_grow_list"
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:overScrollMode="never" />
|
||||
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_no_data"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:gravity="center"
|
||||
android:text="@string/no_data"
|
||||
android:textSize="20sp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
53
app/src/main/res/layout/item_comment_list.xml
Normal file
53
app/src/main/res/layout/item_comment_list.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="74dp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="10dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_commenter_head"
|
||||
android:layout_width="38dp"
|
||||
android:layout_height="38dp"
|
||||
android:layout_marginStart="13dp"
|
||||
android:background="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_commenter_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_toEndOf="@+id/iv_commenter_head"
|
||||
android:textSize="13sp"
|
||||
tools:text="评论者" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_comment_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_toEndOf="@+id/iv_commenter_head"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="13sp"
|
||||
tools:text="评论内容" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_past_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="12dp"
|
||||
tools:text="过去时间" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/divider_gray"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingEnd="12dp" />
|
||||
</RelativeLayout>
|
141
app/src/main/res/layout/item_grow_record_list.xml
Normal file
141
app/src/main/res/layout/item_grow_record_list.xml
Normal file
@ -0,0 +1,141 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="163dp">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="12dp"
|
||||
android:background="@color/black"
|
||||
app:cardCornerRadius="12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
android:padding="11dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<de.hdodenhof.circleimageview.CircleImageView
|
||||
android:id="@+id/civ_baby_head"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:src="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_baby_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="14sp"
|
||||
tools:text="雨曦" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_post_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:textSize="12sp"
|
||||
tools:text="2020-06-06" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="@string/too_big"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="@color/divider_gray" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="11dp"
|
||||
android:weightSum="3">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_height"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="15sp"
|
||||
tools:text="125cm" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/height"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_weight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="15sp"
|
||||
tools:text="55kg" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/weight"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_head"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/text_red"
|
||||
android:textSize="15sp"
|
||||
tools:text="155cm" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/head"
|
||||
android:textSize="13sp" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
</LinearLayout>
|
@ -34,4 +34,6 @@
|
||||
<color name="app_color_9b">#9b9b9b</color>
|
||||
<color name="app_color_e0ff6100">#E0FF6100</color>
|
||||
<color name="app_color_red">#FF0000</color>
|
||||
<color name="dot_hong">#E73111</color>
|
||||
<color name="text_bottom_comment">#9B9B9B</color>
|
||||
</resources>
|
||||
|
@ -57,4 +57,17 @@
|
||||
<string name="grow_record">成长记录</string>
|
||||
<string name="exit">退出</string>
|
||||
<string name="no_data">暂时没有数据\n点击右上角去记录吧~</string>
|
||||
<string name="add_grow_record">增加成长记录</string>
|
||||
<string name="cm">cm</string>
|
||||
<string name="date">日期</string>
|
||||
<string name="input_height">请输入身高</string>
|
||||
<string name="height">身高</string>
|
||||
<string name="weight">体重</string>
|
||||
<string name="kg">kg</string>
|
||||
<string name="input_weight">请输入体重</string>
|
||||
<string name="head">头围</string>
|
||||
<string name="input_head">请输入头围</string>
|
||||
<string name="too_big">宝宝长的又高又大,头围偏大</string>
|
||||
<string name="x_cm">%1$s cm</string>
|
||||
<string name="x_kg">%1$s kg</string>
|
||||
</resources>
|
||||
|
@ -17,6 +17,29 @@
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
</style>
|
||||
|
||||
<style name="main_menu_animstyle">
|
||||
<item name="android:windowEnterAnimation">@anim/anim_enter_from_bottom</item>
|
||||
<item name="android:windowExitAnimation">@anim/anim_exit_from_bottom</item>
|
||||
</style>
|
||||
|
||||
<!-- 中间弹出框 -->
|
||||
<style name="dialog_center" parent="Theme.AppCompat.Dialog.Alert">
|
||||
<!-- 去黑边 -->
|
||||
<item name="android:windowFrame">@null</item>
|
||||
<item name="android:screenOrientation">portrait</item>
|
||||
<!-- 设置是否可滑动 -->
|
||||
<item name="android:windowIsFloating">true</item>
|
||||
<!-- 背景 -->
|
||||
<!-- 窗口背景 @color/touming的值为:#00000000 , style中不能直接引用16进制,感谢评论区的老铁提醒-->
|
||||
|
||||
<item name="android:windowBackground">@color/app_color_transparent</item>
|
||||
|
||||
<!-- 是否变暗 -->
|
||||
<item name="android:backgroundDimEnabled">true</item>
|
||||
<!-- 点击空白部分activity不消失 -->
|
||||
<item name="android:windowCloseOnTouchOutside">true</item>
|
||||
</style>
|
||||
|
||||
<style name="CustomDialog" parent="android:style/Theme.Dialog">
|
||||
<!--背景颜色及和透明程度-->
|
||||
<item name="android:windowBackground">@android:color/transparent</item>
|
||||
|
Loading…
Reference in New Issue
Block a user