diff --git a/Code/LeudaemiaLikeMe/app/src/main/AndroidManifest.xml b/Code/LeudaemiaLikeMe/app/src/main/AndroidManifest.xml
index 5c0611d..2f39b2f 100644
--- a/Code/LeudaemiaLikeMe/app/src/main/AndroidManifest.xml
+++ b/Code/LeudaemiaLikeMe/app/src/main/AndroidManifest.xml
@@ -7,10 +7,9 @@
tools:targetApi="n">
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
@@ -75,18 +49,8 @@
-
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/Code/LeudaemiaLikeMe/app/src/main/assets/litepal.xml b/Code/LeudaemiaLikeMe/app/src/main/assets/litepal.xml
index 0e40e6c..6c18032 100644
--- a/Code/LeudaemiaLikeMe/app/src/main/assets/litepal.xml
+++ b/Code/LeudaemiaLikeMe/app/src/main/assets/litepal.xml
@@ -3,14 +3,11 @@
-
+
-
-
-
\ No newline at end of file
diff --git a/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/APNActivity.java b/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/APNActivity.java
index 86b225b..a21d518 100644
--- a/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/APNActivity.java
+++ b/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/APNActivity.java
@@ -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 messageList = new ArrayList();
- 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 jsonMap = new HashMap();
- 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 jsonMap = new HashMap();
- 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();
}
}
\ No newline at end of file
diff --git a/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/ConcernedProblemActivity.java b/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/ConcernedProblemActivity.java
index fe90948..f8e0a87 100644
--- a/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/ConcernedProblemActivity.java
+++ b/Code/LeudaemiaLikeMe/app/src/main/java/com/example/leudaemialikeme/Activity/ConcernedProblemActivity.java
@@ -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 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 jsonMap= gson.fromJson(jsonStr, new TypeToken