Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
Terminal user interface- command line
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arjun Sundaram
Terminal user interface- command line
Commits
79099496
Commit
79099496
authored
9 years ago
by
Francesco Andreuzzi
Browse files
Options
Downloads
Patches
Plain Diff
created
parent
4472b414
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java
+124
-0
124 additions, 0 deletions
...a/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java
with
124 additions
and
0 deletions
app/src/main/java/ohi/andre/consolelauncher/tuils/SuggestionRunnable.java
0 → 100644
+
124
−
0
View file @
79099496
package
ohi.andre.consolelauncher.tuils
;
/*Copyright Francesco Andreuzzi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.HorizontalScrollView
;
import
android.widget.TextView
;
import
ohi.andre.consolelauncher.managers.SkinManager
;
import
ohi.andre.consolelauncher.managers.SuggestionsManager
;
public
class
SuggestionRunnable
implements
Runnable
{
private
ViewGroup
.
LayoutParams
suggestionViewParams
;
private
ViewGroup
suggestionsView
;
private
HorizontalScrollView
scrollView
;
private
Runnable
scrollRunnable
=
new
Runnable
()
{
@Override
public
void
run
()
{
scrollView
.
fullScroll
(
View
.
FOCUS_LEFT
);
}
};
private
int
n
;
private
TextView
[]
toRecycle
;
private
TextView
[]
toAdd
;
private
SuggestionsManager
.
Suggestion
[]
suggestions
;
private
SkinManager
skinManager
;
private
boolean
interrupted
;
public
SuggestionRunnable
(
SkinManager
skinManager
,
ViewGroup
suggestionsView
,
ViewGroup
.
LayoutParams
suggestionViewParams
,
HorizontalScrollView
parent
)
{
this
.
skinManager
=
skinManager
;
this
.
suggestionsView
=
suggestionsView
;
this
.
suggestionViewParams
=
suggestionViewParams
;
this
.
scrollView
=
parent
;
reset
();
}
public
void
setN
(
int
n
)
{
this
.
n
=
n
;
}
public
void
setToRecycle
(
TextView
[]
toRecycle
)
{
this
.
toRecycle
=
toRecycle
;
}
public
void
setToAdd
(
TextView
[]
toAdd
)
{
this
.
toAdd
=
toAdd
;
}
public
void
setSuggestions
(
SuggestionsManager
.
Suggestion
[]
suggestions
)
{
this
.
suggestions
=
suggestions
;
}
@Override
public
void
run
()
{
if
(
n
<
0
)
{
for
(
int
count
=
toRecycle
.
length
;
count
<
suggestionsView
.
getChildCount
();
count
++)
{
suggestionsView
.
removeViewAt
(
count
--);
}
}
if
(
interrupted
)
{
return
;
}
for
(
int
count
=
0
;
count
<
suggestions
.
length
;
count
++)
{
if
(
interrupted
)
{
return
;
}
String
s
=
suggestions
[
count
].
text
;
if
(
count
<
toRecycle
.
length
)
{
toRecycle
[
count
].
setId
(
suggestions
[
count
].
exec
?
SuggestionsManager
.
Suggestion
.
EXEC_ON_CLICK
:
SuggestionsManager
.
Suggestion
.
NONE
);
toRecycle
[
count
].
setText
(
s
);
toRecycle
[
count
].
setBackgroundDrawable
(
null
);
toRecycle
[
count
].
setBackgroundDrawable
(
skinManager
.
getSuggestionBg
(
suggestions
[
count
].
type
));
}
else
{
int
space
=
suggestions
.
length
-
(
count
+
1
);
if
(
toAdd
!=
null
&&
space
<
toAdd
.
length
)
{
toAdd
[
space
].
setId
(
suggestions
[
count
].
exec
?
SuggestionsManager
.
Suggestion
.
EXEC_ON_CLICK
:
SuggestionsManager
.
Suggestion
.
NONE
);
toAdd
[
space
].
setText
(
s
);
toAdd
[
space
].
setBackgroundDrawable
(
skinManager
.
getSuggestionBg
(
suggestions
[
count
].
type
));
if
(
toAdd
[
space
].
getParent
()
==
null
)
{
suggestionsView
.
addView
(
toAdd
[
space
],
suggestionViewParams
);
}
else
{
throw
new
UnsupportedOperationException
(
"view has a parent(?)"
);
}
}
else
{
throw
new
UnsupportedOperationException
(
"no views enough"
);
}
}
}
scrollView
.
post
(
scrollRunnable
);
}
public
void
interrupt
()
{
interrupted
=
true
;
}
public
void
reset
()
{
interrupted
=
false
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment