Guest User

Untitled

a guest
Nov 17th, 2017
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. @IgnoreExtraProperties
  2. public class Assessment {
  3.  
  4. private String company;
  5. private String industry;
  6. private String location;
  7. private String product;
  8. private String ownerId;
  9. private String ownerName;
  10. private boolean isDraft;
  11. private boolean isQuickWalk;
  12. private Map<String, Category> categories;
  13.  
  14.  
  15.  
  16. public Assessment() {
  17. // Default constructor required for calls to DataSnapshot.getValue()
  18. }
  19.  
  20. public Assessment(String companyName, String industryName, String locationName,
  21. String productName, String ownerId, String ownerName, boolean isDraft, boolean isQuickWalk, Map<String, Category> categories) {
  22. this.company = companyName;
  23. this.industry = industryName;
  24. this.location = locationName;
  25. this.product = productName;
  26. this.ownerId = ownerId;
  27. this.ownerName = ownerName;
  28. this.isDraft = isDraft;
  29. this.isQuickWalk = isQuickWalk;
  30. this.categories = categories;
  31. }
  32.  
  33. public String getCompanyName() {
  34. return company;
  35. }
  36.  
  37. public String getIndustryName() {
  38. return industry;
  39. }
  40.  
  41. public String getLocationName() {
  42. return location;
  43. }
  44.  
  45. public String getProductName() {
  46. return product;
  47. }
  48.  
  49. public String getOwnerName() {
  50. return ownerName;
  51. }
  52.  
  53. public boolean getIsDraft() {
  54. return isDraft;
  55. }
  56.  
  57. public boolean getIsQuickWalk() {
  58. return isQuickWalk;
  59. }
  60.  
  61. String key = mDatabaseRef.child(FIREBASE_ASSESSMENTS).push().getKey();
  62. Assessment assessment = new Assessment(editCompanyText, editLocationText,
  63. editIndustryText, editProductText, uid,
  64. currentUser.getEmail(), isDraft, isQuickWalk, null);
  65.  
  66. Map<String, Object> childUpdates = new HashMap<>();
  67. childUpdates.put("/" + FIREBASE_ASSESSMENTS + "/" + key,
  68. assessment);
  69. mDatabaseRef.updateChildren(childUpdates);
  70.  
  71. FirebaseRecyclerAdapter<Assessment, ViewDraftsViewHolder> adapter;
  72. mRecyclerView = (RecyclerView) findViewById(R.id.draft_recycler_view);
  73. mRecyclerView.setHasFixedSize(true);
  74. mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  75.  
  76. Query query = mEvalRef;
  77. FirebaseRecyclerOptions<Assessment> options = new FirebaseRecyclerOptions.Builder<Assessment>()
  78. .setQuery(query, Assessment.class)
  79. .build();
  80.  
  81. adapter = new FirebaseRecyclerAdapter<Assessment, ViewDraftsViewHolder>(options) {
  82. @Override
  83. protected void onBindViewHolder(ViewDraftsViewHolder holder, int position, Assessment model) {
  84. if(model.getIsDraft()) {
  85. holder.companyName.setText(model.getCompanyName());
  86. holder.industryName.setText(model.getIndustryName());
  87. holder.locationName.setText(model.getLocationName());
  88. holder.productName.setText(model.getProductName());
  89. holder.ownerName.setText(model.getOwnerName());
  90.  
  91. if(model.getIsQuickWalk()) {
  92. holder.isQuickWalk.setText("Quick Walkthrough");
  93. } else {
  94. holder.isQuickWalk.setText("Full Questionnaire");
  95. }
  96. }
  97.  
  98. }
  99.  
  100. @Override
  101. public ViewDraftsViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  102. View view = LayoutInflater.from(parent.getContext())
  103. .inflate(R.layout.completed_and_drafts_list_item, parent, false);
  104. return new ViewDraftsViewHolder(view);
  105. }
  106. };
  107.  
  108. mRecyclerView.setAdapter(adapter);
  109.  
  110. private static class ViewDraftsViewHolder extends RecyclerView.ViewHolder {
  111. TextView companyName;
  112. TextView industryName;
  113. TextView locationName;
  114. TextView productName;
  115. TextView ownerName;
  116. TextView isQuickWalk;
  117.  
  118. public ViewDraftsViewHolder(View itemView) {
  119. super(itemView);
  120.  
  121. companyName = (TextView) itemView.findViewById(R.id.companyView);
  122. industryName = (TextView) itemView.findViewById(R.id.industryView);
  123. locationName = (TextView) itemView.findViewById(R.id.locationView);
  124. productName = (TextView) itemView.findViewById(R.id.productView);
  125. ownerName = (TextView) itemView.findViewById(R.id.ownerName);
  126. isQuickWalk = (TextView) itemView.findViewById(R.id.isQuickWalkView);
  127. }
  128. }
  129.  
  130. "-KzB39l1KH6MyEsgr6Ke" : {
  131. "companyName" : "testing ",
  132. "industryName" : "at",
  133. "isDraft" : true,
  134. "isQuickWalk" : true,
  135. "locationName" : "five fifteen",
  136. "ownerName" : "test@email.com",
  137. "productName" : "please ignore"
  138. },
Add Comment
Please, Sign In to add comment