Skip to content
This repository was archived by the owner on Nov 5, 2020. It is now read-only.

Commit cfec870

Browse files
committed
预约到馆
1 parent 6e236b0 commit cfec870

File tree

8 files changed

+307
-1
lines changed

8 files changed

+307
-1
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package io.github.zhaoqi99.snnu_android;
2+
3+
4+
import android.os.AsyncTask;
5+
import android.os.Bundle;
6+
import android.support.v4.app.Fragment;
7+
import android.support.v7.widget.LinearLayoutManager;
8+
import android.support.v7.widget.RecyclerView;
9+
import android.view.LayoutInflater;
10+
import android.view.View;
11+
import android.view.ViewGroup;
12+
13+
import com.google.gson.Gson;
14+
import com.google.gson.GsonBuilder;
15+
16+
import org.ksoap2.serialization.SoapObject;
17+
import org.ksoap2.serialization.SoapSerializationEnvelope;
18+
import org.ksoap2.transport.HttpTransportSE;
19+
20+
import java.util.ArrayList;
21+
22+
import io.github.zhaoqi99.snnu_android.Model.BorrowInfoModel;
23+
import io.github.zhaoqi99.snnu_android.Model.GradeModel;
24+
25+
26+
/**
27+
* A simple {@link Fragment} subclass.
28+
*/
29+
public class BookInfoFragment extends Fragment {
30+
31+
View view;
32+
RecyclerView recyclerView;
33+
BorrowInfoModel borrowInfoModel;
34+
ArrayList<BorrowInfoModel.Result> newsList = new ArrayList<>();
35+
36+
public BookInfoFragment() {
37+
// Required empty public constructor
38+
}
39+
40+
41+
@Override
42+
public View onCreateView(LayoutInflater inflater, ViewGroup container,
43+
Bundle savedInstanceState) {
44+
// Inflate the layout for this fragment
45+
view = inflater.inflate(R.layout.fragment_book_info, container, false);
46+
BookInfoFragment.GetTask getTask = new BookInfoFragment.GetTask();
47+
getTask.execute();
48+
49+
recyclerView = view.findViewById(R.id.recycler_view_bookInfo);
50+
return view;
51+
}
52+
53+
private class GetTask extends AsyncTask<Void, Void, BorrowInfoModel> {
54+
55+
@Override
56+
protected BorrowInfoModel doInBackground(Void... strings) {
57+
try {
58+
getRemoteInfo();
59+
} catch (Exception e) {
60+
e.printStackTrace();
61+
}
62+
return borrowInfoModel;
63+
}
64+
65+
@Override
66+
protected void onPostExecute(BorrowInfoModel borrowInfoModel) {
67+
newsList = new ArrayList(borrowInfoModel.getResult());
68+
mBookInfoRecyclerViewAdapter myGradeRecyclerViewAdapter = new mBookInfoRecyclerViewAdapter(newsList);
69+
LinearLayoutManager layoutManager = new LinearLayoutManager(view.getContext());
70+
recyclerView.setLayoutManager(layoutManager);
71+
recyclerView.setAdapter(myGradeRecyclerViewAdapter);
72+
}
73+
74+
private BorrowInfoModel getRemoteInfo() throws Exception {
75+
String ss = httprequest.httpRequest("http://118.24.104.99/api/v1/lib/getBorrowInfo");
76+
Gson gson = new GsonBuilder().create();
77+
borrowInfoModel = gson.fromJson(ss, BorrowInfoModel.class);
78+
return borrowInfoModel;
79+
}
80+
}
81+
}

