├── .gitattributes
├── .gitignore
├── BusBooking
└── BusBooking
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ └── org.eclipse.jdt.core.prefs
│ ├── AndroidManifest.xml
│ ├── art
│ ├── 5BAu1.png
│ ├── G1b7c.png
│ └── YKbNW.png
│ ├── ic_launcher-web.png
│ ├── libs
│ └── android-support-v4.jar
│ ├── proguard-project.txt
│ ├── project.properties
│ ├── res
│ ├── drawable-hdpi
│ │ └── ic_launcher.png
│ ├── drawable-mdpi
│ │ └── ic_launcher.png
│ ├── drawable-xhdpi
│ │ └── ic_launcher.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── drawable
│ │ ├── bus_outline.xml
│ │ └── selector.xml
│ ├── layout
│ │ ├── bus_layout.xml
│ │ └── seat.xml
│ ├── values-w820dp
│ │ └── dimens.xml
│ └── values
│ │ ├── dimens.xml
│ │ └── strings.xml
│ └── src
│ └── com
│ └── serveroverload
│ └── busbooking
│ ├── BusLayoutActivity.java
│ └── Seat.java
└── README.md
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 | */build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # =========================
36 | # Operating System Files
37 | # =========================
38 |
39 | # OSX
40 | # =========================
41 |
42 | .DS_Store
43 | .AppleDouble
44 | .LSOverride
45 |
46 | # Thumbnails
47 | ._*
48 |
49 | # Files that might appear in the root of a volume
50 | .DocumentRevisions-V100
51 | .fseventsd
52 | .Spotlight-V100
53 | .TemporaryItems
54 | .Trashes
55 | .VolumeIcon.icns
56 |
57 | # Directories potentially created on remote AFP share
58 | .AppleDB
59 | .AppleDesktop
60 | Network Trash Folder
61 | Temporary Items
62 | .apdisk
63 |
64 | # Windows
65 | # =========================
66 |
67 | # Windows image file caches
68 | Thumbs.db
69 | ehthumbs.db
70 |
71 | # Folder config file
72 | Desktop.ini
73 |
74 | # Recycle Bin used on file shares
75 | $RECYCLE.BIN/
76 |
77 | # Windows Installer files
78 | *.cab
79 | *.msi
80 | *.msm
81 | *.msp
82 |
83 | # Windows shortcuts
84 | *.lnk
85 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | BusBooking
4 |
5 |
6 |
7 |
8 |
9 | com.android.ide.eclipse.adt.ResourceManagerBuilder
10 |
11 |
12 |
13 |
14 | com.android.ide.eclipse.adt.PreCompilerBuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | com.android.ide.eclipse.adt.ApkBuilder
25 |
26 |
27 |
28 |
29 |
30 | com.android.ide.eclipse.adt.AndroidNature
31 | org.eclipse.jdt.core.javanature
32 |
33 |
34 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3 | org.eclipse.jdt.core.compiler.compliance=1.6
4 | org.eclipse.jdt.core.compiler.source=1.6
5 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/art/5BAu1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/art/5BAu1.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/art/G1b7c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/art/G1b7c.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/art/YKbNW.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/art/YKbNW.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/ic_launcher-web.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/BusBooking/BusBooking/proguard-project.txt:
--------------------------------------------------------------------------------
1 | # To enable ProGuard in your project, edit project.properties
2 | # to define the proguard.config property as described in that file.
3 | #
4 | # Add project specific ProGuard rules here.
5 | # By default, the flags in this file are appended to flags specified
6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt
7 | # You can edit the include path and order by changing the ProGuard
8 | # include property in project.properties.
9 | #
10 | # For more details, see
11 | # http://developer.android.com/guide/developing/tools/proguard.html
12 |
13 | # Add any project specific keep options here:
14 |
15 | # If your project uses WebView with JS, uncomment the following
16 | # and specify the fully qualified class name to the JavaScript interface
17 | # class:
18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
19 | # public *;
20 | #}
21 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-23
15 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hiteshsahu/Ticket-Booking-Layout/b163425cac2bba441638b26f04e97a27f08e46e8/BusBooking/BusBooking/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/drawable/bus_outline.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
9 |
10 |
13 |
14 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/drawable/selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | -
5 |
6 | -
7 |
8 |
9 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/layout/bus_layout.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
14 |
15 |
23 |
24 |
32 |
33 |
34 |
42 |
43 |
51 |
52 |
53 |
56 |
57 |
65 |
66 |
76 |
77 |
78 |
81 |
82 |
90 |
91 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/layout/seat.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 | 64dp
9 |
10 |
11 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | BusBooking
5 | Hello world!
6 | Settings
7 |
8 |
9 |
--------------------------------------------------------------------------------
/BusBooking/BusBooking/src/com/serveroverload/busbooking/BusLayoutActivity.java:
--------------------------------------------------------------------------------
1 | package com.serveroverload.busbooking;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.Gravity;
6 | import android.view.LayoutInflater;
7 | import android.view.View;
8 | import android.view.View.OnClickListener;
9 | import android.view.ViewGroup;
10 | import android.widget.LinearLayout;
11 | import android.widget.LinearLayout.LayoutParams;
12 | import android.widget.RelativeLayout;
13 | import android.widget.TextView;
14 | import android.widget.Toast;
15 |
16 | import com.example.busbooking.R;
17 |
18 | public class BusLayoutActivity extends Activity {
19 |
20 | // Test Data Inputs
21 | private final int NUMBER_OF_SEATS_LEFT_UPPER = 5;
22 | private final int NUMBER_OF_SEATS_RIGHT_UPPER = 5;
23 | private final int NUMBER_OF_ROWS_LEFT_UPPER = 1;
24 | private final int NUMBER_OF_ROWS_RIGHT_UPPER = 2;
25 |
26 | private final int NUMBER_OF_SEATS_LEFT_LOWER = 8;
27 | private final int NUMBER_OF_SEATS_RIGHT_LOWER = 8;
28 |
29 | private final int NUMBER_OF_ROWS_LEFT_LOWER = 3;
30 | private final int NUMBER_OF_ROWS_RIGHT_LOWER = 1;
31 |
32 | private Double totatCost = 0.0;
33 | private int totalSeats = 0;
34 | private TextView totalPrice;
35 | private TextView totalBookedSeats;
36 |
37 | private LayoutParams seatParams;
38 |
39 | @Override
40 | protected void onCreate(Bundle savedInstanceState) {
41 | super.onCreate(savedInstanceState);
42 | setContentView(R.layout.bus_layout);
43 |
44 | // Fetch Required Layouts
45 | RelativeLayout busLayoutUpper = (RelativeLayout) findViewById(R.id.upper_deck);
46 | RelativeLayout busLayoutBottom = (RelativeLayout) findViewById(R.id.lower_deck);
47 | totalPrice = (TextView) findViewById(R.id.total_cost);
48 | totalBookedSeats = (TextView) findViewById(R.id.total_seats);
49 |
50 | // Layout Param for Seats
51 | seatParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
52 | LayoutParams.MATCH_PARENT);
53 | seatParams.weight = 1;
54 | seatParams.leftMargin = 5;
55 | seatParams.rightMargin = 5;
56 |
57 | // Add Bottom Seats
58 | addLeftSeats(NUMBER_OF_ROWS_LEFT_UPPER, NUMBER_OF_SEATS_LEFT_UPPER,
59 | busLayoutBottom);
60 | addRightSeats(NUMBER_OF_ROWS_RIGHT_UPPER, NUMBER_OF_SEATS_RIGHT_UPPER,
61 | busLayoutBottom);
62 |
63 | // Add Upper Seats
64 | addLeftSeats(NUMBER_OF_ROWS_LEFT_LOWER, NUMBER_OF_SEATS_LEFT_LOWER,
65 | busLayoutUpper);
66 | addRightSeats(NUMBER_OF_ROWS_RIGHT_LOWER, NUMBER_OF_SEATS_RIGHT_LOWER,
67 | busLayoutUpper);
68 |
69 | }
70 |
71 | /*
72 | * This function draw seats for right row
73 | */
74 | private void addRightSeats(int numberOfRowsRight, float numberOfSeatsInRow,
75 | ViewGroup busLayout) {
76 | int previousRow;
77 |
78 | // ADD RIGHT ROWS
79 |
80 | previousRow = 0;
81 |
82 | // Begin adding rows
83 | for (int rightRowCount = 0; rightRowCount < numberOfRowsRight; rightRowCount++) {
84 |
85 | // Adding Linear layout as row
86 | LinearLayout rightRow = new LinearLayout(getApplicationContext());
87 | rightRow.setGravity(Gravity.CENTER);
88 | rightRow.setId(100 + rightRowCount);
89 |
90 | // make seats equal distance
91 | rightRow.setWeightSum(numberOfSeatsInRow);
92 |
93 | // if it is first row add row to window (ALIGN_PARENT_BOTTOM)
94 | // else add row above window row (ABOVE)
95 | if (previousRow != rightRowCount) {
96 | RelativeLayout.LayoutParams newParams = new RelativeLayout.LayoutParams(
97 | RelativeLayout.LayoutParams.MATCH_PARENT,
98 | RelativeLayout.LayoutParams.WRAP_CONTENT);
99 | newParams.addRule(RelativeLayout.ABOVE, 100 + previousRow);
100 | newParams.setMargins(10, 10, 10, 10);
101 | rightRow.setLayoutParams(newParams);
102 |
103 | } else {
104 |
105 | // Layout params for first row (Window seat), adding margin and
106 | // bottom alignment
107 | RelativeLayout.LayoutParams rightRowParam = new RelativeLayout.LayoutParams(
108 | RelativeLayout.LayoutParams.MATCH_PARENT,
109 | RelativeLayout.LayoutParams.WRAP_CONTENT);
110 | rightRowParam.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
111 | rightRowParam.setMargins(10, 10, 10, 10);
112 | rightRow.setLayoutParams(rightRowParam);
113 | }
114 |
115 | // Add Seats in row we have added
116 | for (int rowCount = 0; rowCount <= numberOfSeatsInRow; rowCount++) {
117 |
118 | // Left Upper
119 | final Seat rightRowSeat = (Seat) LayoutInflater.from(this)
120 | .inflate(R.layout.seat, null);
121 | rightRowSeat.setLayoutParams(seatParams);
122 | rightRowSeat.setSeatNumber("SL" + rowCount);
123 | rightRowSeat.setGravity(Gravity.CENTER);
124 |
125 | rightRowSeat.setOnClickListener(new OnClickListener() {
126 |
127 | @Override
128 | public void onClick(View v) {
129 |
130 | updateCost(rightRowSeat);
131 |
132 | Toast.makeText(getApplicationContext(),
133 | "seat # " + rightRowSeat.getSeatNumber(), 300)
134 | .show();
135 |
136 | }
137 | });
138 |
139 | // add seat to row
140 | rightRow.addView(rightRowSeat);
141 |
142 | }
143 |
144 | // and then add row to bus layout
145 | busLayout.addView(rightRow);
146 |
147 | // update row counter
148 | previousRow = rightRowCount;
149 |
150 | }
151 | }
152 |
153 | /*
154 | * This function draw seats for left row
155 | */
156 | private void addLeftSeats(int numberOfRowsLeft, float nuumberOfSeatsInRow,
157 | ViewGroup busLayout) {
158 | // Adding Left side rows
159 |
160 | int previousRow = 0;
161 |
162 | for (int leftRowCount = 0; leftRowCount < numberOfRowsLeft; leftRowCount++) {
163 |
164 | // Adding Linear layout as row
165 | LinearLayout LeftRow = new LinearLayout(getApplicationContext());
166 | LeftRow.setGravity(Gravity.CENTER);
167 | LeftRow.setId(leftRowCount);
168 |
169 | // Equi distance seats
170 | LeftRow.setWeightSum(nuumberOfSeatsInRow);
171 |
172 | // if it is first row add row to window
173 | // else add row below window row (BELOW)
174 | if (previousRow != leftRowCount) {
175 | RelativeLayout.LayoutParams newParams = new RelativeLayout.LayoutParams(
176 | RelativeLayout.LayoutParams.MATCH_PARENT,
177 | RelativeLayout.LayoutParams.WRAP_CONTENT);
178 | newParams.addRule(RelativeLayout.BELOW, previousRow);
179 | newParams.setMargins(10, 10, 10, 10);
180 | LeftRow.setLayoutParams(newParams);
181 |
182 | } else {
183 | RelativeLayout.LayoutParams leftRowParam = new RelativeLayout.LayoutParams(
184 | RelativeLayout.LayoutParams.MATCH_PARENT,
185 | RelativeLayout.LayoutParams.WRAP_CONTENT);
186 | leftRowParam.setMargins(10, 10, 10, 10);
187 | LeftRow.setLayoutParams(leftRowParam);
188 | }
189 |
190 | // Add Seats in row
191 | for (int rowCount = 0; rowCount <= nuumberOfSeatsInRow; rowCount++) {
192 |
193 | // Left Upper
194 | final Seat leftRowSeat = (Seat) LayoutInflater.from(this)
195 | .inflate(R.layout.seat, null);
196 | leftRowSeat.setLayoutParams(seatParams);
197 | leftRowSeat.setSeatNumber("SL" + rowCount);
198 | leftRowSeat.setGravity(Gravity.CENTER);
199 |
200 | leftRowSeat.setOnClickListener(new OnClickListener() {
201 |
202 | @Override
203 | public void onClick(View v) {
204 |
205 | updateCost(leftRowSeat);
206 |
207 | Toast.makeText(getApplicationContext(),
208 | "seat # " + leftRowSeat.getSeatNumber(), 300)
209 | .show();
210 | }
211 | });
212 |
213 | LeftRow.addView(leftRowSeat);
214 |
215 | }
216 |
217 | // add row to bus layout
218 | busLayout.addView(LeftRow);
219 |
220 | // update row counter
221 | previousRow = leftRowCount;
222 |
223 | }
224 | }
225 |
226 | private void updateCost(final Seat ud_LeftWindowSeat) {
227 |
228 | if (ud_LeftWindowSeat.setSelected()) {
229 |
230 | totatCost += ud_LeftWindowSeat.getSeatPrice();
231 | ++totalSeats;
232 |
233 | } else {
234 | totatCost -= ud_LeftWindowSeat.getSeatPrice();
235 | --totalSeats;
236 | }
237 |
238 | totalPrice.setText("" + totatCost);
239 | totalBookedSeats.setText("" + totalSeats);
240 | }
241 | }
--------------------------------------------------------------------------------
/BusBooking/BusBooking/src/com/serveroverload/busbooking/Seat.java:
--------------------------------------------------------------------------------
1 | package com.serveroverload.busbooking;
2 |
3 | import android.content.Context;
4 | import android.util.AttributeSet;
5 | import android.widget.TextView;
6 |
7 | public class Seat extends TextView {
8 |
9 | public Seat(Context context) {
10 | super(context);
11 |
12 | }
13 |
14 | public Seat(Context context, AttributeSet attrs) {
15 | super(context, attrs);
16 | // TODO Auto-generated constructor stub
17 | }
18 |
19 | public Seat(Context context, AttributeSet attrs, int defStyle) {
20 | super(context, attrs, defStyle);
21 | // TODO Auto-generated constructor stub
22 | }
23 |
24 | private String seatNumber;
25 | private Boolean isSelected = false;
26 | private Boolean isWomen = false;
27 | private Double seatPrice = 100.00;
28 |
29 | public Boolean getIsWomen() {
30 | return isWomen;
31 | }
32 |
33 | public void setIsWomen(Boolean isWomen) {
34 | this.isWomen = isWomen;
35 | }
36 |
37 | public Double getSeatPrice() {
38 | return seatPrice;
39 | }
40 |
41 | public void setSeatPrice(Double seatPrice) {
42 | this.seatPrice = seatPrice;
43 | }
44 |
45 | public Boolean getIsSelected() {
46 | return isSelected;
47 | }
48 |
49 | public Boolean setSelected() {
50 |
51 | this.isSelected = !this.isSelected;
52 |
53 | if (getIsSelected()) {
54 | setBackgroundColor(0xff99cc00);
55 |
56 | } else {
57 | setBackgroundColor(0xff33b5e5);
58 |
59 | }
60 |
61 | return isSelected;
62 |
63 | }
64 |
65 | public String getSeatNumber() {
66 | return seatNumber;
67 | }
68 |
69 | public void setSeatNumber(String seatNumber) {
70 | this.seatNumber = seatNumber;
71 |
72 | setText(seatNumber);
73 | }
74 |
75 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bus-Booking-Layout
2 | Layout for bus booking app
3 |
4 |
5 | ## Screens
6 |
7 | 
8 | 
9 |
10 | ## Total calculation
11 |
12 | 
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------