首页资讯合并2.0

master
Annnnnn 3 years ago
parent d8fc598509
commit fc0b4e7c7b

@ -7,10 +7,9 @@
tools:targetApi="n">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<application
android:name="org.litepal.LitePalApplication"
android:name=".Utils.Data"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@ -18,55 +17,30 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.LeudaemiaLikeMe">
<activity android:name=".Activity.RegisterActivity"></activity>
<activity android:name=".Activity.AddEventActivity" />
<activity android:name=".Activity.MyInfoActivity"></activity>
<activity android:name=".Activity.AddClock" />
<activity android:name=".Activity.AlarmAlert" />
<activity android:name=".ClockDetail" />
<activity android:name=".Activity.AnswerActivity" />
<activity android:name=".Activity.QuestionDetailActivity" />
<activity android:name=".Activity.BlogDetailActivity"/>
<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"
/>
<activity android:name=".Activity.NewsSearchResultActivity"></activity>
<activity android:name=".Activity.NewsSearchActivity" />
<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 android:name=".Activity.BaseActivity" />
<activity android:name=".Activity.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</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.ChatActivity" />
<activity android:name=".Activity.AttentionActivity" />
<activity android:name=".Activity.HistoryActivity" />
<activity android:name=".Activity.CollectActivity" />
<activity android:name=".Activity.SafetyActivity" />
<activity android:name=".Activity.AboutActivity" />
<activity android:name=".Activity.MyQuestionActivity" />
<activity android:name=".Activity.ConcernedProblemActivity" />
<activity android:name=".Activity.DetailActivity" />
<activity android:name=".Activity.MdctRmdActivity" />
<activity android:name=".Activity.SearchActivity" />
<activity android:name=".Activity.InfoActivity" />
@ -75,18 +49,8 @@
<activity android:name=".Activity.SendQuestionActivity" />
<activity android:name=".Activity.APNActivity" />
<activity android:name=".Activity.EventActivity" />
<receiver
android:name=".CallAlarm"
android:process=".remote" />
<activity android:name=".Activity.LoginActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Activity.LoginActivity" />
<activity android:name=".Activity.NewsDetailActivity" />
</application>
</manifest>

@ -3,14 +3,11 @@
<dbname value="leukemia" />
<version value="4" />
<version value="1" />
<list>
<mapping class="com.example.leudaemialikeme.Model.Owner"/>
<mapping class="com.example.leudaemialikeme.Model.Friend"/>
<mapping class="com.example.leudaemialikeme.Model.Message"/>
<mapping class="com.example.leudaemialikeme.Model.Clock"/>
<mapping class="com.example.leudaemialikeme.Model.Event"/>
</list>
</litepal>

@ -1,105 +1,14 @@
package com.example.leudaemialikeme.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import com.example.leudaemialikeme.Adapter.APNPageActivityAdapter;
import com.example.leudaemialikeme.R;
public class APNActivity extends BaseActivity implements ViewPager.OnPageChangeListener{
private static final String ARG_CHANNEL_LIST = "channel_list";
private View view=null; // 碎片的布局实例
private ViewPager viewPager; //内导航的碎片的容器
private RadioGroup rgChannel=null; // 内导航由单选按钮组构成
private HorizontalScrollView hvChannel=null; //单选按钮组可滚动动
private ImageView apn_back;
private String[] channelList = {"回答","帖子"}; //默认的内导航栏目
private APNPageActivityAdapter adapter; //viewPager 的适配器
public class APNActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_apn);
viewPager = findViewById(R.id.vpNewsList);
initViewPager(); //设置 ViewPager
rgChannel = findViewById(R.id.rgChannel);
hvChannel = findViewById(R.id.hvChannel);
initTab(getLayoutInflater());
rgChannel.setOnCheckedChangeListener(
new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
viewPager.setCurrentItem(checkedId);
}
}
);
apn_back = findViewById(R.id.apn_back);
apn_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
private void initViewPager() {
FragmentManager fragmentManager = getSupportFragmentManager();
adapter = new APNPageActivityAdapter(fragmentManager, channelList);
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片 //设置 ViewPager 的适配器
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(2);
//设置显示第 1 个碎片
viewPager.setCurrentItem(0);
//设置 ViewPager 的切换监听
viewPager.addOnPageChangeListener(this);
}
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);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
setTab(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
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();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screenWidth=metrics.widthPixels;
int len=left+width/2-screenWidth/2;
hvChannel.smoothScrollTo(len,0);
}
}

@ -31,8 +31,9 @@ public class BaseActivity extends AppCompatActivity {
public static Owner owner;
//服务器链接
public static String SERVER_IP = "172.30.112.86";
// 172.30.118.24 寝172.18.138.225
//酸奶牛的ip地址IPv4 地址: 192.168.250.25
//校园网的ip的地址是192.168.186.1
public static String SERVER_IP = "192.168.186.1";
// static {
// try {
@ -116,14 +117,12 @@ public class BaseActivity extends AppCompatActivity {
//初始化WS
public void initWebSocket(int ownerNetId){
WS_URL="ws://"+SERVER_IP+":"+SERVER_PORT+"/LeudaemiaLikeMe/chatWS/"+ownerNetId;
// System.out.println(WS_URL);
WS_URL="ws://"+SERVER_IP+":"+SERVER_PORT+"/chatWS/"+ownerNetId;
URI uri=URI.create(WS_URL);
wsClient= new WebSocketClient(uri);
isNeedReconnect=true;
mHandler.postDelayed(heartBeatRunnable, HEART_BEAT_RATE);
try {
Log.d("ws测试","准备连接");
wsClient.connectBlocking();
} catch (InterruptedException e) {
e.printStackTrace();

@ -1,141 +1,17 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.ChatAdapter;
import com.example.leudaemialikeme.Dao.FriendDao;
import com.example.leudaemialikeme.Dao.MessageDao;
import com.example.leudaemialikeme.Model.Friend;
import com.example.leudaemialikeme.Model.Message;
import com.example.leudaemialikeme.Model.MessageItemView;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.TimeUtil;
import com.google.gson.Gson;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class ChatActivity extends BaseActivity {
private MessageDao messageDao = new MessageDao();
private FriendDao friendDao = new FriendDao();
private ImageButton bt_chat_to_chat_list;
private RecyclerView msg_recycler_view;
private TextView text_chat_name;
private EditText edit_content;
private Button bt_send_msg;
public int friendNetId;
private Friend currentFriend;
private ArrayList<Message> messageList = new ArrayList<Message>();
private MessageItemView msgItemView;
private ChatAdapter chatAdapter;
private Gson gson = new Gson();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_chat);
bt_chat_to_chat_list = findViewById(R.id.bt_chat_to_chat_list);
msg_recycler_view = findViewById(R.id.msg_recycler_view);
text_chat_name = findViewById(R.id.text_chat_name);
edit_content = findViewById(R.id.edit_content);
bt_send_msg = findViewById(R.id.bt_send_msg);
initData();
text_chat_name.setText(currentFriend.getUsername());
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
msg_recycler_view.setLayoutManager(layoutManager);
chatAdapter = new ChatAdapter(msgItemView);
msg_recycler_view.setAdapter(chatAdapter);
msg_recycler_view.scrollToPosition(messageList.size() - 1);
edit_content.setImeOptions(EditorInfo.IME_ACTION_SEND);
edit_content.setInputType(EditorInfo.TYPE_TEXT_FLAG_MULTI_LINE);
edit_content.setMaxLines(2);
edit_content.setSingleLine(false);
edit_content.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND
|| actionId == EditorInfo.IME_ACTION_DONE
|| (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) {
String content=edit_content.getText().toString();
if (!content.equals("")){
Message message =new Message(owner.getNetId(),currentFriend.getNetId(),content);
Map<String, String> jsonMap = new HashMap<String, String>();
jsonMap.put("senderNetId", String.valueOf(owner.getNetId()));
jsonMap.put("receiverNetId", String.valueOf(currentFriend.getNetId()));
jsonMap.put("messageType","1");
jsonMap.put("content", content);
jsonMap.put("createTime", TimeUtil.timeToString(new Timestamp(message.getCreateTime())));
addMsg(message,1);
edit_content.setText("");
wsClient.send(gson.toJson(jsonMap));
}
}
return false;
}
});
bt_send_msg.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
String content=edit_content.getText().toString();
if (!content.equals("")){
Message message =new Message(owner.getNetId(),currentFriend.getNetId(),content);
Map<String, String> jsonMap = new HashMap<String, String>();
jsonMap.put("senderNetId", String.valueOf(owner.getNetId()));
jsonMap.put("receiverNetId", String.valueOf(currentFriend.getNetId()));
jsonMap.put("messageType","1");
jsonMap.put("content", content);
jsonMap.put("createTime", TimeUtil.timeToString(new Timestamp(message.getCreateTime())));
addMsg(message,1);
edit_content.setText("");
wsClient.send(gson.toJson(jsonMap));
}
}
});
bt_chat_to_chat_list.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
private void initData() {
//从intent中取出currentNetId并查出对象
Intent intent = getIntent();
friendNetId = intent.getIntExtra("friendNetId", -1);
Log.d("ChatActivity","当前聊天对象ID"+friendNetId);
currentFriend = friendDao.findByNetId(friendNetId, owner.getNetId());
Log.d("ChatActivity","当前聊天对象:"+currentFriend);
//从数据库中查找聊天记录-默认最近20条记录
messageList = messageDao.findNearlyMessage(friendNetId, owner.getNetId());
//组装成MessageItemViw
msgItemView = new MessageItemView(currentFriend, owner, messageList);
}
//消息添加方法
public void addMsg(Message message, int isRead) {
Log.d("刷新","添加一条新消息");
msgItemView.messages.add(message);
chatAdapter.notifyItemInserted(messageList.size() - 1);
msg_recycler_view.scrollToPosition(messageList.size() - 1);
message.setFlag(isRead);
message.save();
}
}

@ -1,103 +1,39 @@
package com.example.leudaemialikeme.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.HistoryQuestionAdapter;
import com.example.leudaemialikeme.Adapter.QuestionAdapter;
import com.example.leudaemialikeme.Model.Question;
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.util.ArrayList;
import java.util.List;
import java.util.Map;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class ConcernedProblemActivity extends BaseActivity {
private List<Question> mData = new ArrayList<>();
private RecyclerView recyclerView;
private boolean isPause;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_concerned_problem);
recyclerView = (RecyclerView) findViewById(R.id.questionList);//获得视图
ImageView back_concerned = findViewById(R.id.back_concerned);
getData();//获得数据
RecyclerView recycleView = (RecyclerView) findViewById(R.id.questionList);//获得视图
LinearLayoutManager layoutManager;
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);//建立线性布局
QuestionAdapter adapter = new QuestionAdapter(mData, ConcernedProblemActivity.this);//创建适配器
recyclerView.setAdapter(adapter);//将视图与适配器连接起来
getData();//获得数据
back_concerned.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
recycleView.setLayoutManager(layoutManager);//建立线性布局
QuestionAdapter adapter = new QuestionAdapter(mData);//创建适配器
recycleView.setAdapter(adapter);//将视图与适配器连接起来
}
private void getData() {
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = ConcernedProblemActivity.SERVER_URL+"/my-servlet?action=concernedQuestion&uid="+ BaseActivity.owner.getNetId()+"&type="+3;
Callback callback = new Callback() {
@Override
public void onFailure(Call call, IOException e) {
System.out.println("-----ERROR----");
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
Gson gson = new Gson();
Map<String, String> jsonMap= gson.fromJson(jsonStr, new TypeToken<Map<String, String>>() {}.getType());
final String message=(String) jsonMap.get("message");
if (message.equals("success")) {
List<Question> questionList = gson.fromJson(jsonMap.get("questionList"), new TypeToken <List<Question>>(){}.getType());
mData = questionList;
QuestionAdapter adapter = new QuestionAdapter(mData, ConcernedProblemActivity.this);//创建适配器
recyclerView.setAdapter(adapter);
}
}
};
OkHttpUtil.asyGet(url,callback);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
Question q1 = new Question("白血病的早期症状和前兆有什么","24浏览","10:24");
mData.add(q1);
Question q2 = new Question("白血病是什么原因引起的","112浏览","15:11");
mData.add(q2);
}
@Override
public void onPause() {
super.onPause();
isPause = true; //记录页面已经被暂停
}
@Override
public void onResume() {
super.onResume();
if (isPause){ //判断是否暂停
isPause = false;
getData();
HistoryQuestionAdapter adapter = new HistoryQuestionAdapter(mData, ConcernedProblemActivity.this);//创建适配器
recyclerView.setAdapter(adapter);
}
}
}

@ -0,0 +1,105 @@
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 com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.Data;
import java.text.SimpleDateFormat;
import java.util.Locale;
//import com.example.leudaemialikeme.Dao.CommentDao;
public class DetailActivity extends BaseActivity {
EditText commentView;
String comment_content;
TextView commitView;//发布评论按钮
// CommentDao comment=new CommentDao();//评论
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);//显示详情页的布局
initView();
setClick();
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);
}
});
}
private void setClick() {//提交评论的方法
commentView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) { //onClick方法
DetailActivity.this.finish();
}
});
commitView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
comment_content=commentView.getText().toString();
long timeCurrent = System.currentTimeMillis();
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
final String time = sdf.format(timeCurrent);
//final String time = "12月5日";
Log.e("输入的time:", time);
new Thread(new Runnable(){
@Override
public void run() {
try {
Data app = (Data)getApplication();
//comment.cInsert(app.bid,app.uid,comment_content,time,0);
Log.e("已经插入评论表:",comment_content);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(DetailActivity.this,
"评论成功",Toast.LENGTH_SHORT).show();
}
});
} catch (Exception exception) {
exception.printStackTrace();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(DetailActivity.this,
"评论失败,请检查您的网络状况",Toast.LENGTH_SHORT).show();
}
});
}
}
}).start();
}
});
}
public void initView(){
commentView=(EditText)findViewById(R.id.editTextTextPersonName);
commitView=(TextView)findViewById(R.id.comment_commit);
}
}

@ -1,9 +1,6 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -12,88 +9,29 @@ import com.example.leudaemialikeme.Adapter.EventAdapter;
import com.example.leudaemialikeme.Model.Event;
import com.example.leudaemialikeme.R;
import org.litepal.LitePal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class EventActivity extends BaseActivity {
// private List<Event> mData = new ArrayList<>();
private List<Map<String,String>> contentList = new ArrayList<Map<String,String>>();
private List<Event> mData = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
ImageView addContent = (ImageView) findViewById(R.id.add_event);
addContent.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(EventActivity.this,AddEventActivity.class);
startActivity(intent);
}
});
ImageView back_my = findViewById(R.id.back_my);
back_my.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Intent intent = new Intent(EventActivity.this,MainActivity.class);
// startActivity(intent);
finish();
}
});
// getData();//获得数据
// RecyclerView recycleView = (RecyclerView) findViewById(R.id.eventList);//获得视图
// LinearLayoutManager layoutManager;
// layoutManager = new LinearLayoutManager(this);
// recycleView.setLayoutManager(layoutManager);//建立线性布局
// EventAdapter adapter = new EventAdapter(mData);//创建适配器
// recycleView.setAdapter(adapter);//将视图与适配器连接起来
}
@Override
protected void onStart(){
super.onStart();
contentList.clear();
initContent();
getData();//获得数据
RecyclerView recycleView = (RecyclerView) findViewById(R.id.eventList);//获得视图
LinearLayoutManager layoutManager;
layoutManager = new LinearLayoutManager(this);
recycleView.setLayoutManager(layoutManager);//建立线性布局
EventAdapter adapter = new EventAdapter(contentList);//创建适配器
EventAdapter adapter = new EventAdapter(mData);//创建适配器
recycleView.setAdapter(adapter);//将视图与适配器连接起来
adapter.notifyDataSetChanged();
}
private void initContent() {
List<Event> events = LitePal.order("id desc").find(Event.class);
for(Event event:events){
String event_day = event.getEvent_day();
String event_month = event.getEvent_month();
String event_info = event.getEvent_info();
String event_place = event.getEvent_place();
String event_doctor_name = event.getEvent_doctor_name();
String event_time = event.getEvent_time();
String event_create_time = event.getEvent_create_time();
Map<String,String> map = new HashMap<String,String>();
map.put("event_day",event_day);
map.put("event_month",event_month);
map.put("event_info",event_info);
map.put("event_place",event_place);
map.put("event_doctor_name",event_doctor_name);
map.put("event_time",event_time);
map.put("event_create_time",event_create_time);
contentList.add(map);
}
private void getData() {
Event event1 = new Event("04","10月","第三次化疗","08:00");
mData.add(event1);
Event event2 = new Event("11","5月","检查","09:00");
mData.add(event2);
}
// private void getData() {
// Event event1 = new Event("04","10月","第三次化疗","08:00");
// mData.add(event1);
// Event event2 = new Event("11","5月","检查","09:00");
// mData.add(event2);
// }
}

@ -6,7 +6,6 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.example.leudaemialikeme.Fragment.CollectFragment;
import com.example.leudaemialikeme.Fragment.HistoryFragment;
import com.example.leudaemialikeme.R;
public class HistoryActivity extends BaseActivity {
@ -18,7 +17,7 @@ public class HistoryActivity extends BaseActivity {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction trans = fm.beginTransaction();
String title = "浏览历史";
trans.replace(R.id.history_frag_layout, new HistoryFragment(title));
trans.replace(R.id.collect_frag_layout, new CollectFragment(title));
trans.commit();
}
}

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

@ -1,28 +1,20 @@
package com.example.leudaemialikeme.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.leudaemialikeme.Dao.FriendDao;
import com.example.leudaemialikeme.Dao.MessageDao;
import com.example.leudaemialikeme.Dao.OwnerDao;
import com.example.leudaemialikeme.Model.Friend;
import com.example.leudaemialikeme.Model.Message;
import com.example.leudaemialikeme.Model.Owner;
import com.example.leudaemialikeme.Model.User;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.example.leudaemialikeme.Utils.TimeUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.litepal.LitePal;
import java.util.HashMap;
import java.util.List;
@ -39,9 +31,6 @@ public class LoginActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
//获取数据库
SQLiteDatabase db = LitePal.getDatabase();
edit_username = findViewById(R.id.edit_username);
edit_pwd = findViewById(R.id.edit_pwd);
bt_login = findViewById(R.id.bt_login);
@ -56,6 +45,7 @@ public class LoginActivity extends BaseActivity {
paramMap.put("username",username);
paramMap.put("password",pwd);
loginRequest(paramMap);
}else {
Toast.makeText(LoginActivity.this, "用户名或密码格式错误!", Toast.LENGTH_SHORT).show();
}
@ -88,9 +78,7 @@ public class LoginActivity extends BaseActivity {
owner = dbOwner;
// ownerInfoSaveToPref(); //记住密码方法
// 初始化WS链接
// System.out.println(owner);
initWebSocket(owner.getNetId());
Log.d("记录","开始获取未读信息");
getUnReadMsg();
}else{
//如果本地为空则说明是首次登录,则需要发送请求获取用户的个人信息及朋友列表数据存入本地数据库中,再进行存储
@ -109,7 +97,6 @@ public class LoginActivity extends BaseActivity {
@Override
public void run() {
try {
Log.d("用户名",username);
String url = LoginActivity.SERVER_URL + "/main-servlet?action=firstLogin&username="+username;
String jsonStr= OkHttpUtil.synGet(url);
firstLoginResponse(jsonStr);
@ -126,14 +113,14 @@ public class LoginActivity extends BaseActivity {
@Override
public void run() {
Gson gson = new Gson();
Map<String, String> jsonMap= gson.fromJson(jsonStr, new TypeToken <Map<String, String>>() {}.getType());
Map jsonMap= gson.fromJson(jsonStr, Map.class);
final String message=(String) jsonMap.get("message");
if (message.equals("success")){
//进行本地数据存储,本地数据库不存储密码防止泄露需要补全imageURL路径
// JSONObject data=(JSONObject) jsonMap.get("data");
// JSONObject netUser=(JSONObject) data.get("owner");
// JSONArray netFriends=(JSONArray) data.get("friends");
User user = gson.fromJson(jsonMap.get("user"), User.class);
User user = (User)jsonMap.get("user");
//
Owner newOwner = new Owner();
newOwner.setUsername(user.getUsername());
@ -141,7 +128,6 @@ public class LoginActivity extends BaseActivity {
newOwner.setNetId(user.getIduser());
// newOwner.setName(netUser.getString("name"));
// newOwner.setImageURL(SERVER_URL+netUser.getString("imagePath"));
ownerDao.insert(newOwner); //插入本地数据库
//
// if (netFriends!=null && netFriends.size()>0){
@ -175,7 +161,6 @@ public class LoginActivity extends BaseActivity {
try {
String url = LoginActivity.SERVER_URL + "/main-servlet?action=getUnReadMsg&username="+username;
String jsonStr= OkHttpUtil.synGet(url);
Log.d("记录","未读信息获取响应");
getUnReadMsgResponse(jsonStr);
}catch (Exception e){
e.printStackTrace();
@ -190,62 +175,26 @@ public class LoginActivity extends BaseActivity {
@Override
public void run() {
Gson gson = new Gson();
Map<String, String> jsonMap= gson.fromJson(jsonStr, new TypeToken <Map<String, String>>() {}.getType());
Map jsonMap= gson.fromJson(jsonStr, Map.class);
final String message=(String) jsonMap.get("message");
if (message.equals("success")){
//进行本地消息存储
List<Map<String, String>> msgList = gson.fromJson(jsonMap.get("messageList"), new TypeToken <List<Map<String,String>>>(){}.getType());
List msgList = (List)jsonMap.get("msgList");
for (int i=0;i<msgList.size();i++){
Map<String, String> unReadMsg = msgList.get(i);
// System.out.println(unReadMsg.getSenderNetId());
String content = unReadMsg.get("content");
int messageType = Integer.parseInt(unReadMsg.get("messageType"));
int receiverId = Integer.parseInt(unReadMsg.get("receiverNetId"));
int senderId = Integer.parseInt(unReadMsg.get("senderNetId"));
Long createTime = TimeUtil.stringToTime(unReadMsg.get("createTime")).getTime();
Message unReadMsg = (Message) msgList.get(i);
String content=unReadMsg.getContent();
int messageType=unReadMsg.getMessageType();
int receiverId= unReadMsg.getReceiverNetId();
int senderId= unReadMsg.getSenderNetId();
Long createTime = unReadMsg.getCreateTime();
Message newMessage=new Message(senderId,receiverId,messageType,content,createTime);
messageDao.insert(newMessage);
getNewFriendRequest(senderId);
Log.d("记录","sender:"+senderId+" receiver:"+receiverId);
}
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}
});
}
private void getNewFriendRequest(final int senderId) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = LoginActivity.SERVER_URL + "/main-servlet?action=getNewFriend&senderId="+senderId;
String jsonStr= OkHttpUtil.synGet(url);
getNewFriendResponse(jsonStr, senderId);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getNewFriendResponse(final String jsonStr, final int senderId) {
runOnUiThread(new Runnable() {
private MessageDao messageDao=new MessageDao();
@Override
public void run() {
Gson gson = new Gson();
Map<String, String> jsonMap= gson.fromJson(jsonStr, new TypeToken <Map<String, String>>() {}.getType());
final String message = jsonMap.get("message");
if (message.equals("success")){
//进行本地消息存储
String username = jsonMap.get("username");
FriendDao friendDao = new FriendDao();
if(friendDao.findByNetId(senderId, owner.getNetId())==null){
Friend friend = new Friend(senderId, username, owner.getNetId());
friendDao.insert(friend);
}
}
// getNewFriends(owner.getUsername());
}
});
}

@ -14,7 +14,6 @@ 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;
@ -39,10 +38,6 @@ public class MainActivity extends BaseActivity {
private TextView textMessage;
private TextView textMy;
private String[] channelList = {"全部","经验"
,"康复","扫雷","问答"}; //默认的内导航栏目
static List<List<Blog>> resourceList=new ArrayList<>();
//底部导航点击事件监听器
@ -72,13 +67,14 @@ 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(); //初始化控件
initEvents(); //初始化事件
initFirstRun(0);//第一次运行初始化界面,第一个碎片
//从InfoActivity活动跳转回来到IndexFragment
int flag = getIntent().getIntExtra("flag", 0);
if (flag == 1) {
getSupportFragmentManager()
@ -87,6 +83,21 @@ public class MainActivity extends BaseActivity {
.addToBackStack(null)
.commit();
}
// new Thread(new Runnable() {
// @Override
// public void run() {
// QuestionDao userDao=new QuestionDao();
// try {
// userDao.qInsert();
// userDao.qSelect();
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// }).start();
}
private void initFirstRun(int i) {
@ -168,8 +179,4 @@ public class MainActivity extends BaseActivity {
fragmentList.add(new MessageFragment());
fragmentList.add(new MyFragment());
}
public Fragment getFragment(int i){
return fragmentList.get(i);
}
}

@ -1,32 +1,21 @@
package com.example.leudaemialikeme.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Switch;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.TimeAdapter;
import com.example.leudaemialikeme.Model.Clock;
import com.example.leudaemialikeme.Adapter.AdapterClock;
import com.example.leudaemialikeme.R;
import org.litepal.LitePal;
import org.litepal.crud.LitePalSupport;
import java.util.ArrayList;
import java.util.List;
public class MdctRmdActivity extends BaseActivity {
private RecyclerView lv;
public static TimeAdapter timeAdapter;
private ImageView add_md;
public static List<Clock> list = new ArrayList<>();
Context context = MdctRmdActivity.this;
private ListView lv;
private AdapterClock adapter;
@Override
@ -45,53 +34,24 @@ public class MdctRmdActivity extends BaseActivity {
}
});
add_md = findViewById(R.id.add_md);
add_md.setOnClickListener(new View.OnClickListener() {
lv=(ListView)findViewById(R.id.lv_list_data);
adapter=new AdapterClock(MdctRmdActivity.this);
lv.setAdapter(adapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onClick(View view) {
Intent intent1 = new Intent(MdctRmdActivity.this, AddClock.class);
startActivity(intent1);
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Switch aSwitch=adapter.getaSwitch(i);
if(aSwitch.isChecked()){
aSwitch.setChecked(false);
//进行业务处理
}else {
aSwitch.setChecked(true);
//进行业务处理
}
}
});
lv=(RecyclerView)findViewById(R.id.rv_list_data);
LitePal.getDatabase();
initRecycleView();
// adapter=new TimeAdapter(MdctRmdActivity.this);
//
//
// lv.setAdapter(adapter);
// lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
// @Override
// public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
// Switch aSwitch=adapter.getaSwitch(i);
// if(aSwitch.isChecked()){
// aSwitch.setChecked(false);
// //进行业务处理
// }else {
// aSwitch.setChecked(true);
// //进行业务处理
// }
// }
// });
}
@Override
protected void onRestart(){
super.onRestart();
initRecycleView();
}
private void initRecycleView() {
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
lv.setLayoutManager(layoutManager);
timeAdapter = new TimeAdapter(list, context);
lv.setAdapter(timeAdapter);
list.clear();
List<Clock> list1 = LitePal.findAll(Clock.class);
for (Clock clock : list1) {
list.add(clock);
}
timeAdapter.notifyDataSetChanged();
}
}

@ -1,101 +1,37 @@
package com.example.leudaemialikeme.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Adapter.MyQuestionAdapter;
import com.example.leudaemialikeme.Model.Question;
import com.example.leudaemialikeme.Model.MyQuestion;
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.util.ArrayList;
import java.util.List;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class MyQuestionActivity extends BaseActivity {
private List<Question> questionList = new ArrayList<>();
RecyclerView recycleView;
private boolean isPause = false;
private List<MyQuestion> mData = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_question);
recycleView = findViewById(R.id.my_question_list);//获得视图
getData();//获得数据
RecyclerView recycleView = (RecyclerView) findViewById(R.id.myQuestionList);//获得视图
LinearLayoutManager layoutManager;
layoutManager = new LinearLayoutManager(this);
recycleView.setLayoutManager(layoutManager);//建立线性布局
MyQuestionAdapter adapter = new MyQuestionAdapter(questionList, MyQuestionActivity.this);//创建适配器
MyQuestionAdapter adapter = new MyQuestionAdapter(mData);//创建适配器
recycleView.setAdapter(adapter);//将视图与适配器连接起来
getMyQustionList();
ImageView my_question_back = findViewById(R.id.my_question_back);
my_question_back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
private void getMyQustionList() {
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = LoginActivity.SERVER_URL+"/my-servlet?action=getMyQuestionList&iduser="+ BaseActivity.owner.getNetId();
OkHttpUtil.asyGet(url, 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();
Gson gson = new Gson();
questionList = gson.fromJson(jsonStr, new TypeToken<List<Question>>() {}.getType());
runOnUiThread(new Runnable(){
@Override
public void run() {
MyQuestionAdapter adapter = new MyQuestionAdapter(questionList, MyQuestionActivity.this);//创建适配器
recycleView.setAdapter(adapter);//将视图与适配器连接起来
}
});
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
@Override
protected void onPause() {
super.onPause();
isPause = true; //记录页面已经被暂停
private void getData() {
MyQuestion q1 = new MyQuestion("成人白血病的早期症状有什么?","2浏览","22:24");
mData.add(q1);
MyQuestion q2 = new MyQuestion("幼儿易得白血病吗?","56浏览","09:11");
mData.add(q2);
}
@Override
protected void onResume() {
super.onResume();
if (isPause){ //判断是否暂停
isPause = false;
getMyQustionList();
MyQuestionAdapter adapter = new MyQuestionAdapter(questionList, MyQuestionActivity.this);//创建适配器
recycleView.setAdapter(adapter);//将视图与适配器连接起来
}
}
}

@ -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);
}
});
}
}

@ -7,12 +7,11 @@ 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.Adapter.NewsAdapter;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
@ -29,68 +28,83 @@ import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class BlogSearchResultActivity extends AppCompatActivity {
ImageView blogSearchBackView;
TextView blogSearchTextView;
TextView blogResultBackView;
public class NewsSearchResultActivity extends BaseActivity {
ImageView newsSearchBackView;
TextView newsSearchTextView;
TextView newsResultBackView;
RecyclerView resultRecyclerView;
List<Blog> resultBlog=new ArrayList<>();
List<News> resultNews=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);
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);
BlogAdapter resultAdapter = new BlogAdapter();
NewsAdapter resultAdapter = new NewsAdapter();
initView();
initData(text);
initView();//初始化视图
newsSearchTextView.setText(text);
initData(text);//显示搜索结果
initClick();
resultAdapter.setRecnewsList(resultBlog);
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(){
blogSearchBackView=(ImageView) findViewById(R.id.blog_search_back);
blogResultBackView=(TextView)findViewById(R.id.blog_result_back);
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){
Map<String,String> paramMap=new HashMap<String, String>();
final Map<String,String> paramMap=new HashMap<String, String>();
paramMap.put("text",text);
// Log.e("initData中的text",text);
String url=BaseActivity.SERVER_URL+"/blog-servlet?action=getSearchResult";
final String url=BaseActivity.SERVER_URL+"/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(){
OkHttpUtil.asyPost(url, paramMap, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
@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<Blog>>() {}.getType();
List<Blog> resultList = gson.fromJson(jsonStr, listType);
resultBlog = resultList ;
Type listType = new TypeToken<List<News>>() {}.getType();
final List<News> resultList = gson.fromJson(jsonStr, listType);
resultNews = resultList ;
runOnUiThread(new Runnable() {
@Override
public void run() {
BlogAdapter resultAdapter = new BlogAdapter();
NewsAdapter resultAdapter = new NewsAdapter();
resultAdapter.setRecnewsList(resultList);
resultRecyclerView.setAdapter(resultAdapter);
}
@ -102,13 +116,13 @@ public class BlogSearchResultActivity extends AppCompatActivity {
}
private void initClick() {
blogSearchBackView.setOnClickListener(new View.OnClickListener(){
newsSearchBackView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
finish();
}
});
blogResultBackView.setOnClickListener(new View.OnClickListener() {
newsResultBackView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
@ -128,7 +142,7 @@ public class BlogSearchResultActivity extends AppCompatActivity {
if (isPause) { //判断是否暂停
isPause = false;
Map<String, String[]> paramMap = new HashMap<String, String[]>();
initData(text);
initData(text);//更新数据
}
}
}
}

@ -1,24 +1,74 @@
package com.example.leudaemialikeme.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import com.example.leudaemialikeme.R;
public class SearchActivity extends BaseActivity {
private EditText nEditText;
private ImageView back;
Context context;
Cursor cursor;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
ImageView back;
back =findViewById(R.id.search_to_index);
context = this ;
initView();
// ImageView back;
// back =findViewById(R.id.search_to_index);
//
// 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);
// }
// });
}
private void initView(){
back=(ImageView)findViewById(R.id.search_to_index);
nEditText = (EditText)findViewById(R.id.EditText);//搜索栏
//设置回首页跳转的点击事件
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);
}
});
//搜索栏EditText添加监听
nEditText.addTextChangedListener(new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}//文本改变之前执行
@Override
public void onClick(View v) {
finish();
//文本改变的时候执行
public void onTextChanged(CharSequence s, int start, int before, int count) {
//如果长度为0
if (s.length() == 0) {
// //隐藏“删除”图片
// mImageView.setVisibility(View.GONE);
} else {//长度不为0
//显示“删除图片”
// mImageView.setVisibility(View.VISIBLE);
//显示ListView
// showListView();显示搜索项
}
}
public void afterTextChanged(Editable s) { }//文本改变之后执行
});
}
}
}

@ -14,12 +14,9 @@ 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 {
@ -65,63 +62,44 @@ public class SendInvitationActivity extends BaseActivity {
}
else{
long timeCurrent = System.currentTimeMillis();
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
String time = sdf.format(timeCurrent);
Log.e("输入的time:", time);
Data app = (Data)getApplication();
Map<String,String> paramMap = new HashMap<String,String>();
paramMap.put("uid",String.valueOf(BaseActivity.owner.getNetId()));//需要获取登录用户的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);
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd", 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();
}
}
});
}
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;
@ -132,11 +110,11 @@ public class SendInvitationActivity extends BaseActivity {
case R.id.SendInvitation_radio_experience:
case R.id.SendInvitation_radio_knowledge:
if (isChecked) {
type=button.getText().toString().substring(0,2);
type=button.getText().toString();
}
break;
default:
type="经验";
type="经验";
break;
}
}

@ -4,6 +4,7 @@ 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;
@ -12,12 +13,9 @@ 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 {
@ -40,7 +38,6 @@ public class SendQuestionActivity extends BaseActivity {
setClick();
}
@SuppressWarnings("unchecked")
private void setClick() {
cancelView.setOnClickListener(new View.OnClickListener() {
@Override
@ -56,35 +53,41 @@ 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 HH:mm:ss", Locale.getDefault());
SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
String time = sdf.format(timeCurrent);
// Log.e("输入的time:", time);
Map<String,String> paramMap = new HashMap<String,String>();
Data app = (Data)getApplication();
paramMap.put("uid",String.valueOf(BaseActivity.owner.getNetId())); // 需要获取登陆用户的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);
// 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();
}
}
});
@ -92,43 +95,6 @@ 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,69 @@
package com.example.leudaemialikeme.Adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Switch;
import android.widget.TextView;
import com.example.leudaemialikeme.R;
import java.util.ArrayList;
import java.util.List;
public class AdapterClock extends BaseAdapter {
private String[] names={"甘露聚糖肽胶囊","消癌平糖浆"};
private String[] time={"每天 8:00 14:00 19:00","每天 8:00 14:00 19:00"};
private List<Switch> list_switch;
private Context mContext;
private TextView tv1,tv2;
private Switch aSwitch;
public AdapterClock(Context context) {
mContext=context;
list_switch=new ArrayList<>();
}
public Switch getaSwitch(int position){
return list_switch.get(position);
}
@Override
public int getCount() {
return names.length;
}
@Override
public Object getItem(int i) {
return names[i];
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
view= LayoutInflater.from(mContext).inflate(R.layout.list_item,null);
tv1=(TextView)view.findViewById(R.id.md_name);
tv2=(TextView)view.findViewById(R.id.md_time);
aSwitch=(Switch)view.findViewById(R.id.sw);
list_switch.add(aSwitch);
tv1.setText(names[i]);
tv2.setText(time[i]);
return view;
}
}

@ -9,9 +9,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Model.Friend;
import com.example.leudaemialikeme.Model.Message;
import com.example.leudaemialikeme.Model.MessageItemView;
import com.example.leudaemialikeme.Model.Owner;
import com.example.leudaemialikeme.R;
@ -19,9 +17,8 @@ import java.util.ArrayList;
import java.util.List;
public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
private List<Message> messageList = new ArrayList<Message>();
private List<Message> messageList = new ArrayList<>();
private Owner owner;
private Friend friend;
static class ViewHolder extends RecyclerView.ViewHolder{
LinearLayout msg_content_left;
@ -35,8 +32,6 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
msg_content_right = (LinearLayout) view.findViewById(R.id.msg_content_right);
left_msg = (TextView) view.findViewById(R.id.left_msg);
right_msg = (TextView) view.findViewById(R.id.right_msg);
layouts.add(msg_content_left);
layouts.add(msg_content_right);
}
public void setVisibility(LinearLayout layout){
@ -50,12 +45,13 @@ public class ChatAdapter extends RecyclerView.Adapter<ChatAdapter.ViewHolder> {
}
}
public ChatAdapter(MessageItemView messageItemView){
this.messageList = messageItemView.messages;
this.owner = messageItemView.owner;
this.friend = messageItemView.friend;
public ChatAdapter(List<Message> messageList, Owner owner){
this.messageList = messageList;
this.owner = owner;
}
@NonNull
@Override
public ChatAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {

@ -0,0 +1,60 @@
package com.example.leudaemialikeme.Adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Model.Collect;
import com.example.leudaemialikeme.R;
import java.util.List;
public class CollectAdapter extends RecyclerView.Adapter<CollectAdapter.ViewHolder>{
private List<Collect> collectList;
//重写构造方法
public CollectAdapter(List<Collect> collectList){
this.collectList = collectList;
}
public int getItemCount(){
return collectList.size();
}
//内部类
static class ViewHolder extends RecyclerView.ViewHolder {
TextView collectTitle,collectName,collectContent,collectRead;
ImageView collectIcon,collectImg;
public ViewHolder(@NonNull View itemView){
super(itemView);
this.collectTitle = (TextView)itemView.findViewById(R.id.collectTitle);
this.collectIcon = (ImageView)itemView.findViewById(R.id.collectIcon);
this.collectName = (TextView)itemView.findViewById(R.id.collectName);
this.collectContent = (TextView)itemView.findViewById(R.id.collectContent);
this.collectImg = (ImageView)itemView.findViewById(R.id.collectImg);
this.collectRead = (TextView)itemView.findViewById(R.id.collectRead);
}
}
//重写 onCreateViewHolder()方法
@Override
public CollectAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.collect_item,parent,false);
CollectAdapter.ViewHolder holder=new CollectAdapter.ViewHolder(view);
return holder;
}
//重写onBindViewHolder()方法
@Override
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
Collect collect = collectList.get(position);
holder.collectTitle.setText(collect.getCollectTitle());
holder.collectName.setText(collect.getCollectName());
holder.collectContent.setText(collect.getCollectContent());
holder.collectRead.setText(collect.getCollectRead());
holder.collectIcon.setImageResource(collect.getCollectIconId());
holder.collectImg.setImageResource(collect.getCollectImgId());
}
}

@ -4,7 +4,7 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import com.example.leudaemialikeme.Fragment.BlogCollectFragment;
import com.example.leudaemialikeme.Fragment.AnswerCollectFragment;
import com.example.leudaemialikeme.Fragment.NewsCollectFragment;
public class CollectPageFragmentAdapter extends FragmentPagerAdapter {
@ -24,7 +24,7 @@ public class CollectPageFragmentAdapter extends FragmentPagerAdapter {
return NewsCollectFragment.newInstance(collectCategoryTitle);
}
else {
return BlogCollectFragment.newInstance(collectCategoryTitle);
return AnswerCollectFragment.newInstance(collectCategoryTitle);
}
}
@Override

@ -1,94 +1,54 @@
package com.example.leudaemialikeme.Adapter;
import android.content.Intent;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.AddEventActivity;
import com.example.leudaemialikeme.Model.Event;
import com.example.leudaemialikeme.R;
import java.util.List;
import java.util.Map;
public class EventAdapter extends RecyclerView.Adapter<EventAdapter.ViewHolder>{
// private List<Event> meventList;
private List<Map<String,String>> mcontentList;
private List<Event> meventList;
//重写构造方法
public EventAdapter(List<Map<String,String>> contentList){
this.mcontentList = contentList;
public EventAdapter(List<Event> meventList){
this.meventList = meventList;
}
public int getItemCount(){
return mcontentList.size();
return meventList.size();
}
//内部类
static class ViewHolder extends RecyclerView.ViewHolder {
View eventView;
TextView event_day,event_month,event_info,event_time;
TextView event_place,event_doctor_name,event_create_time;
LinearLayout event_item_layout;
public ViewHolder(@NonNull View itemView){
super(itemView);
eventView = itemView;
this.event_day = (TextView)itemView.findViewById(R.id.event_day);
this.event_month = (TextView)itemView.findViewById(R.id.event_month);
this.event_info = (TextView)itemView.findViewById(R.id.event_info);
this.event_time = (TextView)itemView.findViewById(R.id.event_time);
this.event_place = itemView.findViewById(R.id.event_place);
this.event_doctor_name = itemView.findViewById(R.id.event_doctor_name);
this.event_create_time = itemView.findViewById(R.id.event_create_time);
this.event_item_layout = itemView.findViewById(R.id.event_item_layout);
}
}
//重写 onCreateViewHolder()方法
@Override
public EventAdapter.ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
public EventAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.event_item,parent,false);
// EventAdapter.ViewHolder holder=new EventAdapter.ViewHolder(view);
final ViewHolder holder = new ViewHolder(view);
holder.eventView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = holder.getAdapterPosition();
String event_day = mcontentList.get(position).get("event_day");
String event_month = mcontentList.get(position).get("event_month");
String event_info = mcontentList.get(position).get("event_info");
String event_place = mcontentList.get(position).get("event_place");
String event_doctor_name = mcontentList.get(position).get("event_doctor_name");
String event_time = mcontentList.get(position).get("event_time");
String event_create_time = mcontentList.get(position).get("event_create_time");
Intent intent = new Intent(parent.getContext(), AddEventActivity.class);
intent.putExtra(AddEventActivity.EVENT_DAY,event_day);
intent.putExtra(AddEventActivity.EVENT_MONTH,event_month);
intent.putExtra(AddEventActivity.EVENT_INFO,event_info);
intent.putExtra(AddEventActivity.EVENT_PLACE,event_place);
intent.putExtra(AddEventActivity.EVENT_DOCTOR_NAME,event_doctor_name);
intent.putExtra(AddEventActivity.EVENT_TIME,event_time);
intent.putExtra(AddEventActivity.EVENT_CREATE_TIME,event_create_time);
parent.getContext().startActivity(intent);
}
});
EventAdapter.ViewHolder holder=new EventAdapter.ViewHolder(view);
return holder;
}
//重写onBindViewHolder()方法
@Override
public void onBindViewHolder(@NonNull ViewHolder holder,int position){
holder.event_day.setText(mcontentList.get(position).get("event_day"));
holder.event_month.setText(mcontentList.get(position).get("event_month"));
holder.event_info.setText(mcontentList.get(position).get("event_info"));
holder.event_time.setText(mcontentList.get(position).get("event_time"));
holder.event_place.setText(mcontentList.get(position).get("event_place"));
holder.event_doctor_name.setText(mcontentList.get(position).get("event_doctor_name"));
holder.event_create_time.setText(mcontentList.get(position).get("event_create_time"));
Event event = meventList.get(position);
holder.event_day.setText(event.getEvent_day());
holder.event_month.setText(event.getEvent_month());
holder.event_info.setText(event.getEvent_info());
holder.event_time.setText(event.getEvent_time());
}
}

@ -11,7 +11,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BlogDetailActivity;
import com.example.leudaemialikeme.Activity.DetailActivity;
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(), BlogDetailActivity.class);
Intent intent=new Intent(view.getContext(), DetailActivity.class);
//intent.putExtra("from",String.valueOf(view.getContext()));
//Log.e("activity",String.valueOf(view.getContext()));
view.getContext().startActivity(intent);

@ -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;
}//返回有效视图的数量
}

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

