Search in sources :

Example 76 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.

the class PendingExpenseDetailFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);
    Log.i(TAG, "onCreateView");
    // Read expenseID from ExpenseDetailPagerAdapter
    Bundle b = this.getArguments();
    expenseID = b.getString("expenseID");
    final View view = inflater.inflate(R.layout.skeleton_list, container, false);
    RecyclerView.ItemDecoration divider = new InsetDivider.Builder(getContext()).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(ContextCompat.getColor(getContext(), R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
    recyclerView = (RecyclerView) view.findViewById(R.id.rv_skeleton);
    layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(divider);
    // todo mettere a posto
    votersViewAdapter = new VotersViewAdapter(voters, getContext());
    recyclerView.setAdapter(votersViewAdapter);
    // Retrieve data of this pending expense
    databaseReference.child("proposedExpenses").child(expenseID).addListenerForSingleValueEvent(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // Show list of voters for this pending expense
            for (DataSnapshot voterSnap : dataSnapshot.child("participants").getChildren()) {
                String vote = voterSnap.child("vote").getValue(String.class);
                FirebaseUtils.getInstance().getVoter(voterSnap.getKey(), vote, voters, votersViewAdapter);
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
    return view;
}
Also used : DatabaseError(com.google.firebase.database.DatabaseError) Bundle(android.os.Bundle) RecyclerView(android.support.v7.widget.RecyclerView) ValueEventListener(com.google.firebase.database.ValueEventListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DataSnapshot(com.google.firebase.database.DataSnapshot) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Example 77 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.

the class ProposedExpenseCommentsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    RecyclerView recyclerView;
    RecyclerView.LayoutManager layoutManager;
    String expenseID;
    View view = inflater.inflate(R.layout.skeleton_list, container, false);
    Bundle fragmentArguments = getArguments();
    expenseID = fragmentArguments.getString("expenseID");
    RecyclerView.ItemDecoration divider = new InsetDivider.Builder(getContext()).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(getResources().getColor(R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
    recyclerView = (RecyclerView) view.findViewById(R.id.rv_skeleton);
    layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(divider);
    expenseCommentsViewAdapter = new ExpenseCommentsViewAdapter(this.getContext(), this, commentsMap, getFragmentManager());
    recyclerView.setAdapter(expenseCommentsViewAdapter);
    DatabaseReference expenseRef = databaseReference.child("proposedExpenses");
    expenseRef.child(expenseID).child("comments").addValueEventListener(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot commentSnapshot) {
            for (DataSnapshot comment : commentSnapshot.getChildren()) {
                FirebaseUtils.getInstance().getComment(comment.getKey(), commentsMap, expenseCommentsViewAdapter);
                Log.d(TAG, comment.getKey());
            }
            expenseCommentsViewAdapter.update(commentsMap);
        }

        @Override
        public void onCancelled(DatabaseError error) {
            // Failed to read value
            Log.w(TAG, "Failed to read value.", error.toException());
        }
    });
    return view;
}
Also used : DatabaseReference(com.google.firebase.database.DatabaseReference) Bundle(android.os.Bundle) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DataSnapshot(com.google.firebase.database.DataSnapshot) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) DatabaseError(com.google.firebase.database.DatabaseError) RecyclerView(android.support.v7.widget.RecyclerView) ValueEventListener(com.google.firebase.database.ValueEventListener)

Example 78 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.

the class SplitPolicyActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_split_policy);
    // somma quote già splittate
    totalTextView = (TextView) findViewById(R.id.total);
    // costo della spesa
    amountTextView = (TextView) findViewById(R.id.tv_amount);
    currencyTextView = (TextView) findViewById(R.id.currency);
    currencyAmountTextView = (TextView) findViewById(R.id.currency_amount);
    Intent intent = getIntent();
    amount = intent.getDoubleExtra("amount", 0);
    currency = intent.getStringExtra("currency");
    groupID = intent.getStringExtra("groupID");
    amountsList = (HashMap<String, Double>) intent.getSerializableExtra("participants");
    Log.d(TAG, "I just entered SplitPolicyActivity. amountsList contains: ");
    for (Map.Entry<String, Double> entry : amountsList.entrySet()) {
        Log.d(TAG, entry.getKey() + " " + entry.getValue());
    }
    totalSplit = intent.getDoubleExtra("totalSplit", 0d);
    totalTextView.setText(df.format(totalSplit));
    amountTextView.setText(df.format(amount));
    currencyTextView.setText(currency);
    currencyAmountTextView.setText(currency);
    participants.clear();
    // Retrieve info about members for this expense
    for (final Map.Entry<String, Double> entry : amountsList.entrySet()) {
        databaseReference.child("users").child(entry.getKey()).addListenerForSingleValueEvent(new ValueEventListener() {

            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                User u = new User();
                u.setName(dataSnapshot.child("name").getValue(String.class));
                u.setSurname(dataSnapshot.child("surname").getValue(String.class));
                u.setProfileImage(dataSnapshot.child("image").getValue(String.class));
                u.setSplitPart(entry.getValue());
                u.setExpenseCurrency(currency);
                participants.put(entry.getKey(), u);
                splittersViewAdapter.update(participants);
                splittersViewAdapter.notifyDataSetChanged();
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {
            }
        });
    }
    RecyclerView.ItemDecoration divider = new InsetDivider.Builder(SplitPolicyActivity.this).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(ContextCompat.getColor(SplitPolicyActivity.this, R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
    recyclerView = (RecyclerView) findViewById(R.id.rv_skeleton);
    layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(divider);
    splittersViewAdapter = new SplittersViewAdapter(participants, SplitPolicyActivity.this, this);
    recyclerView.setAdapter(splittersViewAdapter);
}
Also used : User(com.polito.mad17.madmax.entities.User) Intent(android.content.Intent) DataSnapshot(com.google.firebase.database.DataSnapshot) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DatabaseError(com.google.firebase.database.DatabaseError) RecyclerView(android.support.v7.widget.RecyclerView) ValueEventListener(com.google.firebase.database.ValueEventListener) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 79 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.

the class BalancesActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.skeleton_list);
    Intent intent = getIntent();
    balances = (HashMap<String, Double>) intent.getSerializableExtra("balances");
    groupID = intent.getStringExtra("groupID");
    RecyclerView.ItemDecoration divider = new InsetDivider.Builder(this).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(getResources().getColor(R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
    recyclerView = (RecyclerView) findViewById(R.id.rv_skeleton);
    layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(divider);
    // todo mettere a posto
    balancesViewAdapter = new BalancesViewAdapter(this, this, balances);
    recyclerView.setAdapter(balancesViewAdapter);
}
Also used : Intent(android.content.Intent) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 80 with LayoutManager

use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.

the class ChooseGroupActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_choose_group);
    RecyclerView.ItemDecoration divider = new InsetDivider.Builder(this).orientation(InsetDivider.VERTICAL_LIST).dividerHeight(getResources().getDimensionPixelSize(R.dimen.divider_height)).color(getResources().getColor(R.color.colorDivider)).insets(getResources().getDimensionPixelSize(R.dimen.divider_inset), 0).overlay(true).build();
    recyclerView = (RecyclerView) findViewById(R.id.rv_skeleton);
    layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
    recyclerView.setLayoutManager(layoutManager);
    recyclerView.addItemDecoration(divider);
    groupsViewAdapter = new GroupsViewAdapter(getBaseContext(), this, groups, ChooseGroupActivity.TAG);
    recyclerView.setAdapter(groupsViewAdapter);
    // Ascolto i gruppi dello user
    databaseReference.child("users").child(MainActivity.getCurrentUID()).child("groups").addListenerForSingleValueEvent(new ValueEventListener() {

        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // Per ogni gruppo dello user
            for (DataSnapshot groupSnapshot : dataSnapshot.getChildren()) {
                // Se il gruppo è true, ossia è ancora tra quelli dello user
                if (groupSnapshot.getValue(Boolean.class))
                    FirebaseUtils.getInstance().getGroup(groupSnapshot.getKey(), groups, groupsViewAdapter);
                else {
                    // tolgo il gruppo da quelli che verranno stampati, così lo vedo sparire realtime
                    groups.remove(groupSnapshot.getKey());
                    groupsViewAdapter.update(groups);
                    groupsViewAdapter.notifyDataSetChanged();
                }
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
            Log.w(TAG, databaseError.toException());
        }
    });
}
Also used : GroupsViewAdapter(com.polito.mad17.madmax.activities.groups.GroupsViewAdapter) DatabaseError(com.google.firebase.database.DatabaseError) RecyclerView(android.support.v7.widget.RecyclerView) ValueEventListener(com.google.firebase.database.ValueEventListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) DataSnapshot(com.google.firebase.database.DataSnapshot)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)430 RecyclerView (android.support.v7.widget.RecyclerView)371 View (android.view.View)261 GridLayoutManager (android.support.v7.widget.GridLayoutManager)128 TextView (android.widget.TextView)113 DefaultItemAnimator (android.support.v7.widget.DefaultItemAnimator)79 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)73 ImageView (android.widget.ImageView)71 SwipeRefreshLayout (android.support.v4.widget.SwipeRefreshLayout)47 Intent (android.content.Intent)46 ArrayList (java.util.ArrayList)43 Bundle (android.os.Bundle)37 Nullable (android.support.annotation.Nullable)33 Context (android.content.Context)29 DividerItemDecoration (android.support.v7.widget.DividerItemDecoration)28 BindView (butterknife.BindView)28 Toolbar (android.support.v7.widget.Toolbar)25 ViewGroup (android.view.ViewGroup)25 Handler (android.os.Handler)22 FloatingActionButton (android.support.design.widget.FloatingActionButton)21