app/src/main/java/io/github/zhaoqi99/snnu_android/MainActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
5656
Toast.makeText(MainActivity.this, "x", Toast.LENGTH_SHORT).show();
5757
break;
5858
case R.id.navigation_item_lib:
59+
switchToBookInfo();
5960
break;
6061
case R.id.navigation_item_jwc:
6162
Intent intent=new Intent(MainActivity.this,LoginActivity.class);
@@ -138,6 +139,10 @@ private void switchToCard() {
138139
}
139140
private void switchToJwc() {
140141
getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new JwcFragment() ).commitAllowingStateLoss();
142+
// mToolbar.setTitle(R.string.navigation_book);
143+
}
144+
private void switchToBookInfo() {
145+
getSupportFragmentManager().beginTransaction().replace(R.id.frame_content,new BookInfoFragment() ).commit();
141146
// mToolbar.setTitle(R.string.navigation_book);
142147
}
143148
// @Override
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package io.github.zhaoqi99.snnu_android.Model;
2+
3+
import java.util.Date;
4+
import java.util.List;
5+
6+
public class BorrowInfoModel {
7+
private String msg;
8+
private List<Result> result;
9+
private int status;
10+
private boolean success;
11+
12+
public void setMsg(String msg) {
13+
this.msg = msg;
14+
}
15+
public String getMsg() {
16+
return msg;
17+
}
18+
19+
public void setResult(List<Result> result) {
20+
this.result = result;
21+
}
22+
public List<Result> getResult() {
23+
return result;
24+
}
25+
26+
public void setStatus(int status) {
27+
this.status = status;
28+
}
29+
public int getStatus() {
30+
return status;
31+
}
32+
33+
public void setSuccess(boolean success) {
34+
this.success = success;
35+
}
36+
public boolean getSuccess() {
37+
return success;
38+
}
39+
public class Result {
40+
41+
private String 书名;
42+
private Date 保留结束日期;
43+
private String 单册分馆;
44+
private String 取书地点;
45+
private String 著者;
46+
private String 预约者;
47+
public void set书名(String 书名) {
48+
this.书名 = 书名;
49+
}
50+
public String get书名() {
51+
return 书名;
52+
}
53+
54+
public void set保留结束日期(Date 保留结束日期) {
55+
this.保留结束日期 = 保留结束日期;
56+
}
57+
public Date get保留结束日期() {
58+
return 保留结束日期;
59+
}
60+
61+
public void set单册分馆(String 单册分馆) {
62+
this.单册分馆 = 单册分馆;
63+
}
64+
public String get单册分馆() {
65+
return 单册分馆;
66+
}
67+
68+
public void set取书地点(String 取书地点) {
69+
this.取书地点 = 取书地点;
70+
}
71+
public String get取书地点() {
72+
return 取书地点;
73+
}
74+
75+
public void set著者(String 著者) {
76+
this.著者 = 著者;
77+
}
78+
public String get著者() {
79+
return 著者;
80+
}
81+
82+
public void set预约者(String 预约者) {
83+
this.预约者 = 预约者;
84+
}
85+
public String get预约者() {
86+
return 预约者;
87+
}
88+
89+
}
90+
}

app/src/main/java/io/github/zhaoqi99/snnu_android/NewsTab.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
5757
return view;
5858
}
5959

