mirror of
https://github.com/MinimalBible/MinimalBible
synced 2024-11-22 07:58:20 -05:00
PoC: Don't rebuild the OG on conf change
This commit is contained in:
parent
d61f9057b6
commit
7c483695d3
@ -4,6 +4,7 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.widget.DrawerLayout;
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
|
||||||
@ -47,8 +48,20 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
*/
|
*/
|
||||||
private void buildObjGraph() {
|
private void buildObjGraph() {
|
||||||
if (daObjectGraph == null) {
|
if (daObjectGraph == null) {
|
||||||
daObjectGraph = MinimalBible.get(this)
|
FragmentManager fM = getSupportFragmentManager();
|
||||||
.plus(new DownloadActivityModules(this));
|
DownloadOGHolder ogHolder = (DownloadOGHolder) fM.findFragmentByTag("OG_HOLDER");
|
||||||
|
if (ogHolder == null) {
|
||||||
|
Log.e("DownloadActivity", "Creating new holder...");
|
||||||
|
ogHolder = new DownloadOGHolder();
|
||||||
|
daObjectGraph = MinimalBible.get(this)
|
||||||
|
.plus(new DownloadActivityModules(this));
|
||||||
|
ogHolder.persistObjectGraph(daObjectGraph);
|
||||||
|
fM.beginTransaction().add(ogHolder, "OG_HOLDER").commit();
|
||||||
|
} else {
|
||||||
|
Log.e("DownloadActivity", "Found existing holder...");
|
||||||
|
daObjectGraph = ogHolder.fetchObjectGraph();
|
||||||
|
daObjectGraph.inject(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
daObjectGraph.inject(this);
|
daObjectGraph.inject(this);
|
||||||
}
|
}
|
||||||
@ -62,7 +75,8 @@ public class DownloadActivity extends BaseActivity implements
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
buildObjGraph();
|
inject(this);
|
||||||
|
|
||||||
setContentView(R.layout.activity_download);
|
setContentView(R.layout.activity_download);
|
||||||
|
|
||||||
mNavigationDrawerFragment = (DownloadNavDrawerFragment) getSupportFragmentManager()
|
mNavigationDrawerFragment = (DownloadNavDrawerFragment) getSupportFragmentManager()
|
||||||
|
@ -37,7 +37,8 @@ import de.devland.esperandro.Esperandro;
|
|||||||
DownloadActivity.class,
|
DownloadActivity.class,
|
||||||
InstalledManager.class
|
InstalledManager.class
|
||||||
},
|
},
|
||||||
addsTo = MinimalBibleModules.class
|
addsTo = MinimalBibleModules.class,
|
||||||
|
library = true
|
||||||
)
|
)
|
||||||
public class DownloadActivityModules {
|
public class DownloadActivityModules {
|
||||||
DownloadActivity activity;
|
DownloadActivity activity;
|
||||||
@ -102,4 +103,9 @@ public class DownloadActivityModules {
|
|||||||
Collection<Installer> provideInstallers() {
|
Collection<Installer> provideInstallers() {
|
||||||
return new InstallManager().getInstallers().values();
|
return new InstallManager().getInstallers().values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Provides @Singleton
|
||||||
|
RefreshManager provideRefreshManager() {
|
||||||
|
return new RefreshManager(activity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.bspeice.minimalbible.activity.downloader;
|
package org.bspeice.minimalbible.activity.downloader;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
package org.bspeice.minimalbible.activity.downloader;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
|
||||||
|
import dagger.ObjectGraph;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by bspeice on 7/21/14.
|
||||||
|
*/
|
||||||
|
public class DownloadOGHolder extends Fragment {
|
||||||
|
|
||||||
|
ObjectGraph holder;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setRetainInstance(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void persistObjectGraph(ObjectGraph holder) {
|
||||||
|
this.holder = holder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectGraph fetchObjectGraph() {
|
||||||
|
return this.holder;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user