2020-02-01 15:51:14
package com.xbsaykat.easy24vendorapp;
 
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;
 
public class ReportYearly extends AppCompatActivity {
    private RecyclerView mRecyclerView;
    private static DatabaseReference mRef,mRefAmount;
    String year;
    int totalallpricevalue=0;
    TextView AllTotalA,AllTotalB,AllTotal;
 
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reportmonthly);
 
        year = String.valueOf(android.text.format.DateFormat.format("yyyy", new java.util.Date()));
        mRef = FirebaseDatabase.getInstance().getReference("AdminDiscountRequestReportYearly").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(year);
 
        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("AdminDiscountRequestReportYearlyAmount").child(FirebaseAuth.getInstance().getCurrentUser().getUid()).child(year);
        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