Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
W
wordbase-hacker
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PurkkaKoodari
wordbase-hacker
Commits
29b7abbc
Commit
29b7abbc
authored
Dec 24, 2015
by
PurkkaKoodari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change to swipe refresh
parent
fc9ef111
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
22 deletions
+38
-22
res/layout/activity_game_list.xml
res/layout/activity_game_list.xml
+3
-2
res/menu/mainmenu.xml
res/menu/mainmenu.xml
+0
-6
src/net/pietu1998/wordbasehacker/GameListActivity.java
src/net/pietu1998/wordbasehacker/GameListActivity.java
+35
-14
No files found.
res/layout/activity_game_list.xml
View file @
29b7abbc
<
Linear
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
android.support.v4.widget.SwipeRefresh
Layout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:id=
"@+id/list_swipe"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
...
...
@@ -15,4 +16,4 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
</LinearLayout>
\ No newline at end of file
</android.support.v4.widget.SwipeRefreshLayout>
\ No newline at end of file
res/menu/mainmenu.xml
View file @
29b7abbc
...
...
@@ -25,12 +25,6 @@
android:title=
"@string/off_dev"
/>
</menu>
</item>
<item
android:id=
"@+id/miRefresh"
android:icon=
"@drawable/ic_menu_refresh"
android:showAsAction=
"always"
android:title=
"@string/refresh"
>
</item>
<item
android:id=
"@+id/miInfo"
android:icon=
"@drawable/ic_menu_info_details"
...
...
src/net/pietu1998/wordbasehacker/GameListActivity.java
View file @
29b7abbc
...
...
@@ -25,6 +25,7 @@ import android.database.sqlite.SQLiteDatabase;
import
android.database.sqlite.SQLiteException
;
import
android.os.AsyncTask
;
import
android.os.Bundle
;
import
android.support.v4.widget.SwipeRefreshLayout
;
import
android.text.SpannableString
;
import
android.text.method.LinkMovementMethod
;
import
android.text.util.Linkify
;
...
...
@@ -43,7 +44,8 @@ public class GameListActivity extends ListActivity {
private
ArrayAdapter
<
Game
>
adapter
;
private
List
<
Game
>
games
=
new
ArrayList
<>();
private
boolean
loading
=
false
;;
private
boolean
loading
=
false
;
private
SwipeRefreshLayout
swipe
=
null
;
@SuppressLint
(
"SdCardPath"
)
public
static
final
String
WORDBASE_DB_PATH
=
"/data/data/com.wordbaseapp/databases/wordbase.db"
;
...
...
@@ -52,6 +54,15 @@ public class GameListActivity extends ListActivity {
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_game_list
);
swipe
=
(
SwipeRefreshLayout
)
findViewById
(
R
.
id
.
list_swipe
);
swipe
.
setOnRefreshListener
(
new
SwipeRefreshLayout
.
OnRefreshListener
()
{
@Override
public
void
onRefresh
()
{
loadData
(
true
);
}
});
adapter
=
new
ArrayAdapter
<>(
this
,
android
.
R
.
layout
.
simple_list_item_1
,
games
);
setListAdapter
(
adapter
);
getActionBar
().
setTitle
(
R
.
string
.
choose_game
);
...
...
@@ -69,7 +80,7 @@ public class GameListActivity extends ListActivity {
protected
void
onStart
()
{
super
.
onStart
();
invalidateOptionsMenu
();
loadData
();
loadData
(
false
);
}
@Override
...
...
@@ -88,12 +99,12 @@ public class GameListActivity extends ListActivity {
@SuppressLint
(
"InflateParams"
)
public
boolean
onOptionsItemSelected
(
MenuItem
item
)
{
switch
(
item
.
getItemId
())
{
case
R
.
id
.
miRefresh
:
loadData
();
return
true
;
case
R
.
id
.
miInfo
:
try
{
String
version
=
getPackageManager
().
getPackageInfo
(
getPackageName
(),
0
).
versionName
;
if
(
BuildConfig
.
DEBUG
)
{
version
+=
" (debug build)"
;
}
String
aboutText
=
getResources
().
getString
(
R
.
string
.
about_text
,
version
);
SpannableString
spannable
=
new
SpannableString
(
aboutText
);
Linkify
.
addLinks
(
spannable
,
Pattern
.
compile
(
"https?://[\u0021-\u007e]+"
),
"http://"
);
...
...
@@ -129,7 +140,7 @@ public class GameListActivity extends ListActivity {
if
(
editText
.
length
()
!=
0
)
{
getSharedPreferences
(
"WordbaseHacker"
,
0
).
edit
().
putString
(
"db"
,
editText
.
getText
().
toString
())
.
commit
();
loadData
();
loadData
(
true
);
}
}
});
...
...
@@ -137,7 +148,7 @@ public class GameListActivity extends ListActivity {
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
getSharedPreferences
(
"WordbaseHacker"
,
0
).
edit
().
putString
(
"db"
,
WORDBASE_DB_PATH
).
commit
();
loadData
();
loadData
(
true
);
}
});
dialog
.
show
();
...
...
@@ -155,14 +166,19 @@ public class GameListActivity extends ListActivity {
}
}
private
void
loadData
()
{
private
void
loadData
(
boolean
background
)
{
if
(
loading
)
return
;
loading
=
true
;
ProgressDialog
dialog
=
new
ProgressDialog
(
this
);
dialog
.
setProgressStyle
(
ProgressDialog
.
STYLE_SPINNER
);
dialog
.
setCancelable
(
false
);
dialog
.
show
();
ProgressDialog
dialog
=
null
;
if
(
background
)
{
swipe
.
setRefreshing
(
true
);
}
else
{
dialog
=
new
ProgressDialog
(
this
);
dialog
.
setProgressStyle
(
ProgressDialog
.
STYLE_SPINNER
);
dialog
.
setCancelable
(
false
);
dialog
.
show
();
}
AcquireDatabaseTask
task
=
new
AcquireDatabaseTask
(
getSharedPreferences
(
"WordbaseHacker"
,
0
).
getString
(
"db"
,
WORDBASE_DB_PATH
),
dialog
);
task
.
execute
();
...
...
@@ -262,12 +278,17 @@ public class GameListActivity extends ListActivity {
@Override
protected
void
onProgressUpdate
(
Integer
...
values
)
{
dialog
.
setMessage
(
getResources
().
getString
(
values
[
0
]));
if
(
dialog
!=
null
)
{
dialog
.
setMessage
(
getResources
().
getString
(
values
[
0
]));
}
}
@Override
protected
void
onPostExecute
(
Integer
result
)
{
dialog
.
dismiss
();
if
(
dialog
!=
null
)
{
dialog
.
dismiss
();
}
swipe
.
setRefreshing
(
false
);
if
(
result
!=
0
)
{
new
AlertDialog
.
Builder
(
GameListActivity
.
this
).
setMessage
(
result
)
.
setNeutralButton
(
R
.
string
.
ok
,
new
DialogInterface
.
OnClickListener
()
{
...
...
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