@ -7,13 +7,9 @@ import androidx.fragment.app.FragmentPagerAdapter;
import com.example.leudaemialikeme.Fragment.MessageChannelFragment;
import java.util.ArrayList;
import java.util.List;
public class MessagePageFragmentAdapter extends FragmentPagerAdapter {
private String[] channelList;
private FragmentManager fm;
private List<MessageChannelFragment> mcfList = new ArrayList<>();
public MessagePageFragmentAdapter(@NonNull FragmentManager fm, String[] channelList) {
super(fm);
this.channelList = channelList;
@ -24,17 +20,12 @@ public class MessagePageFragmentAdapter extends FragmentPagerAdapter {
@Override
public Fragment getItem(int position) {
String MessageCategoryTitle = channelList[position];
MessageChannelFragment mcf = MessageChannelFragment.newInstance(MessageCategoryTitle);
mcfList.add(mcf);
return mcf;
return MessageChannelFragment.newInstance(MessageCategoryTitle);
}
@Override
public int getCount() {
return channelList.length;
}
public MessageChannelFragment getMcf(int i){
return mcfList.get(i);
}
}

@ -1,7 +1,5 @@
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;
@ -12,39 +10,31 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.ChatActivity;
import com.example.leudaemialikeme.Dao.MessageDao;
import com.example.leudaemialikeme.Model.Chat;
import com.example.leudaemialikeme.Model.Msg;
import com.example.leudaemialikeme.R;
import java.util.List;
public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.ViewHolder> {
private List<Chat> chatList;
private MessageDao messageDao = new MessageDao();
private List<Msg> msgList;
static class ViewHolder extends RecyclerView.ViewHolder{
ImageView portrait;
TextView nickname;
TextView introduction;
LinearLayout linear_msg;
ImageView point;
TextView chat_friend_id;
public ViewHolder(View view){
super(view);
portrait = (ImageView)view.findViewById(R.id.img_portrait);
nickname = (TextView)view.findViewById(R.id.text_nickname);
introduction = (TextView)view.findViewById(R.id.text_introduction);
linear_msg = (LinearLayout)view.findViewById(R.id.linear_msg);
point = (ImageView)view.findViewById(R.id.img_unread);
chat_friend_id = (TextView)view.findViewById(R.id.chat_friend_id);
}
}
public MsgAdapter(List<Chat> chatList) {
this.chatList = chatList;
public MsgAdapter(List<Msg> msgList) {
this.msgList = msgList;
}
@NonNull
@ -52,43 +42,27 @@ public class MsgAdapter extends RecyclerView.Adapter<MsgAdapter.ViewHolder> {
public MsgAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.pivate_msg_item,parent,false);
MsgAdapter.ViewHolder holder=new MsgAdapter.ViewHolder(view);
// holder.linear_msg.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View view) {
//
// Intent intent = new Intent(view.getContext(), ChatActivity.class);
// intent.putExtra("friendId", fdddddddd);
// }
// });
holder.linear_msg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO 跳转到聊天界面
}
});
return holder;
}
@Override
public void onBindViewHolder(@NonNull final MsgAdapter.ViewHolder holder, int position) {
final Chat chat = chatList.get(position);
holder.introduction.setText(String.valueOf(chat.getLastMessage()));
holder.nickname.setText(chat.getFriendName());
holder.chat_friend_id.setText(String.valueOf(chat.getFriendId()));
Log.d("MsgAdapter","chat_friend_id:"+chat.getFriendId());
if(chat.getFlag()==1){
holder.point.setVisibility(View.GONE);
}
holder.itemView.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
messageDao.changeMsgStatus(Integer.parseInt(holder.chat_friend_id.getText().toString()), BaseActivity.owner.getNetId());
Intent intent = new Intent(v.getContext(), ChatActivity.class);
intent.putExtra("friendNetId",chat.getFriendId());
v.getContext().startActivity(intent);
holder.point.setVisibility(View.GONE);
// checkFriendRequest(params);
}
});
public void onBindViewHolder(@NonNull MsgAdapter.ViewHolder holder, int position) {
Msg msg = msgList.get(position);
holder.portrait.setImageResource(msg.getPortraitID());
holder.introduction.setText(String.valueOf(msg.getIntroduction()));
holder.nickname.setText(msg.getNickname());
}
@Override
public int getItemCount() {
return chatList.size();
return msgList.size();
}
}

@ -1,7 +1,5 @@
package com.example.leudaemialikeme.Adapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -10,89 +8,46 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.LoginActivity;
import com.example.leudaemialikeme.Activity.QuestionDetailActivity;
import com.example.leudaemialikeme.Model.Question;
import com.example.leudaemialikeme.Model.MyQuestion;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.example.leudaemialikeme.Utils.TimeUtil;
import java.util.List;
public class MyQuestionAdapter extends RecyclerView.Adapter<MyQuestionAdapter.ViewHolder>{
private List<Question> questionList;
private Context context;
private List<MyQuestion> myQuestionList;
//重写构造方法
public MyQuestionAdapter(List<Question> questionList, Context context){
this.questionList = questionList;
this.context = context;
public MyQuestionAdapter(List<MyQuestion> myQuestionList){
this.myQuestionList = myQuestionList;
}
public int getItemCount(){
return myQuestionList.size();
}
//内部类
static class ViewHolder extends RecyclerView.ViewHolder {
private TextView text_my_question_id;
private TextView text_my_question_title;
private TextView text_my_question_browse;
private TextView text_my_question_time;
private TextView text_my_question_flag;
TextView questionInfo,questionRead,questionTime;
public ViewHolder(@NonNull View itemView){
super(itemView);
text_my_question_id = itemView.findViewById(R.id.text_my_question_id);
text_my_question_title = itemView.findViewById(R.id.text_my_question_title);
text_my_question_browse = itemView.findViewById(R.id.text_my_question_browse);
text_my_question_time = itemView.findViewById(R.id.text_my_question_time);
text_my_question_flag = itemView.findViewById(R.id.text_my_question_flag);
this.questionInfo = (TextView)itemView.findViewById(R.id.myQuestionInfo);
this.questionRead = (TextView)itemView.findViewById(R.id.myQuestionRead);
this.questionTime = (TextView)itemView.findViewById(R.id.myQuestionTime);
}
}
//重写 onCreateViewHolder()方法
@Override
public MyQuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.my_question_item,parent,false);
final MyQuestionAdapter.ViewHolder holder=new MyQuestionAdapter.ViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int qid = Integer.parseInt(holder.text_my_question_id.getText().toString());
addQuestionBrowse(qid);
Intent intent = new Intent(context, QuestionDetailActivity.class);
intent.putExtra("qid", qid);
context.startActivity(intent);
}
});
MyQuestionAdapter.ViewHolder holder=new MyQuestionAdapter.ViewHolder(view);
return holder;
}
private void addQuestionBrowse(int qid) {
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = LoginActivity.SERVER_URL+"/main-servlet?action=addQuestionBrowse&qid="+qid+"&iduser="+ BaseActivity.owner.getNetId();
OkHttpUtil.synGet(url);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
//重写onBindViewHolder()方法
@Override
public void onBindViewHolder(@NonNull MyQuestionAdapter.ViewHolder holder, int position){
Question question = questionList.get(position);
holder.text_my_question_id.setText(String.valueOf(question.getQid()));
holder.text_my_question_title.setText(question.getQtittle());
holder.text_my_question_browse.setText(String.valueOf(question.getQbrowseNum()));
holder.text_my_question_time.setText(TimeUtil.timeToString(question.getQtime()));
if(question.getFlag()==1)
holder.text_my_question_flag.setText("已审核");
}
@Override
public int getItemCount(){
return questionList.size();
MyQuestion question = myQuestionList.get(position);
holder.questionInfo.setText(question.getMyQuestionInfo());
holder.questionRead.setText(question.getMyQuestionRead());
holder.questionTime.setText(question.getMyQuestionTime());
}
}

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

@ -1,96 +1,55 @@
package com.example.leudaemialikeme.Adapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
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.LoginActivity;
import com.example.leudaemialikeme.Activity.QuestionDetailActivity;
import com.example.leudaemialikeme.Model.Question;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.example.leudaemialikeme.Utils.TimeUtil;
import java.util.List;
public class QuestionAdapter extends RecyclerView.Adapter<QuestionAdapter.ViewHolder>{
private List<Question> questionList;
private Context context;
//重写构造方法
public QuestionAdapter(List<Question> questionList, Context context){
public QuestionAdapter(List<Question> questionList){
this.questionList = questionList;
this.context = context;
}
public QuestionAdapter(){
}
public int getItemCount(){
return questionList.size();
}
//内部类
static class ViewHolder extends RecyclerView.ViewHolder {
private TextView questionId, questiontitle,questionInfo,questionRead,questionTime;
TextView questionInfo,questionRead,questionTime;
LinearLayout questionMore;
public ViewHolder(@NonNull View itemView){
super(itemView);
this.questionId = itemView.findViewById(R.id.question_id);
this.questiontitle = itemView.findViewById(R.id.questionTitle);
this.questionInfo = (TextView)itemView.findViewById(R.id.questionInfo);
this.questionRead = (TextView)itemView.findViewById(R.id.questionRead);
this.questionTime = (TextView)itemView.findViewById(R.id.questionTime);
this.questionMore = (LinearLayout) itemView.findViewById(R.id.questionMore);
}
}
public void setQuestionList(List<Question> questionList){
this.questionList=questionList;
}
//重写 onCreateViewHolder()方法
@Override
public QuestionAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view= LayoutInflater.from(parent.getContext()).inflate(R.layout.question_item,parent,false);
QuestionAdapter.ViewHolder holder=new QuestionAdapter.ViewHolder(view);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int qid = Integer.parseInt(holder.questionId.getText().toString());
addQuestionBrowse(qid);
Intent intent = new Intent(context, QuestionDetailActivity.class);
intent.putExtra("qid", qid);
context.startActivity(intent);
}
});
return holder;
}
private void addQuestionBrowse(int qid) {
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = LoginActivity.SERVER_URL+"/main-servlet?action=addQuestionBrowse&qid="+qid+"&iduser="+ BaseActivity.owner.getNetId();
OkHttpUtil.synGet(url);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
//重写onBindViewHolder()方法
@Override
public void onBindViewHolder(@NonNull QuestionAdapter.ViewHolder holder, int position){
Question question = questionList.get(position);
holder.questionId.setText(String.valueOf(question.getQid()));
holder.questiontitle.setText(question.getQtittle());
holder.questionInfo.setText(question.getQcontent());
holder.questionRead.setText(String.valueOf(question.getQbrowseNum()));
holder.questionTime.setText(TimeUtil.timeToString(question.getQtime()));
holder.questionInfo.setText(question.getQuestionInfo());
holder.questionRead.setText(question.getQuestionRead());
holder.questionTime.setText(question.getQuestionTime());
}
}

@ -12,7 +12,7 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.leudaemialikeme.Activity.BlogDetailActivity;
import com.example.leudaemialikeme.Activity.DetailActivity;
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(), BlogDetailActivity.class);
Intent intent=new Intent(view.getContext(), DetailActivity.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().substring(0,17));
holder.time.setText(recnews.getTime());
}
@Override

