use of com.example.asus.onlinecanteen.model.TopUp in project OnlineCanteen by josephgunawan97.
the class AdminConfirmTopUpActivity method attachDatabaseReadListener.
private void attachDatabaseReadListener() {
if (EventListener == null) {
EventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
TopUp topUp = dataSnapshot.getValue(TopUp.class);
Log.i(AdminConfirmTopUpActivity.class.getSimpleName(), "TES LOG " + topUp.getUid());
adapter.addTopUp(topUp);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
TopUpUtil.query().addChildEventListener(EventListener);
}
}
use of com.example.asus.onlinecanteen.model.TopUp in project OnlineCanteen by josephgunawan97.
the class AdminConfirmTopUpActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_admin_check_top_up_request);
getSupportActionBar().setTitle("Confirm Top Up");
topups = new ArrayList<TopUp>();
adapter = new TopUpAdapter(topups);
recyclerView = (RecyclerView) findViewById(R.id.request_recycler_view);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
}
use of com.example.asus.onlinecanteen.model.TopUp in project OnlineCanteen by josephgunawan97.
the class RequestTopUpActivity method uploadImage.
// To upload image
private void uploadImage() {
final Map topUp = new HashMap();
database = FirebaseDatabase.getInstance().getReference("topuprequest");
final StorageReference profileImageRef = FirebaseStorage.getInstance().getReference("topuprequest/" + System.currentTimeMillis() + ".jpg");
if (imageUri != null) {
profileImageRef.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
@SuppressWarnings("VisibleForTests") Uri downloadUrl = taskSnapshot.getDownloadUrl();
String transferproofUrl = downloadUrl.toString();
TopUp topUp = new TopUp(transferName.getText().toString(), userID, transferproofUrl.toString(), bankName.getText().toString(), Integer.parseInt(amount.getText().toString()));
database.push().setValue(topUp);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getApplicationContext(), "Image failed to upload", Toast.LENGTH_LONG).show();
}
});
}
}
use of com.example.asus.onlinecanteen.model.TopUp in project OnlineCanteen by josephgunawan97.
the class TopUpDetailActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_topup_request);
firebaseDatabase = FirebaseDatabase.getInstance();
reference = firebaseDatabase.getReference("topuprequest");
intent = getIntent();
pos = intent.getIntExtra("Position", 0);
topupHistory = (ArrayList<TopUp>) intent.getSerializableExtra("topup");
topUp = topupHistory.get(pos);
mAuth = FirebaseAuth.getInstance();
transactiondate = findViewById(R.id.topup_detail_topup_date);
username = findViewById(R.id.request_name);
bankname = findViewById(R.id.bank_name);
transfername = findViewById(R.id.trans_name);
amount = findViewById(R.id.topup_detail_amount);
accept = findViewById(R.id.accept_request);
transferproof = findViewById(R.id.proofdetail);
transactiondate.setText(topUp.getRequestDateString(topUp.getRequestdate()));
transfername.setText(topUp.getTransfername());
bankname.setText(topUp.getBank());
amount.setText("Top-up Amount : " + Integer.toString(topUp.getAmount()));
if (topUp.getRequeststatus() == 1) {
accept.setEnabled(false);
}
if (topUp.getProofpicUrl() != null) {
Glide.with(transferproof.getContext()).load(topUp.getProofpicUrl()).into(transferproof);
}
FirebaseDatabase.getInstance().getReference("users").child(topUp.getUid()).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Log.i(TopUpDetailActivity.class.getSimpleName(), "TRANS + " + dataSnapshot.getValue());
username.setText(dataSnapshot.child("name").getValue().toString());
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
accept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FirebaseDatabase.getInstance().getReference().child("wallet").child(topUp.getUid()).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
WalletUtil walletUtil = new WalletUtil();
walletUtil.debitAmount(topUp.getUid(), topUp.getAmount());
Toast.makeText(getApplicationContext(), "Request accepted", Toast.LENGTH_LONG).show();
updateReq();
Intent intent = new Intent(getApplicationContext(), MainActivityAdmin.class);
startActivity(intent);
finish();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
});
}
use of com.example.asus.onlinecanteen.model.TopUp in project OnlineCanteen by josephgunawan97.
the class TopUpAdapter 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 topup Item
final TopUp topup = topUpHistory.get(position);
// Set Information on View
// topup.setName("TEST");
Log.i(TopUpAdapter.class.getSimpleName(), "IF+ " + " " + topup.getUid());
FirebaseDatabase.getInstance().getReference("users").child(topup.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// Log.i(MerchantOrderListFragment.class.getSimpleName(),"IF+ "+merchant.getDisplayName() +" "+ trans.getSid());
holder.NameTextView.setText(dataSnapshot.child("name").getValue().toString());
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
holder.topupDateTextView.setText(topup.getRequestDateString(topup.getRequestdate()));
holder.AmountTextView.setText("Rp " + String.valueOf(topup.getAmount()));
if (topup.getRequeststatus() == 1) {
holder.bg.setBackgroundColor(Color.LTGRAY);
} else
holder.bg.setBackgroundColor(Color.WHITE);
}
Aggregations