parent
2981fdc602
commit
e7371cc45f
@ -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);//更新数据
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}//返回有效视图的数量
|
||||
}
|
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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>
|
Loading…
Reference in new issue