@ -2,7 +2,6 @@ package com.example.leudaemialikeme.Dao;
import android.database.Cursor;
import android.util.Log;
import com.example.leudaemialikeme.Model.Message;
import com.example.leudaemialikeme.Utils.DBUtil;
@ -40,7 +39,6 @@ public class MessageDao extends BaseDao {
ArrayList<Message> messages=DBUtil.cursorToList(cursor,Message.class);
if (messages.size()==0){
Log.d("MessageDao","findUnReadMessage无未读消息");
return null;
}else {
return messages;

@ -0,0 +1,110 @@
package com.example.leudaemialikeme.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.example.leudaemialikeme.Adapter.CollectAdapter;
import com.example.leudaemialikeme.Model.Collect;
import com.example.leudaemialikeme.R;
import java.util.ArrayList;
import java.util.List;
/**
* A simple {@link Fragment} subclass.
* Activities that contain this fragment must implement the
* to handle interaction events.
* Use the {@link AnswerCollectFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class AnswerCollectFragment extends Fragment {
private static final String ARG_CATEGORY_TITLE = "category_title";
private String collectCategoryTitle = "Default";
private List<Collect> collectList = new ArrayList<>();
private SwipeRefreshLayout mSwipeRefreshLayout;
public AnswerCollectFragment() {
// Required empty public constructor
}
public static AnswerCollectFragment newInstance(String collectCategoryTitle) {
Bundle args = new Bundle();
args.putString(ARG_CATEGORY_TITLE, collectCategoryTitle);
AnswerCollectFragment fragment = new AnswerCollectFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
collectCategoryTitle = (String) getArguments().getString(ARG_CATEGORY_TITLE);
}catch (java.lang.NullPointerException e)
{
System.out.println("TestFragment getArg error!");
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_answer_collect, container, false);
getData();//获得数据
RecyclerView recycleView = (RecyclerView) view.findViewById(R.id.APNList);//获得视图
LinearLayoutManager layoutManager;
layoutManager = new LinearLayoutManager(getActivity());
recycleView.setLayoutManager(layoutManager);//建立线性布局
final CollectAdapter adapter = new CollectAdapter(collectList);//创建适配器
recycleView.setItemAnimator(new DefaultItemAnimator());//设置动画效果
recycleView.setAdapter(adapter);
mSwipeRefreshLayout = view.findViewById(R.id.refresh_layout);
// mTextView = view.findViewById(R.id.tv_pull_down_refresh);
handleDownPullUpdate();
return view;
}
private void handleDownPullUpdate() {
mSwipeRefreshLayout.setEnabled(true);
mSwipeRefreshLayout.setColorSchemeResources(R.color.colorAccent,R.color.colorPrimary,R.color.light_grey);
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
//不再显示提示正在刷新和刷新成功
// mTextView.setText("正在刷新...");
//被刷新时的操作
//更新UI
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//更新成功后设置UI停止更新
// mTextView.setText("刷新成功!!!");
mSwipeRefreshLayout.setRefreshing(false);
}
},3000);
}
});
}
private void getData() {
Collect collect1 = new Collect("临时的测算", R.mipmap.img_my_person, "病因很重要", "加油加油"
, R.mipmap.img_search, "12浏览");
collectList.add(collect1);
Collect collect2 = new Collect("临时的测算", R.mipmap.img_my_person, "病因很重要", "加油加油"
, R.mipmap.img_search, "12浏览");
collectList.add(collect2);
}
}

@ -1,20 +1,22 @@
package com.example.leudaemialikeme.Fragment;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import com.example.leudaemialikeme.Adapter.CollectPageFragmentAdapter;
import com.example.leudaemialikeme.R;
@ -30,12 +32,11 @@ public class CollectFragment extends Fragment implements ViewPager.OnPageChangeL
private ViewPager viewPager; //内导航的碎片的容器
private RadioGroup rgChannelCollect=null; // 内导航由单选按钮组构成
private HorizontalScrollView hvChannelCollect=null; //单选按钮组可滚动动
private String[] channelList = {" 资讯 "," 帖子 ",
private String[] channelList = {" 资讯 "," 回答与文章 ",
}; //默认的内导航栏目
private CollectPageFragmentAdapter adapter; //viewPager 的适配器
private TextView Name;
private String title;
private ImageView back_collect;
public CollectFragment() {
// Required empty public constructor
@ -50,7 +51,6 @@ public class CollectFragment extends Fragment implements ViewPager.OnPageChangeL
Bundle savedInstanceState) {
if(view==null){
view=inflater.inflate(R.layout.fragment_collect, container, false);
back_collect = view.findViewById(R.id.back_collect);
viewPager=(ViewPager)view.findViewById(R.id.vpNewsListCollect);
initViewPager(); //设置 ViewPager
@ -68,12 +68,6 @@ public class CollectFragment extends Fragment implements ViewPager.OnPageChangeL
}
}
);
back_collect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
}
});
}
return view;
}
@ -127,6 +121,7 @@ public class CollectFragment extends Fragment implements ViewPager.OnPageChangeL
DisplayMetrics metrics=new DisplayMetrics();
super.getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int screenWidth=metrics.widthPixels;
// int len=left+width/2-screenWidth/2;
int len=left+width/2-screenWidth/2;
hvChannelCollect.smoothScrollTo(len,0);
}

@ -11,7 +11,6 @@ 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;
@ -20,34 +19,25 @@ 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 static ViewPager viewPager; //内导航的碎片的容器
private 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() {
@ -61,7 +51,6 @@ 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);
@ -97,8 +86,8 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
return false;
}
});
bar_send_invitation = (Button)popupWindow_view.findViewById(R.id.bar_send_invitation);
bar_send_question = (Button)popupWindow_view.findViewById(R.id.bar_send_question);
bar_send_invitation = (Button)popupWindow_view.findViewById(R.id.bar_send_invitation);//发帖
bar_send_question = (Button)popupWindow_view.findViewById(R.id.bar_send_question);//提问
bar_answer = (Button)popupWindow_view.findViewById(R.id.bar_answer);
bar_send_invitation.setOnClickListener(new View.OnClickListener() {
@Override
@ -123,16 +112,6 @@ 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;
}
@ -141,8 +120,7 @@ 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);
String text=" "+channelList[i]+" ";
rb.setText(text);
rb.setText(channelList[i]);
RadioGroup.LayoutParams params = new
RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
@ -152,30 +130,19 @@ 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(1);
//设置显示第 1 个碎片
viewPager.setOffscreenPageLimit(2);
//设置显示第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) {
@ -190,7 +157,6 @@ 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);
@ -203,4 +169,5 @@ public class CommunityFragment extends Fragment implements ViewPager.OnPageChang
hvChannel.smoothScrollTo(len,0);
}
}

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

@ -0,0 +1,477 @@
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 String infoCategoryTitle = "Default";
private int infoCategoryTitleNum = 0;
//public static List<List<News>> resourceList=new ArrayList<>();
public static List<News> allNews=new ArrayList<>();
// private TextView mTitleField;
// private List<Recnews> recNews=new ArrayList<>();
// static List<News> newsList=new ArrayList<>();//全部
// private List<News> newsLists=new ArrayList<>();
static List<News> comNews=new ArrayList<>();//公司
static List<News> redNews=new ArrayList<>();//红十字
static List<News> govNews=new ArrayList<>();//政府
static List<News> chaNews=new ArrayList<>();//慈善
// static BlogAdapter allAdapter=new BlogAdapter();
static NewsAdapter comAdapter=new NewsAdapter();//公司的adapter
static NewsAdapter redAdapter=new NewsAdapter();//红十字的adapter
static NewsAdapter govAdapter=new NewsAdapter();//政府的adapter
static NewsAdapter chaAdapter=new NewsAdapter();//慈善的adapter
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 (java.lang.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());
chaRecyclerView.setLayoutManager(layoutManager);
chaRecyclerView.setAdapter(chaAdapter);
// Log.e("应该为4慈善", String.valueOf(invitationCategoryTitleNum));
} else if (infoCategoryTitleNum == 2) {//这里是红十字
redRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
redRecyclerView.setLayoutManager(layoutManager);
redRecyclerView.setAdapter(redAdapter);
// Log.e("应该为2红十字", String.valueOf(invitationCategoryTitleNum));
// Log.e("应该为2红十字",String.valueOf(recBlog));
} else if (infoCategoryTitleNum == 3) {//这里是政府
govRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
govRecyclerView.setLayoutManager(layoutManager);
govRecyclerView.setAdapter(govAdapter);
// Log.e("应该为3政府", String.valueOf(invitationCategoryTitleNum));
}
else if (infoCategoryTitleNum == 1) {//这里是公司
comRecyclerView = (RecyclerView) view.findViewById(R.id.list_community);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
comRecyclerView.setLayoutManager(layoutManager);
comRecyclerView.setAdapter(comAdapter);
}
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);
InfoChannelFragment.comNews=comNewsList;
Log.e("comNews的数据(公司)",String.valueOf(comNewsList));
comRecyclerView= (RecyclerView) (getActivity().getLayoutInflater().inflate(R.layout.recyclerview, null)).findViewById(R.id.list_community);
comAdapter.setRecnewsList(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);
InfoChannelFragment.redNews=redNewsList;
Log.e("resNews的数据(公司)",String.valueOf(redNewsList));
redAdapter.setRecnewsList(redNews);
redRecyclerView= (RecyclerView) (getActivity().getLayoutInflater().inflate(R.layout.recyclerview, null)).findViewById(R.id.list_community);
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);
InfoChannelFragment.govNews=govNewsList;
Log.e("govNews的数据(公司)",String.valueOf(govNewsList));
govAdapter.setRecnewsList(govNews);
govRecyclerView= (RecyclerView) (getActivity().getLayoutInflater().inflate(R.layout.recyclerview, null)).findViewById(R.id.list_community);
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);
InfoChannelFragment.chaNews=chaNewsList;
Log.e("chaNews的数据(公司)",String.valueOf(chaNewsList));
chaAdapter.setRecnewsList(chaNews);
chaRecyclerView= (RecyclerView) (getActivity().getLayoutInflater().inflate(R.layout.recyclerview, null)).findViewById(R.id.list_community);
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);
}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);
}
}
}
}

@ -6,57 +6,49 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.viewpager.widget.ViewPager;
import com.example.leudaemialikeme.Adapter.HistoryPageFragmentAdapter;
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 HistoryFragment extends Fragment implements ViewPager.OnPageChangeListener{
// private static final String ARG_CHANNEL_LIST = "channel_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 rgChannelCollect=null; // 内导航由单选按钮组构成
private HorizontalScrollView hvChannelCollect=null; //单选按钮组可滚动动
private String[] channelList = {" 资讯 "," 问题 "," 帖子 "
}; //默认的内导航栏目
private HistoryPageFragmentAdapter adapter; //viewPager 的适配器
private TextView Name;
private String title;
private ImageView back_history;
public HistoryFragment() {
// Required empty public constructor
}
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 HistoryFragment(String title){
this.title = title;
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_history, container, false);
back_history = view.findViewById(R.id.back_history);
viewPager=(ViewPager)view.findViewById(R.id.vpNewsListHistory);
if(view==null) {
view = inflater.inflate(R.layout.fragment_info, container, false);//显示碎片的布局
viewPager=(ViewPager)view.findViewById(R.id.vpNewsListInfo);//加了这,后面就闪退了
initViewPager(); //设置 ViewPager
rgChannelCollect=(RadioGroup)view.findViewById(R.id.rgChannelHistory);
hvChannelCollect=(HorizontalScrollView)view.findViewById(R.id.hvChannelHistory);
initTab(inflater);
rgChannel=(RadioGroup)view.findViewById(R.id.rgChannel20);
hvChannel=(HorizontalScrollView)view.findViewById(R.id.hvChannel20);
initTab(inflater);//初始化内导航标签
Name = (TextView)view.findViewById(R.id.Name);
Name.setText(title);
rgChannelCollect.setOnCheckedChangeListener(
rgChannel.setOnCheckedChangeListener( //单选按钮的监听事件
new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
@ -64,17 +56,12 @@ public class HistoryFragment extends Fragment implements ViewPager.OnPageChangeL
}
}
);
back_history.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getActivity().finish();
}
});
}
return view;
}
private void initTab(LayoutInflater inflater) {//初始化上面的
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);
@ -83,22 +70,41 @@ public class HistoryFragment extends Fragment implements ViewPager.OnPageChangeL
RadioGroup.LayoutParams(RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
rgChannelCollect.addView(rb,params);
rgChannel.addView(rb,params);
}
rgChannelCollect.check(0);
rgChannel.check(0);
}
private void initViewPager() { //初始化ViewPager
private void initViewPager() {
FragmentManager fragmentManager = super.getActivity().getSupportFragmentManager();
// adapter=new MessagePageFragmentAdapter(fragmentManager, channelList);
adapter=new HistoryPageFragmentAdapter(fragmentManager, channelList);
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片 //设置 ViewPager 的适配器
adapter=new InfoPageFragmentAdapter(fragmentManager, channelList);
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片
// 设置 ViewPager 的适配器
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(2);
//设置显示第 1 个碎片
viewPager.setCurrentItem(0);//这里设置显示第一个碎片
//设置 ViewPager 的切换监听
viewPager.addOnPageChangeListener(this);
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
@ -115,15 +121,6 @@ public class HistoryFragment extends Fragment implements ViewPager.OnPageChangeL
public void onPageScrollStateChanged(int state) {
}
private void setTab(int idx){
RadioButton rb=(RadioButton)rgChannelCollect.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;
hvChannelCollect.smoothScrollTo(len,0);
}
}
}

@ -1,519 +1,102 @@
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.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.Adapter.RecnewsAdapter;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.example.leudaemialikeme.Model.Recnews;
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;
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 = {"全部", "经验"
, "康复", "扫雷", "问答"};
private List<Recnews> recNews=new ArrayList<>();
// int temp=0;
public InvitationChannelFragment() {
// Required empty public constructor
}
public static InvitationChannelFragment newInstance(String invitationCategoryTitle, int pos) {
public static InvitationChannelFragment newInstance(String invitationCategoryTitle) {
InvitationChannelFragment fragment = new InvitationChannelFragment();
Bundle args = new Bundle();
args.putString(ARG_CATEGORY_TITLE, invitationCategoryTitle);
args.putInt(ARG_CATEGORY_TITLE_NUM, pos);
args.putString(ARG_CATEGORY_TITLE,invitationCategoryTitle);
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);
invitationCategoryTitleNum = getArguments().getInt(ARG_CATEGORY_TITLE_NUM);
// Log.e("onCreate","onCreate");
} catch (java.lang.NullPointerException e) {
try{
invitationCategoryTitle = (String)getArguments().getString(ARG_CATEGORY_TITLE);
}catch (java.lang.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);
// 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());
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);
if(invitationCategoryTitle.equals("全部")||invitationCategoryTitle.equals("关注")){
//放那个recycleView
view = inflater.inflate(R.layout.recyclerview,container,false);
RecyclerView recyclerView = (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();
recyclerView.setLayoutManager(layoutManager);
RecnewsAdapter adapter = new RecnewsAdapter(recNews);
recyclerView.setAdapter(adapter);
// 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;
else {
view = inflater.inflate(R.layout.fragment_invitation_channel, container, false);
mTitleField = (TextView)view.findViewById(R.id.invitationCategoryTitle);
mTitleField.setText(invitationCategoryTitle);
}
return view;
}
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, getContext());
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);
}
private void initRecNews(){
for(int i=0;i<2;i++){
Recnews news1=new Recnews(R.drawable.rec_news1,
"哪些人容易得白血病?得白血病的人往往有这种征兆...",
"白血病早期是会有一定症状的。比如持续发烧,一些急性白血病前期会出现持续发热,发热原因可能是由于感染……"
,102,"2021-11-6 09:19:54"
);
recNews.add(news1);
Recnews news2=new Recnews(R.drawable.rec_news2,
"抨击误区——白血病化疗那么痛苦,干脆不做化疗了?!",
" “白血病化疗病死率高!不治病还促进病情严重!”“白血病用化疗药很痛苦的,别治了……"
,100,"2021-12-6 03:19:54"
);
recNews.add(news2);
Recnews news3=new Recnews(R.drawable.rec_news3,
"小天使医典:儿童白血病康复指引",
"目前,医学界公认的儿童白血病的发病率为 4-6/10 万人。其中,新增儿童\n" +
"白血病患儿就占二分之一……"
,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);
}
}
}
}

@ -1,7 +1,6 @@
package com.example.leudaemialikeme.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -11,11 +10,9 @@ 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.MsgAdapter;
import com.example.leudaemialikeme.Model.Chat;
import com.example.leudaemialikeme.Model.Msg;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.service.ChatService;
import java.util.ArrayList;
import java.util.List;
@ -24,8 +21,7 @@ public class MessageChannelFragment extends Fragment {
private static final String ARG_CATEGORY_TITLE = "category_title";
private String messageCategoryTitle = "Default";
private TextView mTitleField;
private List<Chat> chatList = new ArrayList<Chat>();
private RecyclerView recyclerView;
private List<Msg> msgList = new ArrayList<Msg>();
public MessageChannelFragment() {
// Required empty public constructor
@ -55,21 +51,19 @@ public class MessageChannelFragment extends Fragment {
View view;
if (messageCategoryTitle.equals(" 私信 ")) {
view = inflater.inflate(R.layout.fragment_private_msg,container,false);
recyclerView = view.findViewById(R.id.list_private_msg);
System.out.println("oncreateview:"+recyclerView);
RecyclerView recyclerView = (RecyclerView)view.findViewById(R.id.list_private_msg);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(layoutManager);
Log.d("记录","调用方法获取消息列表");
getMsgList();
MsgAdapter msgAdapter = new MsgAdapter(chatList);
MsgAdapter msgAdapter = new MsgAdapter(msgList);
recyclerView.setAdapter(msgAdapter);
} else if (messageCategoryTitle.equals(" 评论 ")) {
view = inflater.inflate(R.layout.fragment_comment, container, false);
} else if (messageCategoryTitle.equals(" 赞 ")) {
view = inflater.inflate(R.layout.fragment_nice, container, false);
} else if (messageCategoryTitle.equals(" 粉丝 ")) {
view = inflater.inflate(R.layout.fragment_fans, container, false);
} else if (messageCategoryTitle.equals(" 赞 ")) {
view = inflater.inflate(R.layout.fragment_nice, container, false);
} else {
view = inflater.inflate(R.layout.fragment_message_channel, container, false);
mTitleField = (TextView) view.findViewById(R.id.messageCategoryTitle);
@ -79,32 +73,7 @@ public class MessageChannelFragment extends Fragment {
}
private void getMsgList(){
ChatService chatService = new ChatService();
chatList = chatService.findChatList(BaseActivity.owner.getNetId());
Log.d("chatlist:", String.valueOf(chatList.size()));
}
// @Override
// public void onResume() {
// System.out.println("-----------------------");
// super.onResume();
// System.out.println("-----------------------");
// getMsgList();
// MsgAdapter adapter = new MsgAdapter(chatList);
// System.out.println("onresume:" + recyclerView);
// recyclerView.setAdapter(adapter);
// recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
// }
public void updateUi(){
getMsgList();
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
MsgAdapter adapter = new MsgAdapter(chatList);
recyclerView.setAdapter(adapter);
}
});
}
public String getMessageCategoryTitle(){
return messageCategoryTitle;
Msg msg = new Msg(R.drawable.img_user1, "张三", " ");
msgList.add(msg);
}
}

@ -72,7 +72,8 @@ public class MessageFragment extends Fragment implements ViewPager.OnPageChangeL
private void initViewPager() { //初始化ViewPager
FragmentManager fragmentManager = super.getActivity().getSupportFragmentManager();
adapter = new MessagePageFragmentAdapter(fragmentManager, channelList);
// adapter=new MessagePageFragmentAdapter(fragmentManager, channelList);
adapter=new MessagePageFragmentAdapter(fragmentManager, channelList);
//参数 channelList 将被适配器用来在动态切换碎片的时候实时创建碎片 //设置 ViewPager 的适配器
viewPager.setAdapter(adapter);
viewPager.setOffscreenPageLimit(2);//并设置预加载页数为2
@ -108,7 +109,4 @@ public class MessageFragment extends Fragment implements ViewPager.OnPageChangeL
int len=left+width/2-screenWidth/2;
hvChannel.smoothScrollTo(len,0);
}
public MessagePageFragmentAdapter getAdapter(){
return adapter;
}
}

@ -5,7 +5,6 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -14,31 +13,31 @@ import androidx.fragment.app.Fragment;
import com.example.leudaemialikeme.Activity.APNActivity;
import com.example.leudaemialikeme.Activity.AboutActivity;
import com.example.leudaemialikeme.Activity.AttentionActivity;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.CollectActivity;
import com.example.leudaemialikeme.Activity.ConcernedProblemActivity;
import com.example.leudaemialikeme.Activity.EventActivity;
import com.example.leudaemialikeme.Activity.HistoryActivity;
import com.example.leudaemialikeme.Activity.LoginActivity;
import com.example.leudaemialikeme.Activity.MdctRmdActivity;
import com.example.leudaemialikeme.Activity.MyInfoActivity;
import com.example.leudaemialikeme.Activity.MyQuestionActivity;
import com.example.leudaemialikeme.Activity.SafetyActivity;
import com.example.leudaemialikeme.Model.User;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
import java.io.IOException;
/**
* A simple {@link Fragment} subclass.
* Use the {@link MyFragment#newInstance} factory method to
* create an instance of this fragment.
*/
public class MyFragment extends Fragment {
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
public class MyFragment extends Fragment {
private User user;
private TextView text_nickname;
public MyFragment() {
// Required empty public constructor
@ -47,6 +46,10 @@ public class MyFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
@Override
@ -55,43 +58,9 @@ public class MyFragment extends Fragment {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_my, container, false);
initClick(view);
text_nickname = view.findViewById(R.id.nickname);
getUser();
return view;
}
private void getUser() {
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = LoginActivity.SERVER_URL+"/my-servlet?action=getUser&username="+ BaseActivity.owner.getUsername();
OkHttpUtil.asyGet(url, 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();
Gson gson = new Gson();
user = gson.fromJson(jsonStr, User.class);
getActivity().runOnUiThread(new Runnable(){
@Override
public void run() {
text_nickname.setText(user.getUsername());
}
});
}
});
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void initClick(View view) {
//关注的问题,提醒和大事记的线性布局
LinearLayout remindLinear = view.findViewById(R.id.my_remind_linear);
@ -107,19 +76,6 @@ public class MyFragment extends Fragment {
TextView invitation = view.findViewById(R.id.my_invitation);
TextView consent = view.findViewById(R.id.my_consent);
TextView attention = view.findViewById(R.id.attention);
//个人信息更多
ImageView img_go_my_info = view.findViewById(R.id.img_go_my_info);
//个人信息管理跳转
img_go_my_info.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), MyInfoActivity.class);
intent.putExtra("user", user);
startActivity(intent);
}
});
//设置文本点击之后的跳转
answer.setOnClickListener(new View.OnClickListener() {
@Override

@ -1,6 +1,10 @@
package com.example.leudaemialikeme.Fragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DefaultItemAnimator;
@ -8,31 +12,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.MainActivity;
import com.example.leudaemialikeme.Adapter.CollectNewsAdapter;
import com.example.leudaemialikeme.Model.News;
import com.example.leudaemialikeme.Adapter.CollectAdapter;
import com.example.leudaemialikeme.Model.Collect;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.example.leudaemialikeme.Utils.TimeUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.sql.Timestamp;
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;
/**
* A simple {@link Fragment} subclass.
@ -44,9 +29,8 @@ import okhttp3.Response;
public class NewsCollectFragment extends Fragment {
private static final String ARG_CATEGORY_TITLE = "category_title";
private String collectCategoryTitle = "Default";
private List<News> collectList = new ArrayList<>();
private List<Collect> collectList = new ArrayList<>();
private SwipeRefreshLayout mSwipeRefreshLayout;
private RecyclerView newsCollectrecycleView;
public NewsCollectFragment() {
// Required empty public constructor
@ -76,14 +60,14 @@ public class NewsCollectFragment extends Fragment {
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_news_collect, container, false);
newsCollectrecycleView = (RecyclerView) view.findViewById(R.id.newsCollectList);//获得视图
getData();//获得数据
RecyclerView recycleView = (RecyclerView) view.findViewById(R.id.APNList);//获得视图
LinearLayoutManager layoutManager;
layoutManager = new LinearLayoutManager(getActivity());
newsCollectrecycleView.setLayoutManager(layoutManager);//建立线性布局
final CollectNewsAdapter adapter = new CollectNewsAdapter(collectList);//创建适配器
newsCollectrecycleView.setItemAnimator(new DefaultItemAnimator());//设置动画效果
newsCollectrecycleView.setAdapter(adapter);
getData();//获得数据
recycleView.setLayoutManager(layoutManager);//建立线性布局
final CollectAdapter adapter = new CollectAdapter(collectList);//创建适配器
recycleView.setItemAnimator(new DefaultItemAnimator());//设置动画效果
recycleView.setAdapter(adapter);
mSwipeRefreshLayout = view.findViewById(R.id.refresh_layout);
// mTextView = view.findViewById(R.id.tv_pull_down_refresh);
handleDownPullUpdate();
@ -114,50 +98,11 @@ public class NewsCollectFragment extends Fragment {
}
private void getData(){
// News collect1 = new News(1,1,"1","临时测试","能解决的!",TimeUtil.stringToTime("2022-01-07 12:12:12"),3);
// collectList.add(collect1);
// News collect2 = new News(1,1,"1","临时测试2","能解决的!",TimeUtil.stringToTime("2022-01-07 12:12:12"),5);
// collectList.add(collect2);
new Thread(new Runnable() {
@Override
public void run() {
try{
String url = MainActivity.SERVER_URL+"/my-servlet?action=collectNews&uid="+BaseActivity.owner.getNetId()+"&type="+1;
Callback callback = new Callback() {
@Override
public void onFailure(Call call, IOException e) {
System.out.println("-----ERROR----");
}
@Override
public void onResponse(Call call, Response response) throws IOException {
String jsonStr = response.body().string();
Gson gson = new Gson();
Map<String, String> jsonMap= gson.fromJson(jsonStr, new TypeToken<Map<String, String>>() {}.getType());
final String message=(String) jsonMap.get("message");
if (message.equals("success")) {
List<News> newsList = gson.fromJson(jsonMap.get("newsList"), new TypeToken <List<News>>(){}.getType());
for(int i=0;i<newsList.size();i++){
News startNews = newsList.get(i);
int nid = startNews.getNid();
int sid = startNews.getSid();
String stype = startNews.getStype();
String stittle = startNews.getStittle();
String scontent = startNews.getScontent();
Timestamp stime = startNews.getStime();
int sbrowseNum = startNews.getSbrowseNum();
News endNews = new News(nid,sid,stype,stittle,scontent,stime,sbrowseNum);
collectList.add(endNews);
}
}
}
};
OkHttpUtil.asyGet(url,callback);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
Collect collect1 = new Collect("临时测算",R.mipmap.img_my_person,"病因很重要","加油加油"
,R.mipmap.img_search,"12浏览");
collectList.add(collect1);
Collect collect2 = new Collect("临时测算",R.mipmap.img_my_person,"病因很重要","加油加油"
,R.mipmap.img_search,"12浏览");
collectList.add(collect2);
}
}

@ -0,0 +1,72 @@
package com.example.leudaemialikeme.Model;
import java.io.Serializable;
public class Collect implements Serializable {
private static final long serialVersionUID = 1L;
private String collectTitle;
private int collectIconId;
private String collectName;
private String collectContent;
private int collectImgId;
private String collectRead;
public Collect(String collectTitle, int collectIconId, String collectName,
String collectContent, int collectImgId, String collectRead){
this.collectTitle = collectTitle;
this.collectIconId = collectIconId;
this.collectName = collectName;
this.collectContent = collectContent;
this.collectRead = collectRead;
this.collectImgId = collectImgId;
}
public String getCollectTitle() {
return collectTitle;
}
public void setCollectTitle(String collectTitle) {
this.collectTitle = collectTitle;
}
public int getCollectIconId() {
return collectIconId;
}
public void setCollectIconId(int collectIconId) {
this.collectIconId = collectIconId;
}
public String getCollectName() {
return collectName;
}
public void setCollectName(String collectName) {
this.collectName = collectName;
}
public String getCollectContent() {
return collectContent;
}
public void setCollectContent(String collectContent) {
this.collectContent = collectContent;
}
public int getCollectImgId() {
return collectImgId;
}
public void setCollectImgId(int collectImgId) {
this.collectImgId = collectImgId;
}
public String getCollectRead() {
return collectRead;
}
public void setCollectRead(String collectRead) {
this.collectRead = collectRead;
}
}

@ -1,34 +1,21 @@
package com.example.leudaemialikeme.Model;
import org.litepal.annotation.Column;
import org.litepal.crud.LitePalSupport;
import java.io.Serializable;
public class Event extends LitePalSupport implements Serializable {
public class Event implements Serializable {
private static final long serialVersionUID = 1L;
//声明所有的变量
private String event_day;
private String event_month;
@Column(unique = true)
private String event_info;
private String event_place;
private String event_doctor_name;
private String event_time;
private String event_create_time;
public Event(){}
public Event(String event_day, String event_month, String event_info, String event_place, String event_doctor_name, String event_time, String event_create_time) {
public Event(String event_day,String event_month,String event_info,String event_time){
this.event_day = event_day;
this.event_month = event_month;
this.event_info = event_info;
this.event_place = event_place;
this.event_doctor_name = event_doctor_name;
this.event_month =event_month;
this.event_time = event_time;
this.event_create_time = event_create_time;
}
public String getEvent_day() {
return event_day;
}
@ -60,28 +47,4 @@ public class Event extends LitePalSupport implements Serializable {
public void setEvent_time(String event_time) {
this.event_time = event_time;
}
public String getEvent_place() {
return event_place;
}
public String getEvent_doctor_name() {
return event_doctor_name;
}
public String getEvent_create_time() {
return event_create_time;
}
public void setEvent_place(String event_place) {
this.event_place = event_place;
}
public void setEvent_doctor_name(String event_doctor_name) {
this.event_doctor_name = event_doctor_name;
}
public void setEvent_create_time(String event_create_time) {
this.event_create_time = event_create_time;
}
}

@ -0,0 +1,41 @@
package com.example.leudaemialikeme.Model;
import java.io.Serializable;
public class MyQuestion implements Serializable {
private static final long serialVersionUID = 1L;
//声明所有变量
private String MyQuestionInfo;
private String MyQuestionRead;
private String MyQuestionTime;
public MyQuestion(String MyQuestionInfo,String MyQuestionRead,String MyQuestionTime){
this. MyQuestionInfo = MyQuestionInfo;
this.MyQuestionRead = MyQuestionRead;
this.MyQuestionTime = MyQuestionTime;
}
public String getMyQuestionInfo() {
return MyQuestionInfo;
}
public void setMyQuestionInfo(String myQuestionInfo) {
MyQuestionInfo = myQuestionInfo;
}
public String getMyQuestionRead() {
return MyQuestionRead;
}
public void setMyQuestionRead(String myQuestionRead) {
MyQuestionRead = myQuestionRead;
}
public String getMyQuestionTime() {
return MyQuestionTime;
}
public void setMyQuestionTime(String myQuestionTime) {
MyQuestionTime = myQuestionTime;
}
}

@ -5,82 +5,81 @@ import java.sql.Timestamp;
public class News implements Serializable {
private static final long serialVersionUID = 1L;
private int nid;
private int sid;
private String stype;
private String stittle;
private String scontent;
private Timestamp stime;
private int sbrowseNum;
private int nid;//资讯编号
private int sid;//小编的编号
private String stype;//资讯类型
private String stittle;//资讯标题
private String scontent;//资讯内容
private Timestamp stime;//发布时间
private int sbrowseNum;//浏览量
public News(){
}
public News(int nid, int sid, String stype, String stittle, String scontent, Timestamp stime, int sbrowseNum) {
this.nid = nid;
this.sid = sid;
this.stype = stype;
this.stittle = stittle;
this.scontent = scontent;
this.stime = stime;
this.sbrowseNum = sbrowseNum;
}
public News(int nid,String stype,String stittle,String scontent,Timestamp stime,int sbrowseNum) {
this.nid=nid;
this.stype=stype;
this.stittle=stittle;
this.scontent=scontent;
this.stime=stime;
this.sbrowseNum=sbrowseNum;
}
public int getNid() {
return nid;
}
public void setNid(int nid) {
this.nid = nid;
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public String getStype() {
return stype;
}
public void setStype(String stype) {
this.stype = stype;
}
public String getStittle() {
return stittle;
}
public void setStittle(String stittle) {
this.stittle = stittle;
}
public String getScontent() {
return scontent;
}
public int getSbrowseNum() {
return sbrowseNum;
public void setScontent(String scontent) {
this.scontent = scontent;
}
public Timestamp getStime() {
return stime;
}
public void setNid(int nid) {
this.nid = nid;
}
public void setSid(int sid) {
this.sid = sid;
}
public void setStype(String stype) {
this.stype = stype;
}
public void setStittle(String stittle) {
this.stittle = stittle;
}
public void setScontent(String scontent) {
this.scontent = scontent;
}
public void setStime(Timestamp stime) {
this.stime = stime;
}
public int getSbrowseNum() {
return sbrowseNum;
}
public void setSbrowseNum(int sbrowseNum) {
this.sbrowseNum = sbrowseNum;
}
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=1; //本地数据库自增id
private int id; //本地数据库自增id
@Column(unique = true)
private int netId; //mysql自增id
@Column(unique = true)

@ -1,98 +1,41 @@
package com.example.leudaemialikeme.Model;
import java.io.Serializable;
import java.sql.Timestamp;
public class Question implements Serializable {
private static final long serialVersionUID = 1L;
private int qid;
private int uid;
private String qtittle;
private String qcontent;
private Timestamp qtime;
private int qfollowNum;
private int qanswerNum;
private int qbrowseNum;
private int flag;
//声明所有变量
private String questionInfo;
private String questionRead;
private String questionTime;
public Question() {}
public Question(int uid,String qtitle,String qcontent,Timestamp qtime,
int qfollowNum,int qanswerNum,int qbrowseNum,int flag) {
this.uid=uid;
this.qtittle=qtitle;
this.qcontent=qcontent;
this.qtime=qtime;
this.qfollowNum=qfollowNum;
this.qanswerNum=qanswerNum;
this.qbrowseNum=qbrowseNum;
this.flag=flag;
public Question(String questionInfo,String questionRead,String questionTime){
this. questionInfo = questionInfo;
this.questionRead = questionRead;
this.questionTime = questionTime;
}
public Question(int qid, int uid, String qtittle, String qcontent, Timestamp timestamp, int qfollowNum, int qanswerNum,
int qbrowseNum, int flag) {
super();
this.qid = qid;
this.uid = uid;
this.qtittle = qtittle;
this.qcontent = qcontent;
this.qtime = timestamp;
this.qfollowNum = qfollowNum;
this.qanswerNum = qanswerNum;
this.qbrowseNum = qbrowseNum;
this.flag = flag;
public String getQuestionInfo() {
return questionInfo;
}
public int getQid() {
return qid;
}
public void setQid(int qid) {
this.qid = qid;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public String getQtittle() {
return qtittle;
}
public void setQtittle(String qtittle) {
this.qtittle = qtittle;
}
public String getQcontent() {
return qcontent;
}
public void setQcontent(String qcontent) {
this.qcontent = qcontent;
}
public Timestamp getQtime() {
return qtime;
}
public void setQtime(Timestamp qtime) {
this.qtime = qtime;
}
public int getQfollowNum() {
return qfollowNum;
}
public void setQfollowNum(int qfollowNum) {
this.qfollowNum = qfollowNum;
}
public int getQanswerNum() {
return qanswerNum;
}
public void setQanswerNum(int qanswerNum) {
this.qanswerNum = qanswerNum;
public void setQuestionInfo(String questionInfo) {
this.questionInfo = questionInfo;
}
public int getQbrowseNum() {
return qbrowseNum;
public String getQuestionRead() {
return questionRead;
}
public void setQbrowseNum(int qbrowseNum) {
this.qbrowseNum = qbrowseNum;
public void setQuestionRead(String questionRead) {
this.questionRead = questionRead;
}
public int getFlag() {
return flag;
public String getQuestionTime() {
return questionTime;
}
public void setFlag(int flag) {
this.flag = flag;
public void setQuestionTime(String questionTime) {
this.questionTime = questionTime;
}
}

@ -1,8 +1,6 @@
package com.example.leudaemialikeme.Model;
import java.io.Serializable;
public class User implements Serializable {
public class User {
private int iduser;
private String username;
private String password;

@ -1,16 +1,37 @@
package com.example.leudaemialikeme.Utils;
import com.example.leudaemialikeme.Model.User;
import com.example.leudaemialikeme.Model.News;
import java.util.ArrayList;
import java.util.List;
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 int uid=1;
public String id="430481200101220131";
public String name="abc";
public int getUid(){
return uid;
}
public User getUser(){
return user;
public void setUid(int uid){
this.uid= uid;
}
public String getId(){
return this.id;
}
public void setId(String id){
this.id= id;
}
//1.6下午两点加的
private List<News> newsList =new ArrayList<>();
public void setNewsList(List<News> newsList){
this.newsList=newsList;
}
//下午五点加的
public List<News> getNewsList() {
return this.newsList ;
}
}

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

@ -2,29 +2,20 @@ package com.example.leudaemialikeme.service;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import android.widget.Toast;
import androidx.annotation.RequiresApi;
import com.example.leudaemialikeme.Activity.BaseActivity;
import com.example.leudaemialikeme.Activity.ChatActivity;
import com.example.leudaemialikeme.Activity.MainActivity;
import com.example.leudaemialikeme.Controller.ActivityController;
import com.example.leudaemialikeme.Fragment.MessageChannelFragment;
import com.example.leudaemialikeme.Fragment.MessageFragment;
import com.example.leudaemialikeme.Model.Message;
import com.example.leudaemialikeme.R;
import com.example.leudaemialikeme.Utils.OkHttpUtil;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.sql.Timestamp;
import java.util.Map;
import java.util.Objects;
public class WebSocketClient extends org.java_websocket.client.WebSocketClient {
@ -37,7 +28,6 @@ public class WebSocketClient extends org.java_websocket.client.WebSocketClient {
public static final int MSG_TEXT=1;
public static final int MSG_IMAGE=2;
public static final int MSG_SYSTEM=3;
private MainActivity mainActivity;
public WebSocketClient(URI serverURI){
@ -49,45 +39,50 @@ public class WebSocketClient extends org.java_websocket.client.WebSocketClient {
Log.d("WS","链接开启");
}
@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onMessage(String message){
try {
// friendDao=new FriendDao();
Log.d("WS",message+" onMessage()回调");
Log.d("WS",message);
//提取消息
Map<String, String> jsonMap = gson.fromJson(message, new TypeToken<Map<String, String>>() {}.getType());
String content = jsonMap.get("content");
int messageType = Integer.parseInt(Objects.requireNonNull(jsonMap.get("messageType")));
int receiverId = Integer.parseInt(Objects.requireNonNull(jsonMap.get("receiverNetId")));
int senderId = Integer.parseInt(Objects.requireNonNull(jsonMap.get("senderNetId")));
long createTime = Timestamp.valueOf(jsonMap.get("createTime")).getTime();
Message unReadMsg= gson.fromJson(message, Message.class);
String content=(String) unReadMsg.getContent();
int messageType=(int)unReadMsg.getMessageType();
int receiverId=(int)unReadMsg.getReceiverNetId();
int senderId=(int)unReadMsg.getSenderNetId();
long createTime=(long) unReadMsg.getCreateTime();
Message newMessage=new Message(senderId,receiverId,messageType, content, createTime);
Log.d("刷新","获取到对面发送的消息");
//获取当前活动对象
currentActivity= ActivityController.getCurrentActivity();
// //判断消息发送者是否为本地好友,如果不是本地好友,需要进行好友同步,0表示是系统发送的消息
// if (senderId!=0){
// Friend friend=friendDao.findByNetId(senderId,receiverId);
// if (friend==null){
// getNewFriends(senderId,receiverId);
// }
// }
//根据消息类型进行判断
/****/
String currentActivityName=currentActivity.getLocalClassName();
Log.d("刷新","当前活动名:"+currentActivityName);
if (messageType==MSG_SYSTEM){
if (content.equals("offline")){
offline();
}
}else {
//如果当前活动为聊天活动则进行数据展示
if (currentActivityName.equals("Activity.ChatActivity")){
Log.d("刷新","当前在聊天界面活动页");
if (currentActivityName.equals("activity.ChatActivity")){
updateChatUi(newMessage);
// 如果当前活动为聊天列表界面,需要对指定的元素进行局部更新,如果没有该用户在聊天列表中,需要添加该好友项
}else if (currentActivity.findViewById(R.id.chat_list_layout)!=null){
newMessage.save();
updateChatListUi();
//如果当前活动为聊天列表界面,需要对指定的元素进行局部更新,如果没有该用户在聊天列表中,需要添加该好友项
// }else if (currentActivityName.equals("activity.ChatListActivity")){
// newMessage.save();
// updateChatListUi();
}else{
newMessage.save();
notification();
updateChatListUi();
}
}
/****/
}catch (Exception e){
e.printStackTrace();
}
@ -108,41 +103,31 @@ public class WebSocketClient extends org.java_websocket.client.WebSocketClient {
currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
chatActivity = (ChatActivity) currentActivity;
//如果当前正在聊天的人为消息的发送者,则进行展示,并存为已读消息
if (chatActivity.friendNetId == newMessage.getSenderNetId()){
Log.d("刷新","当前聊天的人与消息发送者为同一人");
chatActivity.addMsg(newMessage,1);
}
//如果当前正在聊天的人不是消息发送者,则更新一个未读标记
else {
//TODO
// chatActivity=(ChatActivity) currentActivity;
// //如果当前正在聊天的人为消息的发送者,则进行展示,并存为已读消息
// if (chatActivity.friendNetId==newMessage.getSenderNetId()){
// chatActivity.addMsg(newMessage,true);
// }
// //如果当前正在聊天的人不是消息发送者,则更新一个未读标记
// else {
// chatActivity.hasNewMsgView.setVisibility(View.VISIBLE);
newMessage.setFlag(0);
newMessage.save();
}
// newMessage.setRead(false);
// newMessage.save();
// }
}
});
}
public void updateChatListUi(){
currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
mainActivity = (MainActivity) currentActivity;
// FragmentManager fm = mainActivity.getSupportFragmentManager();
// Log.d("刷新","当前碎片管理:"+fm.toString());
// MessageChannelFragment mcf = (MessageChannelFragment) fm.findFragmentById(R.id.fragment_message_channel);
// Log.d("刷新","当前所在碎片:"+mcf);
// MessageChannelFragment msgcf = (MessageChannelFragment) mainActivity.getSupportFragmentManager().findFragmentById(R.id.fragment_message_channel);
// MessageChannelFragment mcf = new MessageChannelFragment();
MessageFragment mf = (MessageFragment) mainActivity.getFragment(2);
MessageChannelFragment mcf = mf.getAdapter().getMcf(0);
Log.d("当前碎片的名字滑动页:", mcf.getMessageCategoryTitle());
mcf.updateUi();
Log.d("刷新","聊天列表刷新完成");
}
});
}
// public void updateChatListUi(){
// currentActivity.runOnUiThread(new Runnable() {
// @Override
// public void run() {
// privateMsgFragment =(ChatListActivity) currentActivity;
// chatListActivity.updateUi();
// }
// });
// }
public void notification(){
currentActivity.runOnUiThread(new Runnable() {
@Override
@ -162,26 +147,26 @@ public class WebSocketClient extends org.java_websocket.client.WebSocketClient {
ex.printStackTrace();
}
// //好友数据同步
// private void getNewFriends(final int friendNetId,final int ownerNetId){
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// String url = BaseActivity.SERVER_URL + "/user/getNewFriendById/"+ownerNetId+"/"+friendNetId;
// String jsonStr= OkHttpUtil.synGet(url);
// getNewFriendsResponse(jsonStr);
// }catch (Exception e){
// e.printStackTrace();
// }
// }
// }).start();
// }
// private void getNewFriendsResponse(final String jsonStr){
// currentActivity.runOnUiThread(new Runnable() {
// @Override
// public void run() {
//
//好友数据同步
private void getNewFriends(final int friendNetId,final int ownerNetId){
new Thread(new Runnable() {
@Override
public void run() {
try {
String url = BaseActivity.SERVER_URL + "/user/getNewFriendById/"+ownerNetId+"/"+friendNetId;
String jsonStr= OkHttpUtil.synGet(url);
getNewFriendsResponse(jsonStr);
}catch (Exception e){
e.printStackTrace();
}
}
}).start();
}
private void getNewFriendsResponse(final String jsonStr){
currentActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
//TODO
// Map jsonMap= JSON.parseObject(jsonStr);
// final String message=(String) jsonMap.get("message");
// if (message.equals("success")){
@ -195,7 +180,10 @@ public class WebSocketClient extends org.java_websocket.client.WebSocketClient {
// friend.save();
// Toast.makeText(currentActivity,"你有新的好友与消息",Toast.LENGTH_SHORT).show();
// }
// }
// });
}
});
}
// public void connectBlocking() {
// }
}

