mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-22 07:28:16 +01:00
reformat to use GameWrapper; just reformat
This commit is contained in:
parent
7c75bd0da8
commit
f6af82e227
4 changed files with 34 additions and 37 deletions
|
@ -1539,10 +1539,10 @@ public class BoardDelegate extends DelegateBase
|
||||||
@Override
|
@Override
|
||||||
public void onStatusClicked()
|
public void onStatusClicked()
|
||||||
{
|
{
|
||||||
if ( BuildConfig.NON_RELEASE || XWPrefs.getDebugEnabled( m_activity ) ) {
|
if ( BuildConfig.NON_RELEASE || XWPrefs.getDebugEnabled(m_activity)) {
|
||||||
View view = findViewById( R.id.netstatus_view );
|
View view = findViewById( R.id.netstatus_view );
|
||||||
PopupMenu popup = new PopupMenu( m_activity, view );
|
PopupMenu popup = new PopupMenu( m_activity, view );
|
||||||
popup.getMenuInflater().inflate( R.menu.netstat, popup.getMenu() );
|
popup.getMenuInflater().inflate(R.menu.netstat, popup.getMenu());
|
||||||
|
|
||||||
if ( ! m_connTypes.contains(CommsConnType.COMMS_CONN_MQTT) ) {
|
if ( ! m_connTypes.contains(CommsConnType.COMMS_CONN_MQTT) ) {
|
||||||
popup.getMenu().removeItem( R.id.netstat_menu_traffic );
|
popup.getMenu().removeItem( R.id.netstat_menu_traffic );
|
||||||
|
@ -1562,7 +1562,8 @@ public class BoardDelegate extends DelegateBase
|
||||||
onStatusClicked( m_jniGamePtr );
|
onStatusClicked( m_jniGamePtr );
|
||||||
break;
|
break;
|
||||||
case R.id.netstat_menu_traffic:
|
case R.id.netstat_menu_traffic:
|
||||||
NetUtils.copyAndLaunchGamePage( m_activity, m_gi.gameID );
|
NetUtils.copyAndLaunchGamePage( m_activity,
|
||||||
|
m_gi.gameID );
|
||||||
break;
|
break;
|
||||||
case R.id.netstat_copyurl:
|
case R.id.netstat_copyurl:
|
||||||
NetUtils.gameURLToClip( m_activity, m_gi.gameID );
|
NetUtils.gameURLToClip( m_activity, m_gi.gameID );
|
||||||
|
@ -3016,17 +3017,14 @@ public class BoardDelegate extends DelegateBase
|
||||||
setupRematchFor( activity, gamePtr, summary, gi );
|
setupRematchFor( activity, gamePtr, summary, gi );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try ( GameLock lock = GameLock.tryLockRO( rowID ) ) {
|
try ( GameUtils.GameWrapper gw = GameUtils
|
||||||
if ( null != lock ) {
|
.GameWrapper.make( activity, rowID ) ) {
|
||||||
summary = DBUtils.getSummary( activity, lock );
|
if ( null == gw ) {
|
||||||
gi = new CurGameInfo( activity );
|
|
||||||
try ( GamePtr gamePtr = GameUtils
|
|
||||||
.loadMakeGame( activity, gi, lock ) ) {
|
|
||||||
setupRematchFor( activity, gamePtr, summary, gi );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
DbgUtils.toastNoLock( TAG, activity, rowID,
|
DbgUtils.toastNoLock( TAG, activity, rowID,
|
||||||
"setupRematchFor(%d)", rowID );
|
"setupRematchFor(%d)", rowID );
|
||||||
|
} else {
|
||||||
|
summary = DBUtils.getSummary( activity, gw.getLock() );
|
||||||
|
setupRematchFor( activity, gw.gamePtr(), summary, gw.gi() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,9 @@ import android.widget.TextView;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Action;
|
import org.eehouse.android.xw4.DlgDelegate.Action;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.Builder;
|
import org.eehouse.android.xw4.DlgDelegate.Builder;
|
||||||
import org.eehouse.android.xw4.DlgDelegate.DlgClickNotify;
|
import org.eehouse.android.xw4.DlgDelegate.DlgClickNotify;
|
||||||
|
import org.eehouse.android.xw4.GameUtils.GameWrapper;
|
||||||
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
import org.eehouse.android.xw4.MultiService.MultiEvent;
|
||||||
|
import org.eehouse.android.xw4.Utils.ISOCode;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnType;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
import org.eehouse.android.xw4.jni.CommsAddrRec.CommsConnTypeSet;
|
||||||
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
import org.eehouse.android.xw4.jni.CommsAddrRec;
|
||||||
|
@ -51,7 +53,6 @@ import org.eehouse.android.xw4.jni.GameSummary;
|
||||||
import org.eehouse.android.xw4.jni.XwJNI.GamePtr;
|
import org.eehouse.android.xw4.jni.XwJNI.GamePtr;
|
||||||
import org.eehouse.android.xw4.jni.XwJNI;
|
import org.eehouse.android.xw4.jni.XwJNI;
|
||||||
import org.eehouse.android.xw4.loc.LocUtils;
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
import org.eehouse.android.xw4.Utils.ISOCode;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -661,7 +662,8 @@ public abstract class DelegateBase implements DlgClickNotify,
|
||||||
{
|
{
|
||||||
Context context = getActivity();
|
Context context = getActivity();
|
||||||
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( gamePtr );
|
CommsAddrRec[] addrs = XwJNI.comms_getAddrs( gamePtr );
|
||||||
CommsAddrRec addr = null != addrs && 0 < addrs.length ? addrs[0] : null;
|
CommsAddrRec addr = null != addrs && 0 < addrs.length
|
||||||
|
? addrs[0] : null;
|
||||||
final GameSummary summary = GameUtils
|
final GameSummary summary = GameUtils
|
||||||
.getSummary( context, gamePtr.getRowid(), 1 );
|
.getSummary( context, gamePtr.getRowid(), 1 );
|
||||||
if ( null != summary ) {
|
if ( null != summary ) {
|
||||||
|
@ -675,7 +677,8 @@ public abstract class DelegateBase implements DlgClickNotify,
|
||||||
if ( null == msg ) {
|
if ( null == msg ) {
|
||||||
askNoAddrsDelete();
|
askNoAddrsDelete();
|
||||||
} else {
|
} else {
|
||||||
showDialogFragment( DlgID.DLG_CONNSTAT, summary, msg );
|
showDialogFragment( DlgID.DLG_CONNSTAT, summary,
|
||||||
|
msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
|
@ -685,14 +688,10 @@ public abstract class DelegateBase implements DlgClickNotify,
|
||||||
public void onStatusClicked( long rowid )
|
public void onStatusClicked( long rowid )
|
||||||
{
|
{
|
||||||
Log.d( TAG, "onStatusClicked(%d)", rowid );
|
Log.d( TAG, "onStatusClicked(%d)", rowid );
|
||||||
try ( GameLock lock = GameLock.tryLockRO( rowid ) ) {
|
|
||||||
if ( null != lock ) {
|
try ( GameWrapper gw = GameWrapper.make(m_activity, rowid)) {
|
||||||
try ( GamePtr gamePtr = GameUtils
|
if ( null != gw ) {
|
||||||
.loadMakeGame( getActivity(), lock ) ) {
|
onStatusClicked( gw.gamePtr() );
|
||||||
if ( null != gamePtr ) {
|
|
||||||
onStatusClicked( gamePtr );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -446,10 +446,10 @@ public class GameUtils {
|
||||||
public static Bitmap loadMakeBitmap( Context context, long rowid )
|
public static Bitmap loadMakeBitmap( Context context, long rowid )
|
||||||
{
|
{
|
||||||
Bitmap thumb = null;
|
Bitmap thumb = null;
|
||||||
try ( GameWrapper gw = makeGameWrapper( context, rowid ) ) {
|
try ( GameWrapper gw = GameWrapper.make( context, rowid ) ) {
|
||||||
if ( null != gw ) {
|
if ( null != gw ) {
|
||||||
thumb = takeSnapshot( context, gw.gamePtr(), gw.gi() );
|
thumb = takeSnapshot( context, gw.gamePtr(), gw.gi() );
|
||||||
DBUtils.saveThumbnail( context, gw.lock(), thumb );
|
DBUtils.saveThumbnail( context, gw.getLock(), thumb );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return thumb;
|
return thumb;
|
||||||
|
@ -575,7 +575,7 @@ public class GameUtils {
|
||||||
private GamePtr mGamePtr;
|
private GamePtr mGamePtr;
|
||||||
private CurGameInfo mGi;
|
private CurGameInfo mGi;
|
||||||
|
|
||||||
GameWrapper( Context context, long rowid )
|
private GameWrapper( Context context, long rowid )
|
||||||
{
|
{
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mLock = GameLock.tryLockRO( rowid );
|
mLock = GameLock.tryLockRO( rowid );
|
||||||
|
@ -586,7 +586,7 @@ public class GameUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public GamePtr gamePtr() { return mGamePtr; }
|
public GamePtr gamePtr() { return mGamePtr; }
|
||||||
public GameLock lock() { return mLock; }
|
public GameLock getLock() { return mLock; }
|
||||||
public CurGameInfo gi() { return mGi; }
|
public CurGameInfo gi() { return mGi; }
|
||||||
public boolean hasGame() { return null != mGamePtr; }
|
public boolean hasGame() { return null != mGamePtr; }
|
||||||
|
|
||||||
|
@ -608,16 +608,16 @@ public class GameUtils {
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static GameWrapper makeGameWrapper( Context context, long rowid )
|
public static GameWrapper make( Context context, long rowid )
|
||||||
{
|
{
|
||||||
GameWrapper result = new GameWrapper( context, rowid );
|
GameWrapper result = new GameWrapper( context, rowid );
|
||||||
if ( !result.hasGame() ) {
|
if ( !result.hasGame() ) {
|
||||||
result.close();
|
result.close();
|
||||||
result = null;
|
result = null;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long makeRematch( Context context, long srcRowid,
|
public static long makeRematch( Context context, long srcRowid,
|
||||||
|
@ -625,7 +625,7 @@ public class GameUtils {
|
||||||
int[] newOrder )
|
int[] newOrder )
|
||||||
{
|
{
|
||||||
long rowid = DBUtils.ROWID_NOTFOUND;
|
long rowid = DBUtils.ROWID_NOTFOUND;
|
||||||
try ( GameWrapper gw = makeGameWrapper( context, srcRowid ) ) {
|
try ( GameWrapper gw = GameWrapper.make( context, srcRowid ) ) {
|
||||||
if ( null != gw ) {
|
if ( null != gw ) {
|
||||||
UtilCtxt util = new UtilCtxtImpl( context );
|
UtilCtxt util = new UtilCtxtImpl( context );
|
||||||
CommonPrefs cp = CommonPrefs.get( context );
|
CommonPrefs cp = CommonPrefs.get( context );
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class RematchConfigView extends LinearLayout
|
||||||
public void configure( long rowid, DlgDelegate.HasDlgDelegate dlgDlgt )
|
public void configure( long rowid, DlgDelegate.HasDlgDelegate dlgDlgt )
|
||||||
{
|
{
|
||||||
mDlgDlgt = dlgDlgt;
|
mDlgDlgt = dlgDlgt;
|
||||||
mWrapper = GameUtils.makeGameWrapper( mContext, rowid );
|
mWrapper = GameUtils.GameWrapper.make( mContext, rowid );
|
||||||
trySetup();
|
trySetup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue