发帖+提问(修补bug)

master
hjw 3 years ago
parent 7cfd288349
commit c4c5378aa7

@ -28,10 +28,44 @@
<activity android:name=".Activity.AnswerActivity" />
<activity android:name=".Activity.QuestionDetailActivity" />
<activity android:name=".Activity.BlogSearchResultActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
></activity>
<activity
android:name=".Activity.BlogSearchActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<meta-data
android:name="com.google.android.actions"
android:resource="@xml/network_security_config" />
<activity
android:name=".Activity.BaseActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<activity
android:name=".Activity.MainActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
>
</activity>
<activity
android:name=".Activity.ChatActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<activity android:name=".Activity.AttentionActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<activity android:name=".Activity.HistoryActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<activity android:name=".Activity.CollectActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<activity android:name=".Activity.SafetyActivity"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
<activity android:name=".Activity.BaseActivity" />
<activity android:name=".Activity.MainActivity" />
<activity android:name=".Activity.ChatActivity" />

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

@ -0,0 +1,342 @@
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.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;
import com.example.leudaemialikeme.Adapter.CommentAdapter;
import com.example.leudaemialikeme.Model.Blog;
import com.example.leudaemialikeme.Model.Comment;
import com.example.leudaemialikeme.Model.User;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.Data;
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.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class BlogDetailActivity extends BaseActivity {
TextView bTitleView;
TextView bAuthorNameView;
TextView bContentView;
TextView bViewNumView;
TextView bColNumView;
TextView bComNumView;
EditText comEditView;
TextView comComView;
ImageView detail_to;
ImageView search;
ImageView bColImage;
Blog blog=new Blog();
User author;
List<Comment> commentList=new ArrayList<>();
CommentAdapter commentAdapter=new CommentAdapter();
RecyclerView recyclerView;
LinearLayout detailColView;
private static ViewPager viewPager; //内导航的碎片的容器
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blogdetail);
Intent intent=getIntent();//新增bid
blog.setBid(Integer.parseInt(intent.getStringExtra("bid")));//新增bid
blog.setBcontent(intent.getStringExtra("bContent"));
blog.setBtittle(intent.getStringExtra("bTitle"));
Log.e("传输后的bid",String.valueOf(blog.getBid()));
blog.setBcollectNum(Integer.parseInt(intent.getStringExtra("bColNum")));
blog.setBbrowse((Integer.parseInt(intent.getStringExtra("bViewNum"))));
blog.setUid(Integer.parseInt(intent.getStringExtra("uid")));
initView();
setData();
initClick();
recyclerView=(RecyclerView)findViewById(R.id.comment_recyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
commentAdapter=new CommentAdapter();
initComments();
Log.e("commentList",String.valueOf(commentList));
commentAdapter.setMCommentList(commentList);
recyclerView.setAdapter(commentAdapter);
}
private Blog getBlogByBid(String bid){
new Thread(new Runnable() {
@Override
public void run() {
}
}).start();
return null;
}
private void initComments() {
new Thread(new Runnable() {
@Override
public void run() {
String url=BaseActivity.SERVER_URL+"/comment-servlet?action=getCommentByBid";
Map<String,String> paramMap=new HashMap<String,String>();
paramMap.put("bid",String.valueOf(blog.getBid()));
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();
runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson=new Gson();
Log.e("comment",jsonStr);
Type listType=new TypeToken<List<Comment>>(){}.getType();
commentList = gson.fromJson(jsonStr,listType);
Log.e("onResponse:commentList",String.valueOf(commentList));
bComNumView.setText("("+String.valueOf(commentList.size())+")");
commentAdapter.setMCommentList(commentList);
recyclerView.setAdapter(commentAdapter);
}
});
}
});
}
}).start();
}
private void setBlogAuthorName(String uid){
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = BaseActivity.SERVER_URL + "/main-servlet?action=getUserById";
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("uid", String.valueOf(blog.getUid()));
Log.e("设置帖子的作者uid",uid);
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();
runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
// Log.e("Blog's Str",jsonStr);
Type listType = new TypeToken<User>() {}.getType();
author = gson.fromJson(jsonStr, listType);
// bAuthorNameView=findViewById(R.id.author);
bAuthorNameView.setText(author.getUsername());
}
});
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void initView(){
bTitleView=findViewById(R.id.detail_theme);
bAuthorNameView=findViewById(R.id.author);
bContentView=findViewById(R.id.bContent);
bViewNumView=findViewById(R.id.detail_view_num);
bColNumView=findViewById(R.id.detail_col_num);
bComNumView=findViewById(R.id.comment_num);
comEditView=findViewById(R.id.comment_edit);
comComView=findViewById(R.id.comment_commit);
detail_to=findViewById(R.id.detail_to);
search=findViewById(R.id.detail_to_search);
detailColView=findViewById(R.id.detail_like);
detailColView=findViewById(R.id.detail_col);
bColImage=findViewById(R.id.imageView15);
}
private void setData(){
setBlogAuthorName(String.valueOf(blog.getUid()));
// setBColNumViewImage(blog.getBid(),BaseActivity.owner.getNetId()); 需要传入登录用户的id
setBColNumViewImage(blog.getBid(),1,2);
bViewNumView.setText(String.valueOf(blog.getBbrowse()));
bTitleView.setText(blog.getBtittle());
bContentView.setText(blog.getBcontent());
bColNumView.setText(String.valueOf(blog.getBcollectNum()));
}
private void setBColNumViewImage(int bid,int uid,int type){
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";
new Thread(new Runnable() {
@Override
public void run() {
String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
runOnUiThread(new Runnable() {
@Override
public void run() {
Log.e("ColNumViewImage-jsonStr",jsonStr);
if(!jsonStr.contains("not")){
bColImage.setImageResource(R.drawable.collect_pick);
bColImage.setTag(R.drawable.collect_pick);
}else{
bColImage.setImageResource(R.drawable.collect);
bColImage.setTag(R.drawable.collect);
}
}
});
System.out.println("更新collect表成功");
}
}).start();
}
private void initClick(){
detail_to.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finish();
}
});
search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(BlogDetailActivity.this,BlogSearchActivity.class);
startActivity(intent);
}
});
comComView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String cont = comEditView.getText().toString();
//获取已登录的用户的信息获取后的结果为user需要把这两句改成owner获取的user对象。
Data app= (Data) getApplication();
User user=app.getUser();
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(),
cont,2);
Map<String,Comment> paramMap=new HashMap<String,Comment>();
paramMap.put("comment",comment);
String url=BaseActivity.SERVER_URL+"/comment-servlet?action=insertComment";
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 {
String jsonStr = response.body().string();
// Log.e("提交评论",jsonStr);
runOnUiThread(new Runnable() {
@Override
public void run() {
commentList.add(comment);
commentAdapter.setMCommentList(commentList);
recyclerView.setAdapter(commentAdapter);
comEditView.setText("");
bComNumView.setText("("+String.valueOf(commentList.size())+")");
}
});
}
});
}
}).start();
}
});
detailColView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Map<String,Integer> paramMap=new HashMap<String, Integer>();
paramMap.put("bid",blog.getBid());
paramMap.put("uid", 1);
paramMap.put("type",2);
String url_collect=BaseActivity.SERVER_URL+"/collect-servlet?action=InsertCollect";
int imageId=getDrawableId(bColImage);
if(imageId==R.drawable.collect) {
bColImage.setImageResource(R.drawable.collect_pick);
bColImage.setTag(R.drawable.collect_pick);
}else {
bColImage.setImageResource(R.drawable.collect);
bColImage.setTag(R.drawable.collect);
}
new Thread(new Runnable() {
@Override
public void run() {
String jsonStr=OkHttpUtil.synPost(url_collect,paramMap);
runOnUiThread(new Runnable() {
@Override
public void run() {
if(jsonStr.contains("insert")){
bColNumView.setText(String.valueOf(Integer.parseInt(bColNumView.getText().toString())+1));
Toast.makeText(BlogDetailActivity.this,
"已收藏",Toast.LENGTH_SHORT).show();
}else{
bColNumView.setText(String.valueOf(Integer.parseInt(bColNumView.getText().toString())-1));
Toast.makeText(BlogDetailActivity.this,
"取消收藏",Toast.LENGTH_SHORT).show();
}
}
});
System.out.println("更新collect表成功");
}
}).start();
}
});
}
private int getDrawableId(ImageView iv) {
return (Integer) iv.getTag();
}
}

@ -0,0 +1,131 @@
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 android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.example.leudaemialikeme.R;
public class BlogSearchActivity extends AppCompatActivity {
ImageView back;
EditText blogSearchEdit;
TextView blogSearchCommit;
TextView recView;
TextView foView;
TextView poView;
TextView meView;
TextView stView;
TextView exView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blog_search);
initView();
initClick();
}
private void initView(){
back = (ImageView)findViewById(R.id.search_back);
blogSearchEdit = (EditText)findViewById(R.id.blog_search_edit);
blogSearchCommit = (TextView) findViewById(R.id.blog_search_commit);
recView=(TextView)findViewById(R.id.recView);
foView=(TextView)findViewById(R.id.foView);
poView=(TextView)findViewById(R.id.poView);
meView=(TextView)findViewById(R.id.meView);
stView=(TextView)findViewById(R.id.stView);
exView=(TextView)findViewById(R.id.exView);
}
private void initClick(){
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
blogSearchCommit.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String text = blogSearchEdit.getText().toString();
if(text.length() != 0){
Intent intent=new Intent(BlogSearchActivity.this,BlogSearchResultActivity.class);
Log.e("onClick-text",text);
intent.putExtra("text",text);
startActivity(intent);}
else{
Toast.makeText(BlogSearchActivity.this, "请输入搜索的内容", Toast.LENGTH_SHORT).show();
}
}
});
recView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
skip(recView);
}
});
foView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skip(foView);
}
});
poView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skip(poView);
}
});
meView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skip(meView);
}
});
stView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skip(stView);
}
});
exView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
skip(exView);
}
});
}
private void skip(TextView view){
String text = view.getText().toString();
Intent intent=new Intent(BlogSearchActivity.this,BlogSearchResultActivity.class);
// Log.e("onClick-text",text);
intent.putExtra("text",text);
startActivity(intent);
}
}

@ -0,0 +1,134 @@
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.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.BlogAdapter;
import com.example.leudaemialikeme.Model.Blog;
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 BlogSearchResultActivity extends AppCompatActivity {
ImageView blogSearchBackView;
TextView blogSearchTextView;
TextView blogResultBackView;
RecyclerView resultRecyclerView;
List<Blog> resultBlog=new ArrayList<>();
private boolean isPause = false;
String text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blog_search_result);
Intent intent=getIntent();
text=intent.getStringExtra("text");
blogSearchTextView=(TextView) findViewById(R.id.blog_search_text);
blogSearchTextView.setText(text);
Log.e("text",text);
resultRecyclerView=(RecyclerView) findViewById(R.id.result_recyclerView);
LinearLayoutManager layoutManager=new LinearLayoutManager(this);
resultRecyclerView.setLayoutManager(layoutManager);
BlogAdapter resultAdapter = new BlogAdapter();
initView();
initData(text);
initClick();
resultAdapter.setRecnewsList(resultBlog);
resultRecyclerView.setAdapter(resultAdapter);
}
private void initView(){
blogSearchBackView=(ImageView) findViewById(R.id.blog_search_back);
blogResultBackView=(TextView)findViewById(R.id.blog_result_back);
}
private void initData(String text){
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";
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 {
Gson gson = new Gson();
String jsonStr = response.body().string();
Log.e("result jsonStr",jsonStr);
Type listType = new TypeToken<List<Blog>>() {}.getType();
List<Blog> resultList = gson.fromJson(jsonStr, listType);
resultBlog = resultList ;
runOnUiThread(new Runnable() {
@Override
public void run() {
BlogAdapter resultAdapter = new BlogAdapter();
resultAdapter.setRecnewsList(resultList);
resultRecyclerView.setAdapter(resultAdapter);
}
});
}
});
}
}).start();
}
private void initClick() {
blogSearchBackView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finish();
}
});
blogResultBackView.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);
}
}
}

@ -1,32 +0,0 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import com.example.leudaemialikeme.R;
public class DetailActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
ImageView detail_to=findViewById(R.id.detail_to);
detail_to.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finish();
}
});
ImageView search=findViewById(R.id.detail_to_search);
search.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent=new Intent(DetailActivity.this,SearchActivity.class);
startActivity(intent);
}
});
}
}

@ -10,10 +10,12 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.example.leudaemialikeme.Dao.QuestionDao;
import com.example.leudaemialikeme.Fragment.CommunityFragment;
import com.example.leudaemialikeme.Fragment.IndexFragment;
import com.example.leudaemialikeme.Fragment.MessageFragment;
import com.example.leudaemialikeme.Fragment.MyFragment;
import com.example.leudaemialikeme.Model.Blog;
import com.example.leudaemialikeme.R;
import java.util.ArrayList;
@ -38,6 +40,10 @@ public class MainActivity extends BaseActivity {
private TextView textMessage;
private TextView textMy;
private String[] channelList = {"全部","经验"
,"康复","扫雷","问答"}; //默认的内导航栏目
static List<List<Blog>> resourceList=new ArrayList<>();
//底部导航点击事件监听器
@ -67,7 +73,7 @@ public class MainActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().hide();
// getSupportActionBar().hide();
setContentView(R.layout.activity_main);
initFragments(); //初始化数据
initViews(); //初始化控件

@ -1,6 +1,5 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
@ -18,9 +17,7 @@ public class SearchActivity extends BaseActivity {
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(SearchActivity.this, MainActivity.class);
i.putExtra("flag",1);
startActivity(i);
finish();
}
});
}

@ -14,9 +14,12 @@ import android.widget.Toast;
import com.example.leudaemialikeme.Dao.InvitationDao;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.Data;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class SendInvitationActivity extends BaseActivity {
@ -62,44 +65,63 @@ public class SendInvitationActivity extends BaseActivity {
}
else{
long timeCurrent = System.currentTimeMillis();
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
String time = sdf.format(timeCurrent);
Log.e("输入的time:", time);
new Thread(new Runnable(){
@Override
public void run() {
try {
Data app = (Data)getApplication();
Log.e("type",type);
// invitation.iInsert(app.uid,type,title,detail,time,0,0);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(SendInvitationActivity.this,
"提交成功",Toast.LENGTH_SHORT).show();
}
});
} catch (Exception exception) {
exception.printStackTrace();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(SendInvitationActivity.this,
"帖子提交失败,请检查您的网络状况",Toast.LENGTH_SHORT).show();
}
});
}
}
}).start();
Data app = (Data)getApplication();
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("uid",String.valueOf(app.getUser().getIduser()));//需要获取登录用户的id
paramMap.put("btype",type);
paramMap.put("btittle",title);
paramMap.put("bcontent",detail);
paramMap.put("btime",time);
paramMap.put("blikeNum",String.valueOf(0));
paramMap.put("bcollectNum",String.valueOf(0));
paramMap.put("bbrowse",String.valueOf(0));
paramMap.put("flag",String.valueOf(0));
sendInvitationRequest(paramMap);
}
}
});
}
private void sendInvitationRequest(final Map paramMap){
new Thread(new Runnable(){
@Override
public void run() {
try{
String url=SendQuestionActivity.SERVER_URL+"/blog-servlet?action=send-invitation&useUnicode=true&characterEncoding=utf-8";
String jsonStr= OkHttpUtil.synPost(url, paramMap);
sendInvitationResponse(jsonStr);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void sendInvitationResponse(final String jsonStr){
runOnUiThread(new Runnable(){
@Override
public void run() {
if (jsonStr.contains("success")){
Toast.makeText(SendInvitationActivity.this,
"提交成功",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SendInvitationActivity.this,
"帖子提交失败,请检查您的网络状况",Toast.LENGTH_SHORT).show();
}
}
});
}
@SuppressLint("NonConstantResourceId")
public void onRadioButtonClicked(View view) {
RadioButton button = (RadioButton) view;
@ -110,11 +132,11 @@ public class SendInvitationActivity extends BaseActivity {
case R.id.SendInvitation_radio_experience:
case R.id.SendInvitation_radio_knowledge:
if (isChecked) {
type=button.getText().toString();
type=button.getText().toString().substring(0,2);
}
break;
default:
type="经验";
type="经验";
break;
}
}

@ -4,7 +4,6 @@ import android.annotation.SuppressLint;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
@ -13,9 +12,12 @@ import android.widget.Toast;
import com.example.leudaemialikeme.Dao.QuestionDao;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.Data;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class SendQuestionActivity extends BaseActivity {
@ -38,6 +40,7 @@ public class SendQuestionActivity extends BaseActivity {
setClick();
}
@SuppressWarnings("unchecked")
private void setClick() {
cancelView.setOnClickListener(new View.OnClickListener() {
@Override
@ -53,41 +56,35 @@ public class SendQuestionActivity extends BaseActivity {
title=titleText.getText().toString();
detail=detailText.getText().toString();
if(titleText.getText().toString().length()<10){
Log.e("输入的title:", String.valueOf(title.length()));
// Log.e("输入的title:", String.valueOf(title.length()));
Toast.makeText(SendQuestionActivity.this,
"您输入的字数尚不足,请完善您的问题以便获得更好的回答",Toast.LENGTH_SHORT).show();
}
else{
long timeCurrent = System.currentTimeMillis();
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
// String time = sdf.format(timeCurrent);
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
String time = sdf.format(timeCurrent);
// Log.e("输入的time:", time);
new Thread(new Runnable(){
@Override
public void run() {
try {
Data app = (Data)getApplication();
// question.qInsert(app.uid,title,detail,time,0,0,0);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(SendQuestionActivity.this,
"提交成功",Toast.LENGTH_SHORT).show();
}
});
} catch (Exception exception) {
exception.printStackTrace();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(SendQuestionActivity.this,
"问题提交失败,请检查您的网络状况",Toast.LENGTH_SHORT).show();
}
});
}
}
}).start();
Map<String,String> paramMap = new HashMap<String,String>();
Data app = (Data)getApplication();
paramMap.put("uid",String.valueOf(app.getUser().getIduser())); // 需要获取登陆用户的id需改
// Log.e("uid",String.valueOf(app.uid));
// for(String key:paramMap.keySet())
// {
// Log.e("Key: "+key," Value: "+paramMap.get(key));
// }
paramMap.put("qtittle",title);
paramMap.put("qcontent",detail);
paramMap.put("qtime",time);
paramMap.put("qfollowNum",String.valueOf(0));
paramMap.put("qanswerNum",String.valueOf(0));
paramMap.put("qbrowseNum",String.valueOf(0));
paramMap.put("flag",String.valueOf(0));
sendQuestionRequest(paramMap);
}
}
});
@ -95,6 +92,43 @@ public class SendQuestionActivity extends BaseActivity {
}
private void sendQuestionRequest(final Map paramMap){
new Thread(new Runnable() {
@Override
public void run() {
try{
String url=SendQuestionActivity.SERVER_URL+"/question-servlet?action=send-question";
String jsonStr= OkHttpUtil.synPost(url, paramMap);
// for(Object key:paramMap.keySet())
// {
// Log.e("Key: "+key," Value: "+paramMap.get(key));
// }
QuestionResponse(jsonStr);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void QuestionResponse(final String jsonStr){
runOnUiThread(new Runnable() {
@Override
public void run() {
if (jsonStr.contains("success")){
Toast.makeText(SendQuestionActivity.this,
"提交成功",Toast.LENGTH_SHORT).show();
}else{
Toast.makeText(SendQuestionActivity.this,
"问题提交失败,请检查您的网络状况", Toast.LENGTH_SHORT).show();
}
}
});
}
public void initViews(){
titleText=(EditText)findViewById(R.id.editText_question);

@ -0,0 +1,156 @@
package com.example.leudaemialikeme.Adapter;
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.BlogDetailActivity;
import com.example.leudaemialikeme.Model.Blog;
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 BlogAdapter extends RecyclerView.Adapter<BlogAdapter.ViewHolder> {
// private List<Recnews> mRecnewsList;
private List<Blog> mBlogList = new ArrayList<Blog>();
private Blog blog;
// private View view;
// private Context context;
// ViewHolder holder;
static class ViewHolder extends RecyclerView.ViewHolder{
ImageView image;
TextView theme;
TextView intro;
TextView visNum;
TextView time;
LinearLayout linear;
TextView blog_id_view;
TextView blog_likeNum_view;
TextView blog_colNum_view;
TextView blog_uid_view;
TextView blog_content_view;
public ViewHolder(View view){
super(view);
blog_likeNum_view=(TextView)view.findViewById(R.id.likeNum);
blog_colNum_view=(TextView)view.findViewById(R.id.colNum);
blog_id_view=(TextView)view.findViewById(R.id.bid);
blog_uid_view=(TextView)view.findViewById(R.id.uid);
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);
blog_content_view=(TextView)view.findViewById(R.id.content);
}
}
public BlogAdapter(List<Blog> blogList){
mBlogList=blogList;
// Log.e("recAdapter中mBlogList的数据",String.valueOf(blogList));
}
public BlogAdapter(){
}
public void setRecnewsList(List<Blog> blogList){
mBlogList=blogList;
}
@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);
// context=parent.getContext();
holder.linear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
UpdateBrowseNum(holder.blog_id_view.getText().toString());
Intent intent=new Intent(view.getContext(), BlogDetailActivity.class);
// intent.putExtra("from",String.valueOf(view.getContext()));
intent.putExtra("bid",holder.blog_id_view.getText().toString());//新增bid
// Log.e("传输前的bid",holder.blog_id_view.getText().toString());
intent.putExtra("type",2);//帖子2
intent.putExtra("bTitle",holder.theme.getText().toString());
intent.putExtra("bContent",holder.blog_content_view.getText().toString());
intent.putExtra("bColNum",holder.blog_colNum_view.getText().toString());
intent.putExtra("bViewNum",String.valueOf(Integer.parseInt(holder.visNum.getText().toString())+1));
intent.putExtra("uid",holder.blog_uid_view.getText().toString());
view.getContext().startActivity(intent);
}
});
return holder;
}
@Override
public void onBindViewHolder(@NonNull BlogAdapter.ViewHolder holder, int position) {
blog=mBlogList.get(position);
// holder.image.setImageResource(R.drawable.rec_news1);
holder.visNum.setText(String.valueOf(blog.getBbrowse()));
holder.intro.setText(blog.getBcontent());
holder.theme.setText(blog.getBtittle());
holder.time.setText(String.valueOf(blog.getBtime()).substring(0,19));
holder.blog_id_view.setText(String.valueOf(blog.getBid()));
holder.blog_colNum_view.setText(String.valueOf(blog.getBcollectNum()));
holder.blog_likeNum_view.setText(String.valueOf(blog.getBlikeNum()));
holder.blog_uid_view.setText(String.valueOf(blog.getUid()));
holder.blog_content_view.setText(blog.getBcontent());
}
@Override
public int getItemCount() {
return mBlogList.size();
}
private void UpdateBrowseNum(String bid){
String url = BaseActivity.SERVER_URL + "/browse-servlet?action=UpdateBrowse";
Map<String,String> paramMap = new HashMap<String,String>();
Log.e("获取浏览量的返回结果","浏览量");
paramMap.put("id", bid);
//登录后需要将uid换为这部分
// paramMap.put("uid", String.valueOf(BaseActivity.owner.getNetId()));
paramMap.put("uid", String.valueOf(1));
// 只对帖子进行更新
paramMap.put("type", String.valueOf(2));
new Thread(new Runnable() {
@Override
public void run() {
Log.e("获取浏览量的返回结果uid",String.valueOf(1));
String jsonStr = OkHttpUtil.synPost(url,paramMap);
Log.e("浏览量的返回结果",jsonStr);
// blog.setBbrowse(blog.getBbrowse()+1);
// ((AppCompatActivity) context).runOnUiThread(new Runnable(){
// @Override
// public void run() {
//// holder.visNum.setText(String.valueOf(blog.getBbrowse()));
// }
// });
}
}).start();
}
}

