mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-05 20:45:49 +01:00
add interface with method that's called whenever a DB record is saved.
GamesList implements that interface and invalidates the list item corresponding so it'll get redrawn with updated info. Should allow to replace m_invalPath but doesn't...
This commit is contained in:
parent
f75318e9d0
commit
030d2e76a7
2 changed files with 41 additions and 2 deletions
|
@ -35,6 +35,12 @@ import org.eehouse.android.xw4.jni.*;
|
||||||
|
|
||||||
public class DBUtils {
|
public class DBUtils {
|
||||||
|
|
||||||
|
public static interface DBChangeListener {
|
||||||
|
public void pathSaved( String path );
|
||||||
|
}
|
||||||
|
private static DBChangeListener[] s_listeners =
|
||||||
|
new DBChangeListener[]{ null };
|
||||||
|
|
||||||
private static SQLiteOpenHelper s_dbHelper = null;
|
private static SQLiteOpenHelper s_dbHelper = null;
|
||||||
|
|
||||||
public static class Obit {
|
public static class Obit {
|
||||||
|
@ -213,6 +219,7 @@ public class DBUtils {
|
||||||
values, selection, null );
|
values, selection, null );
|
||||||
Assert.assertTrue( result >= 0 );
|
Assert.assertTrue( result >= 0 );
|
||||||
}
|
}
|
||||||
|
notifyListeners( path );
|
||||||
db.close();
|
db.close();
|
||||||
}
|
}
|
||||||
} // saveSummary
|
} // saveSummary
|
||||||
|
@ -250,6 +257,7 @@ public class DBUtils {
|
||||||
values, selection, null );
|
values, selection, null );
|
||||||
Assert.assertTrue( result == 1 );
|
Assert.assertTrue( result == 1 );
|
||||||
db.close();
|
db.close();
|
||||||
|
notifyListeners( path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,6 +441,7 @@ public class DBUtils {
|
||||||
Assert.assertTrue( row >= 0 );
|
Assert.assertTrue( row >= 0 );
|
||||||
}
|
}
|
||||||
db.close();
|
db.close();
|
||||||
|
notifyListeners( path );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,6 +568,14 @@ public class DBUtils {
|
||||||
saveChatHistory( context, path, null );
|
saveChatHistory( context, path, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setDBChangeListener( DBChangeListener listener )
|
||||||
|
{
|
||||||
|
synchronized( s_listeners ) {
|
||||||
|
Assert.assertTrue( listener != s_listeners[0] );
|
||||||
|
s_listeners[0] = listener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void saveChatHistory( Context context, String path,
|
private static void saveChatHistory( Context context, String path,
|
||||||
String history )
|
String history )
|
||||||
{
|
{
|
||||||
|
@ -615,4 +632,13 @@ public class DBUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void notifyListeners( String path )
|
||||||
|
{
|
||||||
|
synchronized( s_listeners ) {
|
||||||
|
if ( null != s_listeners[0] ) {
|
||||||
|
s_listeners[0].pathSaved( path );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ import org.eehouse.android.xw4.jni.*;
|
||||||
|
|
||||||
public class GamesList extends XWListActivity
|
public class GamesList extends XWListActivity
|
||||||
implements DispatchNotify.HandleRelaysIface,
|
implements DispatchNotify.HandleRelaysIface,
|
||||||
RefreshMsgsTask.RefreshMsgsIface {
|
RefreshMsgsTask.RefreshMsgsIface,
|
||||||
|
DBUtils.DBChangeListener {
|
||||||
|
|
||||||
private static final int WARN_NODICT = DlgDelegate.DIALOG_LAST + 1;
|
private static final int WARN_NODICT = DlgDelegate.DIALOG_LAST + 1;
|
||||||
private static final int WARN_NODICT_SUBST = WARN_NODICT + 1;
|
private static final int WARN_NODICT_SUBST = WARN_NODICT + 1;
|
||||||
|
@ -236,6 +237,7 @@ public class GamesList extends XWListActivity
|
||||||
{
|
{
|
||||||
super.onStart();
|
super.onStart();
|
||||||
DispatchNotify.SetRelayIDsHandler( this );
|
DispatchNotify.SetRelayIDsHandler( this );
|
||||||
|
DBUtils.setDBChangeListener( this );
|
||||||
|
|
||||||
// TelephonyManager mgr =
|
// TelephonyManager mgr =
|
||||||
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
|
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
|
||||||
|
@ -251,7 +253,7 @@ public class GamesList extends XWListActivity
|
||||||
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
|
// (TelephonyManager)getSystemService( Context.TELEPHONY_SERVICE );
|
||||||
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
|
// mgr.listen( m_phoneStateListener, PhoneStateListener.LISTEN_NONE );
|
||||||
// m_phoneStateListener = null;
|
// m_phoneStateListener = null;
|
||||||
|
DBUtils.setDBChangeListener( null );
|
||||||
DispatchNotify.SetRelayIDsHandler( null );
|
DispatchNotify.SetRelayIDsHandler( null );
|
||||||
|
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
@ -273,6 +275,17 @@ public class GamesList extends XWListActivity
|
||||||
HandleRelaysIDs( relayIDs );
|
HandleRelaysIDs( relayIDs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DBUtils.DBChangeListener interface
|
||||||
|
public void pathSaved( final String path )
|
||||||
|
{
|
||||||
|
m_handler.post( new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
m_adapter.inval( path );
|
||||||
|
onContentChanged();
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWindowFocusChanged( boolean hasFocus )
|
public void onWindowFocusChanged( boolean hasFocus )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue