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
8dc9519f
Commit
8dc9519f
authored
May 29, 2013
by
Alexander Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move chat pages indicator to the chat viewer fragment.
parent
85852bcb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
94 deletions
+105
-94
ChatViewerFragment.java
src/com/xabber/android/ui/ChatViewerFragment.java
+72
-0
ChatViewerAdapter.java
src/com/xabber/android/ui/adapter/ChatViewerAdapter.java
+10
-0
SaveStateAdapter.java
src/com/xabber/android/ui/adapter/SaveStateAdapter.java
+14
-0
PageSwitcher.java
src/com/xabber/android/ui/widget/PageSwitcher.java
+9
-94
No files found.
src/com/xabber/android/ui/ChatViewerFragment.java
View file @
8dc9519f
package
com
.
xabber
.
android
.
ui
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.support.v4.app.FragmentActivity
;
import
android.text.Editable
;
import
android.text.TextWatcher
;
...
...
@@ -10,6 +11,7 @@ import android.view.View.OnClickListener;
import
android.view.View.OnKeyListener
;
import
android.view.ViewGroup
;
import
android.view.animation.Animation
;
import
android.view.animation.Animation.AnimationListener
;
import
android.view.animation.AnimationUtils
;
import
android.widget.EditText
;
import
android.widget.ImageView
;
...
...
@@ -35,6 +37,11 @@ import com.xabber.androiddev.R;
public
class
ChatViewerFragment
{
/**
* Delay before hide pages.
*/
private
static
final
long
PAGES_HIDDER_DELAY
=
1000
;
private
AbstractAvatarInflaterHelper
avatarInflaterHelper
;
private
Animation
shake
;
...
...
@@ -43,6 +50,29 @@ public class ChatViewerFragment {
private
ChatViewHolder
chatViewHolder
;
/**
* Whether pages are shown.
*/
private
boolean
pagesShown
;
private
Handler
handler
;
/**
* Animation used to hide pages.
*/
private
Animation
pagesHideAnimation
;
/**
* Runnable called to hide pages.
*/
private
final
Runnable
pagesHideRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
handler
.
removeCallbacks
(
this
);
chatViewHolder
.
page
.
startAnimation
(
pagesHideAnimation
);
}
};
private
final
FragmentActivity
activity
;
private
final
View
view
;
...
...
@@ -69,11 +99,31 @@ public class ChatViewerFragment {
// super.onCreate(savedInstanceState);
avatarInflaterHelper
=
AbstractAvatarInflaterHelper
.
createAbstractContactInflaterHelper
();
handler
=
new
Handler
();
pagesShown
=
false
;
}
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
shake
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
shake
);
pagesHideAnimation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
R
.
anim
.
chat_page_out
);
pagesHideAnimation
.
setAnimationListener
(
new
AnimationListener
()
{
@Override
public
void
onAnimationStart
(
Animation
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animation
animation
)
{
chatViewHolder
.
page
.
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onAnimationRepeat
(
Animation
animation
)
{
}
});
View
view
=
inflater
.
inflate
(
R
.
layout
.
chat_viewer_item
,
container
,
false
);
ChatMessageAdapter
chatMessageAdapter
=
new
ChatMessageAdapter
(
...
...
@@ -185,6 +235,28 @@ public class ChatViewerFragment {
chatViewHolder
.
chatMessageAdapter
.
onChange
();
}
/**
* Show pages.
*/
public
void
showPages
()
{
if
(
pagesShown
)
return
;
pagesShown
=
true
;
handler
.
removeCallbacks
(
pagesHideRunnable
);
chatViewHolder
.
page
.
clearAnimation
();
chatViewHolder
.
page
.
setVisibility
(
View
.
VISIBLE
);
}
/**
* Requests pages to be hiden in future.
*/
public
void
hidePages
()
{
if
(!
pagesShown
)
return
;
pagesShown
=
false
;
handler
.
postDelayed
(
pagesHideRunnable
,
PAGES_HIDDER_DELAY
);
}
private
static
class
ChatViewHolder
{
final
TextView
page
;
...
...
src/com/xabber/android/ui/adapter/ChatViewerAdapter.java
View file @
8dc9519f
...
...
@@ -103,6 +103,16 @@ public class ChatViewerAdapter extends BaseAdapter implements SaveStateAdapter,
((
ChatViewerFragment
)
view
.
getTag
()).
saveState
();
}
@Override
public
void
hidePages
(
View
view
)
{
((
ChatViewerFragment
)
view
.
getTag
()).
hidePages
();
}
@Override
public
void
showPages
(
View
view
)
{
((
ChatViewerFragment
)
view
.
getTag
()).
showPages
();
}
/**
* Must be called on changes in chat (message sent, received, etc.).
*/
...
...
src/com/xabber/android/ui/adapter/SaveStateAdapter.java
View file @
8dc9519f
...
...
@@ -36,4 +36,18 @@ public interface SaveStateAdapter extends Adapter {
*/
void
saveState
(
View
view
);
/**
* Requests to hide pages indicator.
*
* @param view
*/
void
hidePages
(
View
view
);
/**
* Show pages indicator.
*
* @param view
*/
void
showPages
(
View
view
);
}
src/com/xabber/android/ui/widget/PageSwitcher.java
View file @
8dc9519f
...
...
@@ -16,15 +16,11 @@ package com.xabber.android.ui.widget;
import
android.content.Context
;
import
android.database.DataSetObserver
;
import
android.os.Handler
;
import
android.util.AttributeSet
;
import
android.view.MotionEvent
;
import
android.view.View
;
import
android.view.ViewConfiguration
;
import
android.view.ViewGroup
;
import
android.view.animation.Animation
;
import
android.view.animation.Animation.AnimationListener
;
import
android.view.animation.AnimationUtils
;
import
android.widget.Adapter
;
import
android.widget.ListView
;
import
android.widget.Scroller
;
...
...
@@ -41,15 +37,10 @@ import com.xabber.androiddev.R;
* @author alexander.ivanov
*
*/
public
class
PageSwitcher
extends
ViewGroup
implements
AnimationListener
{
public
class
PageSwitcher
extends
ViewGroup
{
public
static
final
boolean
LOG
=
false
;
/**
* Delay before hide pages.
*/
private
static
final
long
PAGES_HIDDER_DELAY
=
1000
;
/**
* Distance a touch can wander before we think the user is scrolling.
*/
...
...
@@ -136,38 +127,6 @@ public class PageSwitcher extends ViewGroup implements AnimationListener {
*/
private
Object
previousVisibleObject
;
/**
* Animation used to hide pages.
*/
private
final
Animation
pagesHideAnimation
;
/**
* Runnable called to hide pages.
*/
private
final
Runnable
pagesHideRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
if
(
LOG
)
LogManager
.
i
(
this
,
"hide pages"
);
handler
.
removeCallbacks
(
this
);
if
(
selectedView
!=
null
)
selectedView
.
findViewById
(
R
.
id
.
chat_page
).
startAnimation
(
pagesHideAnimation
);
if
(
visibleView
!=
null
)
{
visibleView
.
findViewById
(
R
.
id
.
chat_page
).
setVisibility
(
View
.
GONE
);
visibleView
.
findViewById
(
R
.
id
.
chat_page
).
clearAnimation
();
}
}
};
/**
* Whether pages are shown.
*/
private
boolean
pagesShown
;
private
final
Handler
handler
;
public
PageSwitcher
(
Context
context
,
AttributeSet
attrs
)
{
super
(
context
,
attrs
);
touchSlop
=
ViewConfiguration
.
get
(
getContext
()).
getScaledTouchSlop
();
...
...
@@ -188,12 +147,6 @@ public class PageSwitcher extends ViewGroup implements AnimationListener {
visiblePosition
=
0
;
visibleView
=
null
;
previousVisibleObject
=
null
;
handler
=
new
Handler
();
pagesHideAnimation
=
AnimationUtils
.
loadAnimation
(
context
,
R
.
anim
.
chat_page_out
);
pagesHideAnimation
.
setAnimationListener
(
this
);
pagesShown
=
false
;
}
/**
...
...
@@ -529,11 +482,17 @@ public class PageSwitcher extends ViewGroup implements AnimationListener {
if
(
scrollX
==
0
)
{
if
(
LOG
)
LogManager
.
i
(
this
,
"Scroll X == 0"
);
hidePages
();
if
(
visibleView
!=
null
)
adapter
.
hidePages
(
visibleView
);
if
(
selectedView
!=
null
)
adapter
.
hidePages
(
selectedView
);
}
else
{
if
(
LOG
)
LogManager
.
i
(
this
,
"Scroll X != 0"
);
showPages
();
if
(
visibleView
!=
null
)
adapter
.
showPages
(
visibleView
);
if
(
selectedView
!=
null
)
adapter
.
showPages
(
selectedView
);
}
super
.
scrollTo
(
scrollX
,
0
);
...
...
@@ -541,36 +500,6 @@ public class PageSwitcher extends ViewGroup implements AnimationListener {
dataChanged
=
false
;
}
/**
* Show pages.
*/
private
void
showPages
()
{
if
(
pagesShown
)
return
;
pagesShown
=
true
;
handler
.
removeCallbacks
(
pagesHideRunnable
);
if
(
selectedView
!=
null
)
{
selectedView
.
findViewById
(
R
.
id
.
chat_page
).
clearAnimation
();
selectedView
.
findViewById
(
R
.
id
.
chat_page
).
setVisibility
(
View
.
VISIBLE
);
}
if
(
visibleView
!=
null
)
{
visibleView
.
findViewById
(
R
.
id
.
chat_page
).
clearAnimation
();
visibleView
.
findViewById
(
R
.
id
.
chat_page
)
.
setVisibility
(
View
.
VISIBLE
);
}
}
/**
* Requests pages to be hiden in future.
*/
private
void
hidePages
()
{
if
(!
pagesShown
)
return
;
pagesShown
=
false
;
handler
.
postDelayed
(
pagesHideRunnable
,
PAGES_HIDDER_DELAY
);
}
/**
* Save state of views. Must be called on activity pause.
*/
...
...
@@ -739,20 +668,6 @@ public class PageSwitcher extends ViewGroup implements AnimationListener {
update
(
false
);
}
@Override
public
void
onAnimationStart
(
Animation
animation
)
{
}
@Override
public
void
onAnimationEnd
(
Animation
animation
)
{
if
(
selectedView
!=
null
)
selectedView
.
findViewById
(
R
.
id
.
chat_page
).
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onAnimationRepeat
(
Animation
animation
)
{
}
public
interface
OnSelectListener
{
/**
...
...
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