Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xabber-android
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
xabber-android
Commits
5535f0fa
Commit
5535f0fa
authored
Mar 04, 2015
by
Grigory Fedorov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chat scroll indicator added as first simple implementation.
parent
bd8c40df
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
120 additions
and
2 deletions
+120
-2
ChatViewer.java
app/src/main/java/com/xabber/android/ui/ChatViewer.java
+12
-0
ChatScrollIndicatorAdapter.java
...xabber/android/ui/adapter/ChatScrollIndicatorAdapter.java
+59
-0
ChatViewerAdapter.java
...java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+2
-1
activity_chat_viewer.xml
app/src/main/res/layout/activity_chat_viewer.xml
+20
-1
chat_scroll_indicator_item.xml
app/src/main/res/layout/chat_scroll_indicator_item.xml
+27
-0
No files found.
app/src/main/java/com/xabber/android/ui/ChatViewer.java
View file @
5535f0fa
...
...
@@ -27,6 +27,7 @@ import android.view.MenuItem;
import
android.view.View
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
import
com.xabber.android.data.ActivityManager
;
import
com.xabber.android.data.Application
;
...
...
@@ -50,6 +51,7 @@ import com.xabber.android.data.notification.NotificationManager;
import
com.xabber.android.data.roster.AbstractContact
;
import
com.xabber.android.data.roster.OnContactChangedListener
;
import
com.xabber.android.data.roster.RosterManager
;
import
com.xabber.android.ui.adapter.ChatScrollIndicatorAdapter
;
import
com.xabber.android.ui.adapter.ChatViewerAdapter
;
import
com.xabber.android.ui.dialog.ChatExportDialogFragment
;
import
com.xabber.android.ui.helper.ContactTitleActionBarInflater
;
...
...
@@ -85,6 +87,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
private
String
extraText
=
null
;
ChatScrollIndicatorAdapter
chatScrollIndicatorAdapter
;
ChatViewerAdapter
chatViewerAdapter
;
ViewPager
viewPager
;
...
...
@@ -144,6 +147,10 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
isChatSelected
=
false
;
}
chatScrollIndicatorAdapter
=
new
ChatScrollIndicatorAdapter
(
this
,
(
LinearLayout
)
findViewById
(
R
.
id
.
chat_scroll_indicator
));
chatScrollIndicatorAdapter
.
update
(
chatViewerAdapter
.
getRealCount
());
viewPager
=
(
ViewPager
)
findViewById
(
R
.
id
.
pager
);
viewPager
.
setAdapter
(
chatViewerAdapter
);
viewPager
.
setOnPageChangeListener
(
this
);
...
...
@@ -284,6 +291,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return
;
chatViewerAdapter
.
updateChats
();
chatScrollIndicatorAdapter
.
update
(
chatViewerAdapter
.
getRealCount
());
String
account
=
getAccount
(
intent
);
String
user
=
getUser
(
intent
);
...
...
@@ -292,6 +300,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
selectPage
(
account
,
user
,
false
);
}
@Override
...
...
@@ -539,6 +548,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
if
(
chatViewerAdapter
.
updateChats
())
{
selectPage
(
currentAccount
,
currentUser
,
false
);
chatScrollIndicatorAdapter
.
update
(
chatViewerAdapter
.
getRealCount
());
}
else
{
updateRegisteredChats
();
updateRegisteredRecentChatsFragments
();
...
...
@@ -605,6 +616,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
hideKeyboard
(
this
);
AbstractChat
selectedChat
=
chatViewerAdapter
.
getChatByPageNumber
(
position
);
chatScrollIndicatorAdapter
.
select
(
chatViewerAdapter
.
getRealPagePosition
(
position
));
isChatSelected
=
selectedChat
!=
null
;
...
...
app/src/main/java/com/xabber/android/ui/adapter/ChatScrollIndicatorAdapter.java
0 → 100644
View file @
5535f0fa
package
com
.
xabber
.
android
.
ui
.
adapter
;
import
android.app.Activity
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.LinearLayout
;
import
com.xabber.androiddev.R
;
public
class
ChatScrollIndicatorAdapter
{
private
final
Activity
activity
;
private
final
LinearLayout
linearLayout
;
public
ChatScrollIndicatorAdapter
(
Activity
activity
,
LinearLayout
linearLayout
)
{
this
.
activity
=
activity
;
this
.
linearLayout
=
linearLayout
;
}
public
void
select
(
int
selectedPosition
)
{
for
(
int
index
=
0
;
index
<
linearLayout
.
getChildCount
();
index
++)
{
final
View
view
=
linearLayout
.
getChildAt
(
index
);
final
AccountViewHolder
accountViewHolder
=
(
AccountViewHolder
)
view
.
getTag
();
accountViewHolder
.
selection
.
setVisibility
(
index
==
selectedPosition
?
View
.
VISIBLE
:
View
.
GONE
);
accountViewHolder
.
body
.
setVisibility
(
index
==
selectedPosition
?
View
.
GONE
:
View
.
VISIBLE
);
}
}
public
void
update
(
int
size
)
{
final
LayoutInflater
inflater
=
(
LayoutInflater
)
activity
.
getSystemService
(
Activity
.
LAYOUT_INFLATER_SERVICE
);
while
(
linearLayout
.
getChildCount
()
<
size
)
{
final
View
view
=
inflater
.
inflate
(
R
.
layout
.
chat_scroll_indicator_item
,
linearLayout
,
false
);
linearLayout
.
addView
(
view
);
final
AccountViewHolder
accountViewHolder
=
new
AccountViewHolder
(
view
);
accountViewHolder
.
body
.
getBackground
().
setAlpha
(
127
);
accountViewHolder
.
selection
.
getBackground
().
setAlpha
(
127
);
view
.
setTag
(
accountViewHolder
);
}
while
(
linearLayout
.
getChildCount
()
>
size
)
{
linearLayout
.
removeViewAt
(
size
);
}
}
private
static
class
AccountViewHolder
{
final
View
body
;
final
View
selection
;
public
AccountViewHolder
(
View
view
)
{
body
=
view
.
findViewById
(
R
.
id
.
indicator_item_body
);
selection
=
view
.
findViewById
(
R
.
id
.
indicator_item_selection
);
}
}
}
app/src/main/java/com/xabber/android/ui/adapter/ChatViewerAdapter.java
View file @
5535f0fa
...
...
@@ -144,7 +144,7 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
}
p
rivate
int
getRealPagePosition
(
int
virtualPosition
)
{
p
ublic
int
getRealPagePosition
(
int
virtualPosition
)
{
int
realCount
=
getRealCount
();
int
pageNumber
=
abs
(
virtualPosition
-
OFFSET
)
%
realCount
;
...
...
@@ -194,4 +194,5 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
public
Fragment
getCurrentFragment
()
{
return
currentFragment
;
}
}
\ No newline at end of file
app/src/main/res/layout/activity_chat_viewer.xml
View file @
5535f0fa
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android=
"http://schemas.android.com/apk/res/android"
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<android.support.v4.view.ViewPager
android:id=
"@+id/pager"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:orientation=
"horizontal"
android:layout_centerHorizontal=
"true"
android:layout_marginTop=
"16dp"
android:id=
"@+id/chat_scroll_indicator"
>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
app/src/main/res/layout/chat_scroll_indicator_item.xml
0 → 100644
View file @
5535f0fa
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
android:orientation=
"vertical"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginEnd=
"3dp"
android:layout_marginRight=
"3dp"
android:layout_marginLeft=
"3dp"
android:layout_marginStart=
"3dp"
>
<ImageView
android:id=
"@+id/indicator_item_body"
android:layout_width=
"8dp"
android:layout_height=
"8dp"
android:layout_margin=
"3dp"
android:background=
"@color/grey_500"
/>
<View
android:id=
"@+id/indicator_item_selection"
android:layout_width=
"14dp"
android:layout_height=
"14dp"
android:background=
"@color/grey_500"
android:visibility=
"gone"
/>
</RelativeLayout>
\ 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