Commit f05521e9 authored by Preetam Ozarde's avatar Preetam Ozarde

Make minor codacy changes, delete relevant_complaint module.

parent 51ab033d
...@@ -43,6 +43,7 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde ...@@ -43,6 +43,7 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
private LayoutInflater inflater; private LayoutInflater inflater;
private String sessionId, userId; private String sessionId, userId;
private Fragment fragment; private Fragment fragment;
private TextView textViewCommentLabel;
private List<Venter.Comment> commentList = new ArrayList<>(); private List<Venter.Comment> commentList = new ArrayList<>();
...@@ -122,6 +123,7 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde ...@@ -122,6 +123,7 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
notifyDataSetChanged(); notifyDataSetChanged();
notifyItemRemoved(position); notifyItemRemoved(position);
notifyItemRangeChanged(position, commentList.size() - position); notifyItemRangeChanged(position, commentList.size() - position);
textViewCommentLabel.setText("Comments (" + commentList.size() + ")");
} else { } else {
Toast.makeText(context, "You can't delete this comment", Toast.LENGTH_SHORT).show(); Toast.makeText(context, "You can't delete this comment", Toast.LENGTH_SHORT).show();
} }
...@@ -181,7 +183,8 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde ...@@ -181,7 +183,8 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
return commentList.size(); return commentList.size();
} }
public void setCommentList(List<Venter.Comment> commentList) { public void setCommentList(List<Venter.Comment> commentList, TextView textViewCommentLabel) {
this.commentList = commentList; this.commentList = commentList;
this.textViewCommentLabel = textViewCommentLabel;
} }
} }
\ No newline at end of file
...@@ -27,8 +27,11 @@ public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter { ...@@ -27,8 +27,11 @@ public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
switch (position) { switch (position) {
case 0: case 0:
return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl); return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl);
/* case 1: /*
return RelevantComplaintsFragment.getInstance(sessionid, userid);*/ For version 2:
case 1:
return RelevantComplaintsFragment.getInstance(sessionid, userid);
*/
default: default:
return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl); return ComplaintDetailsFragment.getInstance(sessionid, complaintid, userid, userProfileUrl);
} }
...@@ -46,6 +49,6 @@ public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter { ...@@ -46,6 +49,6 @@ public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
@Override @Override
public int getCount() { public int getCount() {
return 2; return 1;
} }
} }
...@@ -23,10 +23,8 @@ public class UpVotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder ...@@ -23,10 +23,8 @@ public class UpVotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
private static final String TAG = CommentsAdapter.class.getSimpleName(); private static final String TAG = CommentsAdapter.class.getSimpleName();
private LayoutInflater inflater; private LayoutInflater inflater;
private Fragment fragment; private Fragment fragment;
private List<User> userList = new ArrayList<>(); private List<User> userList = new ArrayList<>();
public UpVotesAdapter(Fragment fragment, Context context) { public UpVotesAdapter(Fragment fragment, Context context) {
inflater = LayoutInflater.from(context); inflater = LayoutInflater.from(context);
this.fragment = fragment; this.fragment = fragment;
......
...@@ -3,6 +3,7 @@ package app.insti.fragment; ...@@ -3,6 +3,7 @@ package app.insti.fragment;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.NestedScrollView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log; import android.util.Log;
...@@ -13,8 +14,10 @@ import android.widget.Button; ...@@ -13,8 +14,10 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView; import com.google.android.gms.maps.MapView;
...@@ -24,8 +27,10 @@ import com.google.android.gms.maps.model.CameraPosition; ...@@ -24,8 +27,10 @@ import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions; import com.google.android.gms.maps.model.MarkerOptions;
import com.squareup.picasso.Picasso; import com.squareup.picasso.Picasso;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import app.insti.R; import app.insti.R;
import app.insti.Utils; import app.insti.Utils;
import app.insti.activity.MainActivity; import app.insti.activity.MainActivity;
...@@ -37,6 +42,7 @@ import app.insti.api.model.Venter; ...@@ -37,6 +42,7 @@ import app.insti.api.model.Venter;
import app.insti.api.request.CommentCreateRequest; import app.insti.api.request.CommentCreateRequest;
import app.insti.utils.DateTimeUtil; import app.insti.utils.DateTimeUtil;
import de.hdodenhof.circleimageview.CircleImageView; import de.hdodenhof.circleimageview.CircleImageView;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.Callback; import retrofit2.Callback;
import retrofit2.Response; import retrofit2.Response;
...@@ -67,6 +73,8 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -67,6 +73,8 @@ public class ComplaintDetailsFragment extends Fragment {
private List<Venter.Comment> commentList; private List<Venter.Comment> commentList;
private List<User> upVotesList; private List<User> upVotesList;
private LinearLayout linearLayoutTags; private LinearLayout linearLayoutTags;
private ScrollView layoutUpVotes;
private NestedScrollView nestedScrollView;
public static ComplaintDetailsFragment getInstance(String sessionid, String complaintid, String userid, String userProfileUrl) { public static ComplaintDetailsFragment getInstance(String sessionid, String complaintid, String userid, String userProfileUrl) {
sId = sessionid; sId = sessionid;
...@@ -124,10 +132,12 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -124,10 +132,12 @@ public class ComplaintDetailsFragment extends Fragment {
upVote(detailedComplaint); upVote(detailedComplaint);
} }
}); });
return view; return view;
} }
private void initialiseViews(View view) { private void initialiseViews(View view) {
nestedScrollView = view.findViewById(R.id.nestedScrollViewComplaintDetail);
textViewUserName = view.findViewById(R.id.textViewUserName); textViewUserName = view.findViewById(R.id.textViewUserName);
textViewReportDate = view.findViewById(R.id.textViewReportDate); textViewReportDate = view.findViewById(R.id.textViewReportDate);
textViewLocation = view.findViewById(R.id.textViewLocation); textViewLocation = view.findViewById(R.id.textViewLocation);
...@@ -137,6 +147,7 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -137,6 +147,7 @@ public class ComplaintDetailsFragment extends Fragment {
textViewVoteUpLabel = view.findViewById(R.id.up_vote_label); textViewVoteUpLabel = view.findViewById(R.id.up_vote_label);
tagsLayout = view.findViewById(R.id.tags_layout); tagsLayout = view.findViewById(R.id.tags_layout);
linearLayoutTags = view.findViewById(R.id.linearLayoutTags); linearLayoutTags = view.findViewById(R.id.linearLayoutTags);
layoutUpVotes = view.findViewById(R.id.layoutUpVotes);
recyclerViewComments = view.findViewById(R.id.recyclerViewComments); recyclerViewComments = view.findViewById(R.id.recyclerViewComments);
recyclerViewUpVotes = view.findViewById(R.id.recyclerViewUpVotes); recyclerViewUpVotes = view.findViewById(R.id.recyclerViewUpVotes);
editTextComment = view.findViewById(R.id.edit_comment); editTextComment = view.findViewById(R.id.edit_comment);
...@@ -220,7 +231,7 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -220,7 +231,7 @@ public class ComplaintDetailsFragment extends Fragment {
private void addNewComment(Venter.Comment newComment) { private void addNewComment(Venter.Comment newComment) {
commentList.add(newComment); commentList.add(newComment);
commentListAdapter.setCommentList(commentList); commentListAdapter.setCommentList(commentList, textViewCommentLabel);
commentListAdapter.notifyItemInserted(commentList.indexOf(newComment)); commentListAdapter.notifyItemInserted(commentList.indexOf(newComment));
commentListAdapter.notifyItemRangeChanged(0, commentListAdapter.getItemCount()); commentListAdapter.notifyItemRangeChanged(0, commentListAdapter.getItemCount());
textViewCommentLabel.setText("Comments (" + commentList.size() + ")"); textViewCommentLabel.setText("Comments (" + commentList.size() + ")");
...@@ -235,7 +246,7 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -235,7 +246,7 @@ public class ComplaintDetailsFragment extends Fragment {
private void addCommentsToView(Venter.Complaint detailedComplaint) { private void addCommentsToView(Venter.Complaint detailedComplaint) {
for (Venter.Comment comment : detailedComplaint.getComment()) for (Venter.Comment comment : detailedComplaint.getComment())
commentList.add(comment); commentList.add(comment);
commentListAdapter.setCommentList(commentList); commentListAdapter.setCommentList(commentList, textViewCommentLabel);
commentListAdapter.notifyDataSetChanged(); commentListAdapter.notifyDataSetChanged();
} }
...@@ -249,6 +260,7 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -249,6 +260,7 @@ public class ComplaintDetailsFragment extends Fragment {
Venter.Complaint complaint = response.body(); Venter.Complaint complaint = response.body();
detailedComplaint.setVoteCount(1); detailedComplaint.setVoteCount(1);
addVotesToView(complaint); addVotesToView(complaint);
onUpvote();
} }
} }
...@@ -286,6 +298,15 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -286,6 +298,15 @@ public class ComplaintDetailsFragment extends Fragment {
textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")"); textViewVoteUpLabel.setText("Up Votes (" + detailedComplaint.getUsersUpVoted().size() + ")");
} }
private void onUpvote(){
layoutUpVotes.post(new Runnable() {
@Override
public void run() {
nestedScrollView.fullScroll(ScrollView.FOCUS_DOWN);
}
});
}
private void addTagsToView(Venter.Complaint detailedComplaint) { private void addTagsToView(Venter.Complaint detailedComplaint) {
for (Venter.TagUri tagUri : detailedComplaint.getTags()) { for (Venter.TagUri tagUri : detailedComplaint.getTags()) {
...@@ -305,7 +326,6 @@ public class ComplaintDetailsFragment extends Fragment { ...@@ -305,7 +326,6 @@ public class ComplaintDetailsFragment extends Fragment {
textViewTags.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorTagGreen))); textViewTags.setBackgroundTintList(ColorStateList.valueOf(getContext().getResources().getColor(R.color.colorTagGreen)));
textViewTags.setTextColor(getContext().getResources().getColor(R.color.primaryTextColor)); textViewTags.setTextColor(getContext().getResources().getColor(R.color.primaryTextColor));
tagsLayout.setLayoutParams(layoutParams); tagsLayout.setLayoutParams(layoutParams);
tagsLayout.addView(textViewTags); tagsLayout.addView(textViewTags);
} }
} }
......
...@@ -107,7 +107,6 @@ public class ComplaintFragment extends Fragment { ...@@ -107,7 +107,6 @@ public class ComplaintFragment extends Fragment {
if (viewPager != null) { if (viewPager != null) {
try { try {
ImageViewPagerAdapter imageFragmentPagerAdapter = new ImageViewPagerAdapter(getChildFragmentManager(), detailedComplaint); ImageViewPagerAdapter imageFragmentPagerAdapter = new ImageViewPagerAdapter(getChildFragmentManager(), detailedComplaint);
viewPager.setAdapter(imageFragmentPagerAdapter); viewPager.setAdapter(imageFragmentPagerAdapter);
circleIndicator.setViewPager(viewPager); circleIndicator.setViewPager(viewPager);
imageFragmentPagerAdapter.registerDataSetObserver(circleIndicator.getDataSetObserver()); imageFragmentPagerAdapter.registerDataSetObserver(circleIndicator.getDataSetObserver());
...@@ -122,7 +121,6 @@ public class ComplaintFragment extends Fragment { ...@@ -122,7 +121,6 @@ public class ComplaintFragment extends Fragment {
} }
private void initTabViews(final Venter.Complaint detailedComplaint) { private void initTabViews(final Venter.Complaint detailedComplaint) {
try { try {
if (detailedComplaint != null) { if (detailedComplaint != null) {
viewPager = mview.findViewById(R.id.tab_viewpager_details); viewPager = mview.findViewById(R.id.tab_viewpager_details);
......
...@@ -36,9 +36,9 @@ public class ComplaintsFragment extends BaseFragment { ...@@ -36,9 +36,9 @@ public class ComplaintsFragment extends BaseFragment {
userProfileUrl = bundle.getString(Constants.CURRENT_USER_PROFILE_PICTURE); userProfileUrl = bundle.getString(Constants.CURRENT_USER_PROFILE_PICTURE);
CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar); CollapsingToolbarLayout collapsingToolbarLayout = view.findViewById(R.id.collapsing_toolbar);
collapsingToolbarLayout.setTitleEnabled(false); collapsingToolbarLayout.setTitleEnabled(false);
ViewPager viewPager = (ViewPager) view.findViewById(R.id.tab_viewpager); ViewPager viewPager = view.findViewById(R.id.tab_viewpager);
slidingTabLayout = (TabLayout) view.findViewById(R.id.sliding_tab_layout); slidingTabLayout = view.findViewById(R.id.sliding_tab_layout);
Button buttonVentIssues = view.findViewById(R.id.buttonVentIssues); Button buttonVentIssues = view.findViewById(R.id.buttonVentIssues);
......
...@@ -54,9 +54,9 @@ public class ComplaintsHomeFragment extends Fragment { ...@@ -54,9 +54,9 @@ public class ComplaintsHomeFragment extends Fragment {
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_complaints_home, container, false); View view = inflater.inflate(R.layout.fragment_complaints_home, container, false);
RecyclerView recyclerViewHome = (RecyclerView) view.findViewById(R.id.recyclerViewHome); RecyclerView recyclerViewHome = view.findViewById(R.id.recyclerViewHome);
homeListAdapter = new ComplaintsAdapter(getActivity(), sID, uID, uProfileUrl); homeListAdapter = new ComplaintsAdapter(getActivity(), sID, uID, uProfileUrl);
swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipeContainer); swipeContainer = view.findViewById(R.id.swipeContainer);
error_message_home = view.findViewById(R.id.error_message_home); error_message_home = view.findViewById(R.id.error_message_home);
LinearLayoutManager llm = new LinearLayoutManager(getActivity()); LinearLayoutManager llm = new LinearLayoutManager(getActivity());
......
...@@ -128,6 +128,9 @@ public class FileComplaintFragment extends Fragment { ...@@ -128,6 +128,9 @@ public class FileComplaintFragment extends Fragment {
private LinearLayout linearLayoutAnalyse; private LinearLayout linearLayoutAnalyse;
private LinearLayout linearLayoutScrollTags; private LinearLayout linearLayoutScrollTags;
private boolean userAddedTag = false; private boolean userAddedTag = false;
private ImageButton imageButtonAddTags;
private Button buttonAnalysis;
private ImageButton imageActionButton;
public static FileComplaintFragment getMainActivity() { public static FileComplaintFragment getMainActivity() {
return mainactivity; return mainactivity;
...@@ -150,8 +153,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -150,8 +153,7 @@ public class FileComplaintFragment extends Fragment {
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle savedInstanceState) {
// Inflate the layout for this fragment // Inflate the layout for this fragment
if (view != null) { if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent(); ViewGroup parent = (ViewGroup) view.getParent();
...@@ -159,30 +161,107 @@ public class FileComplaintFragment extends Fragment { ...@@ -159,30 +161,107 @@ public class FileComplaintFragment extends Fragment {
parent.removeView(view); parent.removeView(view);
} }
view = inflater.inflate(R.layout.fragment_file_complaint, container, false); view = inflater.inflate(R.layout.fragment_file_complaint, container, false);
bundleCollection();
prepareTags();
progressDialog = new ProgressDialog(getContext());
final Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Add Complaint");
initviews(view);
Bundle bundle = getArguments(); editTextTags.addTextChangedListener(new TextWatcher() {
userId = bundle.getString(Constants.USER_ID); @Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//Before Text Changed
}
prepareTags(); @Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
linearLayoutScrollTags.setVisibility(View.VISIBLE);
setTags(s);
}
progressDialog = new ProgressDialog(getContext()); @Override
public void afterTextChanged(Editable s) {
//After Text Changed
}
});
imageActionButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
giveOptionsToAddImage();
}
});
imageButtonAddTags.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Add Tags
addUserTags();
}
});
buttonSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
submitComplaint();
}
});
buttonAnalysis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAnalysis();
}
});
autoCompleteTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
searchComplaint(hasFocus);
}
});
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
getMapReady();
//Autocomplete location bar
autoLocation();
//ends here
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
@Override
public void onTagDeleted(TagView tagView, Tag tag, int i) {
//Delete Tag
deleteTag(tagView, tag, i);
}
});
tagViewPopulate.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(Tag tag, int i) {
//Add Tags
addTags(tag);
}
});
return view;
}
private void initviews(View view) {
LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view); LinearLayout imageViewHolder = view.findViewById(R.id.image_holder_view);
CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams( CollapsingToolbarLayout.LayoutParams layoutParams = new CollapsingToolbarLayout.LayoutParams(
CollapsingToolbarLayout.LayoutParams.MATCH_PARENT, CollapsingToolbarLayout.LayoutParams.MATCH_PARENT,
getResources().getDisplayMetrics().heightPixels / 2 getResources().getDisplayMetrics().heightPixels / 2
); );
imageViewHolder.setLayoutParams(layoutParams);
collapsing_toolbar = view.findViewById(R.id.collapsing_toolbar); collapsing_toolbar = view.findViewById(R.id.collapsing_toolbar);
collapsing_toolbar.setVisibility(View.GONE); collapsing_toolbar.setVisibility(View.GONE);
imageViewHolder.setLayoutParams(layoutParams);
final Toolbar toolbar = getActivity().findViewById(R.id.toolbar);
toolbar.setTitle("Add Complaint");
nestedScrollView = view.findViewById(R.id.nested_scrollview); nestedScrollView = view.findViewById(R.id.nested_scrollview);
linearLayoutAnalyse = view.findViewById(R.id.layoutAnalyse); linearLayoutAnalyse = view.findViewById(R.id.layoutAnalyse);
layout_buttons = view.findViewById(R.id.layout_buttons); layout_buttons = view.findViewById(R.id.layout_buttons);
layout_buttons.setVisibility(View.GONE); layout_buttons.setVisibility(View.GONE);
...@@ -190,35 +269,35 @@ public class FileComplaintFragment extends Fragment { ...@@ -190,35 +269,35 @@ public class FileComplaintFragment extends Fragment {
buttonSubmit.setVisibility(View.INVISIBLE); buttonSubmit.setVisibility(View.INVISIBLE);
buttonSubmit.setVisibility(View.GONE); buttonSubmit.setVisibility(View.GONE);
Button buttonAnalysis = view.findViewById(R.id.button_analysis); buttonAnalysis = view.findViewById(R.id.button_analysis);
buttonAnalysis.setVisibility(View.INVISIBLE); buttonAnalysis.setVisibility(View.INVISIBLE);
buttonAnalysis.setVisibility(View.GONE); buttonAnalysis.setVisibility(View.GONE);
linearLayoutScrollTags = view.findViewById(R.id.linearLayoutScrollTags); linearLayoutScrollTags = view.findViewById(R.id.linearLayoutScrollTags);
linearLayoutScrollTags.setVisibility(View.INVISIBLE); linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE); linearLayoutScrollTags.setVisibility(View.GONE);
tagsLayout = view.findViewById(R.id.tags_layout); tagsLayout = view.findViewById(R.id.tags_layout);
viewPager = view.findViewById(R.id.complaint_image_view_pager); viewPager = view.findViewById(R.id.complaint_image_view_pager);
indicator = view.findViewById(R.id.indicator); indicator = view.findViewById(R.id.indicator);
imageActionButton = view.findViewById(R.id.fabButton);
ImageButton imageActionButton = view.findViewById(R.id.fabButton); imageButtonAddTags = view.findViewById(R.id.imageButtonAddTags);
imageActionButton.setOnClickListener(new View.OnClickListener() { editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
@Override editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails);
public void onClick(View v) { editTextTags = view.findViewById(R.id.editTextTags);
giveOptionsToAddImage(); autoCompleteTextView = view.findViewById(R.id.dynamicAutoCompleteTextView);
mMapView = view.findViewById(R.id.google_map);
tagView = view.findViewById(R.id.tag_view);
tagViewPopulate = view.findViewById(R.id.tag_populate);
} }
});
ImageButton imageButtonAddTags = (ImageButton) view.findViewById(R.id.imageButtonAddTags); private void bundleCollection() {
Bundle bundle = getArguments();
userId = bundle.getString(Constants.USER_ID);
}
autoCompleteTextView = (CustomAutoCompleteTextView) view.findViewById(R.id.dynamicAutoCompleteTextView); private void searchComplaint(boolean hasFocus) {
autoCompleteTextView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus) { if (!hasFocus) {
if (!(autoCompleteTextView.getText().toString().trim().isEmpty())) { if (!(autoCompleteTextView.getText().toString().trim().isEmpty())) {
int paddingDp = 60; int paddingDp = 60;
float density = getContext().getResources().getDisplayMetrics().density; float density = getContext().getResources().getDisplayMetrics().density;
...@@ -236,38 +315,10 @@ public class FileComplaintFragment extends Fragment { ...@@ -236,38 +315,10 @@ public class FileComplaintFragment extends Fragment {
linearLayoutAnalyse.setPadding(0, 0, 0, 0); linearLayoutAnalyse.setPadding(0, 0, 0, 0);
} }
} }
});
editTextSuggestions = view.findViewById(R.id.editTextSuggestions);
editTextLocationDetails = view.findViewById(R.id.editTextLocationDetails); private void addUserTags() {
editTextTags = view.findViewById(R.id.editTextTags);
editTextTags.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
//Before Text Changed
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
linearLayoutScrollTags.setVisibility(View.VISIBLE);
setTags(s);
}
@Override
public void afterTextChanged(Editable s) {
//After Text Changed
}
});
imageButtonAddTags.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Add Tags
userAddedTag = true; userAddedTag = true;
populateTags(editTextTags.getText().toString(),userAddedTag); populateTags(editTextTags.getText().toString(), userAddedTag);
editTextTags.setText(""); editTextTags.setText("");
userAddedTag = false; userAddedTag = false;
tagViewPopulate.addTags(new ArrayList<Tag>()); tagViewPopulate.addTags(new ArrayList<Tag>());
...@@ -275,88 +326,8 @@ public class FileComplaintFragment extends Fragment { ...@@ -275,88 +326,8 @@ public class FileComplaintFragment extends Fragment {
linearLayoutScrollTags.setVisibility(View.INVISIBLE); linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE); linearLayoutScrollTags.setVisibility(View.GONE);
} }
});
buttonSubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Tags = new ArrayList<>();
for (int i = 0; i < tagList2.size(); i++) {
Tags.add(tagList2.get(i).getName());
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
}
addComplaint();
}
});
buttonAnalysis.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showAnalysis();
}
});
mMapView = view.findViewById(R.id.google_map);
mMapView.onCreate(savedInstanceState);
mMapView.onResume();
getMapReady();
// Autocomplete location bar
final PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getActivity().getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setCountry("IN")
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setHint("Enter Location");
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(com.google.android.gms.location.places.Place place) {
Location = place.getLatLng();
String Name = place.getName().toString();
Address = place.getAddress().toString();
updateMap(Location, Name, Address, cursor); //on selecting the place will automatically shows the Details on the map.
cursor++;
}
@Override
public void onError(Status status) {
Log.i(TAG, "An error occurred: " + status);
}
});
// ends here
tagView = view.findViewById(R.id.tag_view); private void addTags(Tag tag) {
tagView.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
@Override
public void onTagDeleted(final TagView tagView, final Tag tag, final int i) {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
builder.setMessage("\"" + tag.text + "\" will be deleted. Are you sure?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tagView.remove(i);
tagList2.remove(i);
Log.i(TAG, "tagList2: " + tagList2.toString());
Toast.makeText(getContext(), "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No", null);
builder.show();
}
});
tagViewPopulate = view.findViewById(R.id.tag_populate);
tagViewPopulate.setOnTagClickListener(new TagView.OnTagClickListener() {
@Override
public void onTagClick(Tag tag, int i) {
userAddedTag = false; userAddedTag = false;
editTextTags.setText(tag.text); editTextTags.setText(tag.text);
editTextTags.setSelection(tag.text.length()); editTextTags.setSelection(tag.text.length());
...@@ -367,26 +338,6 @@ public class FileComplaintFragment extends Fragment { ...@@ -367,26 +338,6 @@ public class FileComplaintFragment extends Fragment {
linearLayoutScrollTags.setVisibility(View.INVISIBLE); linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);//to set cursor position linearLayoutScrollTags.setVisibility(View.GONE);//to set cursor position
} }
});
tagViewPopulate.setOnTagDeleteListener(new TagView.OnTagDeleteListener() {
@Override
public void onTagDeleted(final TagView tagView, final Tag tag, final int i) {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
builder.setMessage("\"" + tag.text + "\" will be deleted. Are you sure?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tagView.remove(i);
Toast.makeText(getContext(), "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No", null);
builder.show();
}
});
return view;
}
public void getMapReady() { public void getMapReady() {
...@@ -474,7 +425,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -474,7 +425,7 @@ public class FileComplaintFragment extends Fragment {
@Override @Override
public void onFailure(Exception e) { public void onFailure(Exception e) {
e.printStackTrace(); e.printStackTrace();
Toast.makeText(getContext(), "Something went wrong while getting your location \n"+ e, Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "Something went wrong while getting your location \n" + e, Toast.LENGTH_LONG).show();
} }
}); });
GPSIsSetup = true; GPSIsSetup = true;
...@@ -576,6 +527,32 @@ public class FileComplaintFragment extends Fragment { ...@@ -576,6 +527,32 @@ public class FileComplaintFragment extends Fragment {
} }
} }
private void autoLocation() {
final PlaceAutocompleteFragment autocompleteFragment = (PlaceAutocompleteFragment) getActivity().getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setCountry("IN")
.build();
autocompleteFragment.setFilter(typeFilter);
autocompleteFragment.setHint("Enter Location");
autocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(com.google.android.gms.location.places.Place place) {
Location = place.getLatLng();
String Name = place.getName().toString();
Address = place.getAddress().toString();
updateMap(Location, Name, Address, cursor); //on selecting the place will automatically shows the Details on the map.
cursor++;
}
@Override
public void onError(Status status) {
Log.i(TAG, "An error occurred: " + status);
}
});
}
private void populateTags(String cs, Boolean userAddedTag) { private void populateTags(String cs, Boolean userAddedTag) {
if (!(cs.isEmpty())) { if (!(cs.isEmpty())) {
...@@ -590,7 +567,7 @@ public class FileComplaintFragment extends Fragment { ...@@ -590,7 +567,7 @@ public class FileComplaintFragment extends Fragment {
} }
tagView.addTags(tags); tagView.addTags(tags);
for (int i = 0; i < tagList2.size(); i++){ for (int i = 0; i < tagList2.size(); i++) {
if (userAddedTag && tagList2.get(i).getName() == cs) if (userAddedTag && tagList2.get(i).getName() == cs)
tagList2.get(i).setName(cs + " (U)"); tagList2.get(i).setName(cs + " (U)");
} }
...@@ -650,6 +627,32 @@ public class FileComplaintFragment extends Fragment { ...@@ -650,6 +627,32 @@ public class FileComplaintFragment extends Fragment {
} }
} }
private void deleteTag(final TagView tagView, final Tag tag, final int i) {
android.app.AlertDialog.Builder builder = new android.app.AlertDialog.Builder(getActivity());
builder.setMessage("\"" + tag.text + "\" will be deleted. Are you sure?");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
tagView.remove(i);
tagList2.remove(i);
Log.i(TAG, "tagList2: " + tagList2.toString());
Toast.makeText(getContext(), "\"" + tag.text + "\" deleted", Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton("No", null);
builder.show();
}
private void submitComplaint() {
Tags = new ArrayList<>();
for (int i = 0; i < tagList2.size(); i++) {
Tags.add(tagList2.get(i).getName());
linearLayoutScrollTags.setVisibility(View.INVISIBLE);
linearLayoutScrollTags.setVisibility(View.GONE);
}
addComplaint();
}
private void addComplaint() { private void addComplaint() {
final String complaint = "Complaint: " + autoCompleteTextView.getText().toString(); final String complaint = "Complaint: " + autoCompleteTextView.getText().toString();
final String suggestion; final String suggestion;
......
package app.insti.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import app.insti.R;
import app.insti.adapter.ComplaintsAdapter;
public class RelevantComplaintsFragment extends Fragment {
private SwipeRefreshLayout swipeContainer;
private boolean isCalled = false;
private static String sID, uID;
public static RelevantComplaintsFragment getInstance(String sessionID, String userID) {
sID = sessionID;
uID = userID;
return new RelevantComplaintsFragment();
}
@Override
public void onStart() {
super.onStart();
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
callServerToGetRelevantComplaints();
}
});
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_relevant_complaints, container, false);
RecyclerView recyclerViewRelevantComplaints = (RecyclerView) view.findViewById(R.id.recyclerViewRelevantComplaints);
ComplaintsAdapter relevantComplaintsAdapter = new ComplaintsAdapter(getActivity(), sID, uID, ""); //Change userProfileUrl to the current user Profile Pic
swipeContainer = (SwipeRefreshLayout) view.findViewById(R.id.swipeContainer);
LinearLayoutManager llm = new LinearLayoutManager(getActivity());
recyclerViewRelevantComplaints.setLayoutManager(llm);
recyclerViewRelevantComplaints.setHasFixedSize(true);
recyclerViewRelevantComplaints.setAdapter(relevantComplaintsAdapter);
swipeContainer.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
callServerToGetRelevantComplaints();
}
});
swipeContainer.setColorSchemeResources(R.color.colorPrimary);
if (!isCalled) {
swipeContainer.post(new Runnable() {
@Override
public void run() {
swipeContainer.setRefreshing(true);
callServerToGetRelevantComplaints();
}
});
isCalled = true;
}
return view;
}
private void callServerToGetRelevantComplaints(){
//Get Relevant Complaints from Server
}
}
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@android:color/white" android:background="@android:color/white"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/nestedScrollViewComplaintDetail">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -107,19 +108,11 @@ ...@@ -107,19 +108,11 @@
</LinearLayout> </LinearLayout>
<!--<com.cunoraz.tagview.TagView-->
<!--android:id="@+id/tag_group"-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_margin="10dp"-->
<!--android:clickable="false"-->
<!--android:longClickable="false"/>-->
<LinearLayout <LinearLayout
android:id="@+id/tags_layout" android:id="@+id/tags_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"></LinearLayout> android:orientation="vertical"/>
</LinearLayout> </LinearLayout>
...@@ -222,8 +215,14 @@ ...@@ -222,8 +215,14 @@
</LinearLayout> </LinearLayout>
<android.support.design.widget.CoordinatorLayout <ScrollView
android:id="@+id/layoutUpVotes" android:id="@+id/layoutUpVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="6dp"
android:background="@android:color/white">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
...@@ -236,38 +235,10 @@ ...@@ -236,38 +235,10 @@
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
</LinearLayout> </ScrollView>
<!--<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="@+id/up_vote_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/layoutVotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout> </LinearLayout>
</LinearLayout>-->
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
...@@ -287,7 +258,6 @@ ...@@ -287,7 +258,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</android.support.v4.widget.NestedScrollView> </android.support.v4.widget.NestedScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".fragment.RelevantComplaintsFragment"
android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ededed">
<TextView
android:id="@+id/error_message_relevant_complaints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:text="@string/error_message"
android:textColor="@color/secondaryTextColor"
android:visibility="invisible" />
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerViewRelevantComplaints"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment