* <p>You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.</p>
*/
-package org.adullact.iparapheur.controller.dossier;
+package org.adullact.iparapheur.controller;
import android.app.Activity;
+import android.app.DialogFragment;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.app.DialogFragment;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.Log;
-import android.view.Gravity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
-import android.widget.AdapterView;
import android.widget.FrameLayout;
-import android.widget.Spinner;
import android.widget.Toast;
import com.crashlytics.android.Crashlytics;
import org.adullact.iparapheur.R;
-import org.adullact.iparapheur.controller.IParapheurApplication;
import org.adullact.iparapheur.controller.account.AccountListFragment;
import org.adullact.iparapheur.controller.account.MyAccounts;
-import org.adullact.iparapheur.controller.bureau.BureauxListFragment;
+import org.adullact.iparapheur.controller.dossier.DossierDetailFragment;
import org.adullact.iparapheur.controller.dossier.action.ArchivageDialogFragment;
import org.adullact.iparapheur.controller.dossier.action.MailSecDialogFragment;
import org.adullact.iparapheur.controller.dossier.action.RejectDialogFragment;
import org.adullact.iparapheur.controller.dossier.action.SignatureDialogFragment;
import org.adullact.iparapheur.controller.dossier.action.TdtActesDialogFragment;
import org.adullact.iparapheur.controller.dossier.action.VisaDialogFragment;
-import org.adullact.iparapheur.controller.dossier.filter.FilterAdapter;
-import org.adullact.iparapheur.controller.dossier.filter.FilterDialog;
-import org.adullact.iparapheur.controller.dossier.filter.MyFilters;
import org.adullact.iparapheur.controller.preferences.ImportCertificatesDialogFragment;
import org.adullact.iparapheur.controller.preferences.PreferencesAccountFragment;
import org.adullact.iparapheur.controller.preferences.PreferencesActivity;
import org.adullact.iparapheur.controller.rest.api.RESTClient;
import org.adullact.iparapheur.model.Account;
import org.adullact.iparapheur.model.Action;
+import org.adullact.iparapheur.model.Bureau;
import org.adullact.iparapheur.model.Dossier;
-import org.adullact.iparapheur.model.Filter;
import org.adullact.iparapheur.utils.CollectionUtils;
-import org.adullact.iparapheur.utils.DeviceUtils;
import org.adullact.iparapheur.utils.FileUtils;
import org.adullact.iparapheur.utils.IParapheurException;
-import org.adullact.iparapheur.utils.LoadingTask;
import java.io.File;
import java.util.ArrayList;
* item details side-by-side using two vertical panes.
* <p/>
* The activity makes heavy use of fragments. The list of items is a
- * {@link DossierListFragment} and the item details
+ * {@link MenuFragment} and the item details
* is a {@link DossierDetailFragment}.
* <p/>
* This activity also implements the required
- * {@link DossierListFragment.DossierListFragmentListener} interface
+ * {@link MenuFragment.MenuFragmentListener} interface
* to listen for item selections.
*/
-public class MainActivity extends AppCompatActivity implements DossierListFragment.DossierListFragmentListener, BureauxListFragment.BureauListFragmentListener,
- AccountListFragment.AccountFragmentListener, AdapterView.OnItemSelectedListener, LoadingTask.DataChangeListener, FilterDialog.FilterDialogListener,
+public class MainActivity extends AppCompatActivity implements MenuFragment.MenuFragmentListener, AccountListFragment.AccountFragmentListener,
ActionMode.Callback, DossierDetailFragment.DossierDetailsFragmentListener {
private static final String SHARED_PREFERENCES_MAIN = ":iparapheur:shared_preferences_main";
private DrawerLayout mRightDrawerLayout;
private FrameLayout mLeftDrawerMenu;
private ActionBarDrawerToggle mLeftDrawerToggle;
- private FilterAdapter mFilterAdapter; // Adapter for action bar, used to display user's filters
- private Spinner mFiltersSpinner;
private ActionMode mActionMode; // The actionMode used when dossiers are checked
// <editor-fold desc="LifeCycle">
mLeftDrawerLayout = (DrawerLayout) findViewById(R.id.activity_dossiers_drawer_layout);
mRightDrawerLayout = (DrawerLayout) findViewById(R.id.activity_dossiers_right_drawer_layout);
mLeftDrawerMenu = (FrameLayout) findViewById(R.id.activity_dossiers_left_drawer);
- mFiltersSpinner = (Spinner) findViewById(R.id.activity_dossiers_toolbar_spinner);
- if (mFiltersSpinner != null)
- mFiltersSpinner.setOnItemSelectedListener(this);
-
- Toolbar toolbar = (Toolbar) findViewById(R.id.home_toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.menu_toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null)
if (!certificatesFoundList.isEmpty()) {
File certificateFound = certificatesFoundList.get(0);
DialogFragment actionDialog = ImportCertificatesDialogFragment.newInstance(certificateFound);
- actionDialog.show(getSupportFragmentManager(), ImportCertificatesDialogFragment.FRAGMENT_TAG);
+ actionDialog.show(getFragmentManager(), ImportCertificatesDialogFragment.FRAGMENT_TAG);
}
// Clear backStack (wrong backStack can stay after rotation)
- FragmentManager fragmentManager = getSupportFragmentManager();
+ FragmentManager fragmentManager = getFragmentManager();
fragmentManager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
// ContentView Fragment restore
- Fragment contentFragment = getSupportFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
+ Fragment contentFragment = getFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
if (contentFragment == null)
contentFragment = new DossierDetailFragment();
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.dossier_detail_layout, contentFragment, DossierDetailFragment.FRAGMENT_TAG);
transaction.commit();
- //
-
- Fragment fragmentToDisplay = getSupportFragmentManager().findFragmentByTag(BureauxListFragment.FRAGMENT_TAG);
+ // Right menu Fragment restore
+ MenuFragment fragmentToDisplay = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
if (fragmentToDisplay == null)
- fragmentToDisplay = new BureauxListFragment();
+ fragmentToDisplay = new MenuFragment();
// Replace whatever is in the fragment_container view with this fragment.
fragmentToDisplay.setRetainInstance(true);
if (findViewById(R.id.left_fragment) != null)
- replaceLeftFragment(fragmentToDisplay, BureauxListFragment.FRAGMENT_TAG, false);
+ replaceLeftFragment(fragmentToDisplay, MenuFragment.FRAGMENT_TAG, false);
// Selecting the first account by default, the demo one
editor.putBoolean(SHARED_PREFERENCES_IS_DRAWER_KNOWN, true);
editor.apply();
}
+
+ // Restoring proper Drawer state on selected dossiers
+
+ MenuFragment menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if ((menuFragment != null) && !menuFragment.getCheckedDossiers().isEmpty()) {
+ mActionMode = startSupportActionMode(this);
+
+ if (isDeviceInPortrait)
+ mLeftDrawerLayout.openDrawer(mLeftDrawerMenu);
+ else
+ mLeftDrawerLayout.closeDrawer(mLeftDrawerMenu);
+ }
}
@Override protected void onPause() {
if (requestCode == PreferencesActivity.PREFERENCES_ACTIVITY_REQUEST_CODE) {
// Notify BureauxFragments to update accounts list (the bureau will update back this Activity if needed)
- AccountListFragment accountListFragment = (AccountListFragment) getSupportFragmentManager().findFragmentByTag(AccountListFragment.FRAGMENT_TAG);
+ AccountListFragment accountListFragment = (AccountListFragment) getFragmentManager().findFragmentByTag(AccountListFragment.FRAGMENT_TAG);
if (accountListFragment != null) {
accountListFragment.accountsChanged();
// First, try to pop backStack (and open the drawer to show it)
- if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
+ MenuFragment bureauxFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if (bureauxFragment != null) {
+ if (bureauxFragment.onBackPressed()) {
- if (!mLeftDrawerLayout.isDrawerOpen(mLeftDrawerMenu))
- mLeftDrawerLayout.openDrawer(mLeftDrawerMenu);
+ if (!mLeftDrawerLayout.isDrawerOpen(mLeftDrawerMenu))
+ mLeftDrawerLayout.openDrawer(mLeftDrawerMenu);
- getSupportFragmentManager().popBackStack();
- return;
+ return;
+ }
}
// Then, close the drawer
// Then, try to pop backstack
- if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
- getSupportFragmentManager().popBackStack();
- return;
- }
+ MenuFragment bureauxFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if (bureauxFragment != null)
+ if (bureauxFragment.onBackPressed())
+ return;
}
super.onBackPressed();
@Override public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.dossiers_menu, menu);
+ Toolbar actions_toolbar = (Toolbar) findViewById(R.id.actions_toolbar);
- // Alignment in TopBar isn't working on XML, but works programmatically
-
- Toolbar.LayoutParams spinnerContainerLayoutParams = new Toolbar.LayoutParams(Toolbar.LayoutParams.WRAP_CONTENT,
- Toolbar.LayoutParams.WRAP_CONTENT,
- Gravity.TOP | Gravity.END
- );
- spinnerContainerLayoutParams.rightMargin = Math.round(DeviceUtils.dipsToPixels(this, 20));
- mFiltersSpinner.setLayoutParams(spinnerContainerLayoutParams);
+ if (actions_toolbar != null) {
+ actions_toolbar.getMenu().clear();
+ actions_toolbar.inflateMenu(R.menu.main_activity);
+ actions_toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
+ @Override public boolean onMenuItemClick(MenuItem item) {
+ return onOptionsItemSelected(item);
+ }
+ });
+ }
return super.onCreateOptionsMenu(menu);
}
// Show or hide specific menu actions depending on displayed fragment
- Fragment dossierFragment = getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
- mFiltersSpinner.setVisibility((dossierFragment == null) ? View.GONE : View.VISIBLE);
+ // TODO mFiltersSpinner.setVisibility((dossierFragment == null) ? View.GONE : View.VISIBLE);
// Show or hide specific menu actions depending on Drawer state.
- if ((mLeftDrawerLayout != null) && (mLeftDrawerMenu != null)) {
- boolean actionsVisibility = !mLeftDrawerLayout.isDrawerVisible(mLeftDrawerMenu) && (MyAccounts.INSTANCE.getSelectedAccount() != null);
- menu.setGroupVisible(R.id.dossiers_menu_actions, actionsVisibility);
- return super.onPrepareOptionsMenu(menu);
- }
+// if ((mLeftDrawerLayout != null) && (mLeftDrawerMenu != null)) {
+// boolean actionsVisibility = !mLeftDrawerLayout.isDrawerVisible(mLeftDrawerMenu) && (MyAccounts.INSTANCE.getSelectedAccount() != null);
+// menu.setGroupVisible(R.id.dossiers_menu_actions, actionsVisibility);
+// return super.onPrepareOptionsMenu(menu);
+// }
return false;
}
}
}
- @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
-
- if (position < mFilterAdapter.getCount() - 1) {
- Filter filter = mFilterAdapter.getItem(position);
- if (!filter.equals(MyFilters.INSTANCE.getSelectedFilter())) {
- MyFilters.INSTANCE.selectFilter(filter);
- onDataChanged();
- }
- }
- else {
- Filter filter = MyFilters.INSTANCE.getSelectedFilter();
- if (filter == null)
- filter = new Filter();
-
- FilterDialog.newInstance(filter).show(getSupportFragmentManager(), FilterDialog.TAG);
- }
- }
-
- @Override public void onNothingSelected(AdapterView<?> parent) { }
-
// </editor-fold desc="ActionBar">
// <editor-fold desc="ActionMode">
@Override public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
actionMode.setTitleOptionalHint(true);
MenuInflater inflater = actionMode.getMenuInflater();
- inflater.inflate(R.menu.dossiers_list_menu_actions, menu);
+ inflater.inflate(R.menu.dossier_details_fragment_actions, menu);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
@Override public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
- DossierListFragment fragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
+ MenuFragment fragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
// Default cases
boolean sign = false;
for (Dossier dossier : checkedDossiers) {
actions.retainAll(dossier.getActions());
- sign = sign || (dossier.getActions().contains(Action.SIGNATURE) && !dossier.isSignPapier());
+ sign = sign || (dossier.getActionDemandee() == Action.SIGNATURE) && !dossier.isSignPapier();
}
// Compute visibility
- actionMode.setTitle(getString(R.string.action_mode_nb_dossiers).replace("-number-", String.valueOf(checkedDossiers.size())));
+ actionMode.setTitle(String.format(getString(R.string.action_mode_nb_dossiers), checkedDossiers.size()));
menu.setGroupVisible(R.id.dossiers_menu_main_actions, false);
menu.setGroupVisible(R.id.dossiers_menu_other_actions, false);
int menuItemId;
String menuTitle;
- // Si c'est le visa, et qu'on a aussi de la signature dans le lot, on prend
- // la signature (possible en API v3).
+ // If we have a mixed set of VISA and SIGNATURE, then we have a general SIGNATURE
if (action.equals(Action.VISA) && (sign)) {
menuItemId = Action.SIGNATURE.getMenuItemId();
menuTitle = getString(Action.VISA.getTitle()) + "/" + getString(Action.SIGNATURE.getTitle());
@Override public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
- DossierListFragment dossierListFragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
- return (dossierListFragment != null) && onActionItemChecked(menuItem, dossierListFragment.getCheckedDossiers());
- }
-
- private boolean onActionItemChecked(MenuItem menuItem, HashSet<Dossier> dossiers) {
- DossierListFragment dossierListFragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
-
- if (dossierListFragment != null) {
+ MenuFragment menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if (menuFragment == null)
+ return false;
- String bureauId = dossierListFragment.getBureauId();
- Action invokedAction = Action.fromId(menuItem.getItemId());
+ Bureau bureau = menuFragment.getSelectedBureau();
+ Action invokedAction = Action.fromId(menuItem.getItemId());
- if (invokedAction != null)
- launchActionPopup(dossiers, bureauId, invokedAction);
- }
+ if ((invokedAction != null) && (bureau != null))
+ launchActionPopup(menuFragment.getCheckedDossiers(), bureau.getId(), invokedAction);
- return false;
+ return true;
}
@Override public void onDestroyActionMode(ActionMode actionMode) {
- DossierListFragment fragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
- if (fragment != null)
- fragment.clearSelection();
+ MenuFragment menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if (menuFragment != null)
+ menuFragment.clearCheckSelection();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
// Replace whatever is in the fragment_container view with this fragment.
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
- int enter = animated ? R.anim.push_right_to_center : 0;
- int exit = animated ? R.anim.push_center_to_left : 0;
- transaction.setCustomAnimations(enter, exit, R.anim.push_center_to_right, R.anim.push_left_to_center);
+// int enter = animated ? R.anim.slide_in_right : 0;
+// int exit = animated ? R.anim.slide_out_right : 0;
+// transaction.setCustomAnimations(enter, exit, R.anim.slide_out_left, R.anim.slide_in_left);
transaction.replace(R.id.left_fragment, fragment, tag);
if (animated)
// Replace whatever is in the fragment_container view with this fragment.
- FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ FragmentTransaction transaction = getFragmentManager().beginTransaction();
- int enter = animated ? R.anim.push_right_to_center : 0;
- int exit = animated ? R.anim.push_center_to_left : 0;
- transaction.setCustomAnimations(enter, exit, R.anim.push_center_to_right, R.anim.push_left_to_center);
+// int enter = animated ? R.anim.slide_in_right : 0;
+// int exit = animated ? R.anim.slide_out_right : 0;
+// transaction.setCustomAnimations(enter, exit, R.anim.slide_out_left, R.anim.slide_in_left);
transaction.replace(R.id.drawer_panel, fragment, tag);
if (animated)
}
else {
DialogFragment actionDialog = ImportCertificatesDialogFragment.newInstance(new File(certificateLocalPath));
- actionDialog.show(getSupportFragmentManager(), ImportCertificatesDialogFragment.FRAGMENT_TAG);
+ actionDialog.show(getFragmentManager(), ImportCertificatesDialogFragment.FRAGMENT_TAG);
}
}
else {
private void launchActionPopup(@NonNull Set<Dossier> dossierSet, @NonNull String bureauId, @NonNull Action action) {
- DossierListFragment dossierListFragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
+ MenuFragment menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
DialogFragment actionDialog;
ArrayList<Dossier> dossierList = new ArrayList<>(dossierSet);
if (action == Action.REJET) {
actionDialog = RejectDialogFragment.newInstance(dossierList, bureauId);
- actionDialog.setTargetFragment(dossierListFragment, RejectDialogFragment.REQUEST_CODE_REJECT);
- actionDialog.show(getSupportFragmentManager(), RejectDialogFragment.FRAGMENT_TAG);
+ actionDialog.setTargetFragment(menuFragment, RejectDialogFragment.REQUEST_CODE_REJECT);
+ actionDialog.show(getFragmentManager(), RejectDialogFragment.FRAGMENT_TAG);
}
else if (action == Action.VISA) {
actionDialog = VisaDialogFragment.newInstance(dossierList, bureauId);
- actionDialog.setTargetFragment(dossierListFragment, VisaDialogFragment.REQUEST_CODE_VISA);
- actionDialog.show(getSupportFragmentManager(), VisaDialogFragment.FRAGMENT_TAG);
+ actionDialog.setTargetFragment(menuFragment, VisaDialogFragment.REQUEST_CODE_VISA);
+ actionDialog.show(getFragmentManager(), VisaDialogFragment.FRAGMENT_TAG);
}
else if (action == Action.SIGNATURE) {
actionDialog = SignatureDialogFragment.newInstance(dossierList, bureauId);
- actionDialog.setTargetFragment(dossierListFragment, SignatureDialogFragment.REQUEST_CODE_SIGNATURE);
- actionDialog.show(getSupportFragmentManager(), SignatureDialogFragment.FRAGMENT_TAG);
+ actionDialog.setTargetFragment(menuFragment, SignatureDialogFragment.REQUEST_CODE_SIGNATURE);
+ actionDialog.show(getFragmentManager(), SignatureDialogFragment.FRAGMENT_TAG);
}
else if (action == Action.MAILSEC) {
actionDialog = MailSecDialogFragment.newInstance(dossierList, bureauId);
- actionDialog.show(getSupportFragmentManager(), "MailSecDialogFragment");
+ actionDialog.show(getFragmentManager(), "MailSecDialogFragment");
}
else if ((action == Action.TDT) || (action == Action.TDT_HELIOS) || (action == Action.TDT_ACTES)) {
actionDialog = TdtActesDialogFragment.newInstance(dossierList, bureauId);
- actionDialog.setTargetFragment(dossierListFragment, TdtActesDialogFragment.REQUEST_CODE_ACTES);
- actionDialog.show(getSupportFragmentManager(), TdtActesDialogFragment.FRAGMENT_TAG);
+ actionDialog.setTargetFragment(menuFragment, TdtActesDialogFragment.REQUEST_CODE_ACTES);
+ actionDialog.show(getFragmentManager(), TdtActesDialogFragment.FRAGMENT_TAG);
}
else if (action == Action.ARCHIVAGE) {
actionDialog = ArchivageDialogFragment.newInstance(dossierList, bureauId);
- actionDialog.show(getSupportFragmentManager(), "ArchivageDialogFragment");
+ actionDialog.show(getFragmentManager(), "ArchivageDialogFragment");
}
else {
Log.e("Adrien", "UNKNOWN ACTION : " + action);
@Override public void onAccountSelected(@NonNull Account account) {
- if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
- BureauxListFragment bureauxFragment = new BureauxListFragment();
- replaceDrawerFragment(bureauxFragment, BureauxListFragment.FRAGMENT_TAG, true);
- }
- else {
- mLeftDrawerLayout.closeDrawer(mLeftDrawerMenu);
- }
-
MyAccounts.INSTANCE.selectAccount(account.getId());
- // If we selected a new account, and we are on the DossierFragment displayed
- // We'll want to pop the BackStack to get on the BureauFragment
+ // Close the drawer
- DossierListFragment dossierListFragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
- if (dossierListFragment != null)
- if (getSupportFragmentManager().getBackStackEntryCount() > 0)
- getSupportFragmentManager().popBackStack();
+ if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
+ mLeftDrawerLayout.closeDrawer(mLeftDrawerMenu);
- // Then , we just update the BureauFragment to the accurate Account
+ // If we selected a new account, and we have a Dossier list displayed
+ // We'll want to pop the BackStack to get on the Bureau list
+ // Then , we just update the Bureau with the accurate Account
- BureauxListFragment bureauxFragment = (BureauxListFragment) getSupportFragmentManager().findFragmentByTag(BureauxListFragment.FRAGMENT_TAG);
- if (bureauxFragment != null)
- bureauxFragment.updateBureaux(true);
+ MenuFragment menuFragment = (MenuFragment) getFragmentManager().findFragmentByTag(MenuFragment.FRAGMENT_TAG);
+ if (menuFragment != null) {
+ menuFragment.onBackPressed();
+ menuFragment.updateBureaux(true);
+ }
}
@Override public void onCreateAccountInvoked() {
// </editor-fold desc="AccountFragmentListener">
- // <editor-fold desc="BureauListFragmentListener">
-
- @Override public void onBureauListFragmentSelected(@Nullable String id) {
-
- if (id != null) {
- DossierListFragment fragment = DossierListFragment.newInstance(id);
- replaceLeftFragment(fragment, DossierListFragment.FRAGMENT_TAG, true);
- }
- }
-
- // </editor-fold desc="BureauListFragmentListener">
-
- // <editor-fold desc="FilterDialogListener">
+ // <editor-fold desc="MenuFragment">
- public void onFilterSave(@NonNull Filter filter) {
- MyFilters.INSTANCE.selectFilter(filter);
- MyFilters.INSTANCE.save(filter);
-
- mFiltersSpinner.setSelection(mFilterAdapter.getPosition(filter), true);
-
- mFilterAdapter.notifyDataSetChanged();
- onDataChanged();
- }
-
- public void onFilterChange(@NonNull Filter filter) {
-
- mFiltersSpinner.setSelection(mFilterAdapter.getPosition(filter));
-
- MyFilters.INSTANCE.selectFilter(filter);
- onDataChanged();
- }
-
- public void onFilterCancel() {
- mFiltersSpinner.setSelection(mFilterAdapter.getPosition(MyFilters.INSTANCE.getSelectedFilter()));
- }
+ @Override public void onDossierListFragmentSelected(@NonNull Dossier dossier, @NonNull String bureauId) {
- /**
- * Called when an action is done on a dossier. We have to force reload dossier list and
- * dismiss details.
- */
- @Override public void onDataChanged() {
- DossierListFragment listFragment = (DossierListFragment) getSupportFragmentManager().findFragmentByTag(DossierListFragment.FRAGMENT_TAG);
- if (listFragment != null) {
- // this method will reload dossiers fragments
- listFragment.reload();
- }
-
- onDossierSelected(null, null);
- invalidateOptionsMenu();
- }
-
- // </editor-fold desc="FilterDialogListener">
-
- // <editor-fold desc="DossierListFragmentListener">
-
- @Override public void onDossierSelected(@Nullable Dossier dossier, @Nullable String bureauId) {
-
- if (dossier != null)
- if (mLeftDrawerLayout.isDrawerOpen(mLeftDrawerMenu))
- mLeftDrawerLayout.closeDrawer(mLeftDrawerMenu);
+ if (mLeftDrawerLayout.isDrawerOpen(mLeftDrawerMenu))
+ mLeftDrawerLayout.closeDrawer(mLeftDrawerMenu);
- DossierDetailFragment fragment = (DossierDetailFragment) getSupportFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
- if ((fragment != null) && (dossier != null) && (bureauId != null)) {
+ DossierDetailFragment fragment = (DossierDetailFragment) getFragmentManager().findFragmentByTag(DossierDetailFragment.FRAGMENT_TAG);
+ if ((fragment != null)) {
fragment.showProgressLayout();
fragment.update(dossier, bureauId);
}
}
@Override public void onDossierCheckedChanged(boolean forceClose) {
+
if (mActionMode != null)
mActionMode.invalidate();
else if (!forceClose)
mActionMode = startSupportActionMode(this);
}
- @Override public void onDossiersLoaded(int size) {
- onDossierSelected(null, null);
+ // </editor-fold desc="MenuFragment">
- if (mFilterAdapter == null)
- mFilterAdapter = new FilterAdapter(this);
-
- mFiltersSpinner.setAdapter(mFilterAdapter);
- mFiltersSpinner.setVisibility(View.VISIBLE);
- }
+ // <editor-fold desc="DossierDetailsFragmentListener">
- @Override public void onDossiersNotLoaded() {
- mFiltersSpinner.setVisibility(View.INVISIBLE);
+ @Override public boolean isAnyDrawerOpened() {
+ return (mRightDrawerLayout.isDrawerVisible(GravityCompat.END) || mLeftDrawerLayout.isDrawerVisible(GravityCompat.START));
}
- // </editor-fold desc="DossierListFragmentListener">
-
- // <editor-fold desc="DossierDetailsFragmentListener">
-
@Override public void toggleInfoDrawer() {
if (mRightDrawerLayout.isDrawerOpen(GravityCompat.END))
launchActionPopup(CollectionUtils.asSet(dossier), bureauId, action);
}
-// </editor-fold desc="DossierDetailsFragmentListener">
+ // </editor-fold desc="DossierDetailsFragmentListener">
/**
* Listener used on the Drawer Layout used to control the Action Bar content depending
private class DossiersActionBarDrawerToggle extends ActionBarDrawerToggle {
public DossiersActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout) {
- super(activity, drawerLayout, (Toolbar) activity.findViewById(R.id.home_toolbar), R.string.drawer_open, R.string.drawer_close);
+ super(activity, drawerLayout, (Toolbar) activity.findViewById(R.id.menu_toolbar), R.string.drawer_open, R.string.drawer_close);
}
@Override public void onDrawerClosed(View view) {