userList;
72 |
73 |
74 | public static FindUserAdapter findUserAdapter;
75 | public static FindArticleAdapter findArticleAdapter;
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nuc/calvin/headline/fragment/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.headline.fragment;
2 |
3 | import android.content.Context;
4 | import android.net.Uri;
5 | import android.os.Bundle;
6 | import android.os.Handler;
7 | import android.support.annotation.NonNull;
8 | import android.support.annotation.Nullable;
9 | import android.support.v4.app.Fragment;
10 | import android.support.v4.app.FragmentActivity;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.TextView;
15 |
16 | import com.facebook.drawee.backends.pipeline.Fresco;
17 |
18 | import butterknife.ButterKnife;
19 |
20 |
21 | public abstract class BaseFragment extends Fragment {
22 | private FragmentActivity fragmentActivity;
23 |
24 | public View getMyView() {
25 | return myView;
26 | }
27 |
28 | public View myView;
29 | //可用来Fragment与Activity之间传送数据
30 | protected OnFragmentInteractionListener mListener;
31 | protected Handler handler;
32 |
33 |
34 | public BaseFragment() {
35 | // Required empty public constructor
36 | }
37 |
38 | @Override
39 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
40 | Bundle savedInstanceState) {
41 | myView = inflater.inflate(getContentView(), container, false);
42 | ButterKnife.bind(this, myView);
43 | fragmentActivity = getSupportActivity();
44 | Fresco.initialize(getContext());
45 | initView(myView);
46 | return myView;
47 | }
48 |
49 | @Override
50 | public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
51 | super.onViewCreated(view, savedInstanceState);
52 | // initView(myView);
53 | /* handler = initHandle();*/
54 | }
55 |
56 |
57 | /* protected abstract Handler initHandle();*/
58 |
59 | /**
60 | * 初始化UI
61 | *
62 | * //@param savedInstanceState
63 | */
64 | protected abstract void initView(View view);
65 |
66 | /**
67 | * @return
68 | */
69 | protected abstract int getContentView();
70 |
71 | public FragmentActivity getSupportActivity() {
72 | return super.getActivity();
73 | }
74 |
75 | public void onButtonPressed(Uri uri) {
76 | if (mListener != null) {
77 | mListener.onFragmentInteraction(uri);
78 | }
79 | }
80 |
81 | @Override
82 | public void onAttach(Context context) {
83 | super.onAttach(context);
84 | if (context instanceof OnFragmentInteractionListener) {
85 | mListener = (OnFragmentInteractionListener) context;
86 | } else {
87 | throw new RuntimeException(context.toString()
88 | + " must implement OnFragmentInteractionListener");
89 | }
90 | }
91 |
92 | @Override
93 | public void onDetach() {
94 | super.onDetach();
95 | mListener = null;
96 | }
97 |
98 | public interface OnFragmentInteractionListener {
99 | void onFragmentInteraction(Uri uri);
100 | }
101 |
102 |
103 | @Override
104 | public void onDestroyView() {
105 | super.onDestroyView();
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nuc/calvin/headline/json/UserJs.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.headline.json;
2 |
3 | import com.nuc.calvin.headline.bean.Relation;
4 |
5 | public class UserJs {
6 | private Integer userId;
7 | private String username;
8 | private String email;
9 | private String password;
10 | private String headImg;
11 | private String signature;
12 | private String sex;
13 | private Relation relation;
14 | private int articleCount;
15 | private int followCount;
16 | private int fansCount;
17 |
18 | public Integer getUserId() {
19 | return userId;
20 | }
21 |
22 | public void setUserId(Integer userId) {
23 | this.userId = userId;
24 | }
25 |
26 | public String getUsername() {
27 | return username;
28 | }
29 |
30 | public void setUsername(String username) {
31 | this.username = username;
32 | }
33 |
34 | public String getEmail() {
35 | return email;
36 | }
37 |
38 | public void setEmail(String email) {
39 | this.email = email;
40 | }
41 |
42 | public String getPassword() {
43 | return password;
44 | }
45 |
46 | public void setPassword(String password) {
47 | this.password = password;
48 | }
49 |
50 | public String getHeadImg() {
51 | return headImg;
52 | }
53 |
54 | public void setHeadImg(String headImg) {
55 | this.headImg = headImg;
56 | }
57 |
58 | public String getSignature() {
59 | return signature;
60 | }
61 |
62 | public void setSignature(String signature) {
63 | this.signature = signature;
64 | }
65 |
66 | public String getSex() {
67 | return sex;
68 | }
69 |
70 | public void setSex(String sex) {
71 | this.sex = sex;
72 | }
73 |
74 | public Relation getRelation() {
75 | return relation;
76 | }
77 |
78 | public void setRelation(Relation relation) {
79 | this.relation = relation;
80 | }
81 |
82 | public int getArticleCount() {
83 | return articleCount;
84 | }
85 |
86 | public void setArticleCount(int articleCount) {
87 | this.articleCount = articleCount;
88 | }
89 |
90 | public int getFollowCount() {
91 | return followCount;
92 | }
93 |
94 | public void setFollowCount(int followCount) {
95 | this.followCount = followCount;
96 | }
97 |
98 | public int getFansCount() {
99 | return fansCount;
100 | }
101 |
102 | public void setFansCount(int fansCount) {
103 | this.fansCount = fansCount;
104 | }
105 |
106 | @Override
107 | public String toString() {
108 | return "UserJs{" +
109 | "userId=" + userId +
110 | ", username='" + username + '\'' +
111 | ", email='" + email + '\'' +
112 | ", password='" + password + '\'' +
113 | ", headImg='" + headImg + '\'' +
114 | ", signature='" + signature + '\'' +
115 | ", sex='" + sex + '\'' +
116 | ", relation=" + relation +
117 | ", articleCount=" + articleCount +
118 | ", followCount=" + followCount +
119 | ", fansCount=" + fansCount +
120 | '}';
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nuc/calvin/headline/adapter/FindArticleAdapter.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.headline.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.facebook.drawee.view.SimpleDraweeView;
13 | import com.nuc.calvin.headline.R;
14 | import com.nuc.calvin.headline.json.ArticleJs;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class FindArticleAdapter extends RecyclerView.Adapter {
20 |
21 | Context context;
22 | List list = new ArrayList<>();
23 |
24 | public FindArticleAdapter(Context context, List list) {
25 | this.context = context;
26 | this.list = list;
27 | }
28 |
29 | @NonNull
30 | @Override
31 | public ArticleViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
32 | View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.view_home_choice_item, viewGroup, false);
33 | ArticleViewHolder myHolder = new ArticleViewHolder(view);
34 | return myHolder;
35 | }
36 |
37 | @Override
38 | public void onBindViewHolder(@NonNull ArticleViewHolder articleViewHolder, int i) {
39 | ArticleJs articleJs = list.get(i);
40 | if (articleViewHolder instanceof ArticleViewHolder) {
41 | articleViewHolder.bindArticle(articleJs);
42 | }
43 | }
44 |
45 | @Override
46 | public int getItemCount() {
47 | return list == null ? 0 : list.size();
48 | }
49 |
50 | class ArticleViewHolder extends RecyclerView.ViewHolder {
51 | TextView likeCount;
52 | TextView commentCount;
53 | TextView collectCount;
54 | TextView mTitleTv;
55 | TextView mWhereTv;
56 | ImageView mCommentIv;
57 | ImageView mLikeIv;
58 | ImageView mCollectIv;
59 | SimpleDraweeView authorImg;
60 |
61 | public ArticleViewHolder(@NonNull View itemView) {
62 | super(itemView);
63 | mTitleTv = itemView.findViewById(R.id.item_title);
64 | mWhereTv = itemView.findViewById(R.id.tv_where);
65 | mLikeIv = itemView.findViewById(R.id.iv_like);
66 | mCommentIv = itemView.findViewById(R.id.iv_comment);
67 | mCollectIv = itemView.findViewById(R.id.iv_collect);
68 | authorImg = itemView.findViewById(R.id.sdv_avatar);
69 | likeCount = itemView.findViewById(R.id.like_count);
70 | commentCount = itemView.findViewById(R.id.comment_count);
71 | collectCount = itemView.findViewById(R.id.collect_count);
72 | }
73 |
74 | public void bindArticle(ArticleJs article) {
75 | mTitleTv.setText(article.getArticleTitle());
76 | mWhereTv.setText(article.getUser().getUsername());
77 | authorImg.setImageURI(article.getUser().getHeadImg());
78 | likeCount.setText(String.valueOf(article.getLikeCount()));
79 | commentCount.setText(String.valueOf(article.getCommentCount()));
80 | collectCount.setText(String.valueOf(article.getCollectCount()));
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nuc/calvin/headline/adapter/MyCollectAdapter.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.headline.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.annotation.NonNull;
5 | import android.support.v7.widget.RecyclerView;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.ViewGroup;
9 | import android.widget.ImageView;
10 | import android.widget.TextView;
11 |
12 | import com.facebook.drawee.view.SimpleDraweeView;
13 | import com.nuc.calvin.headline.R;
14 | import com.nuc.calvin.headline.json.CollectJs;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | public class MyCollectAdapter extends RecyclerView.Adapter {
20 | private Context context;
21 | private List collectJsList = new ArrayList<>();
22 | private LayoutInflater layoutInflater;
23 |
24 | public MyCollectAdapter(Context context) {
25 | this.context = context;
26 | layoutInflater = LayoutInflater.from(context);
27 | }
28 |
29 | public void setList(List list) {
30 | collectJsList.clear();
31 | collectJsList.addAll(list);
32 | }
33 |
34 | @NonNull
35 | @Override
36 | public MyCollectAdapter.CollectHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
37 | View view = layoutInflater.inflate(R.layout.view_home_choice_item, viewGroup, false);
38 | return new CollectHolder(view);
39 | }
40 |
41 | @Override
42 | public void onBindViewHolder(@NonNull MyCollectAdapter.CollectHolder collectHolder, int i) {
43 | final CollectJs collectJs = collectJsList.get(i);
44 | collectHolder.bindData(collectJs);
45 | }
46 |
47 | @Override
48 | public int getItemCount() {
49 | return collectJsList == null ? 0 : collectJsList.size();
50 | }
51 |
52 | public class CollectHolder extends RecyclerView.ViewHolder {
53 | TextView likeCount;
54 | TextView commentCount;
55 | TextView collectCount;
56 | TextView mTitleTv;
57 | TextView mWhereTv;
58 | ImageView mCommentIv;
59 | ImageView mLikeIv;
60 | ImageView mCollectIv;
61 | SimpleDraweeView authorImg;
62 |
63 | public CollectHolder(@NonNull View itemView) {
64 | super(itemView);
65 | mTitleTv = itemView.findViewById(R.id.item_title);
66 | mWhereTv = itemView.findViewById(R.id.tv_where);
67 | mLikeIv = itemView.findViewById(R.id.iv_like);
68 | mCommentIv = itemView.findViewById(R.id.iv_comment);
69 | mCollectIv = itemView.findViewById(R.id.iv_collect);
70 | authorImg = itemView.findViewById(R.id.sdv_avatar);
71 | likeCount = itemView.findViewById(R.id.like_count);
72 | commentCount = itemView.findViewById(R.id.comment_count);
73 | collectCount = itemView.findViewById(R.id.collect_count);
74 | }
75 |
76 | public void bindData(CollectJs collectJs) {
77 | mTitleTv.setText(collectJs.getArticle().getArticleTitle());
78 | mWhereTv.setText(collectJs.getUsername());
79 | authorImg.setImageURI(collectJs.getUser().getHeadImg());
80 | likeCount.setText(String.valueOf(collectJs.getArticle().getLikeCount()));
81 | commentCount.setText(String.valueOf(collectJs.getArticle().getCommentCount()));
82 | /* collectCount.setText(String.valueOf(collectJs.getArticle().));*/
83 |
84 | }
85 | }
86 | }
87 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_post_comment.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
16 |
17 |
22 |
23 |
31 |
32 |
33 |
34 |
43 |
44 |
51 |
52 |
60 |
61 |
71 |
72 |
73 |
74 |
75 |
79 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nuc/calvin/headline/json/CommentJs.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.headline.json;
2 |
3 | import com.nuc.calvin.headline.bean.Article;
4 | import com.nuc.calvin.headline.bean.Reply;
5 | import com.nuc.calvin.headline.bean.User;
6 |
7 | import java.util.Date;
8 | import java.util.List;
9 |
10 | public class CommentJs {
11 |
12 | private Integer commentId;
13 | private Integer userId;
14 | private Integer articleId;
15 | private String commentContent;
16 | private Date commentTime;
17 | private User user;
18 | private Article article;
19 | private String username;
20 | private String time;
21 | private int countReply;
22 | private List replyList;
23 |
24 | public Integer getCommentId() {
25 | return commentId;
26 | }
27 |
28 | public void setCommentId(Integer commentId) {
29 | this.commentId = commentId;
30 | }
31 |
32 | public Integer getUserId() {
33 | return userId;
34 | }
35 |
36 | public void setUserId(Integer userId) {
37 | this.userId = userId;
38 | }
39 |
40 | public Integer getArticleId() {
41 | return articleId;
42 | }
43 |
44 | public void setArticleId(Integer articleId) {
45 | this.articleId = articleId;
46 | }
47 |
48 | public String getCommentContent() {
49 | return commentContent;
50 | }
51 |
52 | public void setCommentContent(String commentContent) {
53 | this.commentContent = commentContent;
54 | }
55 |
56 | public Date getCommentTime() {
57 | return commentTime;
58 | }
59 |
60 | public void setCommentTime(Date commentTime) {
61 | this.commentTime = commentTime;
62 | }
63 |
64 | public User getUser() {
65 | return user;
66 | }
67 |
68 | public void setUser(User user) {
69 | this.user = user;
70 | }
71 |
72 | public Article getArticle() {
73 | return article;
74 | }
75 |
76 | public void setArticle(Article article) {
77 | this.article = article;
78 | }
79 |
80 | public String getUsername() {
81 | return username;
82 | }
83 |
84 | public void setUsername(String username) {
85 | this.username = username;
86 | }
87 |
88 | public String getTime() {
89 | return time;
90 | }
91 |
92 | public void setTime(String time) {
93 | this.time = time;
94 | }
95 |
96 | public int getCountReply() {
97 | return countReply;
98 | }
99 |
100 | public void setCountReply(int countReply) {
101 | this.countReply = countReply;
102 | }
103 |
104 | public List getReplyList() {
105 | return replyList;
106 | }
107 |
108 | public void setReplyList(List replyList) {
109 | this.replyList = replyList;
110 | }
111 |
112 | @Override
113 | public String toString() {
114 | return "CommentJs{" +
115 | "commentId=" + commentId +
116 | ", userId=" + userId +
117 | ", articleId=" + articleId +
118 | ", commentContent='" + commentContent + '\'' +
119 | ", commentTime=" + commentTime +
120 | ", user=" + user +
121 | ", article=" + article +
122 | ", username='" + username + '\'' +
123 | ", time='" + time + '\'' +
124 | ", countReply=" + countReply +
125 | ", replyList=" + replyList +
126 | '}';
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_upate_pwd.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
13 |
14 |
19 |
20 |
28 |
29 |
30 |
31 |
40 |
41 |
48 |
49 |
57 |
58 |
68 |
69 |
70 |
71 |
72 |
76 |
77 |
85 |
92 |
93 |
94 |
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/nuc/calvin/headline/activity/SearchActivity.java:
--------------------------------------------------------------------------------
1 | package com.nuc.calvin.headline.activity;
2 |
3 | import android.content.Intent;
4 | import android.support.design.widget.TabLayout;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.view.ViewPager;
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.view.View;
11 | import android.widget.EditText;
12 | import android.widget.ImageView;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import com.google.gson.Gson;
17 | import com.google.gson.reflect.TypeToken;
18 | import com.nuc.calvin.headline.R;
19 | import com.nuc.calvin.headline.adapter.FindArticleAdapter;
20 | import com.nuc.calvin.headline.adapter.FindUserAdapter;
21 | import com.nuc.calvin.headline.adapter.SearchAdapter;
22 | import com.nuc.calvin.headline.bean.UserCustom;
23 | import com.nuc.calvin.headline.fragment.FindArticleFragment;
24 | import com.nuc.calvin.headline.fragment.FindUserFragment;
25 | import com.nuc.calvin.headline.json.ArticleJs;
26 | import com.nuc.calvin.headline.utils.StaticClass;
27 |
28 | import java.io.IOException;
29 | import java.io.Serializable;
30 | import java.util.ArrayList;
31 | import java.util.List;
32 |
33 | import okhttp3.Call;
34 | import okhttp3.Callback;
35 | import okhttp3.OkHttpClient;
36 | import okhttp3.Request;
37 | import okhttp3.Response;
38 |
39 | public class SearchActivity extends BaseActivity {
40 | private static final String TAG = "SearchActivity";
41 | private TabLayout tabLayout;
42 | private ViewPager search_page;
43 | private List list = new ArrayList<>();
44 | private List fragments = new ArrayList<>();
45 | private EditText keyWord;
46 | private TextView cancle;
47 | private ImageView beginSearch;
48 | private List articleJsList = new ArrayList<>();
49 | private List userCustomList = new ArrayList<>();
50 |
51 | @Override
52 | protected void initView(Bundle savedInstanceState) {
53 | beginSearch = findViewById(R.id.begin_search);
54 | keyWord = findViewById(R.id.key_word);
55 | cancle = findViewById(R.id.tv_cancel);
56 | tabLayout = findViewById(R.id.tab);
57 | search_page = findViewById(R.id.pager);
58 | final FindArticleFragment findArticleFragment = new FindArticleFragment();
59 | final FindUserFragment findUserFragment = new FindUserFragment();
60 | fragments.add(findArticleFragment);
61 | fragments.add(findUserFragment);
62 | list.add("文章");
63 | list.add("用户");
64 | tabLayout.setupWithViewPager(search_page);
65 | search_page.setAdapter(new SearchAdapter(getSupportFragmentManager(), fragments, list));
66 | cancle.setOnClickListener(new View.OnClickListener() {
67 | @Override
68 | public void onClick(View v) {
69 | Intent intent = new Intent(SearchActivity.this, MainActivity.class);
70 | intent.putExtra("id", 2);
71 | startActivity(intent);
72 | finish();
73 | }
74 | });
75 |
76 | beginSearch.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View v) {
79 | String word = keyWord.getText().toString();
80 | findArticleFragment.refredata(word);
81 | findUserFragment.refreshData(word);
82 | StaticClass.findUserAdapter = new FindUserAdapter(getApplicationContext(), StaticClass.userList);
83 | StaticClass.findArticleAdapter = new FindArticleAdapter(getApplicationContext(), StaticClass.articleJsList);
84 | }
85 | });
86 |
87 | }
88 |
89 | @Override
90 | protected int getContentView() {
91 | return R.layout.activity_search;
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/my_follow_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
19 |
24 |
25 |
31 |
32 |
38 |
39 |
40 |
49 |
50 |
54 |
55 |
62 |
63 |
71 |
72 |
79 |
80 |
87 |
88 |
89 |
90 |
96 |
97 |
102 |
103 |
--------------------------------------------------------------------------------