2020-02-01 15:49:46
package com.xbsaykat.easy24vendorapp.MonthlyReport;
 
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
 
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
 
import com.firebase.ui.database.FirebaseRecyclerAdapter;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.xbsaykat.easy24vendorapp.MonthlyReport.ModelClass;
import com.xbsaykat.easy24vendorapp.MonthlyReport.ViewClass;
import com.xbsaykat.easy24vendorapp.R;
 
public class ReportMonthly extends AppCompatActivity {
    private RecyclerView mRecyclerView;
    private static DatabaseReference mRef,mRefAmount;
    String month;
    int totalallpricevalue=0;
    TextView AllTotalA,AllTotalB,AllTotal;
 
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reportmonthly);
 
        month = String.valueOf(android.text.format.DateFormat.format("MM-yyyy", new java.util.Date()));
        mRef = FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportMonthly").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(month);
 
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimary, this.getTheme()));
        } else {
            View decorView = getWindow().getDecorView();
            int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
            decorView.setSystemUiVisibility(uiOptions);
        }
 
        AllTotal=findViewById(R.id.Totalallprice);
        mRefAmount= FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportMonthlyAmount").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(month);
        mRefAmount.addValueEventListener(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
                String total=dataSnapshot.child("TotalCalculation").getValue().toString();
                AllTotal.setText("BDT "+total);
            }
 
            @Override
            public void onCancelled(@NonNull DatabaseError databaseError) {
 
            }
        });
        mRecyclerView = findViewById(R.id.report_recycler);
        mRecyclerView.setHasFixedSize(true);
        LinearLayoutManager LayoutManager=new LinearLayoutManager(this);
        mRecyclerView.setLayoutManager(LayoutManager);
 
 
 
    }
    @Override
    protected void onStart() {
        super.onStart();
        FirebaseRecyclerAdapter<ModelClass, ViewClass> firebaseRecyclerAdapter =
                new FirebaseRecyclerAdapter<ModelClass, ViewClass>(ModelClass.class, R.layout.reportmonthview, ViewClass.class, mRef) {
                    @Override
                    protected void populateViewHolder(ViewClass viewHolder, ModelClass model, int position) {
 
                        viewHolder.setDetails(getApplicationContext(), model.getUserNumber(),model.getMoneyrequest(),model.getDate());
                    }
                };
        mRecyclerView.setAdapter(firebaseRecyclerAdapter);
 
 
 
    }
}
 
 
Invalid Email or Password