Skip to content
Permalink
Browse files
Merge pull request #494 from fzurita/cheat_title_not_refreshing
Cheat title not refreshing
  • Loading branch information
Gillou68310 committed Oct 22, 2015
2 parents e8f5791 + 36b8835 commit 256bd33
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
@@ -28,6 +28,7 @@
import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.ActivityHelper;
import paulscode.android.mupen64plusae.ScanRomsActivity;
import paulscode.android.mupen64plusae.cheat.CheatUtils.Cheat;
import paulscode.android.mupen64plusae.compat.AppCompatListActivity;
import paulscode.android.mupen64plusae.dialog.Prompt;
@@ -127,6 +128,9 @@ protected void onCreate( Bundle savedInstanceState )
findViewById( R.id.imgBtnChtSave ).setOnClickListener( this );
findViewById( R.id.imgBtnChtInfo ).setOnClickListener( this );
getListView().setOnItemLongClickListener( this );

//default state is cancelled unless we save
setResult(RESULT_CANCELED, null);
}

private void reload( String crc, byte countryCode )
@@ -235,6 +239,8 @@ public void onClick( View v )

case R.id.imgBtnChtSave:
save( mRomCrc );

setResult(RESULT_OK, null);
CheatEditorActivity.this.finish();
break;

@@ -283,8 +289,6 @@ public void onClick( View v )
{
case R.id.btnEditTitle:
promptTitle( cheat );
Collections.sort(userCheats);
cheatListAdapter.notifyDataSetChanged();
break;
case R.id.btnEditNotes:
promptNotes( cheat );
@@ -360,6 +364,9 @@ public void onDialogClosed( CharSequence text, int which )
{
String str = text.toString().replace( '\n', ' ' );
cheat.name = str;

Collections.sort(userCheats);
cheatListAdapter.notifyDataSetChanged();
}
}
} );
@@ -100,6 +100,8 @@ public class GamePrefsActivity extends AppCompatPreferenceActivity implements On
private PreferenceGroup mScreenCheats = null;
private PreferenceGroup mCategoryCheats = null;

private boolean mClearCheats = false;

// MOGA controller interface
private Controller mMogaController = Controller.getInstance( this );

@@ -238,7 +240,14 @@ public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, Stri
protected void onActivityResult( int requestCode, int resultCode, Intent data )
{
if( requestCode == 111 )
refreshCheatsCategory();
{
if( resultCode == RESULT_OK)
{
//If the user cheats were saved, reset all selected cheatd
mClearCheats = true;
refreshCheatsCategory();
}
}
}

private void refreshViews()
@@ -339,13 +348,23 @@ public void onExtractFinished(ArrayList<Cheat> cheats)
CheatPreference pref = new CheatPreference( this, cheat.cheatIndex, title, notes, optionStrings );

//We store the cheat index in the key as a string
pref.setKey( mRomCrc + " Cheat" + cheat.cheatIndex );
String key = mRomCrc + " Cheat" + cheat.cheatIndex ;
pref.setKey( key );

//We reset if the list was changed by the user
if(mClearCheats)
{
mPrefs.edit().putInt( key, 0 ).commit();
}

// Add the preference menu item to the cheats category
mCategoryCheats.addPreference( pref );
}

mScreenCheats.addPreference( mCategoryCheats );

//Reset this to false if it was set
mClearCheats = false;
}

@Override

0 comments on commit 256bd33

Please sign in to comment.