Skip to content

Commit

Permalink
Merge pull request #509 from fzurita/pause_emulation_when_sidebar_open
Browse files Browse the repository at this point in the history
Mupen64plus core interaction enhancements and UI enhancements
  • Loading branch information
Gillou68310 committed Nov 9, 2015
2 parents 6588405 + 6143f1c commit 2b3866c
Show file tree
Hide file tree
Showing 8 changed files with 311 additions and 94 deletions.
3 changes: 3 additions & 0 deletions res/menu/game_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@
<item
android:id="@+id/menuItem_setIme"
android:title="@string/menuItem_setIme"/>
<item
android:id="@+id/menuItem_reset"
android:title="@string/inputMapActivity_reset"/>

</menu>
61 changes: 57 additions & 4 deletions src/paulscode/android/mupen64plusae/GalleryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;

import org.mupen64plusae.v3.alpha.R;

import paulscode.android.mupen64plusae.GameSidebar.GameSidebarActionHandler;
import paulscode.android.mupen64plusae.dialog.ChangeLog;
import paulscode.android.mupen64plusae.dialog.Popups;
Expand All @@ -57,6 +55,7 @@
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.GravityCompat;
Expand All @@ -77,6 +76,7 @@
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.inputmethod.InputMethodManager;

public class GalleryActivity extends AppCompatActivity implements GameSidebarActionHandler
Expand All @@ -85,6 +85,7 @@ public class GalleryActivity extends AppCompatActivity implements GameSidebarAct
public static final String STATE_QUERY = "query";
public static final String STATE_SIDEBAR = "sidebar";
public static final String STATE_CACHE_ROM_INFO_FRAGMENT= "cache_rom_info_fragment";
public static final String STATE_GALLERY_REFRESH_NEEDED= "gallery_refresh_needed";

// App data and user preferences
private AppData mAppData = null;
Expand Down Expand Up @@ -118,6 +119,9 @@ public class GalleryActivity extends AppCompatActivity implements GameSidebarAct
//True if the restart promp is enabled
boolean mRestartPromptEnabled = true;

//If this is set to true, the gallery will be refreshed next time this activity is resumed
boolean mRefreshNeeded = false;

@Override
protected void onNewIntent( Intent intent )
{
Expand Down Expand Up @@ -312,6 +316,8 @@ public void onClick( MenuItem menuItem )
String query = savedInstanceState.getString( STATE_QUERY );
if( query != null )
mSearchQuery = query;

mRefreshNeeded = savedInstanceState.getBoolean(STATE_GALLERY_REFRESH_NEEDED);
}

// find the retained fragment on activity restarts
Expand All @@ -331,13 +337,59 @@ public void onClick( MenuItem menuItem )
mGlobalPrefs.displayActionBarTransparency ) );
}

@Override
public void onResume()
{
super.onResume();

//mRefreshNeeded will be set to true whenever a game is launched
if(mRefreshNeeded)
{
mRefreshNeeded = false;
refreshGrid();

mGameSidebar.setVisibility( View.GONE );
mDrawerList.setVisibility( View.VISIBLE );

//Close the drawer without an animation
final View view = mDrawerLayout.getChildAt(mDrawerLayout.getChildCount() - 1);
ViewTreeObserver vto = view.getViewTreeObserver();

vto.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener()
{
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onPreDraw()
{
if (AppData.IS_HONEYCOMB)
{
final DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(view.getWidth(), view
.getHeight());
lp.gravity = GravityCompat.START;
view.setLayoutParams(lp);
view.setLeft(-view.getMeasuredWidth());
view.getViewTreeObserver().removeOnPreDrawListener(this);
}
else
{
// For anything less than HONEYCOMB API level, we will still show the animation
mDrawerLayout.closeDrawer(GravityCompat.START);
}

return true;
}
});
}
}

@Override
public void onSaveInstanceState( Bundle savedInstanceState )
{
if( mSearchView != null )
savedInstanceState.putString( STATE_QUERY, mSearchView.getQuery().toString() );
if( mSelectedItem != null )
savedInstanceState.putString( STATE_SIDEBAR, mSelectedItem.md5 );
savedInstanceState.putBoolean(STATE_GALLERY_REFRESH_NEEDED, mRefreshNeeded);

super.onSaveInstanceState( savedInstanceState );
}
Expand Down Expand Up @@ -806,7 +858,7 @@ private void refreshViews()

public void launchGameActivity( String romPath, String zipPath, boolean extracted, String romMd5, String romCrc,
String romHeaderName, byte romCountryCode, String romArtPath, String romGoodName, boolean isRestarting )
{
{
// Make sure that the storage is accessible
if( !mAppData.isSdCardAccessible() )
{
Expand All @@ -833,7 +885,8 @@ public void launchGameActivity( String romPath, String zipPath, boolean extracte
config.save();
}

refreshGrid();
mRefreshNeeded = true;
mSelectedItem = null;

// Launch the game activity
ActivityHelper.startGameActivity( this, romPath, romMd5, romCrc, romHeaderName, romCountryCode,
Expand Down
7 changes: 0 additions & 7 deletions src/paulscode/android/mupen64plusae/game/GameActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,4 @@ protected void onStop()
super.onStop();
mLifecycleHandler.onStop();
}

@Override
protected void onDestroy()
{
super.onDestroy();
mLifecycleHandler.onDestroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,4 @@ protected void onStop()
super.onStop();
mLifecycleHandler.onStop();
}

@Override
protected void onDestroy()
{
super.onDestroy();
mLifecycleHandler.onDestroy();
}
}
Loading

0 comments on commit 2b3866c

Please sign in to comment.