Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
57e171b3
Kaydet (Commit)
57e171b3
authored
Eyl 14, 2013
tarafından
Artur Dryomov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Change the computers fragment to be more simple.
Change-Id: I8acddd744e11aa3c29ba281b321a4e02347a1823
üst
a703824a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
91 deletions
+71
-91
fragment_computers_list.xml
android/sdremote/res/layout/fragment_computers_list.xml
+1
-1
ComputersFragment.java
...libreoffice/impressremote/fragment/ComputersFragment.java
+70
-90
No files found.
android/sdremote/res/layout/fragment_computers_list.xml
Dosyayı görüntüle @
57e171b3
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
<LinearLayout
<LinearLayout
android:animateLayoutChanges=
"true"
android:animateLayoutChanges=
"true"
android:id=
"@+id/
container
_progress"
android:id=
"@+id/
layout
_progress"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:gravity=
"center"
android:gravity=
"center"
android:paddingLeft=
"@dimen/padding_horizontal_progress_layout"
android:paddingLeft=
"@dimen/padding_horizontal_progress_layout"
...
...
android/sdremote/src/org/libreoffice/impressremote/fragment/ComputersFragment.java
Dosyayı görüntüle @
57e171b3
...
@@ -52,8 +52,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -52,8 +52,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
WIFI
,
BLUETOOTH
WIFI
,
BLUETOOTH
}
}
private
Type
mType
;
private
CommunicationService
mCommunicationService
;
private
CommunicationService
mCommunicationService
;
private
BroadcastReceiver
mIntentsReceiver
;
private
BroadcastReceiver
mIntentsReceiver
;
...
@@ -77,8 +75,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -77,8 +75,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
public
void
onCreate
(
Bundle
aSavedInstanceState
)
{
public
void
onCreate
(
Bundle
aSavedInstanceState
)
{
super
.
onCreate
(
aSavedInstanceState
);
super
.
onCreate
(
aSavedInstanceState
);
mType
=
(
Type
)
getArguments
().
getSerializable
(
Fragments
.
Arguments
.
TYPE
);
setUpActionBar
();
setUpActionBar
();
}
}
...
@@ -95,13 +91,17 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -95,13 +91,17 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
public
void
onViewStateRestored
(
Bundle
aSavedInstanceState
)
{
public
void
onViewStateRestored
(
Bundle
aSavedInstanceState
)
{
super
.
onViewStateRestored
(
aSavedInstanceState
);
super
.
onViewStateRestored
(
aSavedInstanceState
);
if
(
aSavedInstanceState
==
null
)
{
if
(
!
isSavedInstanceValid
(
aSavedInstanceState
)
)
{
return
;
return
;
}
}
loadProgressMessage
(
aSavedInstanceState
);
loadProgressMessage
(
aSavedInstanceState
);
}
}
private
boolean
isSavedInstanceValid
(
Bundle
aSavedInstanceState
)
{
return
aSavedInstanceState
!=
null
;
}
private
void
loadProgressMessage
(
Bundle
aSavedInstanceState
)
{
private
void
loadProgressMessage
(
Bundle
aSavedInstanceState
)
{
boolean
aProgressMessageDisplayed
=
aSavedInstanceState
.
getBoolean
(
SavedStates
.
Keys
.
PROGRESS_MESSAGE
);
boolean
aProgressMessageDisplayed
=
aSavedInstanceState
.
getBoolean
(
SavedStates
.
Keys
.
PROGRESS_MESSAGE
);
...
@@ -110,6 +110,37 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -110,6 +110,37 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
}
}
}
}
private
void
showProgressMessage
()
{
TextView
aProgressMessageView
=
getProgressMessageView
();
Animation
aFadeInAnimation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
android
.
R
.
anim
.
fade_in
);
aProgressMessageView
.
setText
(
getProgressMessage
());
aProgressMessageView
.
startAnimation
(
aFadeInAnimation
);
aProgressMessageView
.
setVisibility
(
View
.
VISIBLE
);
}
private
TextView
getProgressMessageView
()
{
return
(
TextView
)
getView
().
findViewById
(
R
.
id
.
text_progress_message
);
}
private
String
getProgressMessage
()
{
switch
(
getType
())
{
case
WIFI:
return
getString
(
R
.
string
.
message_search_wifi
);
case
BLUETOOTH:
return
getString
(
R
.
string
.
message_search_bluetooth
);
default
:
return
""
;
}
}
private
Type
getType
()
{
return
(
Type
)
getArguments
().
getSerializable
(
Fragments
.
Arguments
.
TYPE
);
}
@Override
@Override
public
void
onActivityCreated
(
Bundle
aSavedInstanceState
)
{
public
void
onActivityCreated
(
Bundle
aSavedInstanceState
)
{
super
.
onActivityCreated
(
aSavedInstanceState
);
super
.
onActivityCreated
(
aSavedInstanceState
);
...
@@ -132,22 +163,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -132,22 +163,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
}
}
private
void
startComputersSearch
()
{
private
void
startComputersSearch
()
{
if
(!
isServiceBound
())
{
return
;
}
mCommunicationService
.
startServersSearch
();
mCommunicationService
.
startServersSearch
();
}
}
private
boolean
isServiceBound
()
{
return
mCommunicationService
!=
null
;
}
private
void
loadComputers
()
{
private
void
loadComputers
()
{
if
(!
isServiceBound
())
{
return
;
}
if
(
getComputers
().
isEmpty
())
{
if
(
getComputers
().
isEmpty
())
{
hideComputersList
();
hideComputersList
();
setUpProgressMessage
();
setUpProgressMessage
();
...
@@ -173,7 +192,7 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -173,7 +192,7 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
}
}
private
boolean
isComputerSupportsRequiredType
(
Server
aComputer
)
{
private
boolean
isComputerSupportsRequiredType
(
Server
aComputer
)
{
switch
(
mType
)
{
switch
(
getType
()
)
{
case
WIFI:
case
WIFI:
return
aComputer
.
getProtocol
()
==
Server
.
Protocol
.
TCP
;
return
aComputer
.
getProtocol
()
==
Server
.
Protocol
.
TCP
;
...
@@ -186,28 +205,18 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -186,28 +205,18 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
}
}
private
void
hideComputersList
()
{
private
void
hideComputersList
()
{
s
howView
(
getProgressBarLayout
()
);
s
etCurrentView
(
R
.
id
.
layout_progress
);
}
}
private
void
showView
(
View
aView
)
{
private
void
setCurrentView
(
int
aViewId
)
{
ViewAnimator
aViewAnimator
=
getViewAnimator
();
ViewAnimator
aViewAnimator
=
(
ViewAnimator
)
getView
().
findViewById
(
R
.
id
.
view_animator
);
View
aView
=
getView
().
findViewById
(
aViewId
);
int
aViewIndex
=
aViewAnimator
.
indexOfChild
(
aView
);
int
aCurrentViewIndex
=
aViewAnimator
.
getDisplayedChild
();
if
(
aViewI
ndex
==
aCurrentViewIndex
)
{
if
(
aViewI
d
==
aViewAnimator
.
getCurrentView
().
getId
()
)
{
return
;
return
;
}
}
aViewAnimator
.
setDisplayedChild
(
aViewIndex
);
aViewAnimator
.
setDisplayedChild
(
aViewAnimator
.
indexOfChild
(
aView
));
}
private
ViewAnimator
getViewAnimator
()
{
return
(
ViewAnimator
)
getView
().
findViewById
(
R
.
id
.
view_animator
);
}
private
ViewGroup
getProgressBarLayout
()
{
return
(
ViewGroup
)
getView
().
findViewById
(
R
.
id
.
container_progress
);
}
}
private
void
setUpProgressMessage
()
{
private
void
setUpProgressMessage
()
{
...
@@ -216,58 +225,21 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -216,58 +225,21 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
@Override
@Override
public
void
run
()
{
public
void
run
()
{
if
(!
is
Add
ed
())
{
if
(!
is
ShowingProgressMessageRequir
ed
())
{
return
;
return
;
}
}
if
(
isShowingProgressMessageRequired
())
{
showProgressMessage
();
showProgressMessage
();
}
}
}
private
boolean
isShowingProgressMessageRequired
()
{
private
boolean
isShowingProgressMessageRequired
()
{
return
getProgressMessageView
().
getVisibility
()
==
View
.
INVISIBLE
;
return
getProgressMessageView
().
getVisibility
()
==
View
.
INVISIBLE
;
}
}
private
TextView
getProgressMessageView
()
{
return
(
TextView
)
getView
().
findViewById
(
R
.
id
.
text_progress_message
);
}
private
void
showProgressMessage
()
{
TextView
aProgressMessageView
=
getProgressMessageView
();
Animation
aFadeInAnimation
=
AnimationUtils
.
loadAnimation
(
getActivity
(),
android
.
R
.
anim
.
fade_in
);
aProgressMessageView
.
setText
(
getProgressMessage
());
aProgressMessageView
.
startAnimation
(
aFadeInAnimation
);
aProgressMessageView
.
setVisibility
(
View
.
VISIBLE
);
}
private
String
getProgressMessage
()
{
switch
(
mType
)
{
case
WIFI:
return
getString
(
R
.
string
.
message_search_wifi
);
case
BLUETOOTH:
return
getString
(
R
.
string
.
message_search_bluetooth
);
default
:
return
""
;
}
}
private
void
tearDownComputersAdapter
()
{
private
void
tearDownComputersAdapter
()
{
setListAdapter
(
null
);
setListAdapter
(
null
);
}
}
private
void
showComputersList
()
{
showView
(
getComputersList
());
}
private
ListView
getComputersList
()
{
return
(
ListView
)
getView
().
findViewById
(
android
.
R
.
id
.
list
);
}
private
void
setUpComputersAdapter
()
{
private
void
setUpComputersAdapter
()
{
if
(
isComputersAdapterExist
())
{
if
(
isComputersAdapterExist
())
{
return
;
return
;
...
@@ -289,6 +261,15 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -289,6 +261,15 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
getComputersAdapter
().
add
(
getComputers
());
getComputersAdapter
().
add
(
getComputers
());
}
}
private
void
showComputersList
()
{
setCurrentView
(
android
.
R
.
id
.
list
);
}
@Override
public
void
onServiceDisconnected
(
ComponentName
aComponentName
)
{
mCommunicationService
=
null
;
}
@Override
@Override
public
void
onStart
()
{
public
void
onStart
()
{
super
.
onStart
();
super
.
onStart
();
...
@@ -296,6 +277,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -296,6 +277,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
registerIntentsReceiver
();
registerIntentsReceiver
();
setUpContextMenu
();
setUpContextMenu
();
if
(!
isServiceBound
())
{
return
;
}
startComputersSearch
();
startComputersSearch
();
loadComputers
();
loadComputers
();
}
}
...
@@ -380,6 +365,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -380,6 +365,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
LocalBroadcastManager
.
getInstance
(
getActivity
()).
sendBroadcast
(
aIntent
);
LocalBroadcastManager
.
getInstance
(
getActivity
()).
sendBroadcast
(
aIntent
);
}
}
private
boolean
isServiceBound
()
{
return
mCommunicationService
!=
null
;
}
@Override
@Override
public
boolean
onOptionsItemSelected
(
MenuItem
aMenuItem
)
{
public
boolean
onOptionsItemSelected
(
MenuItem
aMenuItem
)
{
switch
(
aMenuItem
.
getItemId
())
{
switch
(
aMenuItem
.
getItemId
())
{
...
@@ -425,6 +414,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -425,6 +414,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
public
void
onListItemClick
(
ListView
aListView
,
View
aView
,
int
aPosition
,
long
aId
)
{
public
void
onListItemClick
(
ListView
aListView
,
View
aView
,
int
aPosition
,
long
aId
)
{
Server
aComputer
=
getComputersAdapter
().
getItem
(
aPosition
);
Server
aComputer
=
getComputersAdapter
().
getItem
(
aPosition
);
startConnectionActivity
(
aComputer
);
}
private
void
startConnectionActivity
(
Server
aComputer
)
{
Intent
aIntent
=
Intents
.
buildComputerConnectionIntent
(
getActivity
(),
aComputer
);
Intent
aIntent
=
Intents
.
buildComputerConnectionIntent
(
getActivity
(),
aComputer
);
startActivity
(
aIntent
);
startActivity
(
aIntent
);
}
}
...
@@ -438,6 +431,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -438,6 +431,10 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
unregisterIntentsReceiver
();
unregisterIntentsReceiver
();
}
}
private
void
stopComputersSearch
()
{
mCommunicationService
.
stopServersSearch
();
}
private
void
unregisterIntentsReceiver
()
{
private
void
unregisterIntentsReceiver
()
{
try
{
try
{
getBroadcastManager
().
unregisterReceiver
(
mIntentsReceiver
);
getBroadcastManager
().
unregisterReceiver
(
mIntentsReceiver
);
...
@@ -447,14 +444,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -447,14 +444,6 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
}
}
}
}
private
void
stopComputersSearch
()
{
if
(!
isServiceBound
())
{
return
;
}
mCommunicationService
.
stopServersSearch
();
}
@Override
@Override
public
void
onSaveInstanceState
(
Bundle
aOutState
)
{
public
void
onSaveInstanceState
(
Bundle
aOutState
)
{
super
.
onSaveInstanceState
(
aOutState
);
super
.
onSaveInstanceState
(
aOutState
);
...
@@ -476,17 +465,8 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
...
@@ -476,17 +465,8 @@ public class ComputersFragment extends SherlockListFragment implements ServiceCo
}
}
private
void
unbindService
()
{
private
void
unbindService
()
{
if
(!
isServiceBound
())
{
return
;
}
getActivity
().
unbindService
(
this
);
getActivity
().
unbindService
(
this
);
}
}
@Override
public
void
onServiceDisconnected
(
ComponentName
aComponentName
)
{
mCommunicationService
=
null
;
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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