mirror of
https://github.com/MinimalBible/MinimalBible-Legacy
synced 2024-11-12 19:18:34 -05:00
Split out the Nav Drawers between activities
This commit is contained in:
parent
77d808ca1b
commit
0feee0b940
@ -32,7 +32,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_drawer"
|
||||
android:name="org.bspeice.minimalbible.activities.NavigationDrawerFragment"
|
||||
android:name="org.bspeice.minimalbible.activities.viewer.ViewerNavDrawerFragment"
|
||||
android:layout_width="@dimen/navigation_drawer_width"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
<fragment
|
||||
android:id="@+id/navigation_drawer"
|
||||
android:name="org.bspeice.minimalbible.activities.NavigationDrawerFragment"
|
||||
android:name="org.bspeice.minimalbible.activities.downloader.DownloadNavDrawerFragment"
|
||||
android:layout_width="@dimen/navigation_drawer_width"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start" />
|
||||
|
@ -7,5 +7,5 @@
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@android:color/transparent"
|
||||
android:dividerHeight="0dp"
|
||||
tools:context="org.bspeice.minimalbible.activities.NavigationDrawerFragment" />
|
||||
tools:context="org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment" />
|
||||
|
||||
|
@ -34,7 +34,7 @@ import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
* > design guidelines</a> for a complete explanation of the behaviors
|
||||
* implemented here.
|
||||
*/
|
||||
public class NavigationDrawerFragment extends Fragment {
|
||||
public class BaseNavigationDrawerFragment extends Fragment {
|
||||
|
||||
/**
|
||||
* Remember the position of the selected item.
|
||||
@ -58,14 +58,14 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
private ActionBarDrawerToggle mDrawerToggle;
|
||||
|
||||
private DrawerLayout mDrawerLayout;
|
||||
private ListView mDrawerListView;
|
||||
protected ListView mDrawerListView;
|
||||
private View mFragmentContainerView;
|
||||
|
||||
private int mCurrentSelectedPosition = 0;
|
||||
protected int mCurrentSelectedPosition = 0;
|
||||
private boolean mFromSavedInstanceState;
|
||||
private boolean mUserLearnedDrawer;
|
||||
|
||||
public NavigationDrawerFragment() {
|
||||
public BaseNavigationDrawerFragment() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -97,29 +97,6 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mDrawerListView = (ListView) inflater.inflate(
|
||||
R.layout.fragment_navigation_drawer, container, false);
|
||||
mDrawerListView
|
||||
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
selectItem(position);
|
||||
}
|
||||
});
|
||||
mDrawerListView.setAdapter(new ArrayAdapter<String>(getActionBar()
|
||||
.getThemedContext(), android.R.layout.simple_list_item_1,
|
||||
android.R.id.text1, new String[] {
|
||||
getString(R.string.title_section1),
|
||||
getString(R.string.title_section2),
|
||||
getString(R.string.title_section3), }));
|
||||
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
|
||||
return mDrawerListView;
|
||||
}
|
||||
|
||||
public boolean isDrawerOpen() {
|
||||
return mDrawerLayout != null
|
||||
&& mDrawerLayout.isDrawerOpen(mFragmentContainerView);
|
||||
@ -214,7 +191,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
mDrawerLayout.setDrawerListener(mDrawerToggle);
|
||||
}
|
||||
|
||||
private void selectItem(int position) {
|
||||
public void selectItem(int position) {
|
||||
mCurrentSelectedPosition = position;
|
||||
if (mDrawerListView != null) {
|
||||
mDrawerListView.setItemChecked(position, true);
|
||||
@ -275,13 +252,6 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
if (mDrawerToggle.onOptionsItemSelected(item)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (item.getItemId() == R.id.action_example) {
|
||||
Toast.makeText(getActivity(), "Example action.", Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@ -297,7 +267,7 @@ public class NavigationDrawerFragment extends Fragment {
|
||||
// actionBar.setTitle(R.string.app_name);
|
||||
}
|
||||
|
||||
private ActionBar getActionBar() {
|
||||
protected ActionBar getActionBar() {
|
||||
return ((ActionBarActivity) getActivity()).getSupportActionBar();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package org.bspeice.minimalbible.activities.downloader;
|
||||
import org.bspeice.minimalbible.MinimalBibleConstants;
|
||||
import org.bspeice.minimalbible.R;
|
||||
import org.bspeice.minimalbible.activities.BaseActivity;
|
||||
import org.bspeice.minimalbible.activities.NavigationDrawerFragment;
|
||||
import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
@ -23,13 +23,13 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class DownloadActivity extends BaseActivity implements
|
||||
NavigationDrawerFragment.NavigationDrawerCallbacks {
|
||||
BaseNavigationDrawerFragment.NavigationDrawerCallbacks {
|
||||
|
||||
/**
|
||||
* Fragment managing the behaviors, interactions and presentation of the
|
||||
* navigation drawer.
|
||||
*/
|
||||
private NavigationDrawerFragment mNavigationDrawerFragment;
|
||||
private DownloadNavDrawerFragment mNavigationDrawerFragment;
|
||||
|
||||
/**
|
||||
* Used to store the last screen title. For use in
|
||||
@ -42,7 +42,7 @@ public class DownloadActivity extends BaseActivity implements
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_download);
|
||||
|
||||
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
|
||||
mNavigationDrawerFragment = (DownloadNavDrawerFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.navigation_drawer);
|
||||
mTitle = getTitle();
|
||||
|
||||
|
@ -0,0 +1,39 @@
|
||||
package org.bspeice.minimalbible.activities.downloader;
|
||||
|
||||
import org.bspeice.minimalbible.R;
|
||||
import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class DownloadNavDrawerFragment extends BaseNavigationDrawerFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mDrawerListView = (ListView) inflater.inflate(
|
||||
R.layout.fragment_navigation_drawer, container, false);
|
||||
mDrawerListView
|
||||
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
selectItem(position);
|
||||
}
|
||||
});
|
||||
mDrawerListView.setAdapter(new ArrayAdapter<String>(getActionBar()
|
||||
.getThemedContext(), android.R.layout.simple_list_item_1,
|
||||
android.R.id.text1, new String[] {
|
||||
getString(R.string.title_section1),
|
||||
getString(R.string.title_section2),
|
||||
getString(R.string.title_section3), }));
|
||||
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
|
||||
return mDrawerListView;
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import org.bspeice.minimalbible.R.layout;
|
||||
import org.bspeice.minimalbible.R.menu;
|
||||
import org.bspeice.minimalbible.R.string;
|
||||
import org.bspeice.minimalbible.activities.BaseActivity;
|
||||
import org.bspeice.minimalbible.activities.NavigationDrawerFragment;
|
||||
import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment;
|
||||
import org.bspeice.minimalbible.activities.downloader.DownloadActivity;
|
||||
|
||||
import android.app.Activity;
|
||||
@ -28,13 +28,13 @@ import android.widget.TextView;
|
||||
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
||||
|
||||
public class BibleViewer extends BaseActivity implements
|
||||
NavigationDrawerFragment.NavigationDrawerCallbacks {
|
||||
BaseNavigationDrawerFragment.NavigationDrawerCallbacks {
|
||||
|
||||
/**
|
||||
* Fragment managing the behaviors, interactions and presentation of the
|
||||
* navigation drawer.
|
||||
*/
|
||||
private NavigationDrawerFragment mNavigationDrawerFragment;
|
||||
private ViewerNavDrawerFragment mNavigationDrawerFragment;
|
||||
|
||||
/**
|
||||
* Used to store the last screen title. For use in
|
||||
@ -47,7 +47,7 @@ public class BibleViewer extends BaseActivity implements
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_bible_viewer);
|
||||
|
||||
mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager()
|
||||
mNavigationDrawerFragment = (ViewerNavDrawerFragment) getSupportFragmentManager()
|
||||
.findFragmentById(R.id.navigation_drawer);
|
||||
mTitle = getTitle();
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
package org.bspeice.minimalbible.activities.viewer;
|
||||
|
||||
import org.bspeice.minimalbible.R;
|
||||
import org.bspeice.minimalbible.activities.BaseNavigationDrawerFragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.ListView;
|
||||
|
||||
public class ViewerNavDrawerFragment extends BaseNavigationDrawerFragment {
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
mDrawerListView = (ListView) inflater.inflate(
|
||||
R.layout.fragment_navigation_drawer, container, false);
|
||||
mDrawerListView
|
||||
.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
selectItem(position);
|
||||
}
|
||||
});
|
||||
mDrawerListView.setAdapter(new ArrayAdapter<String>(getActionBar()
|
||||
.getThemedContext(), android.R.layout.simple_list_item_1,
|
||||
android.R.id.text1, new String[] {
|
||||
getString(R.string.title_section1),
|
||||
getString(R.string.title_section2),
|
||||
getString(R.string.title_section3)}));
|
||||
mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);
|
||||
return mDrawerListView;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user