@ -12,11 +12,10 @@
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/apn_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="20dp"
android:src="@mipmap/left_back"
android:src="@mipmap/img_go_answer_return"
/>
</LinearLayout>
@ -71,35 +70,45 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="@drawable/shape_round_corner"
android:orientation="vertical">
<RelativeLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#fff">
<!-- 导航标签,包含一个单选按钮组-->
<!-- 任意数量不能显示时的缩略符号 -->
<HorizontalScrollView
android:id="@+id/hvChannel"
android:layout_width="match_parent"
android:background="@color/cardview_light_background"
android:orientation="horizontal">
<TextView
android:id="@+id/textView32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/ivShowChannel"
android:scrollbars="none">
android:layout_weight="1"
android:textSize="18dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="30dp"
android:layout_marginBottom="20dp"
android:text="回答" />
<RadioGroup
android:id="@+id/rgChannel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" />
</HorizontalScrollView>
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="18dp"
android:layout_marginLeft="-30dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:text="帖子" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpNewsList"
android:layout_width="match_parent"
android:layout_height="0dp" android:layout_weight="1"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -15,14 +15,14 @@
android:layout_marginBottom="10dp">
<ImageButton
android:id="@+id/bt_chat_to_chat_list"
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/left_back"
android:background="@color/white"/>
<TextView
android:id="@+id/text_chat_name"
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
@ -49,11 +49,11 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:maxLines="2"
android:hint="type here" />
android:hint="type here"
android:maxLength="3"/>
<Button
android:id="@+id/bt_send_msg"
android:id="@+id/bt_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"

