use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.
the class ExpenseDetailFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
Log.i(TAG, "onCreateView");
setInterface((OnItemClickInterface) getActivity());
// 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);
participantsViewAdapter = new ParticipantsViewAdapter(this.getContext(), this, participants);
recyclerView.setAdapter(participantsViewAdapter);
// Ascolto i participants alla spesa
databaseReference.child("expenses").child(expenseID).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
// Per ogni participant
for (DataSnapshot participantSnap : dataSnapshot.child("participants").getChildren()) {
Double alreadyPaid = participantSnap.child("alreadyPaid").getValue(Double.class);
Double dueImport = alreadyPaid - participantSnap.child("fraction").getValue(Double.class) * dataSnapshot.child("amount").getValue(Double.class);
String currency = dataSnapshot.child("currency").getValue(String.class);
User u = new User();
u.setAlreadyPaid(alreadyPaid);
u.setDueImport(dueImport);
u.setExpenseCurrency(currency);
String participantID = participantSnap.getKey();
FirebaseUtils.getInstance().getParticipantName(participantID, participants, participantsViewAdapter, u);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.w(TAG, databaseError.toException());
}
});
return view;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project MadMax by deviz92.
the class FriendsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final String activityName = getActivity().getClass().getSimpleName();
Log.d(TAG, "Sono nella activity: " + activityName);
final View view = inflater.inflate(R.layout.skeleton_list, container, false);
databaseReference = FirebaseDatabase.getInstance().getReference();
friends.clear();
setInterface((OnItemClickInterface) getActivity(), (OnItemLongClickInterface) getActivity());
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);
friendsViewAdapter = new FriendsViewAdapter(this.getContext(), this, this, friends, groupDetail);
recyclerView.setAdapter(friendsViewAdapter);
// Se sono in MainActivity visualizzo lista degli amici
if (activityName.equals("MainActivity")) {
query = databaseReference.child("users").child(MainActivity.getCurrentUID()).child("friends");
} else // Se sono dentro un gruppo, visualizzo lista membri del gruppo
if (activityName.equals("GroupDetailActivity")) {
Bundle b = this.getArguments();
if (b != null) {
groupID = b.getString("groupID");
query = databaseReference.child("groups").child(groupID).child("members");
}
}
Log.d(TAG, "query: " + query);
groupMembersListener = query.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(final DataSnapshot externalDataSnapshot) {
// svuoto la map, così se viene eliminato uno user dal db, non viene tenuto nella map che si ricarica da zero
friends.clear();
for (final DataSnapshot friendSnapshot : externalDataSnapshot.getChildren()) {
// getFriend(friendSnapshot.getKey());
if (activityName.equals("MainActivity")) {
Log.d(TAG, "key: " + friendSnapshot.getKey());
Log.d(TAG, "value: " + friendSnapshot.getValue());
if (!listenedFriends)
listenedFriends = true;
// Log.d(TAG, friendSnapshot.child("deleted").getValue() + " ");
deleted = friendSnapshot.child("deleted").getValue(Boolean.class);
if (deleted == null) {
deleted = true;
}
if (deleted)
Log.d(TAG, friendSnapshot.getKey() + " is cancelled");
} else if (activityName.equals("GroupDetailActivity")) {
deleted = friendSnapshot.child("deleted").getValue(Boolean.class);
if (deleted == null) {
deleted = true;
}
// Se sono negli amici "generali" e non nei membri di un gruppo, non c'è il campo deleted, quindi sarà null
if (!listenedGroups.contains(groupID))
listenedGroups.add(groupID);
}
if (!deleted) {
final String id = friendSnapshot.getKey();
databaseReference.child("users").child(id).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
String name = dataSnapshot.child("name").getValue(String.class);
String surname = dataSnapshot.child("surname").getValue(String.class);
String profileImage = dataSnapshot.child("image").getValue(String.class);
if (activityName.equals("MainActivity")) {
User u = new User();
u.setID(friendSnapshot.getKey());
u.setName(name);
u.setSurname(surname);
u.setProfileImage(profileImage);
if (!deleted)
friends.put(id, u);
else
friends.remove(id);
friendsViewAdapter.update(friends);
friendsViewAdapter.notifyDataSetChanged();
} else if (activityName.equals("GroupDetailActivity")) {
getUserAndGroupBalance(id, name, surname, profileImage, groupID);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
friendsViewAdapter.update(friends);
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.w(TAG, databaseError.getMessage());
}
});
Log.d(TAG, "dopo setAdapter");
return view;
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project iNGAGE by davis123123.
the class UserProfileActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
if (extras != null) {
username = extras.getString("USER");
Toast.makeText(getApplicationContext(), username, Toast.LENGTH_LONG).show();
}
setContentView(R.layout.activity_user_profile);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
SessionManager session = new SessionManager(getApplicationContext());
HashMap<String, String> info = session.getUserDetails();
curr_avatar = (ImageView) findViewById(R.id.profile_img);
if (username.equals(info.get(SessionManager.KEY_NAME))) {
curr_avatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), ChangeAvatarActivity.class);
finish();
startActivity(intent);
}
});
}
/*display_username = (TextView) findViewById(R.id.user_name);
display_username.setText(username);*/
getSupportActionBar().setTitle(username);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
downloadAvatar();
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project iNGAGE by davis123123.
the class ChatPageListFragment method onViewCreated.
@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
chatActivity = (ChatActivity) getActivity();
recyclerView = (RecyclerView) rootView.findViewById(R.id.pagerecyclerView);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false);
currentPage = Integer.parseInt(chat.get(ChatRoomManager.CUR_PAGE));
Log.d("PAGEFRAG", "STARTED " + currentPage);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(chatPageListAdapter);
Log.d("PAGEFRAG", "pageno " + chatActivity.curPage + " " + currentPage);
if (chatActivity.curPage != -1)
scrollPage();
}
use of android.support.v7.widget.RecyclerView.LayoutManager in project iNGAGE by davis123123.
the class FrontPageFragment method onViewCreated.
@Override
public void onViewCreated(final View view, final Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
threadListRecyclerView = (RecyclerView) rootView.findViewById(R.id.rv_posts);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
threadListRecyclerView.setLayoutManager(layoutManager);
threadListRecyclerView.setAdapter(threadListAdapter);
Log.d("STATE", "serverstring" + json_string);
inflateThreads();
postThreadButton = (FloatingActionButton) rootView.findViewById(R.id.fab);
postThreadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (v == postThreadButton) {
// goInsertThread();
session.updatePage("date");
/* initilize FrontPage Fragment*/
final FragmentManager fragmentManager = getFragmentManager();
final Class fragmentClass = FrontPageFragment.class;
final Fragment fragment = Fragment.instantiate(getContext(), fragmentClass.getName());
fragmentManager.beginTransaction().replace(R.id.main_fragment_container, fragment, fragmentClass.getSimpleName()).setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
Toast.makeText(getActivity(), "Page refreshed!", Toast.LENGTH_LONG).show();
}
}
});
threadListAdapter.setOnLoadMoreListener(new ThreadListAdapter.OnLoadMoreListener() {
@Override
public void onLoadMore() {
Log.d("haint", "Load More");
// threadListAdapter.list.add(null);
// threadListAdapter.notifyItemInserted(threadListAdapter.list.size() - 1);
rowCount += 10;
Thread getJSON = new Thread(new Runnable() {
@Override
public void run() {
getThreadsJSON(rowCount);
while (true) {
if (!threadListAdapter.getLoadStat()) {
Log.d("haint", "Load More222");
break;
}
// no longer loading
}
}
});
getJSON.start();
try {
getJSON.join();
// threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
// threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
inflateThreads();
} catch (InterruptedException e) {
e.printStackTrace();
}
// getThreadsJSON(rowCount);
// inflateThreads();
/*new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Log.e("haint", "Load More 2");
threadListAdapter.list.remove(threadListAdapter.list.size() - 1);
threadListAdapter.notifyItemRemoved(threadListAdapter.list.size());
rowCount += 10;
getThreadsJSON(rowCount);
inflateThreads();
threadListAdapter.setLoaded();
}
}, 10000);*/
}
});
threadListRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
Log.d("...", "Lastnot Item Wow !");
if (// check for scroll down
dy > 0) {
visibleItemCount = layoutManager.getChildCount();
totalItemCount = layoutManager.getItemCount();
pastVisiblesItems = layoutManager.findFirstVisibleItemPosition();
if (!threadListAdapter.isLoading && (visibleItemCount + pastVisiblesItems) >= totalItemCount) {
// if(mOnLoadMoreListener != null){
Log.d("...", "Last Item Wow !");
threadListAdapter.isLoading = true;
// threadListAdapter.list.add(null);
threadListAdapter.mOnLoadMoreListener.onLoadMore();
// }
// loading = false;
// rowCount += 10;
// getThreadsJSON(rowCount);
// inflateThreads();
// Do pagination.. i.e. fetch new data
}
}
}
});
}
Aggregations