Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
f05521e9
Commit
f05521e9
authored
Oct 11, 2018
by
Preetam Ozarde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make minor codacy changes, delete relevant_complaint module.
parent
51ab033d
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
226 additions
and
356 deletions
+226
-356
app/src/main/java/app/insti/adapter/CommentsAdapter.java
app/src/main/java/app/insti/adapter/CommentsAdapter.java
+4
-1
app/src/main/java/app/insti/adapter/ComplaintDetailsPagerAdapter.java
.../java/app/insti/adapter/ComplaintDetailsPagerAdapter.java
+6
-3
app/src/main/java/app/insti/adapter/UpVotesAdapter.java
app/src/main/java/app/insti/adapter/UpVotesAdapter.java
+0
-2
app/src/main/java/app/insti/fragment/ComplaintDetailsFragment.java
...ain/java/app/insti/fragment/ComplaintDetailsFragment.java
+23
-3
app/src/main/java/app/insti/fragment/ComplaintFragment.java
app/src/main/java/app/insti/fragment/ComplaintFragment.java
+0
-2
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
+2
-2
app/src/main/java/app/insti/fragment/ComplaintsHomeFragment.java
.../main/java/app/insti/fragment/ComplaintsHomeFragment.java
+2
-2
app/src/main/java/app/insti/fragment/FileComplaintFragment.java
...c/main/java/app/insti/fragment/FileComplaintFragment.java
+173
-170
app/src/main/java/app/insti/fragment/RelevantComplaintsFragment.java
...n/java/app/insti/fragment/RelevantComplaintsFragment.java
+0
-85
app/src/main/res/layout/fragment_complaint_details.xml
app/src/main/res/layout/fragment_complaint_details.xml
+16
-46
app/src/main/res/layout/fragment_relevant_complaints.xml
app/src/main/res/layout/fragment_relevant_complaints.xml
+0
-40
No files found.
app/src/main/java/app/insti/adapter/CommentsAdapter.java
View file @
f05521e9
...
...
@@ -43,6 +43,7 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
private
LayoutInflater
inflater
;
private
String
sessionId
,
userId
;
private
Fragment
fragment
;
private
TextView
textViewCommentLabel
;
private
List
<
Venter
.
Comment
>
commentList
=
new
ArrayList
<>();
...
...
@@ -122,6 +123,7 @@ public class CommentsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
notifyDataSetChanged
();
notifyItemRemoved
(
position
);
notifyItemRangeChanged
(
position
,
commentList
.
size
()
-
position
);
textViewCommentLabel
.
setText
(
"Comments ("
+
commentList
.
size
()
+
")"
);
}
else
{
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
return
commentList
.
size
();
}
public
void
setCommentList
(
List
<
Venter
.
Comment
>
commentList
)
{
public
void
setCommentList
(
List
<
Venter
.
Comment
>
commentList
,
TextView
textViewCommentLabel
)
{
this
.
commentList
=
commentList
;
this
.
textViewCommentLabel
=
textViewCommentLabel
;
}
}
\ No newline at end of file
app/src/main/java/app/insti/adapter/ComplaintDetailsPagerAdapter.java
View file @
f05521e9
...
...
@@ -27,8 +27,11 @@ public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
switch
(
position
)
{
case
0
:
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
:
return
ComplaintDetailsFragment
.
getInstance
(
sessionid
,
complaintid
,
userid
,
userProfileUrl
);
}
...
...
@@ -46,6 +49,6 @@ public class ComplaintDetailsPagerAdapter extends FragmentPagerAdapter {
@Override
public
int
getCount
()
{
return
2
;
return
1
;
}
}
app/src/main/java/app/insti/adapter/UpVotesAdapter.java
View file @
f05521e9
...
...
@@ -23,10 +23,8 @@ public class UpVotesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
private
static
final
String
TAG
=
CommentsAdapter
.
class
.
getSimpleName
();
private
LayoutInflater
inflater
;
private
Fragment
fragment
;
private
List
<
User
>
userList
=
new
ArrayList
<>();
public
UpVotesAdapter
(
Fragment
fragment
,
Context
context
)
{
inflater
=
LayoutInflater
.
from
(
context
);
this
.
fragment
=
fragment
;
...
...
app/src/main/java/app/insti/fragment/ComplaintDetailsFragment.java
View file @
f05521e9
...
...
@@ -3,6 +3,7 @@ package app.insti.fragment;
import
android.content.res.ColorStateList
;
import
android.os.Bundle
;
import
android.support.v4.app.Fragment
;
import
android.support.v4.widget.NestedScrollView
;
import
android.support.v7.widget.LinearLayoutManager
;
import
android.support.v7.widget.RecyclerView
;
import
android.util.Log
;
...
...
@@ -13,8 +14,10 @@ import android.widget.Button;
import
android.widget.EditText
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.ScrollView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.google.android.gms.maps.CameraUpdateFactory
;
import
com.google.android.gms.maps.GoogleMap
;
import
com.google.android.gms.maps.MapView
;
...
...
@@ -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.MarkerOptions
;
import
com.squareup.picasso.Picasso
;
import
java.util.ArrayList
;
import
java.util.List
;
import
app.insti.R
;
import
app.insti.Utils
;
import
app.insti.activity.MainActivity
;
...
...
@@ -37,6 +42,7 @@ import app.insti.api.model.Venter;
import
app.insti.api.request.CommentCreateRequest
;
import
app.insti.utils.DateTimeUtil
;
import
de.hdodenhof.circleimageview.CircleImageView
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
...
...
@@ -67,6 +73,8 @@ public class ComplaintDetailsFragment extends Fragment {
private
List
<
Venter
.
Comment
>
commentList
;
private
List
<
User
>
upVotesList
;
private
LinearLayout
linearLayoutTags
;
private
ScrollView
layoutUpVotes
;
private
NestedScrollView
nestedScrollView
;
public
static
ComplaintDetailsFragment
getInstance
(
String
sessionid
,
String
complaintid
,
String
userid
,
String
userProfileUrl
)
{
sId
=
sessionid
;
...
...
@@ -124,10 +132,12 @@ public class ComplaintDetailsFragment extends Fragment {
upVote
(
detailedComplaint
);
}
});
return
view
;
}
private
void
initialiseViews
(
View
view
)
{
nestedScrollView
=
view
.
findViewById
(
R
.
id
.
nestedScrollViewComplaintDetail
);
textViewUserName
=
view
.
findViewById
(
R
.
id
.
textViewUserName
);
textViewReportDate
=
view
.
findViewById
(
R
.
id
.
textViewReportDate
);
textViewLocation
=
view
.
findViewById
(
R
.
id
.
textViewLocation
);
...
...
@@ -137,6 +147,7 @@ public class ComplaintDetailsFragment extends Fragment {
textViewVoteUpLabel
=
view
.
findViewById
(
R
.
id
.
up_vote_label
);
tagsLayout
=
view
.
findViewById
(
R
.
id
.
tags_layout
);
linearLayoutTags
=
view
.
findViewById
(
R
.
id
.
linearLayoutTags
);
layoutUpVotes
=
view
.
findViewById
(
R
.
id
.
layoutUpVotes
);
recyclerViewComments
=
view
.
findViewById
(
R
.
id
.
recyclerViewComments
);
recyclerViewUpVotes
=
view
.
findViewById
(
R
.
id
.
recyclerViewUpVotes
);
editTextComment
=
view
.
findViewById
(
R
.
id
.
edit_comment
);
...
...
@@ -220,7 +231,7 @@ public class ComplaintDetailsFragment extends Fragment {
private
void
addNewComment
(
Venter
.
Comment
newComment
)
{
commentList
.
add
(
newComment
);
commentListAdapter
.
setCommentList
(
commentList
);
commentListAdapter
.
setCommentList
(
commentList
,
textViewCommentLabel
);
commentListAdapter
.
notifyItemInserted
(
commentList
.
indexOf
(
newComment
));
commentListAdapter
.
notifyItemRangeChanged
(
0
,
commentListAdapter
.
getItemCount
());
textViewCommentLabel
.
setText
(
"Comments ("
+
commentList
.
size
()
+
")"
);
...
...
@@ -235,7 +246,7 @@ public class ComplaintDetailsFragment extends Fragment {
private
void
addCommentsToView
(
Venter
.
Complaint
detailedComplaint
)
{
for
(
Venter
.
Comment
comment
:
detailedComplaint
.
getComment
())
commentList
.
add
(
comment
);
commentListAdapter
.
setCommentList
(
commentList
);
commentListAdapter
.
setCommentList
(
commentList
,
textViewCommentLabel
);
commentListAdapter
.
notifyDataSetChanged
();
}
...
...
@@ -249,6 +260,7 @@ public class ComplaintDetailsFragment extends Fragment {
Venter
.
Complaint
complaint
=
response
.
body
();
detailedComplaint
.
setVoteCount
(
1
);
addVotesToView
(
complaint
);
onUpvote
();
}
}
...
...
@@ -286,6 +298,15 @@ public class ComplaintDetailsFragment extends Fragment {
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
)
{
for
(
Venter
.
TagUri
tagUri
:
detailedComplaint
.
getTags
())
{
...
...
@@ -305,7 +326,6 @@ public class ComplaintDetailsFragment extends Fragment {
textViewTags
.
setBackgroundTintList
(
ColorStateList
.
valueOf
(
getContext
().
getResources
().
getColor
(
R
.
color
.
colorTagGreen
)));
textViewTags
.
setTextColor
(
getContext
().
getResources
().
getColor
(
R
.
color
.
primaryTextColor
));
tagsLayout
.
setLayoutParams
(
layoutParams
);
tagsLayout
.
addView
(
textViewTags
);
}
}
...
...
app/src/main/java/app/insti/fragment/ComplaintFragment.java
View file @
f05521e9
...
...
@@ -107,7 +107,6 @@ public class ComplaintFragment extends Fragment {
if
(
viewPager
!=
null
)
{
try
{
ImageViewPagerAdapter
imageFragmentPagerAdapter
=
new
ImageViewPagerAdapter
(
getChildFragmentManager
(),
detailedComplaint
);
viewPager
.
setAdapter
(
imageFragmentPagerAdapter
);
circleIndicator
.
setViewPager
(
viewPager
);
imageFragmentPagerAdapter
.
registerDataSetObserver
(
circleIndicator
.
getDataSetObserver
());
...
...
@@ -122,7 +121,6 @@ public class ComplaintFragment extends Fragment {
}
private
void
initTabViews
(
final
Venter
.
Complaint
detailedComplaint
)
{
try
{
if
(
detailedComplaint
!=
null
)
{
viewPager
=
mview
.
findViewById
(
R
.
id
.
tab_viewpager_details
);
...
...
app/src/main/java/app/insti/fragment/ComplaintsFragment.java
View file @
f05521e9
...
...
@@ -36,9 +36,9 @@ public class ComplaintsFragment extends BaseFragment {
userProfileUrl
=
bundle
.
getString
(
Constants
.
CURRENT_USER_PROFILE_PICTURE
);
CollapsingToolbarLayout
collapsingToolbarLayout
=
view
.
findViewById
(
R
.
id
.
collapsing_toolbar
);
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
);
...
...
app/src/main/java/app/insti/fragment/ComplaintsHomeFragment.java
View file @
f05521e9
...
...
@@ -54,9 +54,9 @@ public class ComplaintsHomeFragment extends Fragment {
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
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
);
swipeContainer
=
(
SwipeRefreshLayout
)
view
.
findViewById
(
R
.
id
.
swipeContainer
);
swipeContainer
=
view
.
findViewById
(
R
.
id
.
swipeContainer
);
error_message_home
=
view
.
findViewById
(
R
.
id
.
error_message_home
);
LinearLayoutManager
llm
=
new
LinearLayoutManager
(
getActivity
());
...
...
app/src/main/java/app/insti/fragment/FileComplaintFragment.java
View file @
f05521e9
...
...
@@ -128,6 +128,9 @@ public class FileComplaintFragment extends Fragment {
private
LinearLayout
linearLayoutAnalyse
;
private
LinearLayout
linearLayoutScrollTags
;
private
boolean
userAddedTag
=
false
;
private
ImageButton
imageButtonAddTags
;
private
Button
buttonAnalysis
;
private
ImageButton
imageActionButton
;
public
static
FileComplaintFragment
getMainActivity
()
{
return
mainactivity
;
...
...
@@ -150,8 +153,7 @@ public class FileComplaintFragment extends Fragment {
}
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
// Inflate the layout for this fragment
if
(
view
!=
null
)
{
ViewGroup
parent
=
(
ViewGroup
)
view
.
getParent
();
...
...
@@ -159,30 +161,107 @@ public class FileComplaintFragment extends Fragment {
parent
.
removeView
(
view
);
}
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
();
userId
=
bundle
.
getString
(
Constants
.
USER_ID
);
editTextTags
.
addTextChangedListener
(
new
TextWatcher
()
{
@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
);
CollapsingToolbarLayout
.
LayoutParams
layoutParams
=
new
CollapsingToolbarLayout
.
LayoutParams
(
CollapsingToolbarLayout
.
LayoutParams
.
MATCH_PARENT
,
getResources
().
getDisplayMetrics
().
heightPixels
/
2
);
imageViewHolder
.
setLayoutParams
(
layoutParams
);
collapsing_toolbar
=
view
.
findViewById
(
R
.
id
.
collapsing_toolbar
);
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
);
linearLayoutAnalyse
=
view
.
findViewById
(
R
.
id
.
layoutAnalyse
);
layout_buttons
=
view
.
findViewById
(
R
.
id
.
layout_buttons
);
layout_buttons
.
setVisibility
(
View
.
GONE
);
...
...
@@ -190,35 +269,35 @@ public class FileComplaintFragment extends Fragment {
buttonSubmit
.
setVisibility
(
View
.
INVISIBLE
);
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
.
GONE
);
linearLayoutScrollTags
=
view
.
findViewById
(
R
.
id
.
linearLayoutScrollTags
);
linearLayoutScrollTags
.
setVisibility
(
View
.
INVISIBLE
);
linearLayoutScrollTags
.
setVisibility
(
View
.
GONE
);
tagsLayout
=
view
.
findViewById
(
R
.
id
.
tags_layout
);
viewPager
=
view
.
findViewById
(
R
.
id
.
complaint_image_view_pager
);
indicator
=
view
.
findViewById
(
R
.
id
.
indicator
);
ImageButton
imageActionButton
=
view
.
findViewById
(
R
.
id
.
fabButton
);
imageActionButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
giveOptionsToAddImage
();
imageActionButton
=
view
.
findViewById
(
R
.
id
.
fabButton
);
imageButtonAddTags
=
view
.
findViewById
(
R
.
id
.
imageButtonAddTags
);
editTextSuggestions
=
view
.
findViewById
(
R
.
id
.
editTextSuggestions
);
editTextLocationDetails
=
view
.
findViewById
(
R
.
id
.
editTextLocationDetails
);
editTextTags
=
view
.
findViewById
(
R
.
id
.
editTextTags
);
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
);
autoCompleteTextView
.
setOnFocusChangeListener
(
new
View
.
OnFocusChangeListener
()
{
@Override
public
void
onFocusChange
(
View
v
,
boolean
hasFocus
)
{
private
void
searchComplaint
(
boolean
hasFocus
)
{
if
(!
hasFocus
)
{
if
(!(
autoCompleteTextView
.
getText
().
toString
().
trim
().
isEmpty
()))
{
int
paddingDp
=
60
;
float
density
=
getContext
().
getResources
().
getDisplayMetrics
().
density
;
...
...
@@ -236,38 +315,10 @@ public class FileComplaintFragment extends Fragment {
linearLayoutAnalyse
.
setPadding
(
0
,
0
,
0
,
0
);
}
}
});
editTextSuggestions
=
view
.
findViewById
(
R
.
id
.
editTextSuggestions
);
editTextLocationDetails
=
view
.
findViewById
(
R
.
id
.
editTextLocationDetails
);
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
private
void
addUserTags
()
{
userAddedTag
=
true
;
populateTags
(
editTextTags
.
getText
().
toString
(),
userAddedTag
);
populateTags
(
editTextTags
.
getText
().
toString
(),
userAddedTag
);
editTextTags
.
setText
(
""
);
userAddedTag
=
false
;
tagViewPopulate
.
addTags
(
new
ArrayList
<
Tag
>());
...
...
@@ -275,88 +326,8 @@ public class FileComplaintFragment extends Fragment {
linearLayoutScrollTags
.
setVisibility
(
View
.
INVISIBLE
);
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
);
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
)
{
private
void
addTags
(
Tag
tag
)
{
userAddedTag
=
false
;
editTextTags
.
setText
(
tag
.
text
);
editTextTags
.
setSelection
(
tag
.
text
.
length
());
...
...
@@ -367,26 +338,6 @@ public class FileComplaintFragment extends Fragment {
linearLayoutScrollTags
.
setVisibility
(
View
.
INVISIBLE
);
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
()
{
...
...
@@ -474,7 +425,7 @@ public class FileComplaintFragment extends Fragment {
@Override
public
void
onFailure
(
Exception
e
)
{
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
;
...
...
@@ -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
)
{
if
(!(
cs
.
isEmpty
()))
{
...
...
@@ -590,7 +567,7 @@ public class FileComplaintFragment extends Fragment {
}
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
)
tagList2
.
get
(
i
).
setName
(
cs
+
" (U)"
);
}
...
...
@@ -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
()
{
final
String
complaint
=
"Complaint: "
+
autoCompleteTextView
.
getText
().
toString
();
final
String
suggestion
;
...
...
app/src/main/java/app/insti/fragment/RelevantComplaintsFragment.java
deleted
100644 → 0
View file @
51ab033d
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
}
}
app/src/main/res/layout/fragment_complaint_details.xml
View file @
f05521e9
...
...
@@ -5,7 +5,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
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"
android:layout_width=
"match_parent"
...
...
@@ -107,19 +108,11 @@
</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
android:id=
"@+id/tags_layout"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
></LinearLayout
>
android:orientation=
"vertical"
/
>
</LinearLayout>
...
...
@@ -222,8 +215,14 @@
</LinearLayout>
<
android.support.design.widget.CoordinatorLayout
<
ScrollView
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_height=
"wrap_content"
android:orientation=
"vertical"
...
...
@@ -236,38 +235,10 @@
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
<!--<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">
</ScrollView>
</LinearLayout>
</LinearLayout>-->
<LinearLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
@@ -287,7 +258,6 @@
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
app/src/main/res/layout/fragment_relevant_complaints.xml
deleted
100644 → 0
View file @
51ab033d
<?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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment