首页合并5.0

master
Annnnnn 3 years ago
parent 2981fdc602
commit e7371cc45f

@ -47,6 +47,11 @@
android:name=".Activity.MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activity.ChatActivity"
@ -75,18 +80,14 @@
<activity android:name=".Activity.SendQuestionActivity" />
<activity android:name=".Activity.APNActivity" />
<activity android:name=".Activity.EventActivity" />
<activity android:name=".Activity.NewsDetailActivity" />
<activity android:name=".Activity.NewsSearchResultActivity"/>
<activity android:name=".Activity.NewsSearchActivity"/>
<receiver
android:name=".CallAlarm"
android:process=".remote" />
<activity android:name=".Activity.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity.LoginActivity"/>
</application>
</manifest>

@ -31,7 +31,7 @@ public class BaseActivity extends AppCompatActivity {
public static Owner owner;
//服务器链接
public static String SERVER_IP = "172.30.87.197";
public static String SERVER_IP = "172.30.125.78";
// 172.30.118.24 寝172.18.138.225
// static {

@ -102,7 +102,7 @@ public class BlogDetailActivity extends BaseActivity {
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr=response.body().string();
final String jsonStr=response.body().string();
runOnUiThread(new Runnable() {
@Override
public void run() {
@ -123,7 +123,7 @@ public class BlogDetailActivity extends BaseActivity {
}).start();
}
private void setBlogAuthorName(String uid){
private void setBlogAuthorName(final String uid){
new Thread(new Runnable() {
@Override
public void run() {
@ -140,7 +140,7 @@ public class BlogDetailActivity extends BaseActivity {
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
final String jsonStr = response.body().string();
runOnUiThread(new Runnable() {
@Override
public void run() {
@ -189,15 +189,15 @@ public class BlogDetailActivity extends BaseActivity {
}
private void setBColNumViewImage(int bid,int uid,int type){
Map<String,Integer> paramMap=new HashMap<String, Integer>();
final Map<String,Integer> paramMap=new HashMap<String, Integer>();
paramMap.put("bid",bid);
paramMap.put("uid", uid);
paramMap.put("type",type);
String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=JudgeCollect";
final String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=JudgeCollect";
new Thread(new Runnable() {
@Override
public void run() {
String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
final String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
runOnUiThread(new Runnable() {
@Override
public void run() {
@ -244,11 +244,11 @@ public class BlogDetailActivity extends BaseActivity {
long timeCurrent = System.currentTimeMillis();
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Timestamp time = Timestamp.valueOf(sdf.format(timeCurrent));
Comment comment=new Comment(blog.getBid(),user.getUsername(),time,user.getIduser(),
final Comment comment=new Comment(blog.getBid(),user.getUsername(),time,user.getIduser(),
cont,2);
Map<String,Comment> paramMap=new HashMap<String,Comment>();
final Map<String,Comment> paramMap=new HashMap<String,Comment>();
paramMap.put("comment",comment);
String url=BaseActivity.SERVER_URL+"/comment-servlet?action=insertComment";
final String url=BaseActivity.SERVER_URL+"/comment-servlet?action=insertComment";
new Thread(new Runnable() {
@Override
public void run() {
@ -284,11 +284,11 @@ public class BlogDetailActivity extends BaseActivity {
@Override
public void onClick(View v) {
Map<String,Integer> paramMap=new HashMap<String, Integer>();
final Map<String,Integer> paramMap=new HashMap<String, Integer>();
paramMap.put("bid",blog.getBid());
paramMap.put("uid", BaseActivity.owner.getNetId());
paramMap.put("type",2);
String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=InsertCollect";
final String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=InsertCollect";
int imageId=getDrawableId(bColImage);
if(imageId==R.drawable.collect) {
@ -301,7 +301,7 @@ public class BlogDetailActivity extends BaseActivity {
new Thread(new Runnable() {
@Override
public void run() {
String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
final String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
runOnUiThread(new Runnable() {
@Override
public void run() {

@ -65,10 +65,10 @@ public class BlogSearchResultActivity extends AppCompatActivity {
}
private void initData(String text){
Map<String,String> paramMap=new HashMap<String, String>();
final Map<String,String> paramMap=new HashMap<String, String>();
paramMap.put("text",text);
// Log.e("initData中的text",text);
String url=BaseActivity.SERVER_URL+"/blog-servlet?action=getSearchResult";
final String url=BaseActivity.SERVER_URL+"/blog-servlet?action=getSearchResult";
new Thread(new Runnable() {
@Override
public void run() {
@ -85,7 +85,7 @@ public class BlogSearchResultActivity extends AppCompatActivity {
String jsonStr = response.body().string();
Log.e("result jsonStr",jsonStr);
Type listType = new TypeToken<List<Blog>>() {}.getType();
List<Blog> resultList = gson.fromJson(jsonStr, listType);
final List<Blog> resultList = gson.fromJson(jsonStr, listType);
resultBlog = resultList ;
runOnUiThread(new Runnable() {
@Override

@ -9,10 +9,7 @@ import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.Toast;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.InfoAdapter;
import com.example.leudaemialikeme.Fragment.InfoFragment;
import com.example.leudaemialikeme.Model.Recnews;
import com.example.leudaemialikeme.R;
@ -38,19 +35,24 @@ public class InfoActivity extends BaseActivity {
typeList.add("政府");
typeList.add("慈善");
typeList.add("全部");
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, typeList);
//设置适配器
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, typeList);//
//设置样式
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
//加载适配器
Spinner sp = (Spinner) findViewById(R.id.info_type);
sp.setAdapter(adapter);
sp.setSelection(infoType,true);
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { //监听Spinner的操作
// parent 为控件Spinner view显示文字的TextView position下拉选项的位置从0开始
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { //选取的操作
//获取Spinner控件的适配器
//获取Spinner控件的适配器
ArrayAdapter<String> adapter = (ArrayAdapter<String>) parent.getAdapter();
//tvResult.setText(adapter.getItem(position));
Toast.makeText(getBaseContext(),adapter.getItem(position),Toast.LENGTH_SHORT).show();
// str1=spinner.getSelectedItem().toString();
// Log.e("tag:","你选中的消息是:"+str1);
}
//没有选中时的处理
public void onNothingSelected(AdapterView<?> parent) {
@ -67,14 +69,17 @@ public class InfoActivity extends BaseActivity {
}
});
initRecNews();
RecyclerView recyclerView=(RecyclerView) findViewById(R.id.info_recyclerView);
LinearLayoutManager layoutManager=new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
InfoAdapter infoAdapter=new InfoAdapter(recNews);
recyclerView.setAdapter(infoAdapter);
// initRecNews();
// RecyclerView recyclerView=(RecyclerView) findViewById(R.id.info_recyclerView);//显示recycleview
// LinearLayoutManager layoutManager=new LinearLayoutManager(this);
// recyclerView.setLayoutManager(layoutManager);
// InfoAdapter infoAdapter=new InfoAdapter(recNews);
// recyclerView.setAdapter(infoAdapter);
getSupportFragmentManager() //这里添加一个展示资讯的碎片
.beginTransaction()
.add(R.id.infoFragment,new InfoFragment()) // 此处的R.id.fragment_container是要盛放fragment的父容器
.commit();
}

@ -0,0 +1,102 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
public class NewsDetailActivity extends BaseActivity {
TextView sTitleView;
TextView sAuthorNameView;
TextView sContentView;
TextView sLikeNumView;
TextView sColNumView;
private int nid;
private String nTitle;
private String nContent;
private String nBrowse;
// TextView bComNumView;
// EditText comEditView;
// TextView comComView;//评论的部分
ImageView detail_to;
ImageView search;
News news;
// User author;//资讯不需要显示作者
// List<Comment> commentList;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news_detail);//显示详情页的布局
Intent intent = getIntent();
nid = intent.getIntExtra("nid",-1);
nTitle = intent.getStringExtra("nTitle");//获取帖子标题
nContent = intent.getStringExtra("nContent");//获取内容
nBrowse = intent.getStringExtra("nBrowseNum") ;//获取浏览量
initView();//初始布局
initClick();//初始化点击
// EventBus.getDefault().register(this);//进行EvenBus的注册
// Log.e("news:EventBus", news.getStittle());
// if (news != null) {
// Log.i("NewsDetailActivity", "news not null");
// } else
// Log.i("NewsDetailActivity", "news is null");
setNewsDetail();//设置资讯子项的对应内容
Log.e("传输后资讯编号nid是",String.valueOf(nid));
Log.e("传输后资讯标题是",nTitle);
Log.e("传输后资讯内容是",nContent);
Log.e("传输后在详情页的资讯的浏览量是",nBrowse);
}
// @Override
// protected void onDestroy() {
// super.onDestroy();
// EventBus.getDefault().unregister(this);
// }
// @Subscribe(sticky = true)//标记和发送消息的标记一样
// public void onEvent(News news) {//接受消息
// this.news = news;
// Log.e("接受的消息是",news.getScontent());
// }
private void initView() {//初始化视图
sTitleView = findViewById(R.id.detail_theme);
sAuthorNameView = findViewById(R.id.author);
sContentView = findViewById(R.id.sContent);
sLikeNumView = findViewById(R.id.detail_like_num);//资讯点赞数
sColNumView = findViewById(R.id.detail_col_num);//资讯收藏数
detail_to = findViewById(R.id.detail_to);
search = findViewById(R.id.detail_to_search);
}
private void setNewsDetail() {//显示单个子项的资讯
sTitleView.setText(nTitle);
sContentView.setText(nContent);
sLikeNumView.setText(nBrowse);//设置资讯的浏览量
// updateNewsBrowse();//更新资讯浏览量
// sLikeNumView.setText(String.valueOf(news.getSbrowseNum()));//其实是点赞量,但是显示资讯浏览量
// sColNumView.setText(String.valueOf(news.getBcollectNum()));
}
private void initClick() {
detail_to.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
//搜索的点击事件去掉了
}

@ -0,0 +1,54 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.leudaemialikeme.R;
public class NewsSearchActivity extends BaseActivity {
ImageView back;
EditText newsSearchEdit;
TextView newsSearchCommit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news_search);
initView();
initClick();
}
private void initView(){
back = findViewById(R.id.search_back);
newsSearchEdit = findViewById(R.id.news_search_edit);
newsSearchCommit = findViewById(R.id.news_search_commit);
}
private void initClick(){
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
newsSearchCommit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String text = newsSearchEdit.getText().toString();
Intent intent=new Intent(NewsSearchActivity.this,NewsSearchResultActivity.class);
Log.e("传递到result页的text = ",text);
intent.putExtra("text",text);//把搜索的值传递到显示搜索结果的活动中
startActivity(intent);
}
});
}
}

@ -0,0 +1,148 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.NewsAdapter;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class NewsSearchResultActivity extends BaseActivity {
ImageView newsSearchBackView;
TextView newsSearchTextView;
TextView newsResultBackView;
RecyclerView resultRecyclerView;
List<News> resultNews=new ArrayList<>();
private boolean isPause = false;
String text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_news_search_result);
Intent intent = getIntent();
text=intent.getStringExtra("text");//接受资讯搜索传过来的字符串
Log.e("传递过来的text = ",text);
resultRecyclerView=(RecyclerView) findViewById(R.id.result_recyclerView);
LinearLayoutManager layoutManager=new LinearLayoutManager(this);
resultRecyclerView.setLayoutManager(layoutManager);
NewsAdapter resultAdapter = new NewsAdapter();
initView();//初始化视图
newsSearchTextView.setText(text);
initData(text);//显示搜索结果
initClick();
if(resultNews==null)
Log.e("resultNews","resultNews is null");
resultAdapter.setRecnewsList(resultNews);
if(resultRecyclerView==null)
Log.e("resultRecyclerView","resultRecyclerView is null");
if(resultAdapter==null)
Log.e("resultAdapter","resultAdapter is null");
resultRecyclerView.setAdapter(resultAdapter);
}
//初始化视图
private void initView(){
newsSearchBackView=(ImageView) findViewById(R.id.news_search_back);
newsSearchTextView=(TextView) findViewById(R.id.news_search_text);
newsResultBackView=(TextView)findViewById(R.id.news_result_back);
}
//搜索对应的数据
private void initData(String text){
final Map<String,String> paramMap=new HashMap<String, String>();
paramMap.put("text",text);
final String url=BaseActivity.SERVER_URL+"/news-servlet?action=getSearchResult";//对应Servlet
// String url=BaseActivity.SERVER_URL+"/news-servlet?action=getSearchResult";
new Thread(new Runnable() {
@Override
public void run() {
OkHttpUtil.asyPost(url, paramMap, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
}
// @Override
// public void onResponse(Call call, Response response) throws IOException {
//
// }
// });
@Override
public void onResponse(Call call, Response response) throws IOException {
Gson gson = new Gson();
String jsonStr = response.body().string();
Log.e("result jsonStr",jsonStr);
Type listType = new TypeToken<List<News>>() {}.getType();
final List<News> resultList = gson.fromJson(jsonStr, listType);
resultNews = resultList ;
runOnUiThread(new Runnable() {
@Override
public void run() {
NewsAdapter resultAdapter = new NewsAdapter();
resultAdapter.setRecnewsList(resultList);
resultRecyclerView.setAdapter(resultAdapter);
}
});
}
});
}
}).start();
}
private void initClick() {
newsSearchBackView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finish();
}
});
newsResultBackView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
@Override
public void onPause() {
super.onPause();
isPause = true; //记录页面已经被暂停
}
@Override
public void onResume() {
super.onResume();
if (isPause) { //判断是否暂停
isPause = false;
Map<String, String[]> paramMap = new HashMap<String, String[]>();
initData(text);//更新数据
}
}
}

@ -76,7 +76,7 @@ public class BlogAdapter extends RecyclerView.Adapter<BlogAdapter.ViewHolder> {
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.recnews_item,parent,false);
ViewHolder holder=new ViewHolder(view);
final ViewHolder holder=new ViewHolder(view);
// context=parent.getContext();
holder.linear.setOnClickListener(new View.OnClickListener() {
@ -126,8 +126,8 @@ public class BlogAdapter extends RecyclerView.Adapter<BlogAdapter.ViewHolder> {
}
private void UpdateBrowseNum(String bid){
String url = BaseActivity.SERVER_URL + "/browse-servlet?action=UpdateBrowse";
Map<String,String> paramMap = new HashMap<String,String>();
final String url = BaseActivity.SERVER_URL + "/browse-servlet?action=UpdateBrowse";
final Map<String,String> paramMap = new HashMap<String,String>();
Log.e("获取浏览量的返回结果","浏览量");
paramMap.put("id", bid);

@ -48,7 +48,7 @@ public class HistoryQuestionAdapter extends RecyclerView.Adapter<HistoryQuestion
@Override
public HistoryQuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.question_item,parent,false);
HistoryQuestionAdapter.ViewHolder holder=new HistoryQuestionAdapter.ViewHolder(view);
final HistoryQuestionAdapter.ViewHolder holder=new HistoryQuestionAdapter.ViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -62,7 +62,7 @@ public class HistoryQuestionAdapter extends RecyclerView.Adapter<HistoryQuestion
return holder;
}
private void addQuestionBrowse(int qid) {
private void addQuestionBrowse(final int qid) {
new Thread(new Runnable() {
@Override
public void run() {

@ -0,0 +1,31 @@
package com.example.leudaemialikeme.Adapter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import com.example.leudaemialikeme.Fragment.InfoChannelFragment;
public class InfoPageFragmentAdapter extends FragmentPagerAdapter {
private String[] channelList;
private FragmentManager fm;
public InfoPageFragmentAdapter(@NonNull FragmentManager fm, String[] channelList) {
super(fm);
this.channelList = channelList;
this.fm = fm;
}
@NonNull
@Override
public Fragment getItem(int position) {
String InfoCategoryTitle = channelList[position];
return InfoChannelFragment.newInstance(InfoCategoryTitle,position);
// return InfoChannelFragment.newInstance(InfoCategoryTitle);
}
@Override
public int getCount() {
return channelList.length;
}//返回有效视图的数量
}

@ -65,7 +65,7 @@ public class MyQuestionAdapter extends RecyclerView.Adapter<MyQuestionAdapter.Vi
return holder;
}
private void addQuestionBrowse(int qid) {
private void addQuestionBrowse(final int qid) {
new Thread(new Runnable() {
@Override
public void run() {

@ -0,0 +1,163 @@
package com.example.leudaemialikeme.Adapter;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.NewsDetailActivity;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class NewsAdapter extends RecyclerView.Adapter<NewsAdapter.ViewHolder>{
private List<News> mNewsList = new ArrayList<News>();
private News news;
static class ViewHolder extends RecyclerView.ViewHolder{
private TextView text_news_id;
private Context context;
ImageView image;
private TextView theme;
private TextView intro;
TextView visNum;
TextView time;
LinearLayout linear;
public ViewHolder(View view){
super(view);
text_news_id = view.findViewById(R.id.text_news_id);//新增的newsid
// image=(ImageView)view.findViewById(R.id.recNews_image);//图片
theme=(TextView)view.findViewById(R.id.recNews_theme);//标题
intro=(TextView)view.findViewById(R.id.recNews_intro);//内容
visNum=(TextView)view.findViewById(R.id.recNews_visNum);//浏览量
time=(TextView)view.findViewById(R.id.recNews_time);//时间
linear=(LinearLayout)view.findViewById(R.id.news);
}
}
public NewsAdapter(List<News> newsList){
mNewsList=newsList;
Log.e("recAdapter中mNewsList的数据",String.valueOf(newsList));
}
public NewsAdapter(){
}
public void setRecnewsList(List<News> newsList){
mNewsList=newsList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.recnews_item,parent,false);
//NewsAdapter.ViewHolder holder=new NewsAdapter.ViewHolder(view);
final ViewHolder holder=new ViewHolder(view);
holder.linear.setOnClickListener(new View.OnClickListener() {//注册资讯子项的监听器,用匿名类来实现点击事件的方法
@Override
public void onClick(View view) {
UpdateNewsBrowseNum(holder.text_news_id.getText().toString());//更新资讯浏览量
Intent intent=new Intent(view.getContext(), NewsDetailActivity.class);//去资讯详情页
intent.putExtra("nid",Integer.parseInt(holder.text_news_id.getText().toString()));
Log.e("传输前的nid",(holder.text_news_id.getText().toString()));
intent.putExtra("type",1);//资讯类型是1
intent.putExtra("nTitle",(holder.theme.getText().toString()));
intent.putExtra("nContent",(holder.intro.getText().toString()));
intent.putExtra("nBrowseNum",String.valueOf(Integer.parseInt(holder.visNum.getText().toString())+1 ));//传过去之前浏览量+1
// Log.e("传输前的资讯标题是",holder.theme.getText().toString());
// updateNewsBrowse(newsid);
// intent.putExtra("from",String.valueOf(view.getContext()));
// intent.putExtra("nid",news);//
// intent.putExtra("type",3);//资讯类型是3暂时未用
// EventBus.getDefault().postSticky(news);//发送Stricky事件
// Log.e("坐Evenbus的news",String.valueOf(news.getStittle()));
// if(news!=null)
// Log.i("newsAapter","news is not null");
// else
// Log.i("newsAapter","news is null");
Log.e("activity",String.valueOf(view.getContext()));
view.getContext().startActivity(intent);
}
});
return holder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
//将每个子项holder绑定了数据
news=mNewsList.get(position);
holder.text_news_id.setText(String.valueOf(news.getNid()));//新增的
// holder.image.setImageResource(R.drawable.rec_news3);
holder.visNum.setText(String.valueOf(news.getSbrowseNum()));
holder.intro.setText(news.getScontent());
holder.theme.setText(news.getStittle());
holder.time.setText( String.valueOf(news.getStime() ));
//holder.time.setText(news.getTime());
}
private void UpdateNewsBrowseNum(String nid){
final String url = BaseActivity.SERVER_URL + "/browse-servlet?action=UpdateBrowse";
final Map<String,String> paramMap = new HashMap<String,String>();
Log.e("获取浏览量的返回结果","浏览量");
paramMap.put("id", nid);//把资讯编号nid放进去
//登录后需要将uid换为这部分
// paramMap.put("uid", String.valueOf(BaseActivity.owner.getNetId()));
paramMap.put("uid", String.valueOf(1));//现假设都是用户1操作
// 只对资讯进行更新资讯的类型是1
paramMap.put("type", String.valueOf(1));
new Thread(new Runnable() {
@Override
public void run() {
Log.e("获取浏览量的返回结果uid",String.valueOf(1));
String jsonStr = OkHttpUtil.synPost(url,paramMap);
Log.e("浏览量的返回结果",jsonStr);
}
}).start();
}
// private void updateNewsBrowse(int nid){
// new Thread(new Runnable() {
// @Override
// public void run() {
// try{
// String url = BaseActivity.SERVER_URL + "/news-servlet?action=update-nBrowse";
// OkHttpUtil.synGet(url); //同步的Get
//
// }catch (Exception e){
// e.printStackTrace();
// }
// }
// }).start();
// }
@Override
public int getItemCount() {
return mNewsList.size();
}
}

@ -56,7 +56,7 @@ public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHo
@Override
public QuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.question_item,parent,false);
QuestionAdapter.ViewHolder holder=new QuestionAdapter.ViewHolder(view);
final QuestionAdapter.ViewHolder holder=new QuestionAdapter.ViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -70,7 +70,7 @@ public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHo
return holder;
}
private void addQuestionBrowse(int qid) {
private void addQuestionBrowse(final int qid) {
new Thread(new Runnable() {
@Override
public void run() {

@ -2,6 +2,7 @@ package com.example.leudaemialikeme.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -11,64 +12,43 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.InfoActivity;
import com.example.leudaemialikeme.Activity.MdctRmdActivity;
import com.example.leudaemialikeme.Activity.SearchActivity;
import com.example.leudaemialikeme.Adapter.RecnewsAdapter;
import com.example.leudaemialikeme.Model.Recnews;
import com.example.leudaemialikeme.Activity.NewsSearchActivity;
import com.example.leudaemialikeme.Adapter.NewsAdapter;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A simple {@link Fragment} subclass.
* Use the {@link IndexFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class IndexFragment extends Fragment {
private List<Recnews> recNews=new ArrayList<>();
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public class IndexFragment extends Fragment {
private boolean isPause = false;
private List<News> newsLists = new ArrayList<News>();
private RecyclerView recyclerView;
private NewsAdapter adapter;
public IndexFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* @param param1 Parameter 1.
* @param param2 Parameter 2.
* @return A new instance of fragment IndexFragment.
*/
// TODO: Rename and change types and number of parameters
public static IndexFragment newInstance(String param1, String param2) {
IndexFragment fragment = new IndexFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
// set_eSearch_TextChanged(adapter);
}
@Override
@ -76,12 +56,18 @@ public class IndexFragment extends Fragment {
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view=inflater.inflate(R.layout.fragment_index, container, false);
initRecNews();
RecyclerView recyclerView=(RecyclerView) view.findViewById(R.id.recommend_news);
initRecNews();//初始化精选资讯的数据源
recyclerView=(RecyclerView) view.findViewById(R.id.recommend_news);//获取推荐资讯的布局
LinearLayoutManager layoutManager=new LinearLayoutManager(this.getActivity());
recyclerView.setLayoutManager(layoutManager);
RecnewsAdapter recnewsAdapter =new RecnewsAdapter(recNews);
recyclerView.setAdapter(recnewsAdapter);
//initRecNews();//初始化数据源
adapter = new NewsAdapter();
adapter.setRecnewsList(newsLists);//这里设置数据源
// Log.e("adapter:",String.valueOf(newsLists));
recyclerView.setAdapter(adapter);
initClick(view);
@ -89,6 +75,10 @@ public class IndexFragment extends Fragment {
}
private void initClick(View view){
LinearLayout searchLinear=view.findViewById(R.id.search_linear);
LinearLayout recLinear=view.findViewById(R.id.rec_linear);
@ -100,11 +90,12 @@ public class IndexFragment extends Fragment {
LinearLayout charity=view.findViewById(R.id.charity);
LinearLayout all=view.findViewById(R.id.all);
//首页搜索的跳转
searchLinear.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
Intent intent=new Intent(getContext(), SearchActivity.class);
Intent intent=new Intent(getContext(), NewsSearchActivity.class);
startActivity(intent);
}
});
@ -127,7 +118,8 @@ public class IndexFragment extends Fragment {
@Override
public void onClick(View view) {
Intent intent=new Intent(getContext(), MdctRmdActivity.class);
startActivity(intent); }
startActivity(intent);
}
});
companyLinear.setOnClickListener(new View.OnClickListener(){
@ -185,33 +177,76 @@ public class IndexFragment extends Fragment {
}
//int imageNum,String theme,String intro,int visNum, String time
private void initRecNews(){
for(int i=0;i<2;i++){
Recnews news1=new Recnews(R.drawable.rec_news1,
"儿童急性B淋巴细胞白血病,除了传统疗法还有哪些前沿治疗方法呢?",
"急性淋巴细胞白血病ALL是儿童最常见的恶性肿瘤其中约85%为……"
,102,"2021-11-6 09:19:54"
);
recNews.add(news1);
Recnews news2=new Recnews(R.drawable.rec_news2,
"儿童急性B淋巴细胞白血病,除了传统疗法还有哪些前沿治疗方法呢?",
"急性淋巴细胞白血病ALL是儿童最常见的恶性肿瘤其中约85%为……"
,100,"2021-12-6 03:19:54"
);
recNews.add(news2);
Recnews news3=new Recnews(R.drawable.rec_news3,
"儿童急性B淋巴细胞白血病,除了传统疗法还有哪些前沿治疗方法呢?",
"急性淋巴细胞白血病ALL是儿童最常见的恶性肿瘤其中约85%为……"
,100,"2021-12-6 03:19:54"
);
recNews.add(news3);
Recnews news4=new Recnews(R.drawable.rec_news4,
"儿童急性B淋巴细胞白血病,除了传统疗法还有哪些前沿治疗方法呢?",
"急性淋巴细胞白血病ALL是儿童最常见的恶性肿瘤其中约85%为……"
,100,"2021-12-6 03:19:54"
);
recNews.add(news4);
private void initRecNews(){ //需要将资讯的信息从数据库里取出来,然后根据浏览量降序排列
Map<String,String> paramMap = new HashMap<String,String>();
getInfoRequest(paramMap);
}
private void getInfoRequest(final Map paramMap){//Info请求
new Thread(new Runnable(){ //新开一个线程
@Override
public void run() {
try{
String url= BaseActivity.SERVER_URL+"/news-servlet?action=get-infoIndex";//这里对应Eclipse的Servlet的
OkHttpUtil.asyPost(url, paramMap, new Callback() { //异步post
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();//这里就调用InfoResponse响应
Log.e("首页Info的json",jsonStr);
getInfoResponse(jsonStr);
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getInfoResponse(final String jsonStr){//这里是info响应
getActivity().runOnUiThread(new Runnable(){ //新开一个线程
@Override
public void run() {
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<News>>() {}.getType();
// 把获取到的信息集合存到 newsList 中
newsLists = gson.fromJson(jsonStr, listType);
Log.e("jsonStr",jsonStr);
Log.e("object", String.valueOf(newsLists));
Log.e("newsLists最后",String.valueOf(newsLists));
newsLists = gson.fromJson(jsonStr, listType);
adapter.setRecnewsList(newsLists);//这里设置数据源
recyclerView.setAdapter(adapter);
}
});
}
@Override
public void onPause() {
super.onPause();
isPause = true; //记录页面已经被暂停
}
@Override
public void onResume() {
super.onResume();
if (isPause) { //判断是否暂停
isPause = false;
//刷新页面的显示
//得到请求,然后刷新页面
Map<String,String> paramMap = new HashMap<String,String>();
getInfoRequest(paramMap);
adapter.setRecnewsList(newsLists);//这里设置数据源
recyclerView.setAdapter(adapter);//更新显示
}
}
}

@ -0,0 +1,482 @@
package com.example.leudaemialikeme.Fragment;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Adapter.NewsAdapter;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class InfoChannelFragment extends Fragment {
private static final String ARG_CATEGORY_TITLE = "category_title";
private static final String ARG_CATEGORY_TITLE_NUM = "category_title_num";
private String InfoCategoryTitle = "Default";
private int infoCategoryTitleNum = 0;
public static List<News> allNews=new ArrayList<>();
private List<News> comNews=new ArrayList<>();//公司
private List<News> redNews=new ArrayList<>();//红十字
private List<News> govNews=new ArrayList<>();//政府
private List<News> chaNews=new ArrayList<>();//慈善
// static BlogAdapter allAdapter=new BlogAdapter();
private NewsAdapter comAdapter;//公司的adapter
private NewsAdapter redAdapter;//红十字的adapter
private NewsAdapter govAdapter;//政府的adapter
private NewsAdapter chaAdapter;
RecyclerView allRecyclerView;//全部的RecyclerView
RecyclerView comRecyclerView;//公司的RecyclerView
RecyclerView redRecyclerView;//红十字的RecyclerView
RecyclerView govRecyclerView;//政府的RecyclerView
RecyclerView chaRecyclerView;//慈善的RecyclerView
private boolean isPause = false;
private final String[] channelList = {"全部","公司","红十字","政府","慈善"};
public InfoChannelFragment() {
// Required empty public constructor
}
public static InfoChannelFragment newInstance(String InfoCategoryTitle,int pos) {
InfoChannelFragment fragment = new InfoChannelFragment();
Bundle args = new Bundle();
args.putString(ARG_CATEGORY_TITLE,InfoCategoryTitle);
args.putInt(ARG_CATEGORY_TITLE_NUM,pos);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
InfoCategoryTitle = (String)getArguments().getString(ARG_CATEGORY_TITLE);
infoCategoryTitleNum = getArguments().getInt(ARG_CATEGORY_TITLE_NUM);
}catch (NullPointerException e){
System.out.println("TesFragment getArg error!");
}
//initRecNews();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view;
view = inflater.inflate(R.layout.recyclerview,container,false);
// initAllNews();//所有new组
//全部,公司,红十字,政府,慈善
// comAdapter=new NewsAdapter();
// comAdapter.setRecnewsList(comNews);
//
// redAdapter=new NewsAdapter();
// redAdapter.setRecnewsList(redNews);
//
// govAdapter=new NewsAdapter();
// govAdapter.setRecnewsList(govNews);
//
// chaAdapter=new NewsAdapter();
// chaAdapter.setRecnewsList(chaNews);
if (infoCategoryTitleNum == 0) {//这里是全部的那个内导航
view = inflater.inflate(R.layout.recyclerview,container,false);
allRecyclerView= (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
allRecyclerView.setLayoutManager(layoutManager);
NewsAdapter allAdapter = new NewsAdapter(allNews);
allRecyclerView.setAdapter(allAdapter);
initAllNewsList();//初始化数据
allAdapter.notifyDataSetChanged();
} else if (infoCategoryTitleNum == 4) {//这里是慈善
chaRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
chaAdapter = new NewsAdapter(chaNews);
chaRecyclerView.setLayoutManager(layoutManager);
chaRecyclerView.setAdapter(chaAdapter);
Map<String,String[]> paramMap_cha = new HashMap<String,String[]>();
paramMap_cha.put("channelList", new String[]{"慈善"});
getChaListRequest(paramMap_cha);
} else if (infoCategoryTitleNum == 2) {//这里是红十字
redRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
redAdapter = new NewsAdapter(redNews);
redRecyclerView.setLayoutManager(layoutManager);
redRecyclerView.setAdapter(redAdapter);
Map<String,String[]> paramMap_gov = new HashMap<String,String[]>();
paramMap_gov.put("channelList", new String[]{"红十字"});
getRedListRequest(paramMap_gov);
} else if (infoCategoryTitleNum == 3) {//这里是政府
govRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
govAdapter = new NewsAdapter(govNews);
govRecyclerView.setLayoutManager(layoutManager);
govRecyclerView.setAdapter(govAdapter);
Map<String,String[]> paramMap_gov = new HashMap<String,String[]>();
paramMap_gov.put("channelList", new String[]{"政府"});
getGovListRequest(paramMap_gov);
}
else if (infoCategoryTitleNum == 1) {//这里是公司
comRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
comAdapter = new NewsAdapter(comNews);
comRecyclerView.setLayoutManager(layoutManager);
comRecyclerView.setAdapter(comAdapter);
Map<String,String[]> paramMap_com = new HashMap<String,String[]>();
paramMap_com.put("channelList", new String[]{"公司"});
getComListRequest(paramMap_com);
}
return view;
}
private void initAllNewsList(){
Map<String,String[]> paramMap = new HashMap<String,String[]>();
paramMap.put("channelList", new String[]{"全部"});
getAllNewsListRequest(paramMap);
//getQuestionListRequest();
}
private void initAllNews(){ //初始化全部的资讯
//全部,公司,红十字,政府,慈善
// Map<String,String[]> paramMap_all = new HashMap<String,String[]>();
Map<String,String[]> paramMap_com = new HashMap<String,String[]>();
Map<String,String[]> paramMap_red = new HashMap<String,String[]>();
Map<String,String[]> paramMap_gov = new HashMap<String,String[]>();
Map<String,String[]> paramMap_cha = new HashMap<String,String[]>();
// paramMap.put("channelList",java.util.Arrays.copyOf(channelList,1));
paramMap_com.put("channelList", new String[]{"公司"});
paramMap_red.put("channelList", new String[]{"红十字"});
paramMap_gov.put("channelList",new String[]{"政府"});
paramMap_cha.put("channelList",new String[]{"慈善"});
getComListRequest(paramMap_com);
getRedListRequest(paramMap_red);
getGovListRequest(paramMap_gov);
getChaListRequest(paramMap_cha);//慈善
}
private void getComListRequest(final Map paramMap){//公司的Request
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = BaseActivity.SERVER_URL + "/news-servlet?action=get-info";
OkHttpUtil.asyPost(url, paramMap, new Callback(){//异步
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
Log.e("公司的request的str",jsonStr);
getComInfoResponse(jsonStr);
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getGovListRequest(final Map paramMap){//政府的request
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = BaseActivity.SERVER_URL + "/news-servlet?action=get-info";
OkHttpUtil.asyPost(url, paramMap, new Callback(){
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
getGovInfoResponse(jsonStr);//得到响应
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getRedListRequest(final Map paramMap){//红十字的request
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = BaseActivity.SERVER_URL + "/news-servlet?action=get-info";
OkHttpUtil.asyPost(url, paramMap, new Callback(){
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
getRedInfoResponse(jsonStr);
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getChaListRequest(final Map paramMap){//慈善的request
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = BaseActivity.SERVER_URL + "/news-servlet?action=get-info";
OkHttpUtil.asyPost(url, paramMap, new Callback(){
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
getChaInfoResponse(jsonStr);
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getAllNewsListRequest(final Map paramMap) {//全部(第一栏)
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = BaseActivity.SERVER_URL + "/news-servlet?action=get-info";
OkHttpUtil.asyPost(url, paramMap, new Callback() {//异步的方法
@Override
public void onFailure(Call call, IOException e) {
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
getAllNewsListResponse(jsonStr);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getAllNewsListResponse(final String jsonStr){
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson=new Gson();
Type listType = new TypeToken<List<List<News>>>() {}.getType();
Log.e("AllBlogList:jsonStr",jsonStr);
List<News> lists = gson.fromJson(jsonStr, listType);
// List<Blog> allBlogList=new ArrayList<>();
lists = (List<News>) lists.get(0);
allNews=lists;
// List<List<News>> lists = gson.fromJson(jsonStr, listType);
//// List<Blog> allBlogList=new ArrayList<>();
// allNews = (List<News>) lists.get(0);//标记
Log.e("allNews的数据",String.valueOf(lists));
NewsAdapter allAdapter=new NewsAdapter(allNews);
allRecyclerView.setAdapter(allAdapter);
}
});
}
private void getComInfoResponse(final String jsonStr){//公司的Response
getActivity().runOnUiThread(new Runnable(){
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
Log.e("公司的Response的jsonStr",jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<News>>>() {}.getType();
// Log.e("jsonStr",jsonStr);
List<List<News>> lists = gson.fromJson(jsonStr, listType);
Log.e("公司的lists",String.valueOf(lists));
List<News> comNewsList=new ArrayList<>();
comNewsList = (List<News>) lists.get(0);
comNews=comNewsList;
Log.e("comNews的数据(公司)",String.valueOf(comNewsList));
comAdapter = new NewsAdapter(comNews);
comRecyclerView.setAdapter(comAdapter);
}
});
}
private void getRedInfoResponse(final String jsonStr){//红十字的Response
getActivity().runOnUiThread(new Runnable(){
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
Log.e("红十字的Response的jsonStr",jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<News>>>() {}.getType();
// Log.e("jsonStr",jsonStr);
List<List<News>> lists = gson.fromJson(jsonStr, listType);
List<News> redNewsList=new ArrayList<>();
redNewsList = (List<News>) lists.get(0);
redNews=redNewsList;
Log.e("resNews的数据(公司)",String.valueOf(redNewsList));
redAdapter = new NewsAdapter(redNews);
redRecyclerView.setAdapter(redAdapter);
// Log.e("badBlog",String.valueOf(badBlogList));
}
});
}
private void getGovInfoResponse(final String jsonStr){//政府的Response
getActivity().runOnUiThread(new Runnable(){
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
Log.e("政府的Response的jsonStr",jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<News>>>() {}.getType();
// Log.e("jsonStr",jsonStr);
List<List<News>> lists = gson.fromJson(jsonStr, listType);
List<News> govNewsList=new ArrayList<>();
govNewsList = (List<News>) lists.get(0);
govNews=govNewsList;
Log.e("govNews的数据(公司)",String.valueOf(govNewsList));
govAdapter = new NewsAdapter(govNews);
govRecyclerView.setAdapter(govAdapter);
// Log.e("govNews的数据",String.valueOf(recBlogList));
}
});
}
private void getChaInfoResponse(final String jsonStr){//慈善的Response
getActivity().runOnUiThread(new Runnable(){
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
Log.e("慈善的Response的jsonStr",jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<News>>>() {}.getType();
// Log.e("jsonStr",jsonStr);
List<List<News>> lists = gson.fromJson(jsonStr, listType);
List<News> chaNewsList=new ArrayList<>();
chaNewsList = (List<News>) lists.get(0);
chaNews=chaNewsList;
Log.e("chaNews的数据(公司)",String.valueOf(chaNewsList));
chaAdapter = new NewsAdapter(chaNews);
chaRecyclerView.setAdapter(chaAdapter);
// Log.e("chaNews的数据",String.valueOf(recBlogList));
}
});
}
@Override
public void onPause() {
super.onPause();
isPause = true; //记录页面已经被暂停
}
@Override
public void onResume() {
super.onResume();
if (isPause) { //判断是否暂停
isPause = false;
if (infoCategoryTitleNum == 0) {
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"全部"});
getAllNewsListRequest(paramMap);
NewsAdapter allAdapter = new NewsAdapter(allNews);
allRecyclerView.setAdapter(allAdapter);
}else if(infoCategoryTitleNum == 4) {//4是慈善
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"慈善"});
getChaListRequest(paramMap);
NewsAdapter chaAdapter = new NewsAdapter(chaNews);
chaRecyclerView.setAdapter(chaAdapter);
}else if(infoCategoryTitleNum == 2) { //2是红十字
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"红十字"});
getRedListRequest(paramMap);
NewsAdapter redAdapter = new NewsAdapter(redNews);
redRecyclerView.setAdapter(redAdapter);
Log.e("浏览量更新","已更新");
}else if(infoCategoryTitleNum == 3) { //3是政府
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"政府"});
getGovListRequest(paramMap);
NewsAdapter govAdapter = new NewsAdapter(govNews);
govRecyclerView.setAdapter(govAdapter);
}else if(infoCategoryTitleNum == 1) { //1是公司
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"公司"});
getComListRequest(paramMap);
NewsAdapter comAdapter = new NewsAdapter(comNews);
comRecyclerView.setAdapter(comAdapter);
}
}
}
}

@ -0,0 +1,126 @@
package com.example.leudaemialikeme.Fragment;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import com.example.leudaemialikeme.Adapter.InfoPageFragmentAdapter;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
import java.util.ArrayList;
import java.util.List;
public class InfoFragment extends Fragment implements ViewPager.OnPageChangeListener{
private static final String ARG_CHANNEL_LIST = "channel_list_info";
private View view=null; // 碎片的布局实例
private ViewPager viewPager; //内导航的碎片的容器
private RadioGroup rgChannel=null; // 内导航由单选按钮组构成
private HorizontalScrollView hvChannel=null; //单选按钮组可滚动
private String[] channelList = {" 全部 "," 公司 "," 红十字 "," 政府 "," 慈善 "}; //默认的内导航栏目
private InfoPageFragmentAdapter adapter; //资讯viewPager 的适配器
static List<List<News>> resourceList=new ArrayList<>();
static List<News> newsList=new ArrayList<>();
public InfoFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if(view==null) {
view = inflater.inflate(R.layout.fragment_info, container, false);//显示碎片的布局
viewPager=(ViewPager)view.findViewById(R.id.vpNewsListInfo);//加了这,后面就闪退了
initViewPager(); //设置 ViewPager
rgChannel=(RadioGroup)view.findViewById(R.id.rgChannel20);
hvChannel=(HorizontalScrollView)view.findViewById(R.id.hvChannel20);
initTab(inflater);//初始化内导航标签
rgChannel.setOnCheckedChangeListener( //单选按钮的监听事件
new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
viewPager.setCurrentItem(checkedId);
}
}
);
}
return view;
}
private void initTab(LayoutInflater inflater) {
for(int i=0;i<channelList.length;i++){
RadioButton rb=(RadioButton)inflater.inflate(R.layout.invitation_tab_rb,null);
rb.setId(i);
rb.setText(channelList[i]);
RadioGroup.LayoutParams params = new
RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
rgChannel.addView(rb,params);
}
rgChannel.check(0);
}
private void initViewPager() {
FragmentManager fragmentManager = super.getActivity().getSupportFragmentManager();
adapter=new InfoPageFragmentAdapter(fragmentManager, channelList);
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片
// 设置 ViewPager 的适配器
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(1); //viewpager是默认预加载下一页的界面的
// viewpager提供了一个设置预加载页面数量的方法,让ViewPager多缓存一个页面
viewPager.setCurrentItem(0); //设置显示第1个碎片
viewPager.addOnPageChangeListener((ViewPager.OnPageChangeListener) this);//设置 ViewPager 的切换监听
}
public static List<News> getNewsList(){
return newsList;
}
public static List<List<News>> getResourceList(){
return resourceList;
}
private void setTab(int idx){
RadioButton rb=(RadioButton)rgChannel.getChildAt(idx);
rb.setChecked(true);
int left=rb.getLeft();
int width=rb.getMeasuredWidth();
DisplayMetrics metrics=new DisplayMetrics();
super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screenWidth=metrics.widthPixels;
int len=left+width/2-screenWidth/2;
hvChannel.smoothScrollTo(len,0);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
setTab(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
}

@ -27,6 +27,14 @@ public class News implements Serializable {
this.sbrowseNum = sbrowseNum;
}
public News(int nid,String stype,String stittle,String scontent,Timestamp stime,int sbrowseNum) {
this.nid=nid;
this.stype=stype;
this.stittle=stittle;
this.scontent=scontent;
this.stime=stime;
this.sbrowseNum=sbrowseNum;
}
public int getNid() {
return nid;

@ -58,17 +58,17 @@
android:entries="@array/languages" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@drawable/info_background">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/info_recyclerView"
android:layout_margin="10dp"
<FrameLayout
android:id="@+id/infoFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="0dp"
android:layout_weight="1" />
<!-- <fragment-->
<!-- android:id="@+id/master_fragment_id"-->
<!-- android:name="com.example.leudaemialikeme.Fragment.InfoFragment"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"/>-->
</LinearLayout>
</LinearLayout>

@ -0,0 +1,224 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/detail_to"
android:layout_width="47dp"
android:layout_height="34dp"
android:layout_gravity="center"
android:src="@drawable/back" />
<TextView
android:id="@+id/textView30"
android:layout_width="306dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="详情"
android:textSize="19dp"
android:textStyle="bold" />
<ImageView
android:id="@+id/detail_to_search"
android:layout_width="66dp"
android:layout_height="match_parent"
app:srcCompat="@android:drawable/ic_menu_search" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/detail_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="急性白血病经验分享:第一帖"
android:maxLines="2"
android:ellipsize="end"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="10dp"
android:background="#FFFFFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView13"
android:layout_width="104dp"
android:layout_height="40dp"
android:layout_weight="1"
app:srcCompat="@drawable/person" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp">
<TextView
android:id="@+id/author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="小白帮宇宙唯一官方认证号"
android:textSize="16dp"/>
<TextView
android:id="@+id/author_intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="管住嘴,迈开腿,多喝水" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/sContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="缘起: 一直以来都有很多人劝我希望我可以把自己的经历写下来,我的医生,我的同学,
我的朋友,他们觉得我的经历很有意义,虽然我自己也认同这一点,一直很难以动笔,原因有二,其一觉得
自己学理工的,对自己的文笔没什么自信。其二过往的经历实在是痛苦,写下来的过程无异于把好不容易重
合的伤疤撕开一次,自己的内心实在是有点胆怯。\n \n一谈谈我对白血病的看法\n
初次知道白血病是通过日本电影《血疑》,我相信和我年纪相当的人很多也都是通过这部电影知道这个疾病,当然我从未想过我
会与此牵扯上关系甚至在自己22岁以后的生命中处处时时需要考虑它对我的影响。我初次得病是1998年在那个年代白血病
的确依旧是一个很恐怖的病,我当初的症状就是四肢布满红色出血点,低烧吵死不退,牙龈出血,记得每次早上起床,嘴里总是
有凝结的血块,那是虽然不懂这是怎么回事,但是总是担心的要命,于是便经常刷牙,希望仅仅是上火所致,也不敢去看医生,
于是就自己买消炎药吃,希望可以平安过去。"
android:layout_gravity="center"
android:paddingTop="15dp"
android:layout_margin="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_margin="20dp">
<LinearLayout
android:id="@+id/detail_like"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:background="@drawable/search_background"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/view" />
<TextView
android:id="@+id/detail_like_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="0" />
<TextView
android:id="@+id/textView41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp" />
<!-- android:text="赞" -->
</LinearLayout>
<LinearLayout
android:id="@+id/detail_col"
android:layout_width="77dp"
android:layout_height="wrap_content"
android:background="@drawable/search_background"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView15"
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/collect" />
<TextView
android:id="@+id/detail_col_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="0" />
<TextView
android:id="@+id/textView43"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<!-- android:text="收藏" -->
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpNewsList_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--定义一个SearchView-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/search_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginTop="28dp"
android:layout_marginLeft="15dp"
android:src="@drawable/back" />
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/shape_round_corner"
android:orientation="horizontal">
<SearchView
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</SearchView>
<EditText
android:id="@+id/news_search_edit"
android:layout_width="220dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="center_vertical"
android:hint="请输入搜索内容" />
</LinearLayout>
<TextView
android:id="@+id/news_search_commit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:textSize="18dp"
android:text="搜索"
android:textColor="#f47920"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="搜索发现"
android:textSize="20dp"
android:layout_margin="30dp"
android:textColor="#000000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:background="@drawable/shape_round_corner"
android:gravity="center"
android:text="科普" />
<TextView
android:id="@+id/textView4"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:background="@drawable/shape_round_corner"
android:gravity="center"
android:text="食疗" />
<TextView
android:id="@+id/textView5"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginLeft="20dp"
android:layout_weight="1"
android:background="@drawable/shape_round_corner"
android:gravity="center"
android:text="政策" />
<TextView
android:id="@+id/textView6"
android:layout_width="80dp"
android:layout_height="35dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:background="@drawable/shape_round_corner"
android:gravity="center"
android:text="药物" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textView7"
android:layout_width="120dp"
android:layout_height="35dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:background="@drawable/shape_round_corner"
android:gravity="center"
android:text="暖心故事" />
<TextView
android:id="@+id/textView8"
android:layout_width="120dp"
android:layout_height="35dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:background="@drawable/shape_round3_corner"
android:textColor="#f47920"
android:gravity="center"
android:text="专家问答" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--定义一个SearchView-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/news_search_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginTop="28dp"
android:layout_marginBottom="28dp"
android:layout_marginLeft="15dp"
android:src="@drawable/back" />
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="@drawable/shape_round_corner"
android:orientation="horizontal">
<SearchView
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</SearchView>
<EditText
android:id="@+id/news_search_text"
android:layout_width="220dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="center_vertical"
/>
</LinearLayout>
<TextView
android:id="@+id/news_result_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:textSize="18dp"
android:text="取消"
android:textColor="#f47920"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/result_recyclerView"
android:layout_gravity="center"
android:layout_margin="10dp"
android:paddingLeft="15dp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,84 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.leudaemialikeme.Fragment.InfoFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!-- <LinearLayout-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:layout_marginLeft="10dp"-->
<!-- android:layout_marginTop="10dp"-->
<!-- android:layout_margin="10dp"-->
<!-- android:layout_marginRight="10dp"-->
<!-- android:orientation="horizontal">-->
<!-- <LinearLayout-->
<!-- android:layout_width="350dp"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="@drawable/search_background"-->
<!-- android:orientation="horizontal">-->
<!-- <ImageView-->
<!-- android:id="@+id/imageView5"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:src="@mipmap/img_search" />-->
<!-- <TextView-->
<!-- android:id="@+id/searchtext"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:gravity="center"-->
<!-- android:text="搜索资讯" />-->
<!-- </LinearLayout>-->
<!-- </LinearLayout>-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<!-- 导航标签,包含一个单选按钮组-->
<!-- 任意数量不能显示时的缩略符号 -->
<HorizontalScrollView
android:id="@+id/hvChannel20"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/ivShowChannel"
android:scrollbars="none">
<RadioGroup
android:id="@+id/rgChannel20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
<ImageView
android:id="@+id/ivShowChannel20"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="@mipmap/channel_down_narrow" />
</RelativeLayout>
</LinearLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpNewsListInfo"
android:layout_width="match_parent"
android:layout_height="0dp" android:layout_weight="1"/>
</LinearLayout>
</FrameLayout>

@ -0,0 +1,13 @@
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.leudaemialikeme.Fragment.InfoChannelFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/hello_blank_fragment" />
</FrameLayout>

@ -48,6 +48,12 @@
android:padding="11dp"
tools:ignore="MissingConstraints">
<TextView
android:id="@+id/text_news_id"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="" />
<TextView
android:id="@+id/recNews_theme"
android:layout_width="match_parent"
@ -77,6 +83,12 @@
李冬冬的辅导员说,后续会根据李冬冬的治疗情况,为李冬冬制定新的帮扶方案。
"
android:textSize="11dp" />
<ImageView
android:id="@+id/recNews_image"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
app:srcCompat="@drawable/rec_news1" />
</LinearLayout>

Loading…
Cancel
Save