Online Movie Ticket Booking Android Studio – In this tutorial I have explain how develop android movie ticket booking system using android studio. These days no one buys tickets from theatre. They are directly book tickets online & pay also online via credit/debit card. Few persons only buy offline tickets, otherwise everybody book online.
Because when we book online, the providers give offers like cashback, gift card. That’s also one of the main reason for online booking system. Real time example is BookMyShow, TicketNew, Paytm & theatre own website.
Create Project
Okay let’s start the project, first complete basic steps of package creation, select SDK version, activity etc. After creating the new project open MainAcivity.java file & add the following code below.
package com.ldt.cinematicket.ui.main.admin;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.firestore.FirebaseFirestore;
import com.google.firebase.firestore.QuerySnapshot;
import com.ldt.cinematicket.R;
import com.ldt.cinematicket.model.Movie;
import com.ldt.cinematicket.ui.main.root.trendingtab.NowShowingAdapter;
import com.ldt.cinematicket.ui.widget.fragmentnavigationcontroller.PresentStyle;
import com.ldt.cinematicket.ui.widget.fragmentnavigationcontroller.SupportFragment;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
public class AllMovie extends SupportFragment implements OnCompleteListener<QuerySnapshot>, OnFailureListener{
private static final String TAG ="AllMovie";
public static AllMovie newInstance() {
return new AllMovie();
}
@BindView(R.id.back_button)
ImageView mBackButton;
@BindView(R.id.title)
TextView mTitle;
@BindView(R.id.recycle_view)
RecyclerView mRecyclerView;
@BindView(R.id.swipe_layout)
SwipeRefreshLayout mSwipeLayout;
@BindView(R.id.textView)
TextView mErrorTextView;
NowShowingAdapter mAdapter;
FirebaseFirestore mDb;
@OnClick(R.id.back_button)
void back() {
getMainActivity().dismiss();
}
@Nullable
@Override
protected View onCreateView(LayoutInflater inflater, ViewGroup container) {
return inflater.inflate(R.layout.admin_all_movie,container,false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this,view);
mDb = getMainActivity().mDb;
LinearLayoutManager layoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL,false);
mRecyclerView.setLayoutManager(layoutManager);
mAdapter = new NowShowingAdapter(getActivity());
mRecyclerView.setAdapter(mAdapter);
mSwipeLayout.setOnRefreshListener(this::refreshData);
refreshData();
}
public void refreshData() {
mSwipeLayout.setRefreshing(true);
mDb.collection("movie")
.get()
.addOnCompleteListener(this)
.addOnFailureListener(this);
}
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(mSwipeLayout.isRefreshing())
mSwipeLayout.setRefreshing(false);
mErrorTextView.setVisibility(View.GONE);
mRecyclerView.setVisibility(View.VISIBLE);
if (task.isSuccessful()) {
QuerySnapshot querySnapshot = task.getResult();
List<Movie> mM = querySnapshot.toObjects(Movie.class);
Collections.sort(mM, (o1, o2) -> o1.getId() - o2.getId());
if(mAdapter!=null)
mAdapter.setData(mM);
} else
Log.w(TAG, "Error getting documents.", task.getException());
}
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, "onFailure");
if(mSwipeLayout.isRefreshing())
mSwipeLayout.setRefreshing(false);
mRecyclerView.setVisibility(View.GONE);
mErrorTextView.setVisibility(View.VISIBLE);
}
@Override
public int getPresentTransition() {
return PresentStyle.SLIDE_LEFT;
}
}
Lot of features available on this android application. So in below i have list out the benefit of this app.
Online Movie Ticket Features
- Upcoming Movies
- Suggested Popular Movies
- Material Design
- Every user has unique account to access
- Cancel & Refund initiated option from user side
- User Friendly Navigation
Online Movie Ticket Booking Android Studio
In above I share only one output images. End of the article you can get full source code of android studio. Already in my article I have post Android Tutorials Project without any investment.
Movie ticket is very easy to use. Once you visit the website then repeatedly it’s have so many setting options. After book the order we need to initialize the patients.
Integrate JSON
JavaScript Object Notation is very easy but when working with Jscript it’s asked from the tuition. JSON is a important things for develop high level projects. & modules on android studio IDE.
JSON is very useful for those applications, It’s perfect for call the server side API request responses.
Wants to read our other popular articles?