|
@@ -25,7 +25,6 @@ import android.preference.PreferenceManager;
|
|
|
import android.support.v4.app.Fragment;
|
|
|
import android.support.v4.app.FragmentManager;
|
|
|
import android.support.v4.app.FragmentPagerAdapter;
|
|
|
-import android.view.ViewGroup;
|
|
|
|
|
|
import org.notabug.lifeuser.moviedb.R;
|
|
|
import org.notabug.lifeuser.moviedb.fragment.ListFragment;
|
|
@@ -43,7 +42,6 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
|
|
private final String seriesTabTitle;
|
|
|
private final String savedTabTitle;
|
|
|
private final String personTabTitle;
|
|
|
- private int currentFragmentPosition;
|
|
|
|
|
|
/**
|
|
|
* Determines the (amount of) Pages to be shown.
|
|
@@ -121,21 +119,6 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void setPrimaryItem(ViewGroup container, int position, Object object) {
|
|
|
- currentFragmentPosition = position;
|
|
|
- super.setPrimaryItem(container, position, object);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Gets the fragment position from the setPrimaryItem method.
|
|
|
- *
|
|
|
- * @return the position of the current fragment.
|
|
|
- */
|
|
|
- public int getCurrentFragmentPosition() {
|
|
|
- return currentFragmentPosition;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Returns position based on the Pages that are visible.
|
|
|
*
|
|
@@ -143,31 +126,31 @@ public class SectionsPagerAdapter extends FragmentPagerAdapter {
|
|
|
* @return the position of the case that the switch goes to.
|
|
|
*/
|
|
|
private int getCorrectedPosition(int position) {
|
|
|
- boolean moviesHidden = preferences.getBoolean(HIDE_MOVIES_PREFERENCE, false);
|
|
|
- boolean seriesHidden = preferences.getBoolean(HIDE_SERIES_PREFERENCE, false);
|
|
|
- boolean savedHidden = preferences.getBoolean(HIDE_SAVED_PREFERENCE, false);
|
|
|
- boolean personHidden = preferences.getBoolean(HIDE_PERSON_PREFERENCE, false);
|
|
|
-
|
|
|
- switch (position) {
|
|
|
- case 0:
|
|
|
- if (!moviesHidden) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- case 1:
|
|
|
- if ((position == 0 || !moviesHidden) && !seriesHidden) {
|
|
|
- return 1;
|
|
|
- }
|
|
|
- case 2:
|
|
|
- if ((position < 2 || (!moviesHidden && !seriesHidden)) && !savedHidden) {
|
|
|
- return 2;
|
|
|
- }
|
|
|
- case 3:
|
|
|
- if ((position < 3 || (!moviesHidden && !seriesHidden && !savedHidden))
|
|
|
- && !personHidden) {
|
|
|
- return 3;
|
|
|
- }
|
|
|
- default:
|
|
|
- return -1;
|
|
|
- }
|
|
|
+ int index = 0;
|
|
|
+ index += preferences.getBoolean(HIDE_MOVIES_PREFERENCE, false) ? 8 : 0;
|
|
|
+ index += preferences.getBoolean(HIDE_SERIES_PREFERENCE, false) ? 4 : 0;
|
|
|
+ index += preferences.getBoolean(HIDE_SAVED_PREFERENCE, false) ? 2 : 0;
|
|
|
+ index += preferences.getBoolean(HIDE_PERSON_PREFERENCE, false) ? 1 : 0;
|
|
|
+
|
|
|
+ int[][] corpos = {
|
|
|
+ {0, 1, 2, 3}, // MOV SER SAV PER
|
|
|
+ {0, 1, 2, -1}, // MOV SER SAV ---
|
|
|
+ {0, 1, 3, -1}, // MOV SER PER ---
|
|
|
+ {0, 1, -1, -1}, // MOV SER --- ---
|
|
|
+ {0, 2, 3, -1}, // MOV SAV PER ---
|
|
|
+ {0, 2, -1, -1}, // MOV SAV --- ---
|
|
|
+ {0, 3, -1, -1}, // MOV PER --- ---
|
|
|
+ {0, -1, -1, -1}, // MOV --- --- ---
|
|
|
+ {1, 2, 3, -1}, // SER SAV PER ---
|
|
|
+ {1, 2, -1, -1}, // SER SAV --- ---
|
|
|
+ {1, 3, -1, -1}, // SER PER --- ---
|
|
|
+ {1, -1, -1, -1}, // SER --- --- ---
|
|
|
+ {2, 3, -1, -1}, // SAV PER --- ---
|
|
|
+ {2, -1, -1, -1}, // SAV --- --- ---
|
|
|
+ {3, -1, -1, -1}, // PER --- --- ---
|
|
|
+ {-1, -1, -1, -1},// --- --- --- ---
|
|
|
+ };
|
|
|
+ // magic!
|
|
|
+ return corpos[index][position];
|
|
|
}
|
|
|
}
|