@ -9,23 +9,24 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/back_concerned"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="15dp"
android:src="@mipmap/left_back"
android:src="@mipmap/img_go_answer_return"
/>
<TextView
android:id="@+id/text_concern_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:textSize="20dp"
android:layout_weight="4"
android:textSize="18dp"
android:gravity="center"
android:layout_gravity="center"
android:text="关注的问题" />
</LinearLayout>

@ -6,279 +6,379 @@
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="match_parent"
android:orientation="vertical"
android:background="@drawable/background"
>
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="100dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#FFFFFF"
android:orientation="vertical"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/detail_to"
android:layout_width="47dp"
android:layout_height="34dp"
android:layout_gravity="center"
android:src="@drawable/back" />
<TextView
android:id="@+id/textView30"
android:layout_width="306dp"
android:layout_height="match_parent"
android:gravity="center"
android:text="详情"
android:textSize="19dp"
android:textStyle="bold" />
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" />
<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>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp">
<LinearLayout
android:layout_width="wrap_content"
<TextView
android:id="@+id/detail_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
android:text="急性白血病经验分享,第一帖"
android:textSize="20dp" />
<TextView
android:id="@+id/detail_theme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="急性白血病经验分享,第一帖"
android:textSize="20dp" />
</LinearLayout>
</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:layout_marginBottom="10dp"
android:background="#FFFFFF">
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView13"
android:layout_width="104dp"
android:layout_height="40dp"
android:layout_weight="1"
app:srcCompat="@drawable/person" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:padding="10dp">
android:layout_marginLeft="5dp">
<LinearLayout
<TextView
android:id="@+id/textView36"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView13"
android:layout_width="104dp"
android:layout_height="40dp"
android:layout_weight="1"
app:srcCompat="@drawable/person" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp">
<TextView
android:id="@+id/author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="病因很重要"
android:textSize="18dp"/>
<TextView
android:id="@+id/author_intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="管住嘴,迈开腿,多喝水" />
</LinearLayout>
</LinearLayout>
android:layout_height="wrap_content"
android:text="病因很重要"
android:textSize="18dp"/>
<TextView
android:id="@+id/bContent"
android:id="@+id/textView37"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="缘起: 一直以来都有很多人劝我希望我可以把自己的经历写下来,我的医生,我的同学,
android:text="管住嘴,迈开腿,多喝水" />
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/textView38"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=" 缘起: 一直以来都有很多人劝我希望我可以把自己的经历写下来,我的医生,我的同学,
我的朋友,他们觉得我的经历很有意义,虽然我自己也认同这一点,一直很难以动笔,原因有二,其一觉得
自己学理工的,对自己的文笔没什么自信。其二过往的经历实在是痛苦,写下来的过程无异于把好不容易重
合的伤疤撕开一次,自己的内心实在是有点胆怯。\n \n一谈谈我对白血病的看法\n
合的伤疤撕开一次,自己的内心实在是有点胆怯。"
android:layout_gravity="center"
android:layout_margin="10dp"/>
<TextView
android:id="@+id/textView39"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="一:谈谈我对白血病的看法
初次知道白血病是通过日本电影《血疑》,我相信和我年纪相当的人很多也都是通过这部电影知道这个疾病,当然我从未想过我
会与此牵扯上关系甚至在自己22岁以后的生命中处处时时需要考虑它对我的影响。我初次得病是1998年在那个年代白血病
的确依旧是一个很恐怖的病,我当初的症状就是四肢布满红色出血点,低烧吵死不退,牙龈出血,记得每次早上起床,嘴里总是
有凝结的血块,那是虽然不懂这是怎么回事,但是总是担心的要命,于是便经常刷牙,希望仅仅是上火所致,也不敢去看医生,
于是就自己买消炎药吃,希望可以平安过去。"
android:layout_gravity="center"
android:paddingTop="15dp"
android:layout_margin="10dp"/>
android:layout_gravity="center"
android:layout_margin="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_margin="20dp">
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_margin="20dp">
android:id="@+id/detail_like"
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:background="@drawable/search_background"
android:gravity="center"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/detail_like"
android:layout_width="70dp"
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/zan" />
<TextView
android:id="@+id/detail_like_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:background="@drawable/search_background"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/zan" />
<TextView
android:id="@+id/detail_like_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0" />
<TextView
android:id="@+id/textView41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="赞" />
</LinearLayout>
<LinearLayout
android:id="@+id/detail_col"
android:layout_width="77dp"
android:layout_marginLeft="5dp"
android:text="0" />
<TextView
android:id="@+id/textView41"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/search_background"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView15"
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/collect" />
<TextView
android:id="@+id/detail_col_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0" />
<TextView
android:id="@+id/textView43"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="收藏" />
</LinearLayout>
android:layout_marginLeft="5dp"
android:text="赞" />
</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">
android:id="@+id/detail_col"
android:layout_width="77dp"
android:layout_height="wrap_content"
android:background="@drawable/search_background"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/imageView15"
android:layout_width="20dp"
android:layout_height="20dp"
app:srcCompat="@drawable/collect" />
<TextView
android:id="@+id/textView45"
android:id="@+id/detail_col_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="评论"
android:textSize="19dp"/>
android:text="0" />
<TextView
android:id="@+id/comment_num"
android:id="@+id/textView43"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(0)"
android:textSize="17dp" />
android:text="收藏" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpNewsList_detail"
android:layout_width="match_parent"
<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:layout_weight="1" />
android:text="评论"
android:textSize="19dp"/>
<TextView
android:id="@+id/textView46"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="(0)"
android:textSize="17dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#FFFFFF">
android:layout_height="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/commentuser1"
android:layout_width="104dp"
android:layout_height="30dp"
android:layout_weight="1"
app:srcCompat="@drawable/person" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_round_corner"
android:layout_margin="20dp">
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp">
<TextView
android:id="@+id/commentuname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="刘哈哈与大先生"
android:textSize="18dp"/>
<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" />
<TextView
android:id="@+id/comment_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="赞了Ao的回答"
android:textSize="14dp"/>
</LinearLayout>
</LinearLayout>
<EditText
android:id="@+id/comment_edit"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/commentuser2"
android:layout_width="104dp"
android:layout_height="30dp"
android:layout_weight="1"
app:srcCompat="@drawable/person" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginLeft="5dp">
<TextView
android:id="@+id/commentuname2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:hint="写评论"
android:background="#F1EEEE"
android:layout_marginTop="10dp"/>
android:text="亚子读书"
android:textSize="18dp"/>
<TextView
android:id="@+id/comment_commit"
android:layout_width="wrap_content"
android:id="@+id/comment_content2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20dp"
android:gravity="center"
android:layout_marginTop="10dp"
android:text="发布" />
android:layout_marginTop="8dp"
android:text="赞了Ao的回答"
android:textSize="14dp"/>
</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="wrap_content"
android:background="@drawable/shape_round_corner"
android:layout_margin="20dp">
<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" />
<EditText
android:id="@+id/editTextTextPersonName"
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"/>
<TextView
android:id="@+id/comment_commit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20dp"
android:gravity="center"
android:layout_marginTop="10dp"
android:text="发布" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