@ -0,0 +1,58 @@
package com.example.leudaemialikeme.Adapter;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Model.Comment;
import com.example.leudaemialikeme.R;
import java.util.List;
public class CommentAdapter extends RecyclerView.Adapter<CommentAdapter.ViewHolder>{
List<Comment> mCommentList;
Comment comment;
static class ViewHolder extends RecyclerView.ViewHolder{
TextView comName;
TextView comContent;
TextView comTime;
public ViewHolder(View view){
super(view);
comName=(TextView) view.findViewById(R.id.comment_user_name);
comContent=(TextView)view.findViewById(R.id.comment_content);
comTime=(TextView)view.findViewById(R.id.comment_time);
}
}
public void setMCommentList(List<Comment> commentList){
mCommentList=commentList;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.comment_item,parent,false);
CommentAdapter.ViewHolder holder = new CommentAdapter.ViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull CommentAdapter.ViewHolder holder, int position) {
comment=mCommentList.get(position);
holder.comName.setText(comment.getUName());
holder.comContent.setText(comment.getContent());
holder.comTime.setText(String.valueOf(comment.getTime()).substring(0,19));
}
@Override
public int getItemCount() {
return mCommentList.size();
}
}

@ -11,7 +11,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.DetailActivity;
import com.example.leudaemialikeme.Activity.BlogDetailActivity;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Model.Recnews;
@ -50,7 +50,7 @@ public class InfoAdapter extends RecyclerView.Adapter<InfoAdapter.ViewHolder> {
holder.linear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(view.getContext(), DetailActivity.class);
Intent intent=new Intent(view.getContext(), BlogDetailActivity.class);
//intent.putExtra("from",String.valueOf(view.getContext()));
//Log.e("activity",String.valueOf(view.getContext()));
view.getContext().startActivity(intent);

@ -20,7 +20,7 @@ public class InvitationPageFragmentAdapter extends FragmentPagerAdapter {
@Override
public Fragment getItem(int position) {
String InvitationCategoryTitle = channelList[position];
return InvitationChannelFragment.newInstance(InvitationCategoryTitle);
return InvitationChannelFragment.newInstance(InvitationCategoryTitle,position);
}
@Override

@ -28,6 +28,10 @@ public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHo
this.questionList = questionList;
this.context = context;
}
public QuestionAdapter(){
}
public int getItemCount(){
return questionList.size();
}
@ -44,6 +48,10 @@ public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHo
this.questionTime = (TextView)itemView.findViewById(R.id.questionTime);
}
}
public void setQuestionList(List<Question> questionList){
this.questionList=questionList;
}
//重写 onCreateViewHolder()方法
@Override
public QuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

@ -12,7 +12,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.DetailActivity;
import com.example.leudaemialikeme.Activity.BlogDetailActivity;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Model.Recnews;
@ -52,7 +52,7 @@ public class RecnewsAdapter extends RecyclerView.Adapter<RecnewsAdapter.ViewHold
holder.linear.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent=new Intent(view.getContext(), DetailActivity.class);
Intent intent=new Intent(view.getContext(), BlogDetailActivity.class);
intent.putExtra("from",String.valueOf(view.getContext()));
Log.e("activity",String.valueOf(view.getContext()));
view.getContext().startActivity(intent);
@ -65,11 +65,11 @@ public class RecnewsAdapter extends RecyclerView.Adapter<RecnewsAdapter.ViewHold
@Override
public void onBindViewHolder(@NonNull RecnewsAdapter.ViewHolder holder, int position) {
Recnews recnews=mRecnewsList.get(position);
holder.image.setImageResource(recnews.getImageNum());
holder.visNum.setText(String.valueOf(recnews.getVisNum()));
holder.intro.setText(recnews.getIntro());
holder.theme.setText(recnews.getTheme());
holder.time.setText(recnews.getTime());
holder.time.setText(recnews.getTime().substring(0,17));
}
@Override

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.HorizontalScrollView;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@ -19,25 +20,34 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import com.example.leudaemialikeme.Activity.BlogSearchActivity;
import com.example.leudaemialikeme.Activity.GoAnswerActivity;
import com.example.leudaemialikeme.Activity.SendInvitationActivity;
import com.example.leudaemialikeme.Activity.SendQuestionActivity;
import com.example.leudaemialikeme.Adapter.InvitationPageFragmentAdapter;
import com.example.leudaemialikeme.Model.Blog;
import com.example.leudaemialikeme.R;
import java.util.ArrayList;
import java.util.List;
public class CommunityFragment extends Fragment implements ViewPager.OnPageChangeListener {
private static final String ARG_CHANNEL_LIST = "channel_list";
private View view=null; // 碎片的布局实例
private ViewPager viewPager; //内导航的碎片的容器
private static ViewPager viewPager; //内导航的碎片的容器
private RadioGroup rgChannel=null; // 内导航由单选按钮组构成
private HorizontalScrollView hvChannel=null; //单选按钮组可滚动动
private String[] channelList = {"关注","全部","经验","扫雷","康复","科普","问答"}; //默认的内导航栏目
private String[] channelList = {"全部","经验"
,"康复","扫雷","问答"}; //默认的内导航栏目
private InvitationPageFragmentAdapter adapter; //viewPager 的适配器
private PopupWindow popupWindow;
private ImageButton tab_add;
private Button bar_send_invitation;
private Button bar_send_question;
private Button bar_answer;
private LinearLayout blog_search;
static List<List<Blog>> resourceList=new ArrayList<>();
static List<Blog> blogList=new ArrayList<>();
//列表数据
public CommunityFragment() {
@ -51,6 +61,7 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
view=inflater.inflate(R.layout.fragment_community, container, false);
tab_add = (ImageButton)view.findViewById(R.id.tab_add);
viewPager=(ViewPager)view.findViewById(R.id.vpNewsList);
blog_search=(LinearLayout)view.findViewById(R.id.blog_search);
initViewPager(); //设置 ViewPager
rgChannel=(RadioGroup)view.findViewById(R.id.rgChannel);
@ -112,6 +123,16 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
});
}
});
blog_search.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
Intent intent=new Intent(view.getContext(), BlogSearchActivity.class);
view.getContext().startActivity(intent);
}
});
}
return view;
}
@ -120,7 +141,8 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
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]);
String text=" "+channelList[i]+" ";
rb.setText(text);
RadioGroup.LayoutParams params = new
RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
@ -130,18 +152,30 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
rgChannel.check(0);
}
public static ViewPager getViewPager(){
return viewPager;
}
private void initViewPager() {
FragmentManager fragmentManager = super.getActivity().getSupportFragmentManager();
adapter=new InvitationPageFragmentAdapter(fragmentManager, channelList);
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片 //设置 ViewPager 的适配器
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片 //设置 ViewPager 的适配器
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(2);
viewPager.setOffscreenPageLimit(1);
//设置显示第 1 个碎片
viewPager.setCurrentItem(0);
//设置 ViewPager 的切换监听
viewPager.addOnPageChangeListener(this);
}
public static List<Blog> getBlogList(){
return blogList;
}
public static List<List<Blog>> getResourceList(){
return resourceList;
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
@ -156,6 +190,7 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
public void onPageScrollStateChanged(int state) {
}
private void setTab(int idx){
RadioButton rb=(RadioButton)rgChannel.getChildAt(idx);
rb.setChecked(true);
@ -168,5 +203,4 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
hvChannel.smoothScrollTo(len,0);
}
}

@ -14,9 +14,9 @@ import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.InfoActivity;
import com.example.leudaemialikeme.Activity.MdctRmdActivity;
import com.example.leudaemialikeme.Activity.SearchActivity;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Model.Recnews;
import com.example.leudaemialikeme.Adapter.RecnewsAdapter;
import com.example.leudaemialikeme.Model.Recnews;
import com.example.leudaemialikeme.R;
import java.util.ArrayList;
import java.util.List;
@ -80,7 +80,7 @@ public class IndexFragment extends Fragment {
RecyclerView recyclerView=(RecyclerView) view.findViewById(R.id.recommend_news);
LinearLayoutManager layoutManager=new LinearLayoutManager(this.getActivity());
recyclerView.setLayoutManager(layoutManager);
RecnewsAdapter recnewsAdapter=new RecnewsAdapter(recNews);
RecnewsAdapter recnewsAdapter =new RecnewsAdapter(recNews);
recyclerView.setAdapter(recnewsAdapter);
initClick(view);

@ -1,97 +1,519 @@
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 android.widget.TextView;
import androidx.annotation.RequiresApi;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.RecnewsAdapter;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Adapter.BlogAdapter;
import com.example.leudaemialikeme.Adapter.QuestionAdapter;
import com.example.leudaemialikeme.Model.Blog;
import com.example.leudaemialikeme.Model.Question;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Model.Recnews;
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 InvitationChannelFragment extends Fragment {
private static final String ARG_CATEGORY_TITLE = "category_title";
private static final String ARG_CATEGORY_TITLE_NUM = "category_title_num";
public static List<List<Blog>> resourceList = new ArrayList<>();
private List<Question> allQuestion = new ArrayList<>();
private List<Blog> allBlog = new ArrayList<>();
private String invitationCategoryTitle = "Default";
private int invitationCategoryTitleNum = 0;
private TextView mTitleField;
private List<Recnews> recNews=new ArrayList<>();
static List<Blog> blogList = new ArrayList<>();
private List<Blog> blogLists = new ArrayList<>();
private List<Blog> expBlog = new ArrayList<>();
private List<Blog> badBlog = new ArrayList<>();
private List<Blog> recBlog = new ArrayList<>();
// static BlogAdapter allAdapter=new BlogAdapter();
private QuestionAdapter questionAdapter = new QuestionAdapter();
private BlogAdapter expAdapter = new BlogAdapter();
private BlogAdapter badAdapter = new BlogAdapter();
private BlogAdapter recAdapter = new BlogAdapter();
private RecyclerView allRecyclerView;
private RecyclerView questionRecyclerView;
private RecyclerView expRecyclerView;
private RecyclerView recRecyclerView;
private RecyclerView badRecyclerView;
private boolean isPause = false;
private final String[] channelList = {"全部", "经验"
, "康复", "扫雷", "问答"};
// int temp=0;
public InvitationChannelFragment() {
// Required empty public constructor
}
public static InvitationChannelFragment newInstance(String invitationCategoryTitle) {
public static InvitationChannelFragment newInstance(String invitationCategoryTitle, int pos) {
InvitationChannelFragment fragment = new InvitationChannelFragment();
Bundle args = new Bundle();
args.putString(ARG_CATEGORY_TITLE,invitationCategoryTitle);
args.putString(ARG_CATEGORY_TITLE, invitationCategoryTitle);
args.putInt(ARG_CATEGORY_TITLE_NUM, pos);
fragment.setArguments(args);
// blogList=getBlogList();
// resourceList=getResourceList();
// Log.e("newInstance","newInstance");
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try{
invitationCategoryTitle = (String)getArguments().getString(ARG_CATEGORY_TITLE);
}catch (java.lang.NullPointerException e){
try {
invitationCategoryTitle = (String) getArguments().getString(ARG_CATEGORY_TITLE);
invitationCategoryTitleNum = getArguments().getInt(ARG_CATEGORY_TITLE_NUM);
// Log.e("onCreate","onCreate");
} catch (java.lang.NullPointerException e) {
System.out.println("TesFragment getArg error!");
}
initRecNews();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view;
if(invitationCategoryTitle.equals("全部")){
view = inflater.inflate(R.layout.recyclerview,container,false);
RecyclerView recyclerView = (RecyclerView)view.findViewById(R.id.list_community);
view = inflater.inflate(R.layout.recyclerview, container, false);
// initAllBlog();// 所有blog组
// initAllBlogList(); //第一栏:全部项
questionAdapter = new QuestionAdapter();
questionAdapter.setQuestionList(allQuestion);
expAdapter = new BlogAdapter();
expAdapter.setRecnewsList(expBlog);
badAdapter = new BlogAdapter();
badAdapter.setRecnewsList(badBlog);
recAdapter = new BlogAdapter();
recAdapter.setRecnewsList(recBlog);
if (invitationCategoryTitleNum == 0) {
view = inflater.inflate(R.layout.recyclerview, container, false);
allRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
RecnewsAdapter adapter = new RecnewsAdapter(recNews);
recyclerView.setAdapter(adapter);
}
else {
view = inflater.inflate(R.layout.fragment_invitation_channel, container, false);
mTitleField = (TextView)view.findViewById(R.id.invitationCategoryTitle);
mTitleField.setText(invitationCategoryTitle);
allRecyclerView.setLayoutManager(layoutManager);
BlogAdapter allAdapter = new BlogAdapter(allBlog);
allRecyclerView.setAdapter(allAdapter);
// initAllBlogList();
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"全部"});
getAllBlogListRequest(paramMap);
// allAdapter.notifyDataSetChanged();
} else if (invitationCategoryTitleNum == 4) {
questionRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
questionRecyclerView.setLayoutManager(layoutManager);
questionRecyclerView.setAdapter(questionAdapter);
// Map<String, String[]> paramMap = new HashMap<>();
// paramMap.put("channelList", new String[]{"问答"});
getQuestionListRequest();
// Log.e("应该为4问答", String.valueOf(invitationCategoryTitleNum));
} else if (invitationCategoryTitleNum == 2) {
recRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recRecyclerView.setLayoutManager(layoutManager);
recRecyclerView.setAdapter(recAdapter);
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"康复"});
getRecInvitationRequest(paramMap);
// Log.e("应该为2康复", String.valueOf(invitationCategoryTitleNum));
// Log.e("应该为2康复数据",String.valueOf(recBlog));
} else if (invitationCategoryTitleNum == 3) {
badRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
badRecyclerView.setLayoutManager(layoutManager);
badRecyclerView.setAdapter(badAdapter);
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"扫雷"});
getBadListRequest(paramMap);
// Log.e("应该为3扫雷", String.valueOf(invitationCategoryTitleNum));
} else if (invitationCategoryTitleNum == 1) {
expRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
expRecyclerView.setLayoutManager(layoutManager);
expRecyclerView.setAdapter(expAdapter);
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"经验"});
getExpListRequest(paramMap);
}
// temp=temp+1;
return view;
}
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 initAllBlogList() {
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"全部"});
getAllBlogListRequest(paramMap);
getQuestionListRequest();
}
private void getQuestionListRequest() {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url2 = BaseActivity.SERVER_URL + "/question-servlet?action=get-allQuestion";
OkHttpUtil.asyPost(url2, null, 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();
getQuestionResponse(jsonStr);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getExpListRequest(final Map paramMap) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = BaseActivity.SERVER_URL + "/blog-servlet?action=get-invitation";
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();
getExpInvitationResponse(jsonStr);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getBadListRequest(final Map paramMap) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = BaseActivity.SERVER_URL + "/blog-servlet?action=get-invitation";
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();
getBadInvitationResponse(jsonStr);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getAllBlogListRequest(final Map paramMap) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = BaseActivity.SERVER_URL + "/blog-servlet?action=get-invitation";
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();
getAllBlogListResponse(jsonStr);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getAllBlogListResponse(final String jsonStr) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
Gson gson = new Gson();
Type listType = new TypeToken<List<List<Blog>>>() {
}.getType();
// Log.e("AllBlogList:jsonStr",jsonStr);
List<Blog> lists = gson.fromJson(jsonStr, listType);
// List<Blog> allBlogList=new ArrayList<>();
lists = (List<Blog>) lists.get(0);
allBlog = lists;
// Log.e("allBlog的数据",String.valueOf(lists));
BlogAdapter allAdapter = new BlogAdapter(allBlog);
allRecyclerView.setAdapter(allAdapter);
//
// if(allAdapter==null)
// Log.e("allAdapter","allAdapter is null");
// if(allRecyclerView==null)
// Log.e("allRecyclerView1","allRecyclerView1 is null");
// allRecyclerView= (RecyclerView) (getActivity().getLayoutInflater().inflate(R.layout.recyclerview, null)).findViewById(R.id.list_community);
// if(allRecyclerView==null)
// Log.e("allRecyclerView2","allRecyclerView2 is null");
// allRecyclerView.setAdapter(allAdapter);
//// InvitationChannelFragment.allBlog=allBlogList;
}
});
}
private void initAllBlog() {
Map<String, String[]> paramMap_bad = new HashMap<String, String[]>();
Map<String, String[]> paramMap_rec = new HashMap<String, String[]>();
Map<String, String[]> paramMap_exp = new HashMap<String, String[]>();
Map<String, String[]> paramMap_all = new HashMap<String, String[]>();
Map<String, String[]> paramMap = new HashMap<String, String[]>();
// paramMap.put("channelList",java.util.Arrays.copyOf(channelList,1));
paramMap_rec.put("channelList", new String[]{"康复"});
paramMap_bad.put("channelList", new String[]{"扫雷"});
paramMap_exp.put("channelList", new String[]{"经验"});
getExpListRequest(paramMap_exp);
getBadListRequest(paramMap_bad);
getRecInvitationRequest(paramMap_rec);
}
private void getRecInvitationRequest(final Map paramMap) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = BaseActivity.SERVER_URL + "/blog-servlet?action=get-invitation";
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();
getRecInvitationResponse(jsonStr);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getInvitationRequest(final Map paramMap, final Map paramMap_bad,
final Map paramMap_rec, final Map paramMap_exp) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url1 = BaseActivity.SERVER_URL + "/blog-servlet?action=get-invitation";
String url2 = BaseActivity.SERVER_URL + "/question-servlet?action=get-allQuestion";
// String jsonStr1= OkHttpUtil.synPost(url1, paramMap);换为异步
// String jsonStr2= OkHttpUtil.synPost(url2, null);换为异步
// String jsonStr_rec= OkHttpUtil.synPost(url1, paramMap_rec);
// String jsonStr_bad= OkHttpUtil.synPost(url1, paramMap_bad);
// String jsonStr_exp= OkHttpUtil.synPost(url1, paramMap_exp);
// Log.e("getInvitationRequest","getInvitationRequest");
// getInvitationResponse(jsonStr1);
// getQuestionResponse(jsonStr2);
// getRecInvitationResponse(jsonStr_rec);
// getBadInvitationResponse(jsonStr_bad);
// getExpInvitationResponse(jsonStr_exp);
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
private void getBadInvitationResponse(final String jsonStr) {
getActivity().runOnUiThread(new Runnable() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
// Log.e("jsonStr",jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<Blog>>>() {
}.getType();
// Log.e("jsonStr",jsonStr);
List<List<Blog>> lists = gson.fromJson(jsonStr, listType);
List<Blog> badBlogList = new ArrayList<>();
badBlogList = (List<Blog>) lists.get(0);
badBlog = badBlogList;
BlogAdapter badAdapter = new BlogAdapter();
badAdapter.setRecnewsList(badBlog);
badRecyclerView.setAdapter(badAdapter);
// Log.e("badBlog",String.valueOf(badBlogList));
}
});
}
private void getRecInvitationResponse(final String jsonStr) {
getActivity().runOnUiThread(new Runnable() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
// Log.e("jsonStr",jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<Blog>>>() {
}.getType();
// Log.e("jsonStr",jsonStr);
List<List<Blog>> lists = gson.fromJson(jsonStr, listType);
List<Blog> recBlogList = new ArrayList<>();
recBlogList = (List<Blog>) lists.get(0);
recBlog = recBlogList;
BlogAdapter recAdapter = new BlogAdapter();
recAdapter.setRecnewsList(recBlog);
recRecyclerView.setAdapter(recAdapter);
// Log.e("recBlog的数据",String.valueOf(recBlogList));
}
});
}
private void getExpInvitationResponse(final String jsonStr) {
getActivity().runOnUiThread(new Runnable() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
Log.e("jsonStr", jsonStr);
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
Type listType = new TypeToken<List<List<Blog>>>() {
}.getType();
// Log.e("jsonStr",jsonStr);
List<List<Blog>> lists = gson.fromJson(jsonStr, listType);
List<Blog> expBlogList = new ArrayList<>();
expBlogList = (List<Blog>) lists.get(0);
expBlog = expBlogList;
// Log.e("expBlog的数据",String.valueOf(expBlogList));
BlogAdapter expAdapter = new BlogAdapter();
expAdapter.setRecnewsList(expBlog);
expRecyclerView.setAdapter(expAdapter);
}
});
}
private void getQuestionResponse(final String jsonStr) {
getActivity().runOnUiThread(new Runnable() {
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void run() {
Gson gson = new Gson(); // 使用 gson 库解析 JSON 数据
// 创建一个 TypeToken 的匿名子类对象,并调用对象的 getType()方法
// Log.e("questionListStr",jsonStr);
Type listType = new TypeToken<List<Question>>() {
}.getType();
List<Question> questionList = gson.fromJson(jsonStr, listType);
allQuestion = questionList;
QuestionAdapter questionAdapter = new QuestionAdapter();
questionAdapter.setQuestionList(allQuestion);
questionRecyclerView.setAdapter(questionAdapter);
}
});
}
@Override
public void onPause() {
super.onPause();
isPause = true; //记录页面已经被暂停
}
@Override
public void onResume() {
super.onResume();
if (isPause) { //判断是否暂停
isPause = false;
if (invitationCategoryTitleNum == 0) {
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"全部"});
getAllBlogListRequest(paramMap);
BlogAdapter allAdapter = new BlogAdapter(allBlog);
allRecyclerView.setAdapter(allAdapter);
}else if(invitationCategoryTitleNum == 4) {
getQuestionListRequest();
QuestionAdapter questionAdapter = new QuestionAdapter(allQuestion);
questionRecyclerView.setAdapter(questionAdapter);
}else if(invitationCategoryTitleNum == 2) {
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"康复"});
getRecInvitationRequest(paramMap);
BlogAdapter recAdapter = new BlogAdapter(recBlog);
recRecyclerView.setAdapter(recAdapter);
}else if(invitationCategoryTitleNum == 3) {
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"扫雷"});
getBadListRequest(paramMap);
BlogAdapter badAdapter = new BlogAdapter(badBlog);
badRecyclerView.setAdapter(badAdapter);
}else if(invitationCategoryTitleNum == 1) {
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap = new HashMap<String, String[]>();
paramMap.put("channelList", new String[]{"经验"});
getExpListRequest(paramMap);
BlogAdapter expAdapter = new BlogAdapter(expBlog);
expRecyclerView.setAdapter(expAdapter);
}
}
}
}
}

@ -128,5 +128,4 @@ public class Blog implements Serializable {
this.flag=flag;
}
}

@ -0,0 +1,43 @@
package com.example.leudaemialikeme.Model;
import java.io.Serializable;
public class Browse implements Serializable{
private static final long serialVersionUID = 1L;
private int id;
private int uid;
private int type;
public void setId(int id) {
this.id=id;
}
public int getId() {
return id;
}
public void setUid(int uid) {
this.uid=uid;
}
public int getUid() {
return uid;
}
public void setType(int type) {
this.type=type;
}
public int getType() {
return type;
}
public Browse(int id,int uid,int type) {
this.id=id;
this.uid=uid;
this.type=type;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}

@ -0,0 +1,80 @@
package com.example.leudaemialikeme.Model;
import java.io.Serializable;
import java.sql.Timestamp;
public class Comment implements Serializable {
private static final long serialVersionUID = 1L;
private int cid;
private int id;
private String uName;
private int uid;
private String content;
private Timestamp time;
private int type; //评论1/回答2
public Comment(){
}
public Comment(int id,int cid,String name,int uid,String content,Timestamp time,int type){
this.id=id;
this.cid=cid;
this.uName=name;
this.uid=uid;
this.content=content;
this.time=time;
this.type=type;
}
public Comment(int id,String name,Timestamp time,int uid,String content,int type){
this.time=time;
this.id=id;
this.uName=name;
this.uid=uid;
this.content=content;
this.type=type;
}
public int getId(){
return id;
}
public void setId(int id){
this.id=id;
}
public int getCid(){
return cid;
}
public void setCid(int cid){
this.cid=cid;
}
public String getUName(){
return uName;
}
public void setUName(String name){
this.uName=name;
}
public int getUid(){
return uid;
}
public void setUid(int uid){
this.uid=uid;
}
public String getContent(){
return content;
}
public void setContent(String content){
this.content=content;
}
public Timestamp getTime(){
return time;
}
public void setTime(Timestamp time){
this.time=time;
}
public int getType(){
return type;
}
public void setType(int type){
this.type=type;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}

@ -4,7 +4,7 @@ import org.litepal.annotation.Column;
import org.litepal.crud.LitePalSupport;
public class Owner extends LitePalSupport {
private int id; //本地数据库自增id
private int id=1; //本地数据库自增id
@Column(unique = true)
private int netId; //mysql自增id
@Column(unique = true)

@ -1,5 +1,7 @@
package com.example.leudaemialikeme.Model;
import com.google.gson.Gson;
import java.io.Serializable;
import java.sql.Timestamp;
@ -16,8 +18,18 @@ public class Question implements Serializable {
private int flag;
public Question() {
public Question(int uid,String qtitle,String qcontent,Timestamp qtime,
int qfollowNum,int qanswerNum,int qbrowseNum,int flag) {
this.uid=uid;
this.qtitle=qtitle;
this.qcontent=qcontent;
this.qtime=qtime;
this.qfollowNum=qfollowNum;
this.qanswerNum=qanswerNum;
this.qbrowseNum=qbrowseNum;
this.flag=flag;
}
public Question(int qid, int uid, String qtittle, String qcontent, Timestamp timestamp, int qfollowNum, int qanswerNum,
int qbrowseNum, int flag) {
super();

@ -1,20 +1,16 @@
package com.example.leudaemialikeme.Utils;
public class Data extends android.app.Application {
public int uid=1;
public String id="430481200101220131";
public String name="abc";
public int getUid(){
return uid;
}
public void setUid(int uid){
this.uid= uid;
}
import com.example.leudaemialikeme.Model.User;
public String getId(){
return this.id;
public class Data extends android.app.Application {
private User user=new User(1,"123","123","13877673546","女");
// private User user;
public void setUser(User user){
this.user=user;
}
public void setId(String id){
this.id= id;
public User getUser(){
return user;
}
}

@ -5,6 +5,7 @@ import android.util.Log;
import com.google.gson.Gson;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import okhttp3.Callback;
import okhttp3.FormBody;
@ -14,7 +15,14 @@ import okhttp3.RequestBody;
import okhttp3.Response;
public class OkHttpUtil {
private static OkHttpClient client = new OkHttpClient();
// private static OkHttpClient client = new OkHttpClient();
private static OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(500, TimeUnit.SECONDS)
.readTimeout(500, TimeUnit.SECONDS)
.build();
private static Gson gson = new Gson();
//同步GET请求
public static String synGet(String url){
@ -33,7 +41,6 @@ public class OkHttpUtil {
//同步POST请求
public static String synPost(String url, Map params){
try{
String jsonStr= gson.toJson(params);
RequestBody requestBody=new FormBody.Builder()
.add("jsonStr",jsonStr)
@ -51,6 +58,7 @@ public class OkHttpUtil {
return "error";
}
}
//异步GET请求
public static void asyGet(String url, Callback callback){
try{

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

@ -0,0 +1,163 @@
<?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/blog_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/blog_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/recView"
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/foView"
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/poView"
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/meView"
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/stView"
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/exView"
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,79 @@
<?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/blog_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/blog_search_text"
android:layout_width="220dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text=""
android:background="@null"
android:gravity="center_vertical"
/>
</LinearLayout>
<TextView
android:id="@+id/blog_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_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_margin="10dp"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,329 @@
<?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:layout_marginBottom="10dp"
android:background="#FFFFFF"
android:orientation="vertical">
<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:textSize="20dp" />
</LinearLayout>
<!-- <LinearLayout-->
<!-- android:id="@+id/detail_to_answer"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:orientation="horizontal"-->
<!-- android:padding="10dp">-->
<!-- <TextView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="查看全部回答"-->
<!-- android:textColor="#66c18c"-->
<!-- android:textSize="15dp" />-->
<!-- <ImageView-->
<!-- android:layout_width="24dp"-->
<!-- android:layout_height="13dp"-->
<!-- android:layout_gravity="center"-->
<!-- android:src="@drawable/forwardgreen" />-->
<!-- </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_marginLeft="5dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="病因很重要"
android:textSize="18dp" />
<TextView
android:id="@+id/author_intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="管住嘴,迈开腿,多喝水" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/bContent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp"
android:paddingTop="15dp"
android:text="缘起: 一直以来都有很多人劝我希望我可以把自己的经历写下来,我的医生,我的同学,
我的朋友,他们觉得我的经历很有意义,虽然我自己也认同这一点,一直很难以动笔,原因有二,其一觉得
自己学理工的,对自己的文笔没什么自信。其二过往的经历实在是痛苦,写下来的过程无异于把好不容易重
合的伤疤撕开一次,自己的内心实在是有点胆怯。\n \n一谈谈我对白血病的看法\n
初次知道白血病是通过日本电影《血疑》,我相信和我年纪相当的人很多也都是通过这部电影知道这个疾病,当然我从未想过我
会与此牵扯上关系甚至在自己22岁以后的生命中处处时时需要考虑它对我的影响。我初次得病是1998年在那个年代白血病
的确依旧是一个很恐怖的病,我当初的症状就是四肢布满红色出血点,低烧吵死不退,牙龈出血,记得每次早上起床,嘴里总是
有凝结的血块,那是虽然不懂这是怎么回事,但是总是担心的要命,于是便经常刷牙,希望仅仅是上火所致,也不敢去看医生,
于是就自己买消炎药吃,希望可以平安过去。" />
</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="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:background="@drawable/search_background"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="3dp"
app:srcCompat="@drawable/view" />
<TextView
android:id="@+id/detail_view_num"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="0" />
</LinearLayout>
<LinearLayout
android:id="@+id/detail_col"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/search_background"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView15"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginLeft="3dp"
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:layout_marginRight="10dp"
android:text="0" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#FFFFFF"
android:padding="20dp">
<TextView
android:id="@+id/textView45"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="评论"
android:textSize="19dp"/>
<TextView
android:id="@+id/comment_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(0)"
android:textSize="17dp" />
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:id="@+id/vpNewsList_detail"
android:layout_width="match_parent"
android:layout_weight="1" >
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/comment_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="bottom"
android:background="#FFFFFF">
<!-- android:layout_height="wrap_content"-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="@drawable/shape_round_corner"
android:layout_margin="20dp"
android:layout_weight="1"
>
<ImageView
android:id="@+id/imageView16"
android:layout_width="20dp"
android:layout_height="45dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="20dp"
app:srcCompat="@drawable/write"
android:gravity="center|bottom"/>
<EditText
android:id="@+id/comment_edit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="写评论"
android:background="#F1EEEE"
android:layout_marginTop="10dp"
android:gravity="center|bottom"/>
<TextView
android:id="@+id/comment_commit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20dp"
android:layout_marginTop="10dp"
android:text="发布"
android:gravity="center|bottom"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

@ -77,12 +77,6 @@ android:orientation="vertical"
android:gravity="start"
android:layout_margin="10dp"
android:hint="分享你的经验,互帮互助,大家一起好起来呀!" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/img_upload_img"
android:layout_margin="10dp"
/>
<LinearLayout
android:layout_width="match_parent"

@ -7,58 +7,71 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/comment_user_image"
android:layout_width="104dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/person" />
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:orientation="vertical">
android:layout_marginLeft="10dp"
android:layout_marginTop="12dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/comment_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="亚子读书"
android:textSize="15dp" />
<ImageView
android:id="@+id/comment_user_image"
android:layout_width="104dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/person" />
<TextView
android:id="@+id/comment_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="太棒啦"
android:textSize="14dp" />
android:layout_marginLeft="5dp"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/comment_user_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="亚子读书"
android:textSize="15dp" />
<TextView
android:id="@+id/textView47"
android:layout_width="wrap_content"
android:id="@+id/comment_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="210dp"
android:layout_marginTop="15dp"
android:text="2021-11-06 09:19:54"
android:textSize="12dp" />
android:text="太棒啦"
android:textSize="14dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/comment_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="190dp"
android:layout_marginTop="4dp"
android:text="2021-11-06 09:19:54"
android:textColor="#959191"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<View
android:layout_width="fill_parent"
android:layout_height="1px"
android:layout_gravity="bottom"
android:background="#878484" />
</androidx.cardview.widget.CardView>

@ -22,7 +22,9 @@
android:orientation="horizontal">
<LinearLayout
android:id="@+id/blog_search"
android:layout_width="350dp"
android:layout_marginLeft="2dp"
android:layout_height="wrap_content"
android:background="@drawable/search_background"
android:orientation="horizontal">
@ -31,7 +33,7 @@
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/img_search" />
android:src="@android:drawable/ic_menu_search" />
<TextView
android:id="@+id/textView3"
@ -89,7 +91,8 @@
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpNewsList"
android:layout_width="match_parent"
android:layout_height="0dp" android:layout_weight="1"/>
android:layout_height="0dp"
android:layout_weight="1"/>
</LinearLayout>

@ -29,6 +29,16 @@
android:ellipsize="end"
android:text="问题"
/>
android:layout_height="wrap_content"
android:id="@+id/news"
android:layout_width="334dp"
android:layout_marginLeft="15dp"
android:layout_marginBottom="6dp"
android:background="@drawable/background"
android:elevation="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="11dp">
<TextView
android:id="@+id/questionInfo"

@ -3,20 +3,48 @@
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_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/bid"
android:text=""/>
<!-- 标注bid-->
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/likeNum"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/colNum"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/uid"
android:text=""/>
<TextView
android:layout_width="0dp"
android:layout_height="0dp"
android:id="@+id/content"
android:text=""/>
<LinearLayout
android:id="@+id/news"
android:layout_width="334dp"
android:layout_height="150dp"
android:layout_marginLeft="18dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginBottom="6dp"
android:background="@drawable/background"
android:elevation="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="11dp"
tools:ignore="MissingConstraints">
@ -25,32 +53,31 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="儿童急性B淋巴细胞白血病,除了传统疗法还有哪些前沿治疗方法呢?"
android:maxEms="40"
android:maxLines="2"
android:ellipsize="end"
android:textSize="15dp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="312dp"
android:layout_height="71dp"
android:orientation="horizontal">
<TextView
android:id="@+id/recNews_intro"
android:layout_width="200dp"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginTop="14dp"
android:text="急性淋巴细胞白血病ALL是儿童最常见的恶性肿瘤其中约85%为
android:ellipsize="end"
android:maxEms="40"
android:maxLines="3"
android:text="李冬冬的辅导员告诉澎湃新闻校方得知李冬冬的病情后组织为李冬冬筹款“我们为李冬冬发起了倡议书海南师范大学的微信公众号也进行了转发到24日上午为李冬冬筹集了71万左右善款。”
李冬冬的辅导员说,后续会根据李冬冬的治疗情况,为李冬冬制定新的帮扶方案。
"
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>
<LinearLayout

Loading…
Cancel
Save