Search in sources :

Example 11 with Transaction

use of com.example.asus.onlinecanteen.model.Transaction in project OnlineCanteen by josephgunawan97.

the class TransactionCurrentOrderFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getActivity().setTitle("On-Progress");
    ArrayList<Transaction> transactions = new ArrayList<>();
    adapter = new TransactionHistoryAdapter(this);
    adapter.setTransactionHistory(transactions);
    recyclerView = view.findViewById(R.id.current_recycler_view);
    layoutManager = new LinearLayoutManager(getContext());
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
}
Also used : Transaction(com.example.asus.onlinecanteen.model.Transaction) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) TransactionHistoryAdapter(com.example.asus.onlinecanteen.adapter.TransactionHistoryAdapter)

Example 12 with Transaction

use of com.example.asus.onlinecanteen.model.Transaction in project OnlineCanteen by josephgunawan97.

the class TransactionHistoryFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    getActivity().setTitle(R.string.history_title_item);
    ArrayList<Transaction> transactions = new ArrayList<>();
    adapter = new TransactionHistoryAdapter(this);
    adapter.setTransactionHistory(transactions);
    recyclerView = view.findViewById(R.id.history_recycler_view);
    layoutManager = new LinearLayoutManager(getContext());
    recyclerView.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL));
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(adapter);
}
Also used : Transaction(com.example.asus.onlinecanteen.model.Transaction) ArrayList(java.util.ArrayList) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DividerItemDecoration(android.support.v7.widget.DividerItemDecoration) TransactionHistoryAdapter(com.example.asus.onlinecanteen.adapter.TransactionHistoryAdapter)

Example 13 with Transaction

use of com.example.asus.onlinecanteen.model.Transaction in project OnlineCanteen by josephgunawan97.

the class TransactionHistoryAdapter method onBindViewHolder.

/**
 * Bind the view with data at the specified position
 * @param holder ViewHolder which should be updated
 * @param position position of items in the adapter
 */
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
    // Get Transaction Item
    final Transaction transaction = transactionHistory.get(position);
    // Set Information on View
    FirebaseDatabase.getInstance().getReference().child("store").child(transaction.getSid()).addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            holder.storeNameTextView.setText(dataSnapshot.child("storeName").getValue().toString());
        // Log.i(MerchantOrderListFragment.class.getSimpleName(),"IF+ "+merchant.getDisplayName() +" "+ trans.getSid());
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
    holder.transactionDateTextView.setText(Transaction.getPurchasedDateString(transaction.getPurchaseDate()));
    holder.paymentAmountTextView.setText("Rp " + String.valueOf(transaction.getTotalPrice()));
    holder.statusTextView.setText(statusString(transaction.getDeliveryStatus()));
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) Transaction(com.example.asus.onlinecanteen.model.Transaction) ValueEventListener(com.google.firebase.database.ValueEventListener) DataSnapshot(com.google.firebase.database.DataSnapshot)

Aggregations

Transaction (com.example.asus.onlinecanteen.model.Transaction)13 DataSnapshot (com.google.firebase.database.DataSnapshot)8 DatabaseError (com.google.firebase.database.DatabaseError)8 ValueEventListener (com.google.firebase.database.ValueEventListener)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 Intent (android.content.Intent)3 View (android.view.View)3 ChildEventListener (com.google.firebase.database.ChildEventListener)3 ArrayList (java.util.ArrayList)3 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ListView (android.widget.ListView)2 TextView (android.widget.TextView)2 OrderAdapter (com.example.asus.onlinecanteen.adapter.OrderAdapter)2 TransactionHistoryAdapter (com.example.asus.onlinecanteen.adapter.TransactionHistoryAdapter)2 WalletUtil (com.example.asus.onlinecanteen.utils.WalletUtil)2 HashMap (java.util.HashMap)2 DialogInterface (android.content.DialogInterface)1 AlertDialog (android.support.v7.app.AlertDialog)1 CartActivityAdapter (com.example.asus.onlinecanteen.adapter.CartActivityAdapter)1