-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #338 from wubucheng/master
- Loading branch information
Showing
42 changed files
with
1,053 additions
and
35 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
19 changes: 19 additions & 0 deletions
19
...roidlabs/homeworks/net1414080903220/knowdev/activity/NewsDetailActivity1414080903220.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,19 @@ | ||
package edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.activity; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
/** | ||
* ProjectName: knowdev | ||
* PackName:edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.activity | ||
* Class describe:新闻详情界面 | ||
* Author: cheng | ||
* Create time: 2017/5/16 0:09 | ||
*/ | ||
public class NewsDetailActivity1414080903220 extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...n/java/edu/hzuapps/androidlabs/homeworks/net1414080903220/knowdev/adapter/DevAdapter.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,86 @@ | ||
package edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.adapter; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.squareup.picasso.Picasso; | ||
|
||
import edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.R; | ||
|
||
/** | ||
* ProjectName: knowdev | ||
* PackName:edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.adapter | ||
* Class describe: | ||
* Author: cheng | ||
* Create time: 2017/5/16 15:09 | ||
*/ | ||
public class DevAdapter extends RecyclerView.Adapter<DevAdapter.ViewHolder> { | ||
|
||
private LayoutInflater layoutInflater; | ||
String []type; | ||
String[]images; | ||
String []descs; | ||
String []authors; | ||
String []time; | ||
Context context; | ||
public DevAdapter(Context context){ | ||
this.context=context; | ||
/* | ||
以下数据只是测试 | ||
*/ | ||
type=new String[]{"Android","Android","Android","Android","Android"}; | ||
images=new String[]{"http://img.gank.io/fbaa3bd1-a372-4eb1-8e40-cffeedc38a9f","http://img.gank.io/a85956f6-f82b-4d4a-8226-01fb259a60c0", | ||
"http://img.gank.io/4eaa8f16-3acb-4a84-af07-b8e0c63690d4","http://mmbiz.qpic.cn/mmbiz_png/zXuqh9EzOT8z0z2NXN2pZWK4EZLlTvnIVYpibNicRHNTiaMKm6vj82PFOp6kZ6G8ibTPKV88ebsZWX8T63xo7y52CQ/640?wx_fmt=png&tp=webp&wxfrom=5","http://img.gank.io/b6a9c5b4-a6da-4bfa-8423-14b10a5c0d50"}; | ||
descs=new String[]{"Android灵魂画家的18种混合模式","这次我们抛开术语和概念,从例子入手,由浅入深地讲解 Java 的类加载机制", | ||
"Android setContentView源码分析","Android电量优化的点点滴滴,全告诉你!","横向堆叠效果的自定义Layout"}; | ||
authors=new String[]{"陈宇明","wingjay","HuYounger","null","stone"}; | ||
time=new String[]{"2017-05-15","2017-05-16","2017-05-16","2017-05-16","2017-05-16"}; | ||
} | ||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
layoutInflater=LayoutInflater.from(context); | ||
View view=layoutInflater.inflate(R.layout.template_dev_item_net1414080903220,parent,false); | ||
DevAdapter.ViewHolder viewHolder=new DevAdapter.ViewHolder(view); | ||
return viewHolder; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(ViewHolder holder, int position) { | ||
Picasso.with(context).load(images[position]).into(holder.imageView); | ||
holder.typeTv.setText(type[position]); | ||
holder.descTv.setText(descs[position]); | ||
holder.authorTv.setText(authors[position]); | ||
holder.timeTv.setText("于"+time[position]); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return type.length; | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ | ||
TextView typeTv; | ||
ImageView imageView; | ||
TextView descTv; | ||
TextView authorTv; | ||
TextView timeTv; | ||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
typeTv= (TextView) itemView.findViewById(R.id.tv_type); | ||
imageView= (ImageView) itemView.findViewById(R.id.img_devarticle); | ||
descTv= (TextView) itemView.findViewById(R.id.title_article); | ||
authorTv= (TextView) itemView.findViewById(R.id.tv_author); | ||
timeTv= (TextView) itemView.findViewById(R.id.time_article); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
|
||
} | ||
} | ||
} |
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
117 changes: 117 additions & 0 deletions
117
.../java/edu/hzuapps/androidlabs/homeworks/net1414080903220/knowdev/adapter/NewsAdapter.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,117 @@ | ||
package edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.adapter; | ||
|
||
import android.content.Context; | ||
import android.support.v7.widget.RecyclerView; | ||
import android.util.Log; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.squareup.picasso.Picasso; | ||
|
||
import java.util.List; | ||
|
||
import edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.R; | ||
import edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.bean.News; | ||
|
||
/** | ||
* ProjectName: knowdev | ||
* PackName:edu.hzuapps.androidlabs.homeworks.net1414080903220.knowdev.adapter | ||
* Class describe: | ||
* Author: cheng | ||
* Create time: 2017/5/15 22:12 | ||
*/ | ||
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder> { | ||
|
||
private List<News>newsList; | ||
private LayoutInflater layoutInflater; | ||
|
||
private Context context; | ||
|
||
OnNewsTypeClickListener listener; | ||
|
||
|
||
String[] newsImagesTest; | ||
String[] newsTitleTest; | ||
String[] newsTimeTest; | ||
String[] newsDescTest; | ||
|
||
|
||
public NewsAdapter(List<News>newsList,Context context){ | ||
this.newsList=newsList; | ||
this.context=context; | ||
} | ||
|
||
public NewsAdapter(Context context){ | ||
this.context=context; | ||
/* | ||
以下为测试数据 | ||
*/ | ||
newsImagesTest=new String[]{"http://inews.gtimg.com/newsapp_ls/0/1554927630_300240/0", | ||
"http://inews.gtimg.com/newsapp_ls/0/1554995711_300240/0", | ||
"http://inews.gtimg.com/newsapp_ls/0/1554242214_300240/0","http://inews.gtimg.com/newsapp_ls/0/1554921842_300240/0","http://inews.gtimg.com/newsapp_ls/0/1554268705_300240/0"}; | ||
newsTitleTest=new String[]{"苹果紧急提供23个安全补丁 修补电脑手机系统漏洞","传联想原执行副总裁刘军回归:个人微博现端倪" | ||
,"罗永浩:坚果Pro有爆款迹象 锤子今年出货目标四五百万","全球互联网遭勒索 企业安全意识薄弱","百胜中国收购“到家美食会”控股股权 发展外卖服务"}; | ||
newsTimeTest=new String[]{"2017-05-16 06:40","2017-05-16 07:29","2017-05-15 22:10","2017-05-16 06:32","2017-05-15 22:15"}; | ||
newsDescTest=new String[]{"腾讯科技","腾讯科技","腾讯科技","腾讯科技","腾讯科技"}; | ||
|
||
|
||
} | ||
|
||
public void setOnNewsTypeClickListener(OnNewsTypeClickListener listener){ | ||
this.listener=listener; | ||
} | ||
|
||
@Override | ||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
layoutInflater=LayoutInflater.from(context); | ||
View view=layoutInflater.inflate(R.layout.template_newlist_item_net1414080903220,parent,false); | ||
ViewHolder viewHolder=new ViewHolder(view); | ||
return viewHolder; | ||
} | ||
|
||
@Override | ||
public void onBindViewHolder(ViewHolder holder, int position) { | ||
Picasso.with(context).load(newsImagesTest[position]).into(holder.newsImg); | ||
holder.newstTitle.setText(newsTitleTest[position]); | ||
holder.newsTime.setText(newsTimeTest[position]); | ||
holder.newsDesc.setText("来源:"+newsDescTest[position]); | ||
|
||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return newsImagesTest.length; | ||
} | ||
|
||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ | ||
|
||
private ImageView newsImg; | ||
private TextView newstTitle; | ||
private TextView newsTime; | ||
private TextView newsDesc; | ||
|
||
public ViewHolder(View itemView) { | ||
super(itemView); | ||
newsImg= (ImageView) itemView.findViewById(R.id.img_news); | ||
newstTitle= (TextView) itemView.findViewById(R.id.title_news); | ||
newsTime= (TextView) itemView.findViewById(R.id.time_news); | ||
newsDesc= (TextView) itemView.findViewById(R.id.source_tv); | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
News news=newsList.get(getLayoutPosition()); | ||
if(listener!=null){ | ||
listener.onClick(v,news.getUrl()); | ||
} | ||
} | ||
} | ||
|
||
public interface OnNewsTypeClickListener{ | ||
void onClick(View view,String url); | ||
}; | ||
|
||
} |
Oops, something went wrong.