├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── AirlineBookSystem.iml
├── README.md
├── app
├── .gitignore
├── app.iml
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── levent_j
│ │ └── airlinebooksystem
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── levent_j
│ │ │ └── airlinebooksystem
│ │ │ ├── App.java
│ │ │ ├── activity
│ │ │ ├── AboutActivity.java
│ │ │ ├── AdminActivity.java
│ │ │ ├── BoardingActivity.java
│ │ │ ├── EditClientActivity.java
│ │ │ ├── EditFlightActivity.java
│ │ │ ├── GuideActivity.java
│ │ │ ├── LoginActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── PlaceListActivity.java
│ │ │ └── PriceActivity.java
│ │ │ ├── adapter
│ │ │ ├── AdminClientAdapter.java
│ │ │ ├── AdminFlightAdapter.java
│ │ │ └── DynamicAdapter.java
│ │ │ ├── base
│ │ │ ├── BaseActivity.java
│ │ │ ├── BaseAdapter.java
│ │ │ └── BaseFragment.java
│ │ │ ├── bean
│ │ │ ├── Client.java
│ │ │ ├── Flight.java
│ │ │ ├── Test.java
│ │ │ └── Ticket.java
│ │ │ ├── fragment
│ │ │ ├── AdminClientFragment.java
│ │ │ ├── AdminFlightFragment.java
│ │ │ ├── BookFragment.java
│ │ │ ├── DynamicFragment.java
│ │ │ ├── MainFragment.java
│ │ │ └── QueryFragment.java
│ │ │ ├── utils
│ │ │ └── DividerItemDecoration.java
│ │ │ └── widget
│ │ │ └── InputDialog.java
│ └── res
│ │ ├── drawable
│ │ ├── bg3.jpg
│ │ ├── bg_btn_book.xml
│ │ ├── bg_btn_book0.xml
│ │ ├── bg_btn_book1.xml
│ │ ├── bg_btn_dynamic.xml
│ │ ├── bg_btn_dynamic0.xml
│ │ ├── bg_btn_dynamic1.xml
│ │ ├── dialog_bottom_line.9.png
│ │ ├── ic_add.png
│ │ ├── ic_admin.png
│ │ ├── ic_backandforth.png
│ │ ├── ic_boarding.png
│ │ ├── ic_client.png
│ │ ├── ic_data.png
│ │ ├── ic_fly.png
│ │ ├── ic_guide.png
│ │ ├── ic_muptiply.png
│ │ ├── ic_nav_about.png
│ │ ├── ic_nav_book.png
│ │ ├── ic_nav_dynamic.png
│ │ ├── ic_nav_information.png
│ │ ├── ic_nav_main.png
│ │ ├── ic_nav_query.png
│ │ ├── ic_nav_share.png
│ │ ├── ic_price.png
│ │ ├── layout_border.xml
│ │ ├── side_nav_bar.xml
│ │ └── ticket_border.xml
│ │ ├── layout
│ │ ├── activity_about.xml
│ │ ├── activity_admin.xml
│ │ ├── activity_boarding.xml
│ │ ├── activity_edit_client.xml
│ │ ├── activity_edit_flight.xml
│ │ ├── activity_guide.xml
│ │ ├── activity_login.xml
│ │ ├── activity_main.xml
│ │ ├── activity_place_list.xml
│ │ ├── activity_price.xml
│ │ ├── app_bar_main.xml
│ │ ├── content_main.xml
│ │ ├── dialog_input_layout.xml
│ │ ├── fragment_admin_client.xml
│ │ ├── fragment_admin_flight.xml
│ │ ├── fragment_book.xml
│ │ ├── fragment_dynamic.xml
│ │ ├── fragment_information.xml
│ │ ├── fragment_main.xml
│ │ ├── fragment_query.xml
│ │ ├── item_admin_client.xml
│ │ ├── item_admin_flight.xml
│ │ ├── item_dynamic.xml
│ │ └── nav_header_main.xml
│ │ ├── menu
│ │ ├── activity_main_drawer.xml
│ │ └── main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── icon.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── icon.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── icon.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-v21
│ │ └── styles.xml
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── array.xml
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── levent_j
│ └── airlinebooksystem
│ └── ExampleUnitTest.java
├── build.gradle
├── doc
├── 无标题文档~
├── 综合课程设计报告-李文靖.docx
└── 需求文档
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 | /captures
8 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | AirlineBookSystem
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AirlineBookSystem.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AirlineBookSystem
2 | 综合课程设计项目——航空订票系统android客户端
3 |
4 | ##需求分析:
5 | ###主要任务:
6 | 1. 管理员可以录入或者导入/导出各个航线的航班信息,可以修改航班信息,可以增加/删除/修改操作工作员信息。
7 | 2. 操作工作员可以实现订票订票、退订,查看航线
8 | ###详细功能:
9 | 1. 录入航线信息:每条航线信息包括航班号、飞机号、目的地、订票数、余票数共5项。
10 | 2. 订票业务:客户信息包括姓名, 航班号, 座位号。有新客户订票时, 先输入客户的姓名,身份证号和他提出的航班号, 查询该航线的订票情况, 若有余票, 则为客户办理订票手续, 分配/选择户一个座位号。若无余票, 则输出客满信息。如果该航班已经无票,可以查询输出可选择的其他航班信息。
11 | 3. 退票业务:根据客户提出的航班号和姓名, 办理退票, 从数据库中删除该客户的信息, 并修改数据库中相应航线的订票数和余票数。
12 | 4. 修改航班信息:当航班信息改变可以修改航班数据文件。
13 | 5. 输出全部航线信息和全部客户信息。
14 | 6. 退出系统。要求用数据库保存信息。
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | generateDebugAndroidTestSources
19 | generateDebugSources
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 | useLibrary 'org.apache.http.legacy'
7 |
8 | defaultConfig {
9 | applicationId "com.levent_j.airlinebooksystem"
10 | minSdkVersion 14
11 | targetSdkVersion 23
12 | versionCode 1
13 | versionName "1.0"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 | }
22 |
23 | dependencies {
24 | compile fileTree(dir: 'libs', include: ['*.jar'])
25 | testCompile 'junit:junit:4.12'
26 | compile 'com.android.support:appcompat-v7:23.3.0'
27 | compile 'com.jakewharton:butterknife:7.0.1'
28 | compile 'com.android.support:design:23.3.0'
29 | compile 'com.android.support:cardview-v7:23.2.0'
30 | compile 'com.android.support:recyclerview-v7:23.2.0'
31 | compile 'cn.bmob.android:bmob-sdk:3.5.0'
32 | compile 'cn.bmob.android:bmob-push:0.8'
33 | compile 'com.brucetoo.pickview:library:1.1.1'
34 | compile 'com.wang.avi:library:1.0.5'
35 | compile 'com.nineoldandroids:library:2.4.0'
36 | compile 'com.squareup.picasso:picasso:2.5.2'
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/levent_j/Android/Sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/levent_j/airlinebooksystem/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
50 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/App.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem;
2 |
3 | import android.app.Application;
4 | import android.util.Log;
5 |
6 | import cn.bmob.v3.Bmob;
7 |
8 | /**
9 | * Created by levent_j on 16-6-30.
10 | */
11 | public class App extends Application{
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | Bmob.initialize(this, "0021d3d62dc0cd2ef2352ffd1575a51e");
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/AboutActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import com.levent_j.airlinebooksystem.R;
4 | import com.levent_j.airlinebooksystem.base.BaseActivity;
5 |
6 | /**
7 | * Created by levent_j on 16-7-5.
8 | */
9 | public class AboutActivity extends BaseActivity{
10 | @Override
11 | protected int getLayoutId() {
12 | return R.layout.activity_about;
13 | }
14 |
15 | @Override
16 | protected void initView() {
17 |
18 | }
19 |
20 | @Override
21 | protected void initData() {
22 |
23 | }
24 |
25 | @Override
26 | protected void setListener() {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/AdminActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import android.content.Context;
4 | import android.support.design.widget.TabLayout;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentPagerAdapter;
8 | import android.support.v4.view.ViewPager;
9 | import android.support.v7.widget.Toolbar;
10 |
11 | import com.levent_j.airlinebooksystem.R;
12 | import com.levent_j.airlinebooksystem.base.BaseActivity;
13 | import com.levent_j.airlinebooksystem.base.BaseFragment;
14 | import com.levent_j.airlinebooksystem.fragment.AdminFlightFragment;
15 | import com.levent_j.airlinebooksystem.fragment.AdminClientFragment;
16 |
17 | import java.util.ArrayList;
18 | import java.util.List;
19 |
20 | import butterknife.Bind;
21 |
22 | /**
23 | * Created by levent_j on 16-7-4.
24 | */
25 | public class AdminActivity extends BaseActivity{
26 | @Bind(R.id.tabLayout) TabLayout tabLayout;
27 | @Bind(R.id.viewpager) ViewPager viewPager;
28 | @Bind(R.id.admin_toolbar) Toolbar toolbar;
29 |
30 | private PageAdpater pageAdpater;
31 |
32 | @Override
33 | protected int getLayoutId() {
34 | return R.layout.activity_admin;
35 | }
36 |
37 | @Override
38 | protected void initView() {
39 | setSupportActionBar(toolbar);
40 | pageAdpater = new PageAdpater(getSupportFragmentManager(),this);
41 | pageAdpater.addFragment(AdminFlightFragment.newInstance("航班"),"航班");
42 | pageAdpater.addFragment(AdminClientFragment.newInstance("乘客"),"乘客");
43 | viewPager.setAdapter(pageAdpater);
44 | tabLayout.setupWithViewPager(viewPager);
45 | tabLayout.setTabMode(TabLayout.MODE_FIXED);
46 | }
47 |
48 | @Override
49 | protected void initData() {
50 |
51 | }
52 |
53 | @Override
54 | protected void setListener() {
55 |
56 | }
57 |
58 | public class PageAdpater extends FragmentPagerAdapter{
59 | private List fragmentList;
60 | private List titleList;
61 | private Context context;
62 |
63 | public PageAdpater(FragmentManager fm,Context context) {
64 | super(fm);
65 | this.context = context;
66 | fragmentList = new ArrayList<>();
67 | titleList = new ArrayList<>();
68 | }
69 |
70 | @Override
71 | public Fragment getItem(int position) {
72 | return fragmentList.get(position);
73 | }
74 |
75 | @Override
76 | public int getCount() {
77 | return fragmentList.size();
78 | }
79 |
80 | @Override
81 | public CharSequence getPageTitle(int position) {
82 | // return super.getPageTitle(position);
83 | return titleList.get(position);
84 | }
85 |
86 | public void addFragment(BaseFragment fragment,String title){
87 | fragmentList.add(fragment);
88 | titleList.add(title);
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/BoardingActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import com.levent_j.airlinebooksystem.R;
4 | import com.levent_j.airlinebooksystem.base.BaseActivity;
5 |
6 | /**
7 | * Created by levent_j on 16-7-4.
8 | */
9 | public class BoardingActivity extends BaseActivity{
10 | @Override
11 | protected int getLayoutId() {
12 | return R.layout.activity_boarding;
13 | }
14 |
15 | @Override
16 | protected void initView() {
17 |
18 | }
19 |
20 | @Override
21 | protected void initData() {
22 |
23 | }
24 |
25 | @Override
26 | protected void setListener() {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/EditClientActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Color;
5 | import android.text.TextUtils;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.PopupWindow;
11 | import android.widget.TextView;
12 |
13 | import com.bruce.pickerview.popwindow.DatePickerPopWin;
14 | import com.levent_j.airlinebooksystem.R;
15 | import com.levent_j.airlinebooksystem.base.BaseActivity;
16 | import com.levent_j.airlinebooksystem.bean.Client;
17 | import com.levent_j.airlinebooksystem.bean.Flight;
18 |
19 | import java.util.List;
20 |
21 | import butterknife.Bind;
22 | import cn.bmob.v3.BmobQuery;
23 | import cn.bmob.v3.exception.BmobException;
24 | import cn.bmob.v3.listener.FindListener;
25 | import cn.bmob.v3.listener.SaveListener;
26 | import cn.bmob.v3.listener.UpdateListener;
27 |
28 | /**
29 | * Created by levent_j on 16-7-4.
30 | */
31 | public class EditClientActivity extends BaseActivity implements View.OnClickListener {
32 | @Bind(R.id.et_edit_name) EditText name;
33 | @Bind(R.id.et_edit_client_id) EditText idCard;
34 | @Bind(R.id.et_edit_client_flight) EditText flightNo;
35 | @Bind(R.id.tv_edit_client_data) TextView date;
36 | @Bind(R.id.btn_client_commit) Button commit;
37 |
38 | private DatePickerPopWin pickerPopWin;
39 | private boolean isNew = true;
40 | private String objectId;
41 |
42 | @Override
43 | protected int getLayoutId() {
44 | return R.layout.activity_edit_client;
45 | }
46 |
47 | @Override
48 | protected void initView() {
49 | pickerPopWin = new DatePickerPopWin.Builder(this, new DatePickerPopWin.OnDatePickedListener() {
50 | @Override
51 | public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
52 | date.setText(year+"-"+month+"-"+day);
53 |
54 | }
55 | })
56 | .textConfirm("选择")
57 | .textCancel("取消")
58 | .btnTextSize(16)
59 | .viewTextSize(25)
60 | .colorCancel(Color.parseColor("#999999"))
61 | .colorConfirm(Color.parseColor("#7C4DEF"))
62 | .minYear(1970)
63 | .maxYear(2020)
64 | .dateChose("2016-07-02")
65 | .build();
66 | }
67 |
68 | @Override
69 | protected void initData() {
70 | Intent intent = getIntent();
71 | isNew = intent.getBooleanExtra("isNew", true);
72 | if (!isNew){
73 | //填充数据
74 | objectId = intent.getStringExtra("id");
75 | name.setText(intent.getStringExtra("name"));
76 | idCard.setText(intent.getStringExtra("ic"));
77 | flightNo.setText(intent.getStringExtra("flight"));
78 | date.setText(intent.getStringExtra("date"));
79 | }
80 | }
81 |
82 | @Override
83 | protected void setListener() {
84 | date.setOnClickListener(this);
85 | commit.setOnClickListener(this);
86 | }
87 |
88 | @Override
89 | public void onClick(View v) {
90 | switch (v.getId()){
91 | case R.id.tv_edit_client_data:
92 | pickerPopWin.showPopWin(this);
93 | break;
94 | case R.id.btn_client_commit:
95 | String mName = name.getText().toString();
96 | String mIC = idCard.getText().toString();
97 | String mFlight = flightNo.getText().toString();
98 | String mDate = date.getText().toString();
99 | if (TextUtils.isEmpty(mName)||TextUtils.isEmpty(mIC)||TextUtils.isEmpty(mFlight)||mDate.equals("请选择")){
100 | Toa("请填写完整乘客信息");
101 | }else {
102 | commitClient(mName,mIC,mFlight,mDate);
103 | }
104 | break;
105 | }
106 | }
107 |
108 | private void commitClient(final String mName, final String mIC, final String mFlight, final String mDate) {
109 | commit.setText("请等待");
110 | commit.setEnabled(false);
111 |
112 | //先检查航班号是否存在
113 | BmobQuery query = new BmobQuery<>();
114 | query.addWhereEqualTo("flightNo",mFlight);
115 | query.findObjects(new FindListener() {
116 | @Override
117 | public void done(List list, BmobException e) {
118 | if (e == null) {
119 | if (list.size() > 0) {
120 | //存在该航班
121 | Client client = new Client();
122 | client.setName(mName);
123 | client.setIdCard(mIC);
124 | client.setFlightNo(mFlight);
125 | client.setData(mDate);
126 | if (isNew) {
127 | createClient(client);
128 | } else {
129 | updateClient(client);
130 | }
131 | } else {
132 | Toa("不存在该航班!");
133 | commit.setText("提交");
134 | commit.setEnabled(true);
135 | }
136 | } else {
137 | Toa("网络繁忙,请稍后再试");
138 | Log.e("Bmob", "query error:" + e.getMessage());
139 | }
140 | }
141 | });
142 | }
143 |
144 | private void createClient(Client client) {
145 | client.save(new SaveListener() {
146 | @Override
147 | public void done(String s, BmobException e) {
148 | if (e==null){
149 | finish();
150 | }else {
151 | Toa("网络繁忙,请稍后再试");
152 | Log.e("Bmob", "save error:" + e.getMessage());
153 | commit.setText("提交");
154 | commit.setEnabled(true);
155 | }
156 | }
157 | });
158 | }
159 |
160 | private void updateClient(Client client) {
161 | client.update(objectId, new UpdateListener() {
162 | @Override
163 | public void done(BmobException e) {
164 | if (e==null){
165 | finish();
166 | }else {
167 | Toa("网络繁忙,请稍后再试");
168 | Log.e("Bmob", "save error:" + e.getMessage());
169 | commit.setText("提交");
170 | commit.setEnabled(true);
171 | }
172 | }
173 | });
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/EditFlightActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Color;
5 | import android.text.TextUtils;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.TextView;
11 |
12 | import com.bruce.pickerview.popwindow.DatePickerPopWin;
13 | import com.levent_j.airlinebooksystem.R;
14 | import com.levent_j.airlinebooksystem.base.BaseActivity;
15 | import com.levent_j.airlinebooksystem.bean.Flight;
16 |
17 | import butterknife.Bind;
18 | import butterknife.ButterKnife;
19 | import cn.bmob.v3.exception.BmobException;
20 | import cn.bmob.v3.listener.SaveListener;
21 | import cn.bmob.v3.listener.UpdateListener;
22 |
23 | /**
24 | * Created by levent_j on 16-7-4.
25 | */
26 | public class EditFlightActivity extends BaseActivity implements View.OnClickListener {
27 | @Bind(R.id.tv_edit_origin) TextView origin;
28 | @Bind(R.id.tv_edit_destination) TextView destination;
29 | @Bind(R.id.tv_edit_flight_date) TextView date;
30 | @Bind(R.id.et_edit_time_start) EditText start;
31 | @Bind(R.id.et_edit_time_end) EditText end;
32 | @Bind(R.id.et_edit_flightNo) EditText flightNo;
33 | @Bind(R.id.et_edit_flight_type) EditText flightType;
34 | @Bind(R.id.et_edit_price) EditText price;
35 | @Bind(R.id.et_edit_booked) TextView booked;
36 | @Bind(R.id.et_edit_surplus) TextView surplus;
37 | @Bind(R.id.btn_flight_commit) Button commit;
38 |
39 | private boolean isNew = true;
40 | private int REQUEST_ORIGIN = 0;
41 | private int REQUEST_DESTINATION = 1;
42 | private String objectId;
43 | private DatePickerPopWin pickerPopWin;
44 |
45 |
46 | @Override
47 | protected int getLayoutId() {
48 | return R.layout.activity_edit_flight;
49 | }
50 |
51 | @Override
52 | protected void initView() {
53 | pickerPopWin = new DatePickerPopWin.Builder(this, new DatePickerPopWin.OnDatePickedListener() {
54 | @Override
55 | public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
56 | date.setText(year+"-"+month+"-"+day);
57 |
58 | }
59 | })
60 | .textConfirm("选择")
61 | .textCancel("取消")
62 | .btnTextSize(16)
63 | .viewTextSize(25)
64 | .colorCancel(Color.parseColor("#999999"))
65 | .colorConfirm(Color.parseColor("#7C4DEF"))
66 | .minYear(1970)
67 | .maxYear(2020)
68 | .dateChose("2016-07-02")
69 | .build();
70 | }
71 |
72 | @Override
73 | protected void initData() {
74 | Intent intent = getIntent();
75 | isNew = intent.getBooleanExtra("isNew", true);
76 | if (!isNew){
77 | //填充数据
78 | objectId = intent.getStringExtra("id");
79 | origin.setText(intent.getStringExtra("origin"));
80 | destination.setText(intent.getStringExtra("destination"));
81 | date.setText(intent.getStringExtra("date"));
82 | start.setText(intent.getStringExtra("start"));
83 | end.setText(intent.getStringExtra("end"));
84 | flightNo.setText(intent.getStringExtra("no"));
85 | flightType.setText(intent.getStringExtra("type"));
86 | price.setText(String.valueOf(intent.getIntExtra("price", 0)));
87 | booked.setText(String.valueOf(intent.getIntExtra("booked",0)));
88 | surplus.setText(String.valueOf(intent.getIntExtra("surplus", 0)));
89 | }
90 | }
91 |
92 | @Override
93 | protected void setListener() {
94 | origin.setOnClickListener(this);
95 | destination.setOnClickListener(this);
96 | date.setOnClickListener(this);
97 | commit.setOnClickListener(this);
98 | }
99 |
100 | @Override
101 | public void onClick(View v) {
102 | switch (v.getId()){
103 | case R.id.tv_edit_origin:
104 | startCityList(REQUEST_ORIGIN);
105 | break;
106 | case R.id.tv_edit_destination:
107 | startCityList(REQUEST_DESTINATION);
108 | break;
109 | case R.id.tv_edit_flight_date:
110 | pickerPopWin.showPopWin(this);
111 | break;
112 | case R.id.btn_flight_commit:
113 | String mOrigin = origin.getText().toString();
114 | String mDestination = destination.getText().toString();
115 | String mDate = date.getText().toString();
116 | String mStart = start.getText().toString();
117 | String mEnd = end.getText().toString();
118 | String mFlight = flightNo.getText().toString();
119 | String mType = flightType.getText().toString();
120 | int mPrice = Integer.parseInt(TextUtils.isEmpty(price.getText().toString())?"0":price.getText().toString());
121 | int mBooked = Integer.parseInt(TextUtils.isEmpty(booked.getText().toString())?"0":booked.getText().toString());
122 | int mSurplus = Integer.parseInt(TextUtils.isEmpty(surplus.getText().toString())?"0":surplus.getText().toString());
123 | if (mOrigin.equals("请选择")){
124 | Toa("请选择出发地");
125 | }else if (mDestination.equals("请选择")) {
126 | Toa("请选择目的地");
127 | }else if (mDate.equals("请选择")){
128 | Toa("请选择日期");
129 | } else if (TextUtils.isEmpty(mStart)||TextUtils.isEmpty(mEnd)||TextUtils.isEmpty(mFlight)
130 | ||TextUtils.isEmpty(mType)){
131 | Toa("请填写完整航班信息");
132 | }else {
133 | commitFlight(mOrigin,mDestination,mDate,mStart,mEnd,mFlight,mType,mPrice,mBooked,mSurplus);
134 | }
135 |
136 | break;
137 | }
138 | }
139 |
140 | private void commitFlight(String mOrigin, String mDestination, String mDate, String mStart, String mEnd,
141 | String mFlight, String mType, int mPrice, int mBooked, int mSurplus) {
142 | commit.setText("请等待");
143 | commit.setEnabled(false);
144 |
145 | Flight flight = new Flight();
146 | flight.setOriginPlace(mOrigin);
147 | flight.setDestinationPlace(mDestination);
148 | flight.setData(mDate);
149 | flight.setStartTime(mStart);
150 | flight.setEndTime(mEnd);
151 | flight.setFlightNo(mFlight);
152 | flight.setFlightType(mType);
153 | flight.setPrice(mPrice);
154 | flight.setBookedTickets(mBooked);
155 | flight.setSurplusTickets(mSurplus);
156 |
157 | if (isNew){
158 | createFlight(flight);
159 | }else {
160 | updateFlight(flight);
161 | }
162 | }
163 |
164 | private void updateFlight(Flight flight) {
165 | flight.update(objectId, new UpdateListener() {
166 | @Override
167 | public void done(BmobException e) {
168 | if (e==null){
169 | finish();
170 | }else {
171 | Toa("网络繁忙,请稍后再试");
172 | commit.setText("提交");
173 | commit.setEnabled(true);
174 | Log.e("Bmob","save error:"+e.getMessage());
175 | }
176 | }
177 | });
178 | }
179 |
180 | private void createFlight(Flight flight) {
181 |
182 | flight.save(new SaveListener() {
183 | @Override
184 | public void done(String s, BmobException e) {
185 | if (e==null){
186 | finish();
187 | }else {
188 | Toa("网络繁忙,请稍后再试");
189 | commit.setText("提交");
190 | commit.setEnabled(true);
191 | Log.e("Bmob","save error:"+e.getMessage());
192 | }
193 | }
194 | });
195 |
196 | }
197 |
198 | private void startCityList(int code) {
199 | Intent intent = new Intent(this,PlaceListActivity.class);
200 | intent.putExtra("type",code);
201 | startActivityForResult(intent,code);
202 | }
203 |
204 | @Override
205 | protected void onActivityResult(int requestCode, int resultCode, Intent data) {
206 | super.onActivityResult(requestCode, resultCode, data);
207 | if (requestCode==REQUEST_ORIGIN){
208 | origin.setText(data.getStringExtra("place"));
209 | }else {
210 | destination.setText(data.getStringExtra("place"));
211 | }
212 | }
213 | }
214 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/GuideActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import com.levent_j.airlinebooksystem.R;
4 | import com.levent_j.airlinebooksystem.base.BaseActivity;
5 |
6 | /**
7 | * Created by levent_j on 16-7-4.
8 | */
9 | public class GuideActivity extends BaseActivity{
10 | @Override
11 | protected int getLayoutId() {
12 | return R.layout.activity_guide;
13 | }
14 |
15 | @Override
16 | protected void initView() {
17 |
18 | }
19 |
20 | @Override
21 | protected void initData() {
22 |
23 | }
24 |
25 | @Override
26 | protected void setListener() {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/LoginActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import com.levent_j.airlinebooksystem.R;
4 | import com.levent_j.airlinebooksystem.base.BaseActivity;
5 |
6 | /**
7 | * Created by levent_j on 16-7-4.
8 | */
9 | public class LoginActivity extends BaseActivity{
10 | @Override
11 | protected int getLayoutId() {
12 | return R.layout.activity_login;
13 | }
14 |
15 | @Override
16 | protected void initView() {
17 |
18 | }
19 |
20 | @Override
21 | protected void initData() {
22 |
23 | }
24 |
25 | @Override
26 | protected void setListener() {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.Bundle;
6 | import android.support.design.widget.FloatingActionButton;
7 | import android.support.design.widget.Snackbar;
8 | import android.support.v4.app.FragmentManager;
9 | import android.view.View;
10 | import android.support.design.widget.NavigationView;
11 | import android.support.v4.view.GravityCompat;
12 | import android.support.v4.widget.DrawerLayout;
13 | import android.support.v7.app.ActionBarDrawerToggle;
14 | import android.support.v7.widget.Toolbar;
15 | import android.view.Menu;
16 | import android.view.MenuItem;
17 | import android.widget.FrameLayout;
18 |
19 | import com.levent_j.airlinebooksystem.R;
20 | import com.levent_j.airlinebooksystem.base.BaseActivity;
21 | import com.levent_j.airlinebooksystem.base.BaseFragment;
22 | import com.levent_j.airlinebooksystem.fragment.BookFragment;
23 | import com.levent_j.airlinebooksystem.fragment.DynamicFragment;
24 | import com.levent_j.airlinebooksystem.fragment.MainFragment;
25 | import com.levent_j.airlinebooksystem.fragment.QueryFragment;
26 |
27 | import java.util.ArrayList;
28 | import java.util.List;
29 |
30 | import butterknife.Bind;
31 |
32 | public class MainActivity extends BaseActivity
33 | implements NavigationView.OnNavigationItemSelectedListener, View.OnClickListener {
34 |
35 | @Bind(R.id.toolbar) Toolbar toolbar;
36 | @Bind(R.id.fab) FloatingActionButton fab;
37 | @Bind(R.id.drawer_layout) DrawerLayout drawer;
38 | @Bind(R.id.nav_view) NavigationView navigationView;
39 | @Bind(R.id.container) FrameLayout container;
40 |
41 | private ActionBarDrawerToggle toggle;
42 | private static final String TITLE_MAIN = "首页";
43 | private static final String TITLE_DYNAMIC = "航班动态";
44 | private static final String TITLE_BOOK = "预订机票";
45 | private static final String TITLE_QUERY = "查询机票";
46 | private static final String TITLE_INFORMAtiON = "个人信息";
47 | private static final String TITLE_ABOUT = "关于";
48 |
49 | private int current;
50 | private String id = "id";
51 | private FragmentManager fragmentManager;
52 |
53 | private List fragmentList;
54 |
55 | private long lastBackTime = 0;
56 |
57 |
58 | @Override
59 | protected void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | }
62 |
63 | @Override
64 | protected int getLayoutId() {
65 | return R.layout.activity_main;
66 | }
67 |
68 | @Override
69 | protected void initView() {
70 | setSupportActionBar(toolbar);
71 | toggle = new ActionBarDrawerToggle(
72 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
73 | drawer.setDrawerListener(toggle);
74 | toggle.syncState();
75 | navigationView.setCheckedItem(R.id.nav_main);
76 |
77 | //填充所有fragment
78 | fragmentManager = getSupportFragmentManager();
79 | fragmentList = new ArrayList<>();
80 | fragmentList.add(MainFragment.newInstance(id));
81 | fragmentList.add(DynamicFragment.newInstance(id));
82 | fragmentList.add(BookFragment.newInstance(id));
83 | fragmentList.add(QueryFragment.newInstance(id));
84 | fragmentManager.beginTransaction()
85 | .replace(R.id.container,fragmentList.get(0))
86 | .addToBackStack(fragmentList.get(0).getClass().getSimpleName())
87 | .commit();
88 | }
89 |
90 | @Override
91 | protected void initData() {
92 | toolbar.setTitle(TITLE_MAIN);
93 | }
94 |
95 | @Override
96 | protected void setListener() {
97 | fab.setOnClickListener(this);
98 | navigationView.setNavigationItemSelectedListener(this);
99 | }
100 |
101 | @Override
102 | public void onBackPressed() {
103 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
104 | if (drawer.isDrawerOpen(GravityCompat.START)) {
105 | drawer.closeDrawer(GravityCompat.START);
106 | } else {
107 | if (System.currentTimeMillis()-lastBackTime>3000){
108 | Toa("重复操作退出程序");
109 | lastBackTime = System.currentTimeMillis();
110 | }else {
111 | // super.onBackPressed();
112 | finish();
113 | }
114 |
115 | }
116 | }
117 |
118 | @Override
119 | public boolean onCreateOptionsMenu(Menu menu) {
120 | // Inflate the menu; this adds items to the action bar if it is present.
121 | getMenuInflater().inflate(R.menu.main, menu);
122 | return true;
123 | }
124 |
125 | @Override
126 | public boolean onOptionsItemSelected(MenuItem item) {
127 | // Handle action bar item clicks here. The action bar will
128 | // automatically handle clicks on the Home/Up button, so long
129 | // as you specify a parent activity in AndroidManifest.xml.
130 | int id = item.getItemId();
131 |
132 | //noinspection SimplifiableIfStatement
133 | if (id == R.id.action_settings) {
134 | return true;
135 | }
136 |
137 | return super.onOptionsItemSelected(item);
138 | }
139 |
140 | /**
141 | * 监听侧滑菜单栏
142 | * */
143 | @SuppressWarnings("StatementWithEmptyBody")
144 | @Override
145 | public boolean onNavigationItemSelected(MenuItem item) {
146 | // Handle navigation view item clicks here.
147 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
148 |
149 | int select = item.getItemId();
150 | if (select == current){
151 | drawer.closeDrawer(GravityCompat.START);
152 | return true;
153 | }
154 |
155 | current = select;
156 | BaseFragment fragment = null;
157 |
158 | switch (select){
159 | case R.id.nav_main:
160 | fragment = fragmentList.get(0);
161 | toolbar.setTitle(TITLE_MAIN);
162 | drawer.closeDrawer(GravityCompat.START);
163 | break;
164 | case R.id.nav_dynamic:
165 | fragment = fragmentList.get(1);
166 | toolbar.setTitle(TITLE_DYNAMIC);
167 | drawer.closeDrawer(GravityCompat.START);
168 | break;
169 | case R.id.nav_book:
170 | fragment = fragmentList.get(2);
171 | toolbar.setTitle(TITLE_BOOK);
172 | drawer.closeDrawer(GravityCompat.START);
173 | break;
174 | case R.id.nav_query:
175 | fragment = fragmentList.get(3);
176 | toolbar.setTitle(TITLE_QUERY);
177 | drawer.closeDrawer(GravityCompat.START);
178 | break;
179 | case R.id.nav_about:
180 | //关于
181 | startActivity(new Intent(this,AboutActivity.class));
182 | drawer.closeDrawer(GravityCompat.START);
183 | return true;
184 | }
185 | // fragmentManager.popBackStack();
186 | fragmentManager.beginTransaction()
187 | .replace(R.id.container,fragment)
188 | .addToBackStack(fragment.getClass().getSimpleName())
189 | .commit();
190 | return true;
191 | }
192 |
193 | @Override
194 | public void onClick(View v) {
195 | Snackbar.make(v, "Replace with your own action", Snackbar.LENGTH_LONG)
196 | .setAction("Action", null).show();
197 | }
198 |
199 | public void backMainFragment(){
200 |
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/PlaceListActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import android.content.Intent;
4 | import android.view.View;
5 | import android.widget.AdapterView;
6 | import android.widget.ListView;
7 |
8 | import com.levent_j.airlinebooksystem.R;
9 | import com.levent_j.airlinebooksystem.base.BaseActivity;
10 |
11 | import butterknife.Bind;
12 |
13 | /**
14 | * Created by levent_j on 16-7-2.
15 | */
16 | public class PlaceListActivity extends BaseActivity{
17 | @Bind(R.id.lv_cities) ListView cityList;
18 |
19 | private int type = 0;
20 | private String[] cities = new String[]{"北京","上海","广州","深圳","成都","西安","昆明","厦门","杭州","乌鲁木齐","南京","哈尔滨"};
21 |
22 | @Override
23 | protected int getLayoutId() {
24 | return R.layout.activity_place_list;
25 | }
26 |
27 | @Override
28 | protected void initView() {
29 |
30 |
31 |
32 | cityList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
33 | @Override
34 | public void onItemClick(AdapterView> parent, View view, int position, long id) {
35 | Intent intent = new Intent();
36 | intent.putExtra("place",cities[position]);
37 | setResult(type,intent);
38 | finish();
39 | }
40 | });
41 |
42 |
43 | }
44 |
45 | @Override
46 | protected void initData() {
47 | type = getIntent().getIntExtra("type",0);
48 | }
49 |
50 | @Override
51 | protected void setListener() {
52 |
53 | }
54 |
55 | @Override
56 | public void onBackPressed() {
57 | Intent intent = new Intent();
58 | intent.putExtra("place","未选择");
59 | setResult(type, intent);
60 | finish();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/activity/PriceActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.activity;
2 |
3 | import com.levent_j.airlinebooksystem.R;
4 | import com.levent_j.airlinebooksystem.base.BaseActivity;
5 |
6 | /**
7 | * Created by levent_j on 16-7-4.
8 | */
9 | public class PriceActivity extends BaseActivity{
10 | @Override
11 | protected int getLayoutId() {
12 | return R.layout.activity_price;
13 | }
14 |
15 | @Override
16 | protected void initView() {
17 |
18 | }
19 |
20 | @Override
21 | protected void initData() {
22 |
23 | }
24 |
25 | @Override
26 | protected void setListener() {
27 |
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/adapter/AdminClientAdapter.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.support.v7.app.AlertDialog;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import com.levent_j.airlinebooksystem.R;
17 | import com.levent_j.airlinebooksystem.activity.EditClientActivity;
18 | import com.levent_j.airlinebooksystem.activity.EditFlightActivity;
19 | import com.levent_j.airlinebooksystem.base.BaseAdapter;
20 | import com.levent_j.airlinebooksystem.bean.Client;
21 | import com.levent_j.airlinebooksystem.fragment.AdminClientFragment;
22 |
23 | import butterknife.Bind;
24 | import butterknife.ButterKnife;
25 | import cn.bmob.v3.exception.BmobException;
26 | import cn.bmob.v3.listener.UpdateListener;
27 |
28 | /**
29 | * Created by levent_j on 16-7-4.
30 | */
31 | public class AdminClientAdapter extends BaseAdapter{
32 |
33 | public AdminClientAdapter(Context context) {
34 | super(context);
35 | }
36 |
37 | @Override
38 | public mViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
39 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_admin_client,parent,false);
40 | return new mViewHolder(view);
41 | }
42 |
43 | @Override
44 | public void onBindViewHolder(mViewHolder holder, int position) {
45 | holder.bindView(mDatas.get(position));
46 | }
47 |
48 | public class mViewHolder extends RecyclerView.ViewHolder{
49 | @Bind(R.id.tv_admin_client_name) TextView name;
50 | @Bind(R.id.tv_admin_client_id) TextView idcard;
51 | @Bind(R.id.tv_admin_client_flight) TextView flight;
52 | @Bind(R.id.tv_admin_client_data) TextView data;
53 | @Bind(R.id.layout_admin_client) LinearLayout layout;
54 |
55 | public mViewHolder(View itemView) {
56 | super(itemView);
57 | ButterKnife.bind(this,itemView);
58 | }
59 |
60 | public void bindView(final Client client) {
61 | name.setText("姓名:"+client.getName());
62 | idcard.setText("身份证:" + client.getIdCard());
63 | flight.setText("航班:" + client.getFlightNo());
64 | data.setText("乘机日期:" + client.getData());
65 | layout.setOnClickListener(new View.OnClickListener() {
66 | @Override
67 | public void onClick(View v) {
68 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
69 | builder.setTitle("提示")
70 | .setMessage("选择操作选项").setPositiveButton("修改", new DialogInterface.OnClickListener() {
71 | @Override
72 | public void onClick(DialogInterface dialog, int which) {
73 | Intent intent = new Intent(mContext, EditClientActivity.class);
74 | intent.putExtra("isNew", false);
75 | intent.putExtra("id", client.getObjectId());
76 | intent.putExtra("name", client.getName());
77 | intent.putExtra("ic", client.getIdCard());
78 | intent.putExtra("flight", client.getFlightNo());
79 | intent.putExtra("date", client.getData());
80 | mContext.startActivity(intent);
81 | dialog.dismiss();
82 | }
83 | })
84 | .setNeutralButton("取消", new DialogInterface.OnClickListener() {
85 | @Override
86 | public void onClick(DialogInterface dialog, int which) {
87 | dialog.dismiss();
88 | }
89 | })
90 | .setNegativeButton("删除", new DialogInterface.OnClickListener() {
91 | @Override
92 | public void onClick(DialogInterface dialog, int which) {
93 | Client c = new Client();
94 | c.setObjectId(client.getObjectId());
95 | c.delete(new UpdateListener() {
96 | @Override
97 | public void done(BmobException e) {
98 | if (e == null) {
99 | Toast.makeText(mContext,"删除成功!",Toast.LENGTH_SHORT).show();
100 | } else {
101 | Log.e("Bmob","delete error:"+e.getMessage());
102 | }
103 | }
104 | });
105 | dialog.dismiss();
106 | }
107 | })
108 | .create()
109 | .show();
110 | }
111 | });
112 | }
113 |
114 |
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/adapter/AdminFlightAdapter.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.adapter;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.support.v7.app.AlertDialog;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.LinearLayout;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import com.levent_j.airlinebooksystem.R;
17 | import com.levent_j.airlinebooksystem.activity.EditFlightActivity;
18 | import com.levent_j.airlinebooksystem.base.BaseAdapter;
19 | import com.levent_j.airlinebooksystem.bean.Flight;
20 |
21 | import java.util.zip.Inflater;
22 |
23 | import butterknife.Bind;
24 | import butterknife.ButterKnife;
25 | import cn.bmob.v3.exception.BmobException;
26 | import cn.bmob.v3.listener.UpdateListener;
27 |
28 | /**
29 | * Created by levent_j on 16-7-4.
30 | */
31 | public class AdminFlightAdapter extends BaseAdapter{
32 |
33 | public AdminFlightAdapter(Context context) {
34 | super(context);
35 | }
36 |
37 | @Override
38 | public mViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
39 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_admin_flight,parent,false);
40 | return new mViewHolder(view);
41 | }
42 |
43 | @Override
44 | public void onBindViewHolder(mViewHolder holder, int position) {
45 | holder.bindView(mDatas.get(position));
46 | }
47 |
48 | public class mViewHolder extends RecyclerView.ViewHolder{
49 | @Bind(R.id.tv_admin_start_time) TextView start;
50 | @Bind(R.id.tv_admin_end_time) TextView end;
51 | @Bind(R.id.tv_admin_place_start) TextView origin;
52 | @Bind(R.id.tv_admin_place_end) TextView destination;
53 | @Bind(R.id.tv_admin_plane_no) TextView flightNo;
54 | @Bind(R.id.tv_admin_price) TextView price;
55 | @Bind(R.id.tv_admin_flight_surplus) TextView surplus;
56 | @Bind(R.id.tv_admin_flight_booked) TextView booked;
57 | @Bind(R.id.layout_admin_flight) LinearLayout layout;
58 |
59 | public mViewHolder(View itemView) {
60 | super(itemView);
61 | ButterKnife.bind(this,itemView);
62 | }
63 |
64 | public void bindView(final Flight flight) {
65 | start.setText(flight.getStartTime());
66 | end.setText(flight.getEndTime());
67 | origin.setText(flight.getOriginPlace());
68 | destination.setText(flight.getDestinationPlace());
69 | flightNo.setText(flight.getFlightNo()+"("+flight.getFlightType()+")");
70 | price.setText(String.valueOf(flight.getPrice())+"¥");
71 | surplus.setText("剩余"+String.valueOf(flight.getSurplusTickets())+"张");
72 | booked.setText("已订"+String.valueOf(flight.getBookedTickets())+"张");
73 | layout.setOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View v) {
76 | AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
77 | builder.setTitle("提示")
78 | .setMessage("选择操作选项").setPositiveButton("修改", new DialogInterface.OnClickListener() {
79 | @Override
80 | public void onClick(DialogInterface dialog, int which) {
81 | Intent intent = new Intent(mContext, EditFlightActivity.class);
82 | intent.putExtra("isNew",false);
83 | intent.putExtra("id",flight.getObjectId());
84 | intent.putExtra("origin",flight.getOriginPlace());
85 | intent.putExtra("destination",flight.getDestinationPlace());
86 | intent.putExtra("date",flight.getData());
87 | intent.putExtra("start",flight.getStartTime());
88 | intent.putExtra("end",flight.getEndTime());
89 | intent.putExtra("no",flight.getFlightNo());
90 | intent.putExtra("type",flight.getFlightType());
91 | intent.putExtra("price",flight.getPrice());
92 | intent.putExtra("booked",flight.getBookedTickets());
93 | intent.putExtra("surplus",flight.getSurplusTickets());
94 | mContext.startActivity(intent);
95 | dialog.dismiss();
96 | }
97 | })
98 | .setNeutralButton("取消", new DialogInterface.OnClickListener() {
99 | @Override
100 | public void onClick(DialogInterface dialog, int which) {
101 | dialog.dismiss();
102 | }
103 | })
104 | .setNegativeButton("删除", new DialogInterface.OnClickListener() {
105 | @Override
106 | public void onClick(DialogInterface dialog, int which) {
107 | Flight f = new Flight();
108 | f.setObjectId(flight.getObjectId());
109 | f.delete(new UpdateListener() {
110 | @Override
111 | public void done(BmobException e) {
112 | if (e==null){
113 | Toast.makeText(mContext,"删除成功!",Toast.LENGTH_SHORT).show();
114 | }else {
115 | Toast.makeText(mContext,"网络繁忙,请稍后再试",Toast.LENGTH_SHORT).show();
116 | Log.e("Bmob","delete error:"+e.getMessage());
117 | }
118 | }
119 | });
120 | dialog.dismiss();
121 | }
122 | })
123 | .create()
124 | .show();
125 | }
126 | });
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/adapter/DynamicAdapter.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.adapter;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.TextView;
9 |
10 | import com.levent_j.airlinebooksystem.R;
11 | import com.levent_j.airlinebooksystem.base.BaseAdapter;
12 | import com.levent_j.airlinebooksystem.bean.Flight;
13 |
14 | import java.util.zip.Inflater;
15 |
16 | import butterknife.Bind;
17 | import butterknife.ButterKnife;
18 |
19 | /**
20 | * Created by levent_j on 16-7-2.
21 | */
22 | public class DynamicAdapter extends BaseAdapter{
23 |
24 | public DynamicAdapter(Context context) {
25 | super(context);
26 | }
27 |
28 | @Override
29 | public mViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
30 | View view = LayoutInflater.from(mContext).inflate(R.layout.item_dynamic,parent,false);
31 | return new mViewHolder(view);
32 | }
33 |
34 | @Override
35 | public void onBindViewHolder(mViewHolder holder, int position) {
36 | Flight flight = mDatas.get(position);
37 | holder.bindView(flight);
38 | }
39 |
40 | class mViewHolder extends RecyclerView.ViewHolder{
41 | @Bind(R.id.tv_start_time) TextView start;
42 | @Bind(R.id.tv_end_time) TextView end;
43 | @Bind(R.id.tv_place_start) TextView origin;
44 | @Bind(R.id.tv_place_end) TextView destination;
45 | @Bind(R.id.tv_plane_no) TextView flightNo;
46 | @Bind(R.id.tv_price) TextView price;
47 | @Bind(R.id.tv_surplus_tickets) TextView tickets;
48 |
49 | public mViewHolder(View itemView) {
50 | super(itemView);
51 | ButterKnife.bind(this,itemView);
52 | }
53 |
54 | public void bindView(Flight flight) {
55 | start.setText(flight.getStartTime());
56 | end.setText(flight.getEndTime());
57 | origin.setText(flight.getOriginPlace());
58 | destination.setText(flight.getDestinationPlace());
59 | flightNo.setText(flight.getFlightNo()+"("+flight.getFlightType()+")");
60 | price.setText(String.valueOf(flight.getPrice())+"¥");
61 | tickets.setText(String.valueOf(flight.getSurplusTickets()));
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/base/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.base;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.util.Log;
5 | import android.view.Menu;
6 | import android.view.MenuItem;
7 | import android.widget.Toast;
8 | import android.os.Bundle;
9 |
10 | import com.levent_j.airlinebooksystem.R;
11 |
12 | import butterknife.ButterKnife;
13 |
14 | /**
15 | * Created by levent_j on 16-6-30.
16 | */
17 |
18 | public abstract class BaseActivity extends AppCompatActivity {
19 | public String TAG = this.getClass().getSimpleName();;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(getLayoutId());
25 | ButterKnife.bind(this);
26 | initView();
27 | initData();
28 | setListener();
29 |
30 | }
31 |
32 | protected abstract int getLayoutId();
33 |
34 | protected abstract void initView();
35 |
36 | protected abstract void initData();
37 |
38 | protected abstract void setListener();
39 |
40 | protected void msg(String s) {
41 | Log.d(TAG, s);
42 | }
43 |
44 | protected void Toa(String s) {
45 | Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
46 | }
47 |
48 |
49 |
50 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/base/BaseAdapter.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.base;
2 |
3 | import android.content.Context;
4 | import android.support.v7.widget.RecyclerView;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 |
9 | /**
10 | * Created by levent_j on 16-6-30.
11 | */
12 | public abstract class BaseAdapter
13 | extends RecyclerView.Adapter{
14 |
15 | public List mDatas;
16 |
17 | public Context mContext;
18 |
19 | public BaseAdapter(Context context){
20 | mDatas = new ArrayList();
21 | this.mContext = context;
22 | }
23 |
24 | @Override
25 | public int getItemCount() {
26 | return mDatas.size();
27 | }
28 |
29 | public void appendData(List datas){
30 | int start = mDatas.size();
31 | int itemCount = datas.size();
32 | mDatas.addAll(datas);
33 | notifyItemRangeInserted(start,itemCount);
34 | }
35 |
36 | public void replaceData(List datas){
37 | mDatas.clear();
38 | mDatas.addAll(datas);
39 | notifyDataSetChanged();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/base/BaseFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.base;
2 |
3 | import android.os.Bundle;
4 | import android.support.annotation.Nullable;
5 | import android.support.v4.app.Fragment;
6 | import android.util.Log;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.Toast;
11 |
12 | import butterknife.ButterKnife;
13 |
14 | /**
15 | * Created by levent_j on 16-6-30.
16 | */
17 |
18 | public abstract class BaseFragment extends Fragment {
19 | public String TAG;
20 |
21 | @Nullable
22 | @Override
23 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
24 | TAG = this.getClass().getSimpleName();
25 |
26 | View view = inflater.inflate(setRootViewId(), container, false);
27 | ButterKnife.bind(this,view);
28 | return view;
29 | }
30 |
31 | @Override
32 | public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
33 | super.onViewCreated(view, savedInstanceState);
34 | initView();
35 | initDatas();
36 | }
37 |
38 |
39 |
40 | protected abstract void initDatas();
41 |
42 | protected abstract void initView();
43 |
44 | protected abstract int setRootViewId();
45 |
46 | @Override
47 | public void onDestroyView() {
48 | super.onDestroyView();
49 | ButterKnife.unbind(this);
50 | }
51 |
52 |
53 | protected void msg(String s) {
54 | Log.d(TAG, s);
55 | }
56 |
57 | protected void Toa(String s) {
58 | Toast.makeText(getActivity(), s, Toast.LENGTH_SHORT).show();
59 | }
60 |
61 | @Override
62 | public void onDestroy() {
63 | super.onDestroy();
64 |
65 | }
66 |
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/bean/Client.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.bean;
2 |
3 | import cn.bmob.v3.BmobObject;
4 |
5 | /**
6 | * Created by levent_j on 16-7-2.
7 | */
8 | public class Client extends BmobObject{
9 | private String name;
10 | private String idCard;
11 | private String flightNo;
12 | private String data;
13 | private Integer seatNo;
14 |
15 | public String getName() {
16 | return name;
17 | }
18 |
19 | public void setName(String name) {
20 | this.name = name;
21 | }
22 |
23 | public String getIdCard() {
24 | return idCard;
25 | }
26 |
27 | public void setIdCard(String idCard) {
28 | this.idCard = idCard;
29 | }
30 |
31 | public String getFlightNo() {
32 | return flightNo;
33 | }
34 |
35 | public void setFlightNo(String flightNo) {
36 | this.flightNo = flightNo;
37 | }
38 |
39 | public String getData() {
40 | return data;
41 | }
42 |
43 | public void setData(String data) {
44 | this.data = data;
45 | }
46 |
47 | public int getSeatNo() {
48 | return seatNo;
49 | }
50 |
51 | public void setSeatNo(Integer seatNo) {
52 | this.seatNo = seatNo;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/bean/Flight.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.bean;
2 |
3 | import cn.bmob.v3.BmobObject;
4 |
5 | /**
6 | * Created by levent_j on 16-7-2.
7 | */
8 | public class Flight extends BmobObject{
9 | private String flightNo;
10 | private String flightType;
11 | private String originPlace;
12 | private String destinationPlace;
13 | private String data;
14 | private String startTime;
15 | private String endTime;
16 | private Integer price;
17 | private Integer bookedTickets;
18 | private Integer surplusTickets;
19 |
20 | public String getFlightNo() {
21 | return flightNo;
22 | }
23 |
24 | public void setFlightNo(String flightNo) {
25 | this.flightNo = flightNo;
26 | }
27 |
28 | public String getFlightType() {
29 | return flightType;
30 | }
31 |
32 | public void setFlightType(String flightType) {
33 | this.flightType = flightType;
34 | }
35 |
36 | public String getOriginPlace() {
37 | return originPlace;
38 | }
39 |
40 | public void setOriginPlace(String originPlace) {
41 | this.originPlace = originPlace;
42 | }
43 |
44 | public String getDestinationPlace() {
45 | return destinationPlace;
46 | }
47 |
48 | public void setDestinationPlace(String destinationPlace) {
49 | this.destinationPlace = destinationPlace;
50 | }
51 |
52 | public String getData() {
53 | return data;
54 | }
55 |
56 | public void setData(String data) {
57 | this.data = data;
58 | }
59 |
60 | public String getStartTime() {
61 | return startTime;
62 | }
63 |
64 | public void setStartTime(String startTime) {
65 | this.startTime = startTime;
66 | }
67 |
68 | public String getEndTime() {
69 | return endTime;
70 | }
71 |
72 | public void setEndTime(String endTime) {
73 | this.endTime = endTime;
74 | }
75 |
76 | public int getPrice() {
77 | return price;
78 | }
79 |
80 | public void setPrice(Integer price) {
81 | this.price = price;
82 | }
83 |
84 | public int getBookedTickets() {
85 | return bookedTickets;
86 | }
87 |
88 | public void setBookedTickets(Integer bookedTickets) {
89 | this.bookedTickets = bookedTickets;
90 | }
91 |
92 | public int getSurplusTickets() {
93 | return surplusTickets;
94 | }
95 |
96 | public void setSurplusTickets(Integer surplusTickets) {
97 | this.surplusTickets = surplusTickets;
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/bean/Test.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.bean;
2 |
3 | import cn.bmob.v3.BmobObject;
4 |
5 | /**
6 | * Created by levent_j on 16-7-1.
7 | */
8 | public class Test extends BmobObject{
9 | private String test;
10 |
11 | public String getTest() {
12 | return test;
13 | }
14 |
15 | public void setTest(String test) {
16 | this.test = test;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/bean/Ticket.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.bean;
2 |
3 | import cn.bmob.v3.BmobObject;
4 |
5 | /**
6 | * Created by levent_j on 16-7-2.
7 | */
8 | public class Ticket extends BmobObject{
9 | private String clientName;
10 | private String flightNo;
11 | private String data;
12 | private String destination;
13 | private int seatNo;
14 |
15 | public String getClientName() {
16 | return clientName;
17 | }
18 |
19 | public void setClientName(String clientName) {
20 | this.clientName = clientName;
21 | }
22 |
23 | public String getFlightNo() {
24 | return flightNo;
25 | }
26 |
27 | public void setFlightNo(String flightNo) {
28 | this.flightNo = flightNo;
29 | }
30 |
31 | public String getData() {
32 | return data;
33 | }
34 |
35 | public void setData(String data) {
36 | this.data = data;
37 | }
38 |
39 | public String getDestination() {
40 | return destination;
41 | }
42 |
43 | public void setDestination(String destination) {
44 | this.destination = destination;
45 | }
46 |
47 | public int getSeatNo() {
48 | return seatNo;
49 | }
50 |
51 | public void setSeatNo(int seatNo) {
52 | this.seatNo = seatNo;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/fragment/AdminClientFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.fragment;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.view.View;
10 |
11 | import com.levent_j.airlinebooksystem.R;
12 | import com.levent_j.airlinebooksystem.activity.EditClientActivity;
13 | import com.levent_j.airlinebooksystem.adapter.AdminClientAdapter;
14 | import com.levent_j.airlinebooksystem.base.BaseFragment;
15 | import com.levent_j.airlinebooksystem.bean.Client;
16 | import com.levent_j.airlinebooksystem.utils.DividerItemDecoration;
17 |
18 | import java.util.List;
19 |
20 | import butterknife.Bind;
21 | import cn.bmob.v3.BmobQuery;
22 | import cn.bmob.v3.exception.BmobException;
23 | import cn.bmob.v3.listener.FindListener;
24 |
25 | /**
26 | * Created by levent_j on 16-7-4.
27 | */
28 | public class AdminClientFragment extends BaseFragment{
29 | @Bind(R.id.rlv_admin_client) RecyclerView clientRecyclerView;
30 | @Bind(R.id.srl_client) SwipeRefreshLayout refresh;
31 | @Bind(R.id.fab_client) FloatingActionButton fab;
32 |
33 | private static final String KEY = "ARGS";
34 | private AdminClientAdapter adapter;
35 |
36 | public static AdminClientFragment newInstance(String s){
37 | AdminClientFragment fragment = new AdminClientFragment();
38 | Bundle args = new Bundle();
39 | args.putString(KEY, s);
40 | fragment.setArguments(args);
41 | return fragment;
42 | }
43 |
44 | @Override
45 | protected void initDatas() {
46 | updateData();
47 | }
48 |
49 | @Override
50 | protected void initView() {
51 | adapter = new AdminClientAdapter(getContext());
52 | clientRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
53 | clientRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
54 | clientRecyclerView.setAdapter(adapter);
55 | refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
56 | @Override
57 | public void onRefresh() {
58 | updateData();
59 | }
60 | });
61 | fab.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View v) {
64 | Intent intent = new Intent(getActivity(), EditClientActivity.class);
65 | intent.putExtra("isNew",true);
66 | getActivity().startActivity(intent);
67 | }
68 | });
69 | }
70 |
71 | public void updateData() {
72 | BmobQuery query = new BmobQuery<>();
73 | query.findObjects(new FindListener() {
74 | @Override
75 | public void done(List list, BmobException e) {
76 | refresh.setRefreshing(false);
77 | if (e==null){
78 | adapter.replaceData(list);
79 | }else {
80 | Toa("网络繁忙,请稍后再试");
81 | }
82 | }
83 | });
84 | }
85 |
86 | @Override
87 | protected int setRootViewId() {
88 | return R.layout.fragment_admin_client;
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/fragment/AdminFlightFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.fragment;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.design.widget.FloatingActionButton;
6 | import android.support.v4.widget.SwipeRefreshLayout;
7 | import android.support.v7.widget.LinearLayoutManager;
8 | import android.support.v7.widget.RecyclerView;
9 | import android.util.Log;
10 | import android.view.View;
11 |
12 | import com.levent_j.airlinebooksystem.R;
13 | import com.levent_j.airlinebooksystem.activity.AdminActivity;
14 | import com.levent_j.airlinebooksystem.activity.EditClientActivity;
15 | import com.levent_j.airlinebooksystem.activity.EditFlightActivity;
16 | import com.levent_j.airlinebooksystem.adapter.AdminFlightAdapter;
17 | import com.levent_j.airlinebooksystem.base.BaseFragment;
18 | import com.levent_j.airlinebooksystem.bean.Flight;
19 | import com.levent_j.airlinebooksystem.utils.DividerItemDecoration;
20 |
21 | import java.util.List;
22 |
23 | import butterknife.Bind;
24 | import cn.bmob.v3.BmobQuery;
25 | import cn.bmob.v3.exception.BmobException;
26 | import cn.bmob.v3.listener.FindListener;
27 |
28 | /**
29 | * Created by levent_j on 16-7-4.
30 | */
31 | public class AdminFlightFragment extends BaseFragment{
32 | @Bind(R.id.rlv_admin_flight) RecyclerView flightRecyclerView;
33 | @Bind(R.id.srl_flight) SwipeRefreshLayout refresh;
34 | @Bind(R.id.fab_flight) FloatingActionButton fab;
35 |
36 | private static final String KEY = "ARGS";
37 | private AdminFlightAdapter adapter;
38 |
39 | public static AdminFlightFragment newInstance(String s){
40 | AdminFlightFragment fragment = new AdminFlightFragment();
41 | Bundle args = new Bundle();
42 | args.putString(KEY, s);
43 | fragment.setArguments(args);
44 | return fragment;
45 | }
46 |
47 | @Override
48 | protected void initDatas() {
49 | updateDate();
50 | }
51 |
52 | public void updateDate() {
53 | BmobQuery query = new BmobQuery<>();
54 | query.findObjects(new FindListener() {
55 | @Override
56 | public void done(List list, BmobException e) {
57 | refresh.setRefreshing(false);
58 | if (e==null){
59 | adapter.replaceData(list);
60 | }else {
61 | Toa("网络繁忙,请稍后再试");
62 | }
63 | }
64 | });
65 | }
66 |
67 | @Override
68 | protected void initView() {
69 | adapter = new AdminFlightAdapter(getContext());
70 | flightRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
71 | flightRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
72 | flightRecyclerView.setAdapter(adapter);
73 |
74 | refresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
75 | @Override
76 | public void onRefresh() {
77 | updateDate();
78 | }
79 | });
80 | fab.setOnClickListener(new View.OnClickListener() {
81 | @Override
82 | public void onClick(View v) {
83 | Intent intent = new Intent(getActivity(), EditFlightActivity.class);
84 | intent.putExtra("isNew",true);
85 | getActivity().startActivity(intent);
86 | }
87 | });
88 | }
89 |
90 | @Override
91 | protected int setRootViewId() {
92 | return R.layout.fragment_admin_flight;
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/fragment/BookFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.fragment;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.Intent;
5 | import android.graphics.Color;
6 | import android.os.Bundle;
7 | import android.support.design.widget.TextInputLayout;
8 | import android.support.v7.app.AlertDialog;
9 | import android.text.TextUtils;
10 | import android.util.Log;
11 | import android.view.View;
12 | import android.widget.Button;
13 | import android.widget.EditText;
14 | import android.widget.TextView;
15 |
16 | import com.bruce.pickerview.popwindow.DatePickerPopWin;
17 | import com.levent_j.airlinebooksystem.R;
18 | import com.levent_j.airlinebooksystem.activity.MainActivity;
19 | import com.levent_j.airlinebooksystem.base.BaseFragment;
20 | import com.levent_j.airlinebooksystem.bean.Client;
21 | import com.levent_j.airlinebooksystem.bean.Flight;
22 |
23 | import java.util.List;
24 |
25 | import butterknife.Bind;
26 | import cn.bmob.v3.BmobQuery;
27 | import cn.bmob.v3.exception.BmobException;
28 | import cn.bmob.v3.listener.FindListener;
29 | import cn.bmob.v3.listener.SaveListener;
30 | import cn.bmob.v3.listener.UpdateListener;
31 |
32 | /**
33 | * Created by levent_j on 16-7-1.
34 | */
35 | public class BookFragment extends BaseFragment{
36 | @Bind(R.id.til_book_name) TextInputLayout nameWrapper;
37 | @Bind(R.id.til_book_idcard) TextInputLayout idCardWrapper;
38 | @Bind(R.id.til_book_flightNo) TextInputLayout flightNoWrapper;
39 | @Bind(R.id.et_book_name) EditText name;
40 | @Bind(R.id.et_book_idcard) EditText idCard;
41 | @Bind(R.id.et_book_flightNo) EditText flightNo;
42 | @Bind(R.id.tv_book_data) TextView data;
43 | @Bind(R.id.btn_book_search) Button search;
44 |
45 | private String customerId;
46 | private DatePickerPopWin pickerPopWin;
47 |
48 | private boolean isBooked = false;
49 | private boolean isUpdated = false;
50 |
51 | public static BookFragment newInstance(String id){
52 | BookFragment bookFragment = new BookFragment();
53 | Bundle args = new Bundle();
54 | args.putString("id",id);
55 | bookFragment.setArguments(args);
56 | return bookFragment;
57 | }
58 |
59 | @Override
60 | protected void initDatas() {
61 | customerId = getArguments().getString("id");
62 | }
63 |
64 | @Override
65 | protected void initView() {
66 |
67 | pickerPopWin = new DatePickerPopWin.Builder(getContext(), new DatePickerPopWin.OnDatePickedListener() {
68 | @Override
69 | public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
70 | data.setText(year+"-"+month+"-"+day);
71 |
72 | }
73 | })
74 | .textConfirm("选择")
75 | .textCancel("取消")
76 | .btnTextSize(16)
77 | .viewTextSize(25)
78 | .colorCancel(Color.parseColor("#999999"))
79 | .colorConfirm(Color.parseColor("#7C4DEF"))
80 | .minYear(1970)
81 | .maxYear(2020)
82 | .dateChose("2016-07-02")
83 | .build();
84 |
85 | data.setOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View v) {
88 | pickerPopWin.showPopWin(getActivity());
89 | }
90 | });
91 |
92 | search.setOnClickListener(new View.OnClickListener() {
93 | @Override
94 | public void onClick(View v) {
95 | final String clientName = name.getText().toString();
96 | final String clientIdCard = idCard.getText().toString();
97 | final String clientFlightNo = flightNo.getText().toString();
98 | final String day = data.getText().toString();
99 | if (TextUtils.isEmpty(clientName)) {
100 | nameWrapper.setError("姓名不能为空");
101 | return;
102 | } else {
103 | nameWrapper.setErrorEnabled(false);
104 | }
105 | if (TextUtils.isEmpty(clientIdCard)) {
106 | idCardWrapper.setError("身份证号不能为空");
107 | return;
108 | } else {
109 | idCardWrapper.setErrorEnabled(false);
110 | }
111 | if (TextUtils.isEmpty(clientFlightNo)) {
112 | flightNoWrapper.setError("航班号不能为空");
113 | return;
114 | } else {
115 | flightNoWrapper.setErrorEnabled(false);
116 | }
117 | if (day.equals("日期")) {
118 | Toa("请选择日期");
119 | return;
120 | }
121 |
122 | search.setText("请等待");
123 | search.setEnabled(false);
124 |
125 | BmobQuery query = new BmobQuery();
126 | query.addWhereEqualTo("flightNo", clientFlightNo);
127 | query.addWhereEqualTo("data", day);
128 | query.findObjects(new FindListener() {
129 | @Override
130 | public void done(List list, BmobException e) {
131 | search.setText("查询");
132 | search.setEnabled(true);
133 | if (e == null) {
134 | if (list.size()>0){
135 | if (list.get(0).getSurplusTickets() > 0) {
136 | AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
137 | builder.setTitle("订票")
138 | .setMessage("现有余票" + list.get(0).getSurplusTickets() + "张,是否购票?")
139 | .setPositiveButton("确定", new DialogInterface.OnClickListener() {
140 | @Override
141 | public void onClick(DialogInterface dialog, int which) {
142 | bookTicket(clientName, clientIdCard, clientFlightNo,day, dialog);
143 | }
144 | })
145 | .setNegativeButton("取消", new DialogInterface.OnClickListener() {
146 | @Override
147 | public void onClick(DialogInterface dialog, int which) {
148 | dialog.dismiss();
149 | }
150 | })
151 | .create()
152 | .show();
153 | } else {
154 | Toa("该航班已无余票");
155 | }
156 | }else {
157 | Toa("无此航班信息");
158 | }
159 |
160 | } else {
161 | Toa("网络繁忙,请稍后再试");
162 | Log.e("Bmob", "error:" + e.getMessage());
163 | }
164 | }
165 | });
166 |
167 |
168 | }
169 | });
170 | }
171 |
172 | private void bookTicket(String name, String idCard, String flightNo,String data, final DialogInterface dialog) {
173 | search.setText("请等待");
174 | search.setEnabled(false);
175 |
176 | //增加客户
177 | addClient(name, idCard, flightNo, data);
178 |
179 | //航班票量改变
180 | updateTickets(flightNo);
181 |
182 | dialog.dismiss();
183 | }
184 |
185 | private void updateTickets(String flightNo) {
186 | BmobQuery query = new BmobQuery();
187 | query.addWhereEqualTo("flightNo", flightNo);
188 | query.findObjects(new FindListener() {
189 | @Override
190 | public void done(List list, BmobException e) {
191 | if (e == null) {
192 | String id = list.get(0).getObjectId();
193 | int booked = list.get(0).getBookedTickets();
194 | int surplus = list.get(0).getSurplusTickets();
195 |
196 | Flight flight = list.get(0);
197 | flight.setBookedTickets( booked + 1);
198 | flight.setSurplusTickets( surplus - 1);
199 | flight.update(id, new UpdateListener() {
200 | @Override
201 | public void done(BmobException e) {
202 | if (e == null) {
203 | isUpdated = true;
204 | startActivity(new Intent(getActivity(), MainActivity.class));
205 | getActivity().finish();
206 | } else {
207 | Toa("网络繁忙,请稍后再试");
208 | Log.e("Bmob", "update error:" + e.getMessage());
209 | }
210 | }
211 | });
212 | } else {
213 | Toa("网络繁忙,请稍后再试");
214 | Log.e("Bmob", "change error:" + e.getMessage());
215 | }
216 | }
217 | });
218 | }
219 |
220 | private void addClient(String name, String idCard, String flightNo,String data) {
221 | Client client = new Client();
222 | client.setName(name);
223 | client.setIdCard(idCard);
224 | client.setFlightNo(flightNo);
225 | client.setData(data);
226 | client.save(new SaveListener() {
227 | @Override
228 | public void done(String s, BmobException e) {
229 | if (e==null){
230 | isBooked = true;
231 | }else {
232 | Toa("网络繁忙,请稍后再试");
233 | Log.e("Bmob","save error:"+e.getMessage());
234 | }
235 | }
236 | });
237 | }
238 |
239 | @Override
240 | protected int setRootViewId() {
241 | return R.layout.fragment_book;
242 | }
243 | }
244 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/fragment/DynamicFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.fragment;
2 |
3 | import android.content.Intent;
4 | import android.graphics.Color;
5 | import android.os.Bundle;
6 | import android.support.v7.widget.LinearLayoutManager;
7 | import android.support.v7.widget.RecyclerView;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.widget.Button;
11 | import android.widget.ImageView;
12 | import android.widget.TextView;
13 |
14 | import com.bruce.pickerview.popwindow.DatePickerPopWin;
15 | import com.levent_j.airlinebooksystem.R;
16 | import com.levent_j.airlinebooksystem.activity.PlaceListActivity;
17 | import com.levent_j.airlinebooksystem.adapter.DynamicAdapter;
18 | import com.levent_j.airlinebooksystem.base.BaseFragment;
19 | import com.levent_j.airlinebooksystem.bean.Flight;
20 | import com.levent_j.airlinebooksystem.utils.DividerItemDecoration;
21 | import com.wang.avi.AVLoadingIndicatorView;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 |
26 | import butterknife.Bind;
27 | import cn.bmob.v3.BmobQuery;
28 | import cn.bmob.v3.exception.BmobException;
29 | import cn.bmob.v3.listener.FindListener;
30 |
31 | /**
32 | * Created by levent_j on 16-7-1.
33 | */
34 | public class DynamicFragment extends BaseFragment implements View.OnClickListener {
35 | @Bind(R.id.tv_origin_place) TextView originPlace;
36 | @Bind(R.id.tv_destination_place) TextView destinationPlace;
37 | @Bind(R.id.iv_backandforth) ImageView transfor;
38 | @Bind(R.id.tv_dynamic_data) TextView data;
39 | @Bind(R.id.iv_dynamic_data) ImageView ivData;
40 | @Bind(R.id.btn_dynamic_search) Button search;
41 | @Bind(R.id.rlv_dynamic) RecyclerView flightRecyclerView;
42 | @Bind(R.id.loading_dynamic) AVLoadingIndicatorView loading;
43 |
44 | private String customerId;
45 | private int REQUEST_ORIGIN = 0;
46 | private int REQUEST_DESTINATION = 1;
47 |
48 | private DynamicAdapter adapter;
49 | private DatePickerPopWin pickerPopWin;
50 |
51 | public static DynamicFragment newInstance(String id){
52 | DynamicFragment dynamicFragment = new DynamicFragment();
53 | Bundle args = new Bundle();
54 | args.putString("id",id);
55 | dynamicFragment.setArguments(args);
56 | return dynamicFragment;
57 | }
58 |
59 | @Override
60 | protected void initDatas() {
61 | customerId = getArguments().getString("id");
62 | }
63 |
64 | @Override
65 | protected void initView() {
66 | originPlace.setOnClickListener(this);
67 | destinationPlace.setOnClickListener(this);
68 | data.setOnClickListener(this);
69 | search.setOnClickListener(this);
70 | transfor.setOnClickListener(this);
71 | ivData.setOnClickListener(this);
72 | adapter = new DynamicAdapter(getActivity());
73 |
74 |
75 | flightRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
76 | flightRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
77 | flightRecyclerView.setAdapter(adapter);
78 |
79 | pickerPopWin = new DatePickerPopWin.Builder(getContext(), new DatePickerPopWin.OnDatePickedListener() {
80 | @Override
81 | public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
82 | data.setText(year+"-"+month+"-"+day);
83 |
84 | }
85 | })
86 | .textConfirm("选择")
87 | .textCancel("取消")
88 | .btnTextSize(16)
89 | .viewTextSize(25)
90 | .colorCancel(Color.parseColor("#999999"))
91 | .colorConfirm(Color.parseColor("#7C4DEF"))
92 | .minYear(1970)
93 | .maxYear(2020)
94 | .dateChose("2016-07-02")
95 | .build();
96 |
97 | }
98 |
99 | @Override
100 | protected int setRootViewId() {
101 | return R.layout.fragment_dynamic;
102 | }
103 |
104 | @Override
105 | public void onClick(View v) {
106 | switch (v.getId()){
107 | case R.id.tv_origin_place:
108 | startCityList(REQUEST_ORIGIN);
109 | break;
110 | case R.id.tv_destination_place:
111 | startCityList(REQUEST_DESTINATION);
112 | break;
113 | case R.id.iv_dynamic_data:
114 | case R.id.tv_dynamic_data:
115 |
116 | pickerPopWin.showPopWin(getActivity());
117 |
118 | break;
119 | case R.id.btn_dynamic_search:
120 |
121 | String origin = originPlace.getText().toString();
122 | String destination = destinationPlace.getText().toString();
123 | String day = data.getText().toString();
124 | if (origin.equals("出发地")||origin.equals("未选择")){
125 | Toa("请选择正确的出发地");
126 | }else if (destination.equals("目的地")||destination.equals("未选择")){
127 | Toa("请选择正确的目的地");
128 | }else if (day.equals("日期")){
129 | Toa("请选择正确的时间");
130 | }else {
131 | loading.setVisibility(View.VISIBLE);
132 | BmobQuery query = new BmobQuery<>();
133 | query.addWhereEqualTo("originPlace", origin);
134 | query.addWhereEqualTo("destinationPlace", destination);
135 | query.addWhereEqualTo("data", day);
136 | query.findObjects(new FindListener() {
137 | @Override
138 | public void done(List list, BmobException e) {
139 | loading.setVisibility(View.GONE);
140 | if (e == null) {
141 |
142 | if (list.size() > 0) {
143 | adapter.replaceData(list);
144 | }else {
145 | Toa("暂无航班");
146 | }
147 |
148 | } else {
149 | Toa("网络繁忙,请稍后再试");
150 | Log.e("Bmob", "error:" + e.getMessage());
151 | }
152 |
153 | }
154 | });
155 | }
156 | break;
157 | case R.id.iv_backandforth:
158 | String swap = destinationPlace.getText().toString();
159 | destinationPlace.setText(originPlace.getText().toString());
160 | originPlace.setText(swap);
161 | break;
162 | }
163 | }
164 |
165 | private void startCityList(int code) {
166 | Intent intent = new Intent(getActivity(),PlaceListActivity.class);
167 | intent.putExtra("type",code);
168 | startActivityForResult(intent,code);
169 | }
170 |
171 | @Override
172 | public void onActivityResult(int requestCode, int resultCode, Intent data) {
173 | super.onActivityResult(requestCode, resultCode, data);
174 | if (requestCode==REQUEST_ORIGIN){
175 | originPlace.setText(data.getStringExtra("place"));
176 | }else {
177 | destinationPlace.setText(data.getStringExtra("place"));
178 | }
179 |
180 | }
181 | }
182 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/fragment/MainFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.fragment;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.ImageView;
7 | import android.widget.LinearLayout;
8 |
9 | import com.levent_j.airlinebooksystem.R;
10 | import com.levent_j.airlinebooksystem.activity.AdminActivity;
11 | import com.levent_j.airlinebooksystem.activity.BoardingActivity;
12 | import com.levent_j.airlinebooksystem.activity.GuideActivity;
13 | import com.levent_j.airlinebooksystem.activity.PriceActivity;
14 | import com.levent_j.airlinebooksystem.base.BaseFragment;
15 | import com.levent_j.airlinebooksystem.widget.InputDialog;
16 | import com.squareup.picasso.Picasso;
17 |
18 | import butterknife.Bind;
19 |
20 | /**
21 | * Created by levent_j on 16-7-1.
22 | */
23 | public class MainFragment extends BaseFragment implements View.OnClickListener {
24 | @Bind(R.id.layout_guide) LinearLayout guide;
25 | @Bind(R.id.layout_boarding) LinearLayout boarding;
26 | @Bind(R.id.layout_price) LinearLayout price;
27 | @Bind(R.id.layout_admin) LinearLayout admin;
28 | @Bind(R.id.iv_bg) ImageView bg;
29 |
30 | private String customerId;
31 |
32 | public static MainFragment newInstance(String id){
33 | MainFragment mainFragment = new MainFragment();
34 | Bundle args = new Bundle();
35 | args.putString("id",id);
36 | mainFragment.setArguments(args);
37 | return mainFragment;
38 | }
39 |
40 | @Override
41 | protected void initDatas() {
42 | customerId = getArguments().getString("id");
43 | }
44 |
45 | @Override
46 | protected void initView() {
47 | Picasso.with(getContext())
48 | .load(R.drawable.bg3)
49 | .resize(400,280)
50 | .into(bg);
51 | guide.setOnClickListener(this);
52 | boarding.setOnClickListener(this);
53 | price.setOnClickListener(this);
54 | admin.setOnClickListener(this);
55 | }
56 |
57 | @Override
58 | protected int setRootViewId() {
59 | return R.layout.fragment_main;
60 | }
61 |
62 | @Override
63 | public void onClick(View v) {
64 | switch (v.getId()){
65 | case R.id.layout_guide:
66 | startActivity(new Intent(getActivity(), GuideActivity.class));
67 | break;
68 | case R.id.layout_boarding:
69 | startActivity(new Intent(getActivity(), BoardingActivity.class));
70 | break;
71 | case R.id.layout_price:
72 | startActivity(new Intent(getActivity(), PriceActivity.class));
73 | break;
74 | case R.id.layout_admin:
75 | InputDialog.Builder builder = new InputDialog.Builder(getContext());
76 | builder.setTitle("登陆认证")
77 | .setInputHint("输入管理员密码")
78 | .setInputMaxWords(6)
79 | .setPositiveButton("登陆", new InputDialog.ButtonActionListener() {
80 | @Override
81 | public void onClick(CharSequence inputText) {
82 | if (inputText.toString().equals("admin")){
83 | startActivity(new Intent(getActivity(), AdminActivity.class));
84 | }else {
85 | Toa("密码错误!");
86 | }
87 | }
88 | })
89 | .show();
90 | break;
91 | }
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/fragment/QueryFragment.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.fragment;
2 |
3 | import android.graphics.Color;
4 | import android.os.Bundle;
5 | import android.support.design.widget.TextInputLayout;
6 | import android.text.TextUtils;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.Button;
10 | import android.widget.EditText;
11 | import android.widget.LinearLayout;
12 | import android.widget.TextView;
13 |
14 | import com.bruce.pickerview.popwindow.DatePickerPopWin;
15 | import com.levent_j.airlinebooksystem.R;
16 | import com.levent_j.airlinebooksystem.base.BaseFragment;
17 | import com.levent_j.airlinebooksystem.bean.Client;
18 | import com.levent_j.airlinebooksystem.bean.Flight;
19 | import com.wang.avi.AVLoadingIndicatorView;
20 |
21 | import java.util.List;
22 |
23 | import butterknife.Bind;
24 | import cn.bmob.v3.BmobQuery;
25 | import cn.bmob.v3.exception.BmobException;
26 | import cn.bmob.v3.listener.FindListener;
27 | import cn.bmob.v3.listener.UpdateListener;
28 |
29 | /**
30 | * Created by levent_j on 16-7-1.
31 | */
32 | public class QueryFragment extends BaseFragment implements View.OnClickListener {
33 | @Bind(R.id.til_query_name) TextInputLayout nameWrapper;
34 | @Bind(R.id.til_query_idcard) TextInputLayout idCardWrapper;
35 | @Bind(R.id.til_query_flightNo) TextInputLayout flightNoWrapper;
36 | @Bind(R.id.et_query_name) EditText name;
37 | @Bind(R.id.et_query_idcard) EditText idCard;
38 | @Bind(R.id.et_query_flightNo) EditText flightNo;
39 | @Bind(R.id.tv_query_data) TextView data;
40 | @Bind(R.id.btn_query_search) Button search;
41 | @Bind(R.id.btn_query_unsubscribe) Button unSubscribe;
42 | @Bind(R.id.tv_ticket_destination) TextView sDestination;
43 | @Bind(R.id.tv_ticket_flightNo) TextView sFlightNo;
44 | @Bind(R.id.tv_ticket_name) TextView sName;
45 | @Bind(R.id.tv_ticket_seat) TextView sSeat;
46 | @Bind(R.id.tv_ticket_no) TextView sNo;
47 | @Bind(R.id.layout_ticket) LinearLayout ticket;
48 | @Bind(R.id.loading_query) AVLoadingIndicatorView loading;
49 |
50 | private String customerId;
51 |
52 | //id值,用来删除更新数据
53 | private String clientId = "1";
54 | private String flightId;
55 | private String dData;
56 |
57 | private DatePickerPopWin pickerPopWin;
58 |
59 | public static QueryFragment newInstance(String id){
60 | QueryFragment queryFragment = new QueryFragment();
61 | Bundle args = new Bundle();
62 | args.putString("id",id);
63 | queryFragment.setArguments(args);
64 | return queryFragment;
65 | }
66 |
67 | @Override
68 | protected void initDatas() {
69 | customerId = getArguments().getString("id");
70 | }
71 |
72 | @Override
73 | protected void initView() {
74 | ticket.setVisibility(View.GONE);
75 | pickerPopWin = new DatePickerPopWin.Builder(getContext(), new DatePickerPopWin.OnDatePickedListener() {
76 | @Override
77 | public void onDatePickCompleted(int year, int month, int day, String dateDesc) {
78 | data.setText(year+"-"+month+"-"+day);
79 |
80 | }
81 | })
82 | .textConfirm("选择")
83 | .textCancel("取消")
84 | .btnTextSize(16)
85 | .viewTextSize(25)
86 | .colorCancel(Color.parseColor("#999999"))
87 | .colorConfirm(Color.parseColor("#7C4DEF"))
88 | .minYear(1970)
89 | .maxYear(2020)
90 | .dateChose("2016-07-02")
91 | .build();
92 | data.setOnClickListener(this);
93 | search.setOnClickListener(this);
94 | unSubscribe.setOnClickListener(this);
95 | }
96 |
97 | @Override
98 | protected int setRootViewId() {
99 | return R.layout.fragment_query;
100 | }
101 |
102 | @Override
103 | public void onClick(View v) {
104 | switch (v.getId()){
105 | case R.id.tv_query_data:
106 | pickerPopWin.showPopWin(getActivity());
107 | break;
108 | case R.id.btn_query_search:
109 |
110 | ticket.setVisibility(View.GONE);
111 |
112 | String tName = name.getText().toString();
113 | String tIdCard = idCard.getText().toString();
114 | String tFlightNo = flightNo.getText().toString();
115 | String tData = data.getText().toString();
116 | dData = tData;
117 |
118 | if (TextUtils.isEmpty(tName)){
119 | nameWrapper.setError("姓名不能为空");
120 | break;
121 | }else {
122 | nameWrapper.setErrorEnabled(false);
123 | }
124 | if (TextUtils.isEmpty(tIdCard)){
125 | idCardWrapper.setError("身份证号不能为空");
126 | break;
127 | }else {
128 | idCardWrapper.setErrorEnabled(false);
129 | }
130 | if (TextUtils.isEmpty(tFlightNo)){
131 | flightNoWrapper.setError("航班号不能为空");
132 | break;
133 | }else {
134 | flightNoWrapper.setErrorEnabled(false);
135 | }
136 | if (tData.equals("日期")){
137 | Toa("请选择正确日期");
138 | break;
139 | }
140 |
141 | loading.setVisibility(View.VISIBLE);
142 |
143 | BmobQuery query = new BmobQuery<>();
144 | query.addWhereEqualTo("name",tName);
145 | query.addWhereEqualTo("idCard",tIdCard);
146 | query.addWhereEqualTo("flightNo",tFlightNo);
147 | query.addWhereEqualTo("data",tData);
148 | query.findObjects(new FindListener() {
149 | @Override
150 | public void done(List list, BmobException e) {
151 | if (e == null) {
152 |
153 | if (list.size()>0){
154 | Client client = list.get(0);
155 | sName.setText("姓名\n" + client.getName());
156 | sFlightNo.setText("航班号\n" + client.getFlightNo());
157 | sSeat.setText("座位号\n" + client.getSeatNo());
158 | sNo.setText("NO:"+client.getObjectId());
159 |
160 | clientId = client.getObjectId();
161 | flightId = client.getFlightNo();
162 | Log.e("Bmob", "flightid:" + flightId);
163 |
164 | //查询航班目的地
165 | BmobQuery fquery = new BmobQuery();
166 | fquery.addWhereEqualTo("flightNo", client.getFlightNo());
167 | fquery.findObjects(new FindListener() {
168 | @Override
169 | public void done(List list, BmobException e) {
170 | if (e == null) {
171 | loading.setVisibility(View.GONE);
172 | ticket.setVisibility(View.VISIBLE);
173 | sDestination.setText("目的地\n"+list.get(0).getDestinationPlace());
174 | } else {
175 | Log.e("Bmob","fquery error:"+e.getMessage());
176 | }
177 | }
178 | });
179 | }else {
180 | loading.setVisibility(View.GONE);
181 | Toa("无该机票信息!");
182 | }
183 |
184 |
185 | } else {
186 | ticket.setVisibility(View.GONE);
187 | Log.e("Bmob", "query error:" + e.getMessage());
188 | }
189 | }
190 | });
191 | break;
192 | case R.id.btn_query_unsubscribe:
193 | //首先要查询一下该票是否存在
194 | BmobQuery cquery = new BmobQuery<>();
195 | cquery.addWhereEqualTo("objectId",clientId);
196 | cquery.findObjects(new FindListener() {
197 | @Override
198 | public void done(List list, BmobException e) {
199 |
200 | ticket.setVisibility(View.GONE);
201 | loading.setVisibility(View.VISIBLE);
202 |
203 | if (e == null) {
204 | if (list.size() > 0) {
205 | //存在此机票
206 | deleTicket();
207 | } else {
208 | Toa("无该机票信息!");
209 | loading.setVisibility(View.GONE);
210 | }
211 | } else {
212 | Log.e("Bmob", "delete error:" + e.getMessage());
213 | }
214 | }
215 | });
216 |
217 |
218 | break;
219 | }
220 |
221 | }
222 |
223 | private void deleTicket() {
224 | //删除客户信息
225 | Client client = new Client();
226 | client.setObjectId(clientId);
227 | client.delete(new UpdateListener() {
228 | @Override
229 | public void done(BmobException e) {
230 | if (e == null) {
231 | Toa("删除成功!");
232 | loading.setVisibility(View.GONE);
233 | } else {
234 | Log.e("Bmob","delete error:"+e.getMessage());
235 | }
236 | }
237 | });
238 | //更新票数信息
239 | BmobQuery fquery = new BmobQuery<>();
240 | fquery.addWhereEqualTo("flightNo",flightId);
241 | fquery.addWhereEqualTo("data",dData);
242 | fquery.findObjects(new FindListener() {
243 | @Override
244 | public void done(List list, BmobException e) {
245 |
246 | if (e == null) {
247 | String id = list.get(0).getObjectId();
248 | int booked = list.get(0).getBookedTickets();
249 | int surplus = list.get(0).getSurplusTickets();
250 |
251 | Flight flight = new Flight();
252 | flight.setBookedTickets(booked - 1);
253 | flight.setSurplusTickets(surplus + 1);
254 | flight.update(id, new UpdateListener() {
255 | @Override
256 | public void done(BmobException e) {
257 | if (e == null) {
258 |
259 | } else {
260 | Log.e("Bmob","change error:"+e.getMessage());
261 | }
262 | }
263 | });
264 | } else {
265 |
266 | }
267 |
268 | }
269 | });
270 | }
271 | }
272 |
--------------------------------------------------------------------------------
/app/src/main/java/com/levent_j/airlinebooksystem/utils/DividerItemDecoration.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem.utils;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.Rect;
7 | import android.graphics.drawable.Drawable;
8 | import android.support.v7.widget.LinearLayoutManager;
9 | import android.support.v7.widget.RecyclerView;
10 | import android.util.Log;
11 | import android.view.View;
12 |
13 | public class DividerItemDecoration extends RecyclerView.ItemDecoration {
14 |
15 | private static final int[] ATTRS = new int[]{
16 | android.R.attr.listDivider
17 | };
18 |
19 | public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
20 |
21 | public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
22 |
23 | private Drawable mDivider;
24 |
25 | private int mOrientation;
26 |
27 | public DividerItemDecoration(Context context, int orientation) {
28 | final TypedArray a = context.obtainStyledAttributes(ATTRS);
29 | mDivider = a.getDrawable(0);
30 | a.recycle();
31 | setOrientation(orientation);
32 | }
33 |
34 | public void setOrientation(int orientation) {
35 | if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
36 | throw new IllegalArgumentException("invalid orientation");
37 | }
38 | mOrientation = orientation;
39 | }
40 |
41 | @Override
42 | public void onDraw(Canvas c, RecyclerView parent) {
43 |
44 | if (mOrientation == VERTICAL_LIST) {
45 | drawVertical(c, parent);
46 | } else {
47 | drawHorizontal(c, parent);
48 | }
49 |
50 | }
51 |
52 |
53 | public void drawVertical(Canvas c, RecyclerView parent) {
54 | final int left = parent.getPaddingLeft();
55 | final int right = parent.getWidth() - parent.getPaddingRight();
56 |
57 | final int childCount = parent.getChildCount();
58 | for (int i = 0; i < childCount; i++) {
59 | final View child = parent.getChildAt(i);
60 | android.support.v7.widget.RecyclerView v = new android.support.v7.widget.RecyclerView(parent.getContext());
61 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
62 | .getLayoutParams();
63 | final int top = child.getBottom() + params.bottomMargin;
64 | final int bottom = top + mDivider.getIntrinsicHeight();
65 | mDivider.setBounds(left, top, right, bottom);
66 | mDivider.draw(c);
67 | }
68 | }
69 |
70 | public void drawHorizontal(Canvas c, RecyclerView parent) {
71 | final int top = parent.getPaddingTop();
72 | final int bottom = parent.getHeight() - parent.getPaddingBottom();
73 |
74 | final int childCount = parent.getChildCount();
75 | for (int i = 0; i < childCount; i++) {
76 | final View child = parent.getChildAt(i);
77 | final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
78 | .getLayoutParams();
79 | final int left = child.getRight() + params.rightMargin;
80 | final int right = left + mDivider.getIntrinsicHeight();
81 | mDivider.setBounds(left, top, right, bottom);
82 | mDivider.draw(c);
83 | }
84 | }
85 |
86 | @Override
87 | public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
88 | if (mOrientation == VERTICAL_LIST) {
89 | outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
90 | } else {
91 | outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/bg3.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_book.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_book0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_book1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_dynamic.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_dynamic0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bg_btn_dynamic1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/dialog_bottom_line.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/dialog_bottom_line.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_add.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_admin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_admin.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_backandforth.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_backandforth.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_boarding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_boarding.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_client.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_client.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_data.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_fly.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_fly.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_guide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_guide.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_muptiply.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_muptiply.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_about.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_about.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_book.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_dynamic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_dynamic.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_information.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_information.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_main.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_query.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_query.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_nav_share.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_nav_share.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_price.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/drawable/ic_price.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/layout_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ticket_border.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
10 |
16 |
17 |
24 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_admin.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
23 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_boarding.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
20 |
28 |
29 |
30 |
38 |
44 |
52 |
53 |
54 |
62 |
68 |
76 |
77 |
78 |
86 |
92 |
100 |
101 |
102 |
113 |
114 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_flight.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
21 |
28 |
29 |
30 |
39 |
45 |
52 |
53 |
54 |
63 |
69 |
76 |
77 |
78 |
87 |
93 |
102 |
103 |
104 |
113 |
119 |
128 |
129 |
130 |
139 |
145 |
153 |
154 |
155 |
164 |
170 |
178 |
179 |
180 |
189 |
195 |
204 |
210 |
211 |
220 |
226 |
235 |
241 |
242 |
243 |
252 |
258 |
267 |
273 |
274 |
275 |
287 |
288 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_guide.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
10 |
11 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_place_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_price.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/dialog_input_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
20 |
21 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_admin_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
11 |
16 |
17 |
18 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_admin_flight.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
12 |
17 |
18 |
19 |
20 |
21 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_book.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
13 |
20 |
21 |
22 |
26 |
34 |
35 |
36 |
40 |
48 |
49 |
50 |
58 |
59 |
68 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_dynamic.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
15 |
22 |
32 |
38 |
48 |
49 |
50 |
56 |
62 |
71 |
72 |
73 |
74 |
85 |
86 |
87 |
88 |
91 |
99 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_information.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
12 |
16 |
21 |
29 |
35 |
43 |
44 |
45 |
52 |
58 |
66 |
67 |
68 |
69 |
74 |
81 |
87 |
95 |
96 |
97 |
105 |
111 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_query.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
16 |
20 |
27 |
28 |
29 |
33 |
41 |
42 |
43 |
47 |
55 |
56 |
57 |
65 |
66 |
74 |
86 |
98 |
99 |
100 |
107 |
115 |
122 |
131 |
138 |
147 |
148 |
157 |
158 |
159 |
160 |
166 |
175 |
176 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_admin_client.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
22 |
29 |
30 |
36 |
43 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_admin_flight.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
13 |
17 |
27 |
32 |
42 |
43 |
47 |
56 |
65 |
66 |
67 |
75 |
76 |
81 |
90 |
98 |
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_dynamic.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
12 |
16 |
26 |
31 |
41 |
42 |
46 |
55 |
64 |
65 |
66 |
74 |
75 |
80 |
89 |
96 |
104 |
105 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
4 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-hdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-mdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-xhdpi/icon.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 | >
2 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/array.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | - 北京
5 | - 上海
6 | - 广州
7 | - 深圳
8 | - 成都
9 | - 西安
10 | - 昆明
11 | - 厦门
12 | - 杭州
13 | - 乌鲁木齐
14 | - 南京
15 | - 哈尔滨
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #ac38bf
4 | #701994
5 | #E1BEE7
6 | #448AFF
7 | #FFFFFF
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 160dp
5 |
6 | 16dp
7 | 16dp
8 | 16dp
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | 你要去哪儿
3 |
4 | Open navigation drawer
5 | Close navigation drawer
6 |
7 | 设置
8 | 你要去哪儿——一款航空订票系统,这是我的综合课程设计项目,主要功能有:\n
9 | 客户:\n
10 | 1.航班动态功能——查询指定地点间、指定日期的航班信息\n
11 | 2.预订机票功能——根据航班号订购机票\n
12 | 3.查询机票功能——根据客户姓名、身份证号码及出行日期查询机票,选择是否退票\n
13 | 管理员:\n
14 | 增删改查所有航班信息和客户信息\n
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/levent_j/airlinebooksystem/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.levent_j.airlinebooksystem;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:1.3.0'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" }
19 | }
20 | }
21 |
22 | task clean(type: Delete) {
23 | delete rootProject.buildDir
24 | }
25 |
--------------------------------------------------------------------------------
/doc/无标题文档~:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/doc/无标题文档~
--------------------------------------------------------------------------------
/doc/综合课程设计报告-李文靖.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/doc/综合课程设计报告-李文靖.docx
--------------------------------------------------------------------------------
/doc/需求文档:
--------------------------------------------------------------------------------
1 | AirlineBookSystem
2 | 综合课程设计项目——航空订票系统android客户端
3 |
4 | 需求分析:
5 | 主要任务:
6 | 1. 管理员可以录入或者导入/导出各个航线的航班信息,可以修改航班信息,可以增加/删除/修改操作工作员信息。
7 | 2. 操作工作员可以实现订票订票、退订,查看航线
8 | 详细功能:
9 | 1. 录入航线信息:每条航线信息包括航班号、飞机号、目的地、订票数、余票数共5项。
10 | 2. 订票业务:客户信息包括姓名, 航班号, 座位号。有新客户订票时, 先输入客户的姓名,身份证号和他提出的航班号, 查询该航线的订票情况, 若有余票, 则为客户办理订票手续, 分配/选择户一个座位号。若无余票, 则输出客满信息。如果该航班已经无票,可以查询输出可选择的其他航班信息。
11 | 3. 退票业务:根据客户提出的航班号和姓名, 办理退票, 从数据库中删除该客户的信息, 并修改数据库中相应航线的订票数和余票数。
12 | 4. 修改航班信息:当航班信息改变可以修改航班数据文件。
13 | 5. 输出全部航线信息和全部客户信息。
14 | 6. 退出系统。要求用数据库保存信息。
15 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Levent-J/AirlineBookSystem/9184997f754aba2a42070845a6489f15ebc5b2c9/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Jun 30 16:49:18 CST 2016
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------