Search in sources :

Example 1 with RespondentListDataAdapter

use of com.jexapps.bloodhub.m_UI.RespondentListDataAdapter in project BloodHub by kazijehangir.

the class MyRequestDetail method onCreateView.

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mAuth = FirebaseAuth.getInstance();
    user = mAuth.getCurrentUser();
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            request = null;
        } else {
            request = extras.getString("request");
        }
    }
    if (request != null && !request.isEmpty()) {
        FirebaseDatabase.getInstance().getReference().child("bloodrequests").child(request).addListenerForSingleValueEvent(new ValueEventListener() {

            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                BloodRequest data = dataSnapshot.getValue(BloodRequest.class);
                TextView mName = (TextView) findViewById(R.id.name);
                mName.setText(data.name);
                TextView mTime = (TextView) findViewById(R.id.time);
                String date = DateFormat.getDateInstance().format(new Date(data.date));
                mTime.setText(date);
                TextView mLocation = (TextView) findViewById(R.id.location);
                mLocation.setText(data.location);
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
    }
    View rootView = inflater.inflate(R.layout.fragment_my_request_details, container, false);
    db = FirebaseDatabase.getInstance().getReference().child("donations");
    fetchData();
    mRecyclerView = (RecyclerView) rootView.findViewById(R.id.respondent_list_recycler_view);
    mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new RecycleMarginDecoration(this));
    mAdapter = new RespondentListDataAdapter(users, this);
    mRecyclerView.setAdapter(mAdapter);
    return rootView;
}
Also used : RespondentListDataAdapter(com.jexapps.bloodhub.m_UI.RespondentListDataAdapter) Bundle(android.os.Bundle) DataSnapshot(com.google.firebase.database.DataSnapshot) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Date(java.util.Date) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) DatabaseError(com.google.firebase.database.DatabaseError) TextView(android.widget.TextView) ValueEventListener(com.google.firebase.database.ValueEventListener) BloodRequest(com.jexapps.bloodhub.m_Model.BloodRequest)

Example 2 with RespondentListDataAdapter

use of com.jexapps.bloodhub.m_UI.RespondentListDataAdapter in project BloodHub by kazijehangir.

the class MyRequestDetail method onCreate.

// @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_my_request_details);
    mAuth = FirebaseAuth.getInstance();
    user = mAuth.getCurrentUser();
    if (savedInstanceState == null) {
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            request = null;
        } else {
            request = extras.getString("request");
        }
    }
    db = FirebaseDatabase.getInstance().getReference().child("donations");
    fetchData();
    mRecyclerView = (RecyclerView) findViewById(R.id.respondent_list_recycler_view);
    // mRecyclerView.setHasFixedSize(true);
    mLayoutManager = new LinearLayoutManager(getApplicationContext());
    mRecyclerView.setLayoutManager(mLayoutManager);
    mRecyclerView.setItemAnimator(new DefaultItemAnimator());
    mRecyclerView.addItemDecoration(new RecycleMarginDecoration(this));
    mAdapter = new RespondentListDataAdapter(users, this);
    mRecyclerView.setAdapter(mAdapter);
    if (request != null && !request.isEmpty()) {
        FirebaseDatabase.getInstance().getReference().child("bloodrequests").child(request).addListenerForSingleValueEvent(new ValueEventListener() {

            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                BloodRequest data = dataSnapshot.getValue(BloodRequest.class);
                TextView mName = (TextView) findViewById(R.id.name);
                mName.setText(data.name);
                TextView mTime = (TextView) findViewById(R.id.time);
                String date = DateFormat.getDateInstance().format(new Date(data.date));
                mTime.setText(date);
                TextView mLocation = (TextView) findViewById(R.id.location);
                mLocation.setText(data.location);
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
    }
// View rootView = inflater.inflate(R.layout.fragment_my_request_details, container, false);
// return rootView;
}
Also used : RespondentListDataAdapter(com.jexapps.bloodhub.m_UI.RespondentListDataAdapter) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DataSnapshot(com.google.firebase.database.DataSnapshot) DefaultItemAnimator(android.support.v7.widget.DefaultItemAnimator) Date(java.util.Date) DatabaseError(com.google.firebase.database.DatabaseError) TextView(android.widget.TextView) ValueEventListener(com.google.firebase.database.ValueEventListener) BloodRequest(com.jexapps.bloodhub.m_Model.BloodRequest)

Aggregations

Bundle (android.os.Bundle)2 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 TextView (android.widget.TextView)2 DataSnapshot (com.google.firebase.database.DataSnapshot)2 DatabaseError (com.google.firebase.database.DatabaseError)2 ValueEventListener (com.google.firebase.database.ValueEventListener)2 BloodRequest (com.jexapps.bloodhub.m_Model.BloodRequest)2 RespondentListDataAdapter (com.jexapps.bloodhub.m_UI.RespondentListDataAdapter)2 Date (java.util.Date)2 RecyclerView (android.support.v7.widget.RecyclerView)1 View (android.view.View)1