Search in sources :

Example 1 with TicketLayoutAdapter

use of com.manan.dev.ec2018app.Adapters.TicketLayoutAdapter in project EC2018App by Manan-YMCA.

the class Tickets method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tickets);
    SharedPreferences preferences = getSharedPreferences(getResources().getString(R.string.sharedPrefName), MODE_PRIVATE);
    phoneNumber = preferences.getString("Phone", null);
    mProgress = new ProgressDialog(this);
    mProgress.setMessage("Showing your ticket.");
    mProgress.setTitle("Loading...");
    mProgress.setCanceledOnTouchOutside(false);
    noTickets = (TextView) findViewById(R.id.tv_no_tickets);
    userTicketsView = (RecyclerView) findViewById(R.id.gl_user_tickets);
    userTicketsView.setLayoutManager(new LinearLayoutManager(Tickets.this));
    userTickets = new ArrayList<>();
    mIncomingHandler = new IncomingHandler(Tickets.this);
    databaseController = new DatabaseController(Tickets.this);
    mAdapter = new TicketLayoutAdapter(Tickets.this, userTickets);
    if (userTickets.size() > 0) {
        noTickets.setVisibility(View.GONE);
    }
    userTicketsView.setAdapter(mAdapter);
    tickback = findViewById(R.id.tic_back_button);
    s = findViewById(R.id.swipe_refresh_layout);
    s.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {

        @Override
        public void onRefresh() {
            if (isNetworkAvailable())
                new LoadTickets().execute(phoneNumber);
            else
                MDToast.makeText(Tickets.this, "No Internet Connection", Toast.LENGTH_SHORT, MDToast.TYPE_ERROR).show();
            s.setRefreshing(false);
        }
    });
    if (phoneNumber == null) {
    } else {
        new DisplayTickets().execute(phoneNumber);
    }
    tickback.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
}
Also used : SharedPreferences(android.content.SharedPreferences) TicketLayoutAdapter(com.manan.dev.ec2018app.Adapters.TicketLayoutAdapter) DatabaseController(com.manan.dev.ec2018app.DatabaseHandler.DatabaseController) ProgressDialog(android.app.ProgressDialog) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) SwipeRefreshLayout(android.support.v4.widget.SwipeRefreshLayout) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 2 with TicketLayoutAdapter

use of com.manan.dev.ec2018app.Adapters.TicketLayoutAdapter in project EC2018App by Manan-YMCA.

the class Tickets method displayTickets.

private void displayTickets(String phoneNumber) {
    userTickets = databaseController.retrieveAllTickets();
    if (userTickets.size() > 0) {
        noTickets.setVisibility(View.GONE);
        mProgress.dismiss();
        mAdapter = new TicketLayoutAdapter(Tickets.this, userTickets);
        userTicketsView.setAdapter(mAdapter);
    }
// mAdapter.notifyDataSetChanged();
}
Also used : TicketLayoutAdapter(com.manan.dev.ec2018app.Adapters.TicketLayoutAdapter)

Aggregations

TicketLayoutAdapter (com.manan.dev.ec2018app.Adapters.TicketLayoutAdapter)2 ProgressDialog (android.app.ProgressDialog)1 SharedPreferences (android.content.SharedPreferences)1 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 DatabaseController (com.manan.dev.ec2018app.DatabaseHandler.DatabaseController)1