Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Krishna Vemulavada
/
vera_2.1_app
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
68031446
authored
Apr 06, 2018
by
Kunj Gupta
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Removed unused classes.
parent
458beb8c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
77 deletions
app/src/main/java/com/vsoft/servicenow/chat/MessageAdapter.java → app/src/main/java/com/vsoft/servicenow/adapters/ChatMessageAdapter.java
app/src/main/java/com/vsoft/servicenow/chat/Message.java
app/src/main/java/com/vsoft/servicenow/db/models/ChatBotHistory.java
app/src/main/java/com/vsoft/servicenow/ui/ChatActivity.java
app/src/main/java/com/vsoft/servicenow/
chat/
MessageAdapter.java
→
app/src/main/java/com/vsoft/servicenow/
adapters/Chat
MessageAdapter.java
View file @
68031446
package
com
.
vsoft
.
servicenow
.
chat
;
package
com
.
vsoft
.
servicenow
.
adapters
;
import
android.content.Context
;
import
android.support.v7.widget.RecyclerView
;
...
...
@@ -9,19 +9,20 @@ import android.view.ViewGroup;
import
android.widget.TextView
;
import
com.vsoft.servicenow.R
;
import
com.vsoft.servicenow.db.models.ChatBotHistory
;
import
com.vsoft.servicenow.utils.PrefManager
;
import
com.vsoft.servicenow.utils.Util
;
import
java.util.List
;
public
class
MessageAdapter
extends
RecyclerView
.
Adapter
<
MessageAdapter
.
ViewHolder
>
{
public
class
ChatMessageAdapter
extends
RecyclerView
.
Adapter
<
Chat
MessageAdapter
.
ViewHolder
>
{
private
List
<
Message
>
mMessages
;
private
List
<
ChatBotHistory
>
mMessages
;
private
int
[]
mUsernameColors
;
private
Context
mContext
;
public
MessageAdapter
(
Context
context
,
List
<
Message
>
messages
)
{
public
ChatMessageAdapter
(
Context
context
,
List
<
ChatBotHistory
>
messages
)
{
mMessages
=
messages
;
mContext
=
context
;
mUsernameColors
=
context
.
getResources
().
getIntArray
(
R
.
array
.
username_colors
);
...
...
@@ -37,10 +38,10 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.ViewHold
@Override
public
void
onBindViewHolder
(
ViewHolder
viewHolder
,
int
position
)
{
Message
message
=
mMessages
.
get
(
position
);
viewHolder
.
setMessage
(
message
.
getUsername
(),
message
.
getMessage
());
if
(
message
.
getUsern
ame
()
!=
null
)
{
viewHolder
.
setUsername
(
message
.
getUsern
ame
());
ChatBotHistory
chatBotHistory
=
mMessages
.
get
(
position
);
viewHolder
.
setMessage
(
chatBotHistory
.
getUserName
(),
chatBotHistory
.
getMessage
());
if
(
chatBotHistory
.
getUserN
ame
()
!=
null
)
{
viewHolder
.
setUsername
(
chatBotHistory
.
getUserN
ame
());
}
}
...
...
@@ -51,7 +52,7 @@ public class MessageAdapter extends RecyclerView.Adapter<MessageAdapter.ViewHold
@Override
public
int
getItemViewType
(
int
position
)
{
return
mMessages
.
get
(
position
).
getType
()
;
return
-
1
;
}
public
class
ViewHolder
extends
RecyclerView
.
ViewHolder
{
...
...
app/src/main/java/com/vsoft/servicenow/chat/Message.java
deleted
100755 → 0
View file @
458beb8c
package
com
.
vsoft
.
servicenow
.
chat
;
public
class
Message
{
public
static
final
int
TYPE_MESSAGE
=
0
;
public
static
final
int
TYPE_LOG
=
1
;
public
static
final
int
TYPE_ACTION
=
2
;
private
int
mType
;
private
String
mMessage
;
private
String
mUsername
;
private
Message
()
{}
public
int
getType
()
{
return
mType
;
};
public
String
getMessage
()
{
return
mMessage
;
};
public
String
getUsername
()
{
return
mUsername
;
};
public
static
class
Builder
{
private
final
int
mType
;
private
String
mUsername
;
private
String
mMessage
;
public
Builder
(
int
type
)
{
mType
=
type
;
}
public
Builder
username
(
String
username
)
{
mUsername
=
username
;
return
this
;
}
public
Builder
message
(
String
message
)
{
mMessage
=
message
;
return
this
;
}
public
Message
build
()
{
Message
message
=
new
Message
();
message
.
mType
=
mType
;
message
.
mUsername
=
mUsername
;
message
.
mMessage
=
mMessage
;
return
message
;
}
}
}
app/src/main/java/com/vsoft/servicenow/db/models/ChatBotHistory.java
View file @
68031446
...
...
@@ -54,6 +54,7 @@ public class ChatBotHistory {
public
static
final
class
ChatBotBuilder
{
private
long
id
=
-
1
;
private
long
userId
;
private
String
userName
;
private
String
message
;
private
long
timestamp
;
...
...
@@ -74,6 +75,11 @@ public class ChatBotHistory {
return
this
;
}
public
ChatBotBuilder
setUserName
(
String
val
)
{
userName
=
val
;
return
this
;
}
public
ChatBotBuilder
setMessage
(
String
val
)
{
message
=
val
;
return
this
;
...
...
@@ -85,13 +91,14 @@ public class ChatBotHistory {
}
public
ChatBotBuilder
but
()
{
return
aChatBotHistory
().
setId
(
id
).
setUserId
(
userId
).
setMessage
(
message
).
setTimestamp
(
timestamp
);
return
aChatBotHistory
().
setId
(
id
).
setUserId
(
userId
).
set
UserName
(
userName
).
set
Message
(
message
).
setTimestamp
(
timestamp
);
}
public
ChatBotHistory
build
()
{
ChatBotHistory
chatBotHistory
=
new
ChatBotHistory
();
chatBotHistory
.
setId
(
id
);
chatBotHistory
.
setUserId
(
userId
);
chatBotHistory
.
setUserName
(
userName
);
chatBotHistory
.
setMessage
(
message
);
chatBotHistory
.
setTimestamp
(
timestamp
);
return
chatBotHistory
;
...
...
app/src/main/java/com/vsoft/servicenow/ui/ChatActivity.java
View file @
68031446
...
...
@@ -25,8 +25,7 @@ import com.github.nkzawa.socketio.client.Socket;
import
com.vsoft.servicenow.CatalogueApplication
;
import
com.vsoft.servicenow.R
;
import
com.vsoft.servicenow.api.managers.LoginApiManager
;
import
com.vsoft.servicenow.chat.Message
;
import
com.vsoft.servicenow.chat.MessageAdapter
;
import
com.vsoft.servicenow.adapters.ChatMessageAdapter
;
import
com.vsoft.servicenow.chat.Speaker
;
import
com.vsoft.servicenow.db.managers.ChatBotHistoryManager
;
import
com.vsoft.servicenow.db.managers.ChatBotUserManager
;
...
...
@@ -66,7 +65,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
private
RecyclerView
mMessagesView
;
private
EditText
mInputMessageView
;
private
List
<
Message
>
mMessages
=
new
ArrayList
<>();
private
List
<
ChatBotHistory
>
mMessages
=
new
ArrayList
<>();
private
RecyclerView
.
Adapter
mAdapter
;
private
String
mLoggedInUsername
;
private
String
mLoggedInUserSysId
;
...
...
@@ -139,14 +138,9 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
mMessagesView
=
(
RecyclerView
)
findViewById
(
R
.
id
.
messages
);
mMessagesView
.
setLayoutManager
(
new
LinearLayoutManager
(
this
));
List
<
ChatBotHistory
>
chatBotHistoryList
=
ChatBotHistoryManager
.
getAllChatBotHistory
();
for
(
int
i
=
0
;
i
<
chatBotHistoryList
.
size
();
i
++)
{
ChatBotHistory
chatBotHistory
=
chatBotHistoryList
.
get
(
i
);
mMessages
.
add
(
new
Message
.
Builder
(
Message
.
TYPE_MESSAGE
)
.
username
(
chatBotHistory
.
getUserName
()).
message
(
chatBotHistory
.
getMessage
()).
build
());
}
mAdapter
=
new
MessageAdapter
(
this
,
mMessages
);
/*Get all chats from local DB.*/
mMessages
=
ChatBotHistoryManager
.
getAllChatBotHistory
();
mAdapter
=
new
ChatMessageAdapter
(
this
,
mMessages
);
mMessagesView
.
setAdapter
(
mAdapter
);
scrollToBottom
();
...
...
@@ -213,6 +207,7 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
ChatBotHistory
chatBotHistory
=
ChatBotHistory
.
ChatBotBuilder
.
aChatBotHistory
()
.
setMessage
(
message
)
.
setUserId
(
userLocalId
)
.
setUserName
(
username
)
.
setTimestamp
(
System
.
currentTimeMillis
()).
build
();
ChatBotHistoryManager
.
save
(
chatBotHistory
);
...
...
@@ -224,9 +219,8 @@ public class ChatActivity extends HandleNotificationActivity implements OnDSList
speaker
.
allow
(
true
);
speaker
.
speak
(
message
);
}
mMessages
.
add
(
new
Message
.
Builder
(
Message
.
TYPE_MESSAGE
)
.
username
(
username
).
message
(
message
).
build
());
mMessages
.
add
(
chatBotHistory
);
mAdapter
.
notifyItemInserted
(
mMessages
.
size
()
-
1
);
scrollToBottom
();
}
...
...
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