-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/IstrajI/Insight
# Conflicts: # .idea/modules.xml # MyApplication/dependencies.gradle # app/build.gradle # app/src/main/java/com/npgames/insight/ui/book/top_panel/TopPanelView.java # build.gradle # gradle/wrapper/gradle-wrapper.properties
- Loading branch information
Showing
76 changed files
with
1,506 additions
and
160 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
app/src/main/java/com/npgames/insight/MvpDialogFragmentCompat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
package com.npgames.insight; | ||
|
||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.support.v4.app.DialogFragment; | ||
import android.support.v4.app.Fragment; | ||
|
||
import com.arellomobile.mvp.MvpDelegate; | ||
import com.arellomobile.mvp.MvpDialogFragment; | ||
|
||
public class MvpDialogFragmentCompat extends DialogFragment { | ||
private boolean mIsStateSaved; | ||
private MvpDelegate<? extends MvpDialogFragmentCompat> mMvpDelegate; | ||
|
||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
getMvpDelegate().onCreate(savedInstanceState); | ||
} | ||
|
||
public void onResume() { | ||
super.onResume(); | ||
|
||
mIsStateSaved = false; | ||
|
||
getMvpDelegate().onAttach(); | ||
} | ||
|
||
public void onSaveInstanceState(Bundle outState) { | ||
super.onSaveInstanceState(outState); | ||
|
||
mIsStateSaved = true; | ||
|
||
getMvpDelegate().onSaveInstanceState(outState); | ||
getMvpDelegate().onDetach(); | ||
} | ||
|
||
@Override | ||
public void onStop() { | ||
super.onStop(); | ||
|
||
getMvpDelegate().onDetach(); | ||
} | ||
|
||
@Override | ||
public void onDestroyView() { | ||
super.onDestroyView(); | ||
|
||
getMvpDelegate().onDetach(); | ||
getMvpDelegate().onDestroyView(); | ||
} | ||
|
||
@Override | ||
public void onDestroy() { | ||
super.onDestroy(); | ||
|
||
//We leave the screen and respectively all fragments will be destroyed | ||
if (getActivity().isFinishing()) { | ||
getMvpDelegate().onDestroy(); | ||
return; | ||
} | ||
|
||
// When we rotate device isRemoving() return true for fragment placed in backstack | ||
// http://stackoverflow.com/questions/34649126/fragment-back-stack-and-isremoving | ||
if (mIsStateSaved) { | ||
mIsStateSaved = false; | ||
return; | ||
} | ||
|
||
// See https://github.com/Arello-Mobile/Moxy/issues/24 | ||
boolean anyParentIsRemoving = false; | ||
|
||
if (Build.VERSION.SDK_INT >= 17) { | ||
Fragment parent = getParentFragment(); | ||
while (!anyParentIsRemoving && parent != null) { | ||
anyParentIsRemoving = parent.isRemoving(); | ||
parent = parent.getParentFragment(); | ||
} | ||
} | ||
|
||
if (isRemoving() || anyParentIsRemoving) { | ||
getMvpDelegate().onDestroy(); | ||
} | ||
} | ||
|
||
/** | ||
* @return The {@link MvpDelegate} being used by this Fragment. | ||
*/ | ||
public MvpDelegate getMvpDelegate() { | ||
if (mMvpDelegate == null) { | ||
mMvpDelegate = new MvpDelegate<>(this); | ||
} | ||
|
||
return mMvpDelegate; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/src/main/java/com/npgames/insight/data/directory/DirectoryItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.npgames.insight.data.directory; | ||
|
||
public class DirectoryItem { | ||
public String title; | ||
public String content; | ||
public boolean isOpen; | ||
} |
76 changes: 76 additions & 0 deletions
76
app/src/main/java/com/npgames/insight/data/directory/DirectoryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.npgames.insight.data.directory; | ||
|
||
import android.content.Context; | ||
import android.content.res.Resources; | ||
import android.util.Pair; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DirectoryRepository { | ||
private static DirectoryRepository directoryRepository; | ||
private final Resources resources; | ||
private final String packageName; | ||
|
||
private DirectoryRepository(final Context context) { | ||
this.resources = context.getResources(); | ||
this.packageName = context.getPackageName(); | ||
} | ||
|
||
public static DirectoryRepository getInstance(final Context context) { | ||
if (directoryRepository == null) { | ||
directoryRepository = new DirectoryRepository(context); | ||
} | ||
return directoryRepository; | ||
} | ||
|
||
public List<DirectoryItem> getDirectoryList() { | ||
final List<DirectoryItem> directoryItems = new ArrayList<>(); | ||
|
||
int counter = 1; | ||
Pair<Integer, Integer> directoryResources = getDirectoryResources(counter); | ||
int directoryTitleResId = directoryResources.first; | ||
int directoryContentResId = directoryResources.second; | ||
|
||
while (directoryTitleResId != 0 && directoryContentResId != 0) { | ||
final DirectoryItem directoryItem = new DirectoryItem(); | ||
|
||
try { | ||
directoryItem.title = resources.getString(directoryTitleResId); | ||
directoryItem.content = resources.getString(directoryContentResId); | ||
directoryItems.add(directoryItem); | ||
} catch (Resources.NotFoundException ex) { | ||
|
||
} | ||
|
||
counter++; | ||
directoryResources = getDirectoryResources(counter); | ||
directoryTitleResId = directoryResources.first; | ||
directoryContentResId = directoryResources.second; | ||
} | ||
|
||
return directoryItems; | ||
} | ||
|
||
private Pair<Integer, Integer> getDirectoryResources(final int number) { | ||
final String directoryTitleResName = formatTitleResName(number); | ||
final String directoryContentResName = formatTitleResContent(number); | ||
|
||
final int directoryTitleResId = resources.getIdentifier(directoryTitleResName, "string", packageName); | ||
final int directoryContentResId = resources.getIdentifier(directoryContentResName, "string", packageName); | ||
|
||
return new Pair<>(directoryTitleResId, directoryContentResId); | ||
} | ||
|
||
final String DIRECTORY_TITLE_RES_STRING = "directory_title_"; | ||
final String DIRECTORY_CONTENT_RES_STRING = "directory_description_"; | ||
|
||
private String formatTitleResName(final int number) { | ||
return DIRECTORY_TITLE_RES_STRING + number; | ||
} | ||
|
||
private String formatTitleResContent(final int number) { | ||
return DIRECTORY_CONTENT_RES_STRING + number; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.