60-
private class QueryTask extends AsyncTask<String, Integer, String> {
60+
private class QueryTask extends AsyncTask<String, Integer, String> {
6161

6262
@Override
6363
protected String doInBackground(String... strings) {
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package io.github.zhaoqi99.snnu_android;
2+
3+
import android.support.v7.widget.RecyclerView;
4+
import android.view.LayoutInflater;
5+
import android.view.View;
6+
import android.view.ViewGroup;
7+
import android.widget.TextView;
8+
9+
import java.util.List;
10+
11+
import io.github.zhaoqi99.snnu_android.Model.BorrowInfoModel;
12+
13+
14+
public class mBookInfoRecyclerViewAdapter extends RecyclerView.Adapter <mBookInfoRecyclerViewAdapter.ViewHolder>{
15+
16+
private List<BorrowInfoModel.Result> resultList;
17+
18+
public mBookInfoRecyclerViewAdapter(List<BorrowInfoModel.Result> resultList)
19+
{
20+
this.resultList = resultList;
21+
}
22+
23+
static class ViewHolder extends RecyclerView.ViewHolder{
24+
25+
TextView user;
26+
TextView author;
27+
TextView bookname;
28+
TextView deadline;
29+
TextView loc;
30+
TextView campus;
31+
32+
public ViewHolder(View view)
33+
{
34+
super(view);
35+
user = (TextView)view.findViewById(R.id.bookInfo_user);
36+
bookname=(TextView)view.findViewById(R.id.bookInfo_bookname);
37+
author=(TextView)view.findViewById(R.id.bookInfo_author);
38+
deadline=(TextView)view.findViewById(R.id.bookInfo_deadline);
39+
loc=(TextView)view.findViewById(R.id.bookInfo_loc);
40+
campus=(TextView)view.findViewById(R.id.bookInfo_campus);
41+
}
42+
}
43+
@Override
44+
public int getItemCount() {
45+
return resultList.size();
46+
}
47+
48+
@Override
49+
public void onBindViewHolder(mBookInfoRecyclerViewAdapter.ViewHolder holder, int position) {
50+
BorrowInfoModel.Result message = resultList.get(position);
51+
holder.deadline.setText("保留结束日期"+message.get保留结束日期().toString());
52+
holder.user.setText("预约者:"+message.get预约者());
53+
holder.bookname.setText("书名:"+message.get书名());
54+
holder.loc.setText("取书地点:"+message.get取书地点());
55+
holder.campus.setText("单册分馆:"+message.get单册分馆());
56+
}
57+
58+
@Override
59+
public mBookInfoRecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
60+
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.book_recycler_layout
61+
,parent,false);
62+
mBookInfoRecyclerViewAdapter.ViewHolder holder = new mBookInfoRecyclerViewAdapter.ViewHolder(view);
63+
return holder;
64+
}
65+
66+
67+
68+
69+
70+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:orientation="vertical">
6+
7+
<TextView
8+
android:id="@+id/bookInfo_bookname"
9+
android:layout_width="match_parent"
10+
android:textSize="@dimen/bookinfo_text_size"
11+
android:layout_height="wrap_content" />
12+
13+
<TextView
14+
android:id="@+id/bookInfo_author"
15+
android:layout_width="match_parent"
16+
android:textSize="@dimen/bookinfo_text_size"
17+
android:layout_height="wrap_content" />
18+
19+
<TextView
20+
android:id="@+id/bookInfo_campus"
21+
android:layout_width="match_parent"
22+
android:textSize="@dimen/bookinfo_text_size"
23+
android:layout_height="wrap_content" />
24+
25+
<TextView
26+
android:id="@+id/bookInfo_user"
27+
android:layout_width="match_parent"
28+
android:textSize="@dimen/bookinfo_text_size"
29+
android:layout_height="wrap_content" />
30+
31+
<TextView
32+
android:id="@+id/bookInfo_loc"
33+
android:layout_width="match_parent"
34+
android:textSize="@dimen/bookinfo_text_size"
35+
android:layout_height="wrap_content" />
36+
37+
<TextView
38+
android:id="@+id/bookInfo_deadline"
39+
android:layout_width="match_parent"
40+
android:textSize="@dimen/bookinfo_text_size"
41+
android:layout_height="wrap_content" />
42+
</LinearLayout>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:orientation="vertical"
7+
tools:context=".BookInfoFragment">
8+
9+
<android.support.v7.widget.RecyclerView
10+
android:id="@+id/recycler_view_bookInfo"
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content">
13+
14+
</android.support.v7.widget.RecyclerView>
15+
android:text="@string/hello_blank_fragment" />
16+
17+
</LinearLayout>

app/src/main/res/values/dimens.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<dimen name="activity_horizontal_margin">16dp</dimen>
44
<dimen name="activity_vertical_margin">16dp</dimen>
55
<dimen name="grade_text_size">20dp</dimen>
6+
<dimen name="bookinfo_text_size">18dp</dimen>
67
</resources>

0 commit comments

Comments
 (0)