Skip to content

Commit

Permalink
Change hack to a forced full app "relaunch" on first run
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrupczak3 committed Jun 15, 2019
1 parent 3eda384 commit 45b8c6f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
7 changes: 7 additions & 0 deletions doom/src/main/java/net/nullsum/freedoom/EntryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Bundle;
Expand Down Expand Up @@ -65,6 +66,12 @@ protected void onCreate(Bundle savedInstanceState) {

}

public void restart(){
Intent intent = new Intent(this, EntryActivity.class);
this.startActivity(intent);
this.finishAffinity();
}

@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
// Restore the previously serialized current tab position.
Expand Down
28 changes: 21 additions & 7 deletions doom/src/main/java/net/nullsum/freedoom/LaunchFragmentGZdoom.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -85,15 +86,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
// https://stackoverflow.com/questions/15262747/refresh-or-force-redraw-the-fragment

// simple refresh of wad list
listAdapter.notifyDataSetChanged();
(new Handler()).postDelayed(this::listRefreshHack, 10000);


// // Extremely aggressive redraw of wad list
// listview.invalidateViews();

// Aggressive hack which forces the entire fragment to redraw
FragmentTransaction tr = getFragmentManager().beginTransaction();
tr.replace(((ViewGroup)getView().getParent()).getId(), this);
tr.commit();

// END HACK
}
Expand Down Expand Up @@ -154,6 +150,24 @@ public void resultResult(String result) {
return mainView;
}

void listRefreshHack() {
Log.d(LOG, "HACK refreshing wad list");

// Doesn't work
listAdapter.notifyDataSetChanged();

// // Extremely aggressive redraw of wad list
// listview.invalidateViews();

// Force the main activity to respawn (nuclear option) @TODO fix me
((EntryActivity)getActivity()).restart();

//// Aggressive hack which forces the entire fragment to redraw
// FragmentTransaction tr = getFragmentManager().beginTransaction();
// tr.replace(((ViewGroup)getView().getParent()).getId(), this);
// tr.commit();
}

void startGame(final String base, boolean ignoreMusic, final String moreArgs) {
//Check gzdoom.pk3 wad exists
//File extrawad = new File(base + "/gzdoom.pk3");
Expand Down
5 changes: 0 additions & 5 deletions doom/src/main/java/net/nullsum/freedoom/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ static void copyFreedoomFilesToSD(Activity responsibleActivity) {
Utils.copyAsset(responsibleActivity, "brightmaps.pk3", fullModDir);
}

tester = new File( fullModDir + "/" + "gzdoom.pk3");
if (!tester.exists()) {
Utils.copyAsset(responsibleActivity, "gzdoom.pk3", fullModDir);
}

tester = new File( fullModDir + "/" + "lights.pk3");
if (!tester.exists()) {
Utils.copyAsset(responsibleActivity, "lights.pk3", fullModDir);
Expand Down

0 comments on commit 45b8c6f

Please sign in to comment.