-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
iMeiji
committed
Jun 15, 2017
1 parent
6890f2b
commit 42067aa
Showing
18 changed files
with
2,105 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/src/main/java/com/meiji/toutiao/api/IMobileSearchApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.meiji.toutiao.api; | ||
|
||
import com.meiji.toutiao.bean.search.SearchBean; | ||
import com.meiji.toutiao.bean.search.SearchSuggestionBean; | ||
|
||
import io.reactivex.Observable; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Query; | ||
|
||
/** | ||
* Created by Meiji on 2017/6/13. | ||
*/ | ||
|
||
public interface IMobileSearchApi { | ||
|
||
/** | ||
* 获取搜索建议 | ||
* http://is.snssdk.com/2/article/search_sug/?keyword=3&from=search_tab&iid=10344168417&device_id=36394312781 | ||
* | ||
* @param keyword 搜索内容 | ||
*/ | ||
@GET("http://is.snssdk.com/2/article/search_sug/?from=search_tab&iid=10344168417&device_id=36394312781") | ||
Observable<SearchSuggestionBean> getSearchSuggestion(@Query("keyword") String keyword); | ||
|
||
/** | ||
* 获取搜索结果 | ||
* http://is.snssdk.com/api/2/wap/search_content/?from=search_tab&keyword=123&iid=10344168417&device_id=36394312781&count=10&cur_tab=1&format=json&offset=20 | ||
* | ||
* @param keyword 搜索内容 | ||
* @param curTab 搜索栏目 1综合 2视频 3图集 4用户 5问答 | ||
* @param offset 偏移量 | ||
*/ | ||
@GET("http://is.snssdk.com/api/2/wap/search_content/?from=search_tab&iid=10344168417&device_id=36394312781&count=10&format=json") | ||
Observable<SearchBean> getSearchArticle( | ||
@Query("keyword") String keyword, | ||
@Query("cur_tab") String curTab, | ||
@Query("offset") int offset); | ||
} |
1,336 changes: 1,336 additions & 0 deletions
1,336
app/src/main/java/com/meiji/toutiao/bean/search/SearchBean.java
Large diffs are not rendered by default.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
app/src/main/java/com/meiji/toutiao/bean/search/SearchSuggestionBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.meiji.toutiao.bean.search; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Created by Meiji on 2017/6/14. | ||
*/ | ||
|
||
public class SearchSuggestionBean { | ||
/** | ||
* message : success | ||
* data : [{"keyword":"6 18小米6"},{"keyword":"618小米手机"},{"keyword":"618京东"},{"keyword":"6 18"},{"keyword":"618手机"},{"keyword":"618京东节"},{"keyword":"618电商大战"},{"keyword":"618电商节"},{"keyword":"618大促"},{"keyword":"618手机排行榜"}] | ||
*/ | ||
|
||
private String message; | ||
private List<DataBean> data; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public List<DataBean> getData() { | ||
return data; | ||
} | ||
|
||
public void setData(List<DataBean> data) { | ||
this.data = data; | ||
} | ||
|
||
public static class DataBean { | ||
/** | ||
* keyword : 6 18小米6 | ||
*/ | ||
|
||
private String keyword; | ||
|
||
public String getKeyword() { | ||
return keyword; | ||
} | ||
|
||
public void setKeyword(String keyword) { | ||
this.keyword = keyword; | ||
} | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
app/src/main/java/com/meiji/toutiao/binder/SearchViewBinder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package com.meiji.toutiao.binder; | ||
|
||
import android.support.annotation.NonNull; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.text.TextUtils; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.meiji.toutiao.R; | ||
import com.meiji.toutiao.bean.news.NewsArticleBean; | ||
import com.meiji.toutiao.bean.search.SearchBean; | ||
import com.meiji.toutiao.module.news.content.NewsContentActivity; | ||
import com.meiji.toutiao.utils.ImageLoader; | ||
import com.meiji.toutiao.utils.TimeUtil; | ||
import com.meiji.toutiao.widget.CircleImageView; | ||
|
||
import me.drakeet.multitype.ItemViewBinder; | ||
|
||
/** | ||
* Created by Meiji on 2017/6/13. | ||
*/ | ||
|
||
public class SearchViewBinder extends ItemViewBinder<SearchBean.DataBeanX, SearchViewBinder.ViewHolder> { | ||
|
||
|
||
@NonNull | ||
@Override | ||
protected SearchViewBinder.ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) { | ||
View view = inflater.inflate(R.layout.item_news_article, parent, false); | ||
return new ViewHolder(view); | ||
} | ||
|
||
@Override | ||
protected void onBindViewHolder(@NonNull SearchViewBinder.ViewHolder holder, @NonNull final SearchBean.DataBeanX item) { | ||
try { | ||
|
||
if (item.getImage_list().size() > 0) { | ||
String url = item.getImage_list().get(0).getUrl(); | ||
ImageLoader.loadCenterCrop(holder.itemView.getContext(), url, holder.iv_image, R.color.viewBackground); | ||
} | ||
|
||
String tv_title = item.getTitle(); | ||
String tv_abstract = item.getAbstractX(); | ||
String tv_source = item.getSource(); | ||
String tv_comment_count = item.getComment_count() + "评论"; | ||
String tv_datetime = item.getBehot_time() + ""; | ||
if (!TextUtils.isEmpty(tv_datetime)) { | ||
tv_datetime = TimeUtil.getTimeStampAgo(tv_datetime); | ||
} | ||
|
||
holder.tv_title.setText(tv_title); | ||
holder.tv_abstract.setText(tv_abstract); | ||
holder.tv_extra.setText(tv_source + " - " + tv_comment_count + " - " + tv_datetime); | ||
holder.itemView.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
NewsArticleBean.DataBean dataBean = new NewsArticleBean.DataBean(); | ||
dataBean.setDisplay_url(item.getDisplay_url()); | ||
dataBean.setTitle(item.getTitle()); | ||
dataBean.setMedia_name(item.getMedia_name()); | ||
dataBean.setMedia_url(item.getMedia_url()); | ||
dataBean.setGroup_id(item.getGroup_id()); | ||
dataBean.setItem_id(item.getGroup_id()); | ||
NewsContentActivity.launch(dataBean); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
|
||
} | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder { | ||
|
||
private CircleImageView iv_media; | ||
private ImageView iv_image; | ||
private TextView tv_title; | ||
private TextView tv_abstract; | ||
private TextView tv_extra; | ||
|
||
ViewHolder(View itemView) { | ||
super(itemView); | ||
this.iv_media = (CircleImageView) itemView.findViewById(R.id.iv_media); | ||
this.iv_image = (ImageView) itemView.findViewById(R.id.iv_image); | ||
this.tv_title = (TextView) itemView.findViewById(R.id.tv_title); | ||
this.tv_abstract = (TextView) itemView.findViewById(R.id.tv_abstract); | ||
this.tv_extra = (TextView) itemView.findViewById(R.id.tv_extra); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.