diff options
Diffstat (limited to 'org.fox.ttcomics/src')
-rw-r--r-- | org.fox.ttcomics/src/main/java/org/fox/ttcomics2/MainActivity.java | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/MainActivity.java b/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/MainActivity.java index 8141488..bc0df31 100644 --- a/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/MainActivity.java +++ b/org.fox.ttcomics/src/main/java/org/fox/ttcomics2/MainActivity.java @@ -25,7 +25,7 @@ public class MainActivity extends CommonActivity implements MaterialTabListener private final static int TRIAL_DAYS = 7; private int m_selectedTab; - private String m_baseDirectory = ""; + //private String m_baseDirectory = ""; private MaterialTabHost tabHost; @SuppressLint("NewApi") @@ -40,28 +40,29 @@ public class MainActivity extends CommonActivity implements MaterialTabListener tabHost = (MaterialTabHost) this.findViewById(R.id.materialTabHost); if (savedInstanceState == null) { - m_selectedTab = getIntent().getIntExtra("selectedTab", 0); - - Log.d(TAG, "selTab=" + m_selectedTab); + m_selectedTab = 0; //getIntent().getIntExtra("selectedTab", 0); - ComicListFragment frag = new ComicListFragment(); - frag.setMode(m_selectedTab); + //Log.d(TAG, "selTab=" + m_selectedTab); - if (getIntent().getStringExtra("baseDir") != null) { + ComicListFragment frag = new ComicListFragment(); + frag.setMode(m_selectedTab); + frag.setBaseDirectory(m_prefs.getString("comics_directory", "")); + + /*if (getIntent().getStringExtra("baseDir") != null) { m_baseDirectory = getIntent().getStringExtra("baseDir"); frag.setBaseDirectory(m_baseDirectory); - } + frag.setMode(m_selectedTab); + } */ - FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); - ft.replace(R.id.comics_list, frag, FRAG_COMICS_LIST); - ft.commit(); - - m_selectedTab = -1; - } else { - m_selectedTab = -1; - m_baseDirectory = savedInstanceState.getString("baseDir"); + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + ft.replace(R.id.comics_list, frag, FRAG_COMICS_LIST); + ft.commit(); + } else { + //m_baseDirectory = savedInstanceState.getString("baseDir"); } + m_selectedTab = -1; + tabHost.addTab(tabHost.newTab() .setText(getString(R.string.tab_all_comics)) .setTabListener(this)); @@ -88,7 +89,7 @@ public class MainActivity extends CommonActivity implements MaterialTabListener tabHost.setSelectedNavigationItem(m_selectedTab); ActionBar actionBar = getSupportActionBar(); - actionBar.setDisplayHomeAsUpEnabled(m_baseDirectory.length() > 0); + //actionBar.setDisplayHomeAsUpEnabled(m_baseDirectory.length() > 0); if (m_prefs.getString("comics_directory", null) == null) { AlertDialog.Builder builder = new AlertDialog.Builder(this); @@ -112,9 +113,9 @@ public class MainActivity extends CommonActivity implements MaterialTabListener alert.show(); } - if (m_baseDirectory.length() > 0) { - setTitle(new File(m_baseDirectory).getName()); - } + //if (m_baseDirectory.length() > 0) { + //setTitle(new File(m_baseDirectory).getName()); + //} //((ViewGroup)findViewById(R.id.comics_list)).setLayoutTransition(new LayoutTransition()); } @@ -131,15 +132,15 @@ public class MainActivity extends CommonActivity implements MaterialTabListener super.onSaveInstanceState(out); out.putInt("selectedTab", m_selectedTab); - out.putString("baseDir", m_baseDirectory); + //out.putString("baseDir", m_baseDirectory); } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - if (m_baseDirectory.length() > 0) { + //if (m_baseDirectory.length() > 0) { finish(); - } + //} return true; default: Log.d(TAG, @@ -155,13 +156,22 @@ public class MainActivity extends CommonActivity implements MaterialTabListener File file = new File(fileName); if (file.isDirectory()) { - Intent intent = new Intent(MainActivity.this, + /*Intent intent = new Intent(MainActivity.this, MainActivity.class); intent.putExtra("baseDir", fileName); intent.putExtra("selectedTab", m_selectedTab); - startActivityForResult(intent, 0); + startActivityForResult(intent, 0);*/ + + FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); + + ComicListFragment frag = new ComicListFragment(); + frag.setBaseDirectory(fileName); + + ft.replace(R.id.comics_list, frag, FRAG_COMICS_LIST); + ft.addToBackStack(null); + ft.commit(); } else if (file.canRead()) { Intent intent = new Intent(MainActivity.this, @@ -215,9 +225,9 @@ public class MainActivity extends CommonActivity implements MaterialTabListener if (m_selectedTab != tab.getPosition() && m_selectedTab != -1) { ComicListFragment frag = new ComicListFragment(); - frag.setMode(tab.getPosition()); + frag.setMode(tab.getPosition()); - frag.setBaseDirectory(m_baseDirectory); + //frag.setBaseDirectory(m_baseDirectory); sft.replace(R.id.comics_list, frag, FRAG_COMICS_LIST); } |