@ -16,7 +16,6 @@
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="15dp"
android:id="@+id/back_my"
android:src="@mipmap/img_go_answer_return" />
<TextView
@ -33,7 +32,6 @@
android:layout_height="30dp"
android:layout_margin="15dp"
android:src="@mipmap/img_add"
android:id="@+id/add_event"
/>
</LinearLayout>

@ -10,6 +10,6 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/history_frag_layout">
android:id="@+id/collect_frag_layout">
</FrameLayout>
</LinearLayout>

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

@ -63,9 +63,9 @@
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
<ListView
android:layout_margin="18dp"
android:id="@+id/rv_list_data"
android:id="@+id/lv_list_data"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

@ -9,40 +9,31 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/my_question_back"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="12dp"
android:src="@mipmap/left_back"
android:layout_margin="15dp"
android:src="@mipmap/img_go_answer_return"
/>
<TextView
android:id="@+id/text_concern_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="110dp"
android:textSize="20dp"
android:layout_weight="4"
android:textSize="18dp"
android:gravity="center"
android:layout_gravity="center"
android:text="我的提问" />
</LinearLayout>
<LinearLayout
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/myQuestionList"
android:background="@color/light_grey"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/light_grey">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/my_question_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
android:layout_height="match_parent" />
</LinearLayout>

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

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

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

@ -39,7 +39,7 @@
android:layout_weight="1"
android:background="@null"
android:gravity="center_vertical"
android:text="请输入搜索内容" />
android:hint="请输入搜索内容" />
</LinearLayout>
@ -58,18 +58,23 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:layout_weight="1"
android:text="搜索发现"
android:textSize="20dp"
android:layout_margin="30dp"
android:textColor="#000000"/>
android:textColor="#000000"
android:textSize="20dp" />
<ListView
android:id="@+id/listview"
android:layout_width="match_parent"
android:layout_height="0dp"></ListView>
</LinearLayout>

@ -77,6 +77,12 @@ 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"

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:background="@drawable/shape_round_corner"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="wrap_content">
<TextView
android:id="@+id/collectTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="18dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_weight="3"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:orientation="horizontal">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:id="@+id/collectIcon"
/>
<TextView
android:id="@+id/collectName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="14dp"
android:layout_marginLeft="20dp"
android:layout_gravity="center"
/>
</LinearLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:id="@+id/collectContent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
/>
</LinearLayout>
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_weight="1"
android:id="@+id/collectImg"
/>
</LinearLayout>
<TextView
android:id="@+id/collectRead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="16dp"
android:layout_marginLeft="20dp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/event_item_layout"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
@ -11,16 +9,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="28dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="30dp"
/>
<TextView
android:id="@+id/a"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="20dp"
android:text="号"
android:layout_marginLeft="20dp"
android:layout_marginTop="30dp"
/>
@ -30,24 +19,14 @@
android:layout_height="wrap_content"
android:textSize="18dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="-20dp"
android:layout_weight="1"
/>
<TextView
android:id="@+id/aa"
android:layout_width="10dp"
android:layout_height="wrap_content"
android:textSize="18dp"
android:layout_marginTop="40dp"
android:layout_marginLeft="-10dp"
android:text="月"
android:layout_weight="1"
/>
/>
<LinearLayout
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="8"
android:layout_weight="6"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:background="@color/white"
@ -59,117 +38,21 @@
android:layout_margin="10dp"
android:orientation="horizontal">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="start"
android:src="@mipmap/event_dot"
android:foregroundGravity="center"
/>
<LinearLayout
android:layout_width="211dp"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1">
<TextView
android:id="@+id/textView55"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="事件信息:"
android:textSize="16dp" />
<TextView
android:id="@+id/event_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="事件信息"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1">
<TextView
android:id="@+id/textView57"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="事件地点:"
android:textSize="16dp" />
<TextView
android:id="@+id/event_place"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="事件地点"
android:textSize="18dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="5dp"
android:layout_weight="1">
<TextView
android:id="@+id/textView56"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="事件医生名:"
android:textSize="16dp" />
<TextView
android:id="@+id/event_doctor_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:text="事件医生名"
android:textSize="18dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/textView59"
android:id="@+id/event_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="16dp"
android:layout_marginLeft="5dp"
android:text="事件提醒时间:" />
android:textSize="18dp"
android:layout_gravity="center"
/>
<TextView
android:id="@+id/textView60"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="16dp"
android:layout_marginLeft="5dp"
android:text="创建时间:" />
</LinearLayout>
<LinearLayout
@ -183,20 +66,19 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginLeft="40dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:layout_weight="3"
android:textSize="12dp" />
<TextView
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/event_create_time"
android:layout_marginBottom="10dp"
android:layout_gravity="right"
/>
android:src="@mipmap/img_go_more" />
</LinearLayout>
</LinearLayout>

@ -0,0 +1,23 @@
<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.AnswerCollectFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/refresh_layout"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/APNList"
android:background="@color/light_grey"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</FrameLayout>

@ -15,20 +15,20 @@
android:layout_height="match_parent"
android:layout_weight="20">
<ImageView
android:id="@+id/back_collect"
android:id="@+id/imageButton2"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:src="@mipmap/left_back" />
android:src="@mipmap/img_go_answer_return" />
<TextView
android:id="@+id/Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="110dp"
android:layout_gravity="center"
android:textSize="20dp"
android:text="我的收藏"/>
android:layout_margin="10dp"
android:layout_weight="20"
android:gravity="center"
android:textSize="20dp" />
</LinearLayout>

@ -22,9 +22,7 @@
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">
@ -33,7 +31,7 @@
android:id="@+id/imageView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_menu_search" />
android:src="@mipmap/img_search" />
<TextView
android:id="@+id/textView3"
@ -91,8 +89,7 @@
<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>

@ -42,12 +42,12 @@
/>
<TextView
android:id="@+id/textView"
android:id="@+id/textBox"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="你不知道的白血病知识" />
android:hint="你不知道的白血病知识" />
</LinearLayout>
</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>

@ -11,6 +11,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="30sp" />
android:textSize="30sp"></TextView>
<!-- android:text="@string/hello_blank_fragment"--> />
</FrameLayout>

@ -9,6 +9,7 @@
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -39,20 +40,20 @@
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_margin="10dp"
android:text="XXX"
android:text="187****3609"
android:textSize="18dp" />
<TextView
android:id="@+id/slogan"
android:id="@+id/signature"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="管住嘴,迈开腿,多喝水"
android:text="管住嘴,多饮水,常保暖"
android:textSize="16dp" />
</LinearLayout>
<ImageView
android:id="@+id/img_go_my_info"
android:id="@+id/textView12"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center"

@ -15,7 +15,7 @@
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/newsCollectList"
android:id="@+id/APNList"
android:background="@color/light_grey"
android:layout_width="match_parent"
android:layout_height="match_parent" />

@ -3,8 +3,7 @@
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:background="#ffffff"
android:id="@+id/chat_list_layout">
android:background="#ffffff">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_private_msg"

@ -1,88 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/todetail"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="match_parent"
android:layout_margin="18dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
<LinearLayout
android:layout_width="200dp"
android:layout_height="60dp"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/hour"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="10dp"
android:textStyle="bold"
android:textColor="@color/colorBlack"
android:text="07"
android:textSize="38sp" />
<TextView
android:id="@+id/net"
android:textStyle="bold"
android:textColor="@color/colorBlack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_toRightOf="@id/hour"
android:text=" : "
android:textSize="28sp" />
<TextView
android:layout_toRightOf="@id/net"
android:id="@+id/minute"
android:layout_marginTop="10dp"
android:textColor="@color/colorBlack"
android:textStyle="bold"
android:text="28"
android:textSize="38sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<TextView
android:id="@+id/content_name"
android:id="@+id/md_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/time"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:text="药品名"
android:textColor="@color/colorBlack"
android:textSize="18sp" />
android:layout_marginTop="7dp"
android:paddingTop="5dp"
android:text="甘露聚糖肽胶囊"
android:textSize="16dp" />
<TextView
android:id="@+id/content_dosage"
android:id="@+id/md_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/time"
android:layout_toRightOf="@id/content_name"
android:text="剂量"
android:textColor="@color/colorBlack"
android:textSize="18sp" />
<Switch
android:id="@+id/switch_control"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:background="#B6B5B5" />
android:layout_gravity="center_vertical"
android:text="每天 8:00 14:00 19:00" />
</LinearLayout>
<Switch
android:id="@+id/sw"
android:layout_width="200dp"
android:layout_height="60dp"
android:gravity="center_vertical"
android:layout_weight="1"
android:focusable="false"
android:clickable="false"
android:padding="10dp"
android:layout_alignParentRight="true"/>
</LinearLayout>

@ -1,67 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="334dp"
android:background="@drawable/background"
android:elevation="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="15dp">
<TextView
android:id="@+id/text_my_question_id"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="" />
android:background="@color/white"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_my_question_title"
android:id="@+id/myQuestionInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="问题标题"
android:textSize="15dp"
android:textStyle="bold"
android:maxLines="2"
android:ellipsize="end"/>
android:textSize="20dp"
android:layout_margin="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_weight="1"
android:gravity="bottom"
android:layout_marginTop="5dp">
<TextView
android:id="@+id/text_my_question_browse"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="--"
android:textSize="12dp"/>
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/myQuestionRead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="浏览 "
android:textSize="11dp"/>
android:layout_weight="1"
android:textSize="16dp"
android:layout_marginLeft="5dp"
/>
<TextView
android:id="@+id/text_my_question_time"
android:id="@+id/myQuestionTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="xxxx-xx-xx xx:xx:xx"
android:textSize="11dp"/>
android:layout_weight="2"
android:textSize="16dp"
/>
<TextView
android:id="@+id/text_my_question_flag"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:textColor="#f30"
android:text="未审核" />
android:id="@+id/question"
android:orientation="horizontal">
</LinearLayout>
</LinearLayout>
</LinearLayout>

@ -19,7 +19,7 @@
</LinearLayout>
<LinearLayout
android:layout_width="300dp"
android:layout_width="353dp"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
@ -33,21 +33,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text=""
android:ellipsize="end"/>
<TextView
android:id="@+id/chat_friend_id"
android:layout_width="0dp"
android:layout_height="0dp"
android:textSize="0dp"/>
android:text="" />
</LinearLayout>
<ImageView
android:id="@+id/img_unread"
android:layout_width="28dp"
android:layout_height="37dp"
android:src="@mipmap/point"
/>
</LinearLayout>

@ -1,80 +1,41 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:id="@+id/news"
android:layout_width="334dp"
android:layout_marginLeft="35dp"
android:layout_marginBottom="10dp"
android:background="@drawable/background"
android:elevation="10dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="11dp">
<TextView
android:id="@+id/question_id"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="" />
<TextView
android:id="@+id/questionTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:layout_marginBottom="5dp"
android:textStyle="bold"
android:maxLines="2"
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:background="@color/white"
android:layout_marginTop="10dp"
android:orientation="vertical"
android:padding="11dp">
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/questionInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:layout_margin="5dp"
android:text="内容"
android:textSize="20dp"
android:layout_margin="15dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_margin="10dp"
android:orientation="horizontal">
<TextView
android:id="@+id/questionRead"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12dp"
android:layout_weight="1"
android:textSize="16dp"
android:layout_marginLeft="5dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="浏览" />
<TextView
android:id="@+id/questionTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="2"
android:textSize="11dp"
android:textSize="16dp"
/>
<LinearLayout
@ -89,7 +50,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="13dp"
android:textSize="16dp"
android:gravity="right"
android:layout_marginRight="10dp"
android:text="我要回答" />

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

@ -7,13 +7,5 @@
<color name="hair_grey">#66c18c</color>
<color name="white">#fff</color>
<color name="grey">#F1EEEE</color>
<color name="colorPrimaryBackups">#3F51B5</color>
<color name="colorPrimaryDarkBackups">#303F9F</color>
<color name="colorAccentBackups">#4CAF50</color>
<color name="colorOrange">#ff8c00</color>
<color name="colorWhite">#ffffff</color>
<color name="colorGray">#D3D3D3</color>
<color name="colorBlack">#000000</color>
<color name="colorRed">#ff3700</color>
</resources>
Loading…
Cancel
Save