Full Code of NoireFHC/NHentai-android for AI

master 140f9ae64799 cached
119 files
346.6 KB
89.6k tokens
755 symbols
1 requests
Download .txt
Showing preview only (384K chars total). Download the full file or copy to clipboard to get everything.
Repository: NoireFHC/NHentai-android
Branch: master
Commit: 140f9ae64799
Files: 119
Total size: 346.6 KB

Directory structure:
gitextract_wd0zl69i/

├── .gitignore
├── LICENSE
├── README.md
├── app/
│   ├── .gitignore
│   ├── app-release.apk
│   ├── build.gradle
│   ├── proguard-rules.pro
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           ├── assets/
│           │   └── licenses.html
│           ├── java/
│           │   ├── moe/
│           │   │   └── feng/
│           │   │       └── nhentai/
│           │   │           ├── api/
│           │   │           │   ├── BookApi.java
│           │   │           │   ├── PageApi.java
│           │   │           │   └── common/
│           │   │           │       └── NHentaiUrl.java
│           │   │           ├── cache/
│           │   │           │   ├── common/
│           │   │           │   │   └── Constants.java
│           │   │           │   └── file/
│           │   │           │       ├── FileCacheManager.java
│           │   │           │       └── OfflineDocumentManager.java
│           │   │           ├── dao/
│           │   │           │   ├── CommonPreferences.java
│           │   │           │   └── SearchHistoryManager.java
│           │   │           ├── model/
│           │   │           │   ├── BaseMessage.java
│           │   │           │   └── Book.java
│           │   │           ├── ui/
│           │   │           │   ├── BookDetailsActivity.java
│           │   │           │   ├── CategoryActivity.java
│           │   │           │   ├── GalleryActivity.java
│           │   │           │   ├── MainActivity.java
│           │   │           │   ├── SearchResultActivity.java
│           │   │           │   ├── SettingsActivity.java
│           │   │           │   ├── adapter/
│           │   │           │   │   ├── BookListRecyclerAdapter.java
│           │   │           │   │   ├── BookPreviewGridAdapter.java
│           │   │           │   │   ├── GalleryPagerAdapter.java
│           │   │           │   │   └── HomePagerAdapter.java
│           │   │           │   ├── common/
│           │   │           │   │   ├── AbsActivity.java
│           │   │           │   │   └── AbsRecyclerViewAdapter.java
│           │   │           │   └── fragment/
│           │   │           │       ├── BookPageFragment.java
│           │   │           │       ├── main/
│           │   │           │       │   ├── DownloadManagerFragment.java
│           │   │           │       │   ├── FavoriteFragment.java
│           │   │           │       │   └── HomeFragment.java
│           │   │           │       └── settings/
│           │   │           │           ├── SettingsLicense.java
│           │   │           │           └── SettingsMain.java
│           │   │           ├── util/
│           │   │           │   ├── AsyncTask.java
│           │   │           │   ├── ColorGenerator.java
│           │   │           │   ├── FullScreenHelper.java
│           │   │           │   ├── HttpTools.java
│           │   │           │   ├── Settings.java
│           │   │           │   ├── TextDrawable.java
│           │   │           │   └── Utility.java
│           │   │           └── view/
│           │   │               ├── AutoWrapLayout.java
│           │   │               ├── ExpandableHeightGridView.java
│           │   │               ├── WheelProgressView.java
│           │   │               └── pref/
│           │   │                   ├── Preference.java
│           │   │                   ├── SwitchPreference.java
│           │   │                   └── TwoStatePreference.java
│           │   └── sumimakito/
│           │       └── android/
│           │           └── quickkv/
│           │               ├── DataProcessor.java
│           │               ├── QKVConfig.java
│           │               ├── QKVFSReader.java
│           │               ├── QKVLogger.java
│           │               ├── QuickKV.java
│           │               ├── database/
│           │               │   ├── KeyValueDatabase.java
│           │               │   └── QKVDatabase.java
│           │               └── security/
│           │                   └── AES256.java
│           └── res/
│               ├── color/
│               │   └── drawer_item_color.xml
│               ├── drawable/
│               │   ├── shadow_gradient.xml
│               │   ├── shadow_gradient_reserve.xml
│               │   ├── shadow_normal.xml
│               │   └── shadow_normal_reserve.xml
│               ├── layout/
│               │   ├── activity_book_details.xml
│               │   ├── activity_gallery.xml
│               │   ├── activity_main.xml
│               │   ├── activity_search_result.xml
│               │   ├── activity_settings.xml
│               │   ├── custom_preference.xml
│               │   ├── custom_preference_widget_switch.xml
│               │   ├── fragment_book_page.xml
│               │   ├── fragment_download.xml
│               │   ├── fragment_favorite.xml
│               │   ├── fragment_home.xml
│               │   ├── list_item_book_card.xml
│               │   ├── list_item_book_picture_thumb.xml
│               │   ├── list_item_menu_row.xml
│               │   └── navigation_header.xml
│               ├── menu/
│               │   ├── menu_main.xml
│               │   └── navigation_menu.xml
│               ├── values/
│               │   ├── attrs.xml
│               │   ├── color.xml
│               │   ├── dimen.xml
│               │   ├── strings.xml
│               │   └── styles.xml
│               ├── values-v21/
│               │   └── styles.xml
│               ├── values-zh-rCN/
│               │   └── strings.xml
│               ├── values-zh-rTW/
│               │   └── strings.xml
│               └── xml/
│                   └── settings_main.xml
├── build.gradle
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── libraries/
│   └── PersistentSearch/
│       ├── .gitignore
│       ├── build.gradle
│       ├── gradle.properties
│       ├── proguard-rules.pro
│       └── src/
│           └── main/
│               ├── AndroidManifest.xml
│               ├── java/
│               │   ├── com/
│               │   │   ├── balysv/
│               │   │   │   └── materialmenu/
│               │   │   │       ├── MaterialMenu.java
│               │   │   │       ├── MaterialMenuDrawable.java
│               │   │   │       └── MaterialMenuView.java
│               │   │   └── quinny898/
│               │   │       └── library/
│               │   │           └── persistentsearch/
│               │   │               ├── SearchBox.java
│               │   │               └── SearchResult.java
│               │   └── io/
│               │       └── codetail/
│               │           ├── animation/
│               │           │   ├── RevealAnimator.java
│               │           │   ├── ReverseInterpolator.java
│               │           │   ├── SupportAnimator.java
│               │           │   ├── SupportAnimatorLollipop.java
│               │           │   ├── SupportAnimatorPreL.java
│               │           │   └── ViewAnimationUtils.java
│               │           └── widget/
│               │               ├── RevealFrameLayout.java
│               │               └── RevealLinearLayout.java
│               └── res/
│                   ├── anim/
│                   │   └── anim_down.xml
│                   ├── layout/
│                   │   ├── search_option.xml
│                   │   └── searchbox.xml
│                   └── values/
│                       ├── strings.xml
│                       └── styles.xml
└── settings.gradle

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
.gradle
/local.properties
/.idea
.DS_Store
/build

*.iml


================================================
FILE: LICENSE
================================================
                    GNU GENERAL PUBLIC LICENSE
                       Version 3, 29 June 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU General Public License is a free, copyleft license for
software and other kinds of works.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.  We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors.  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights.  Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received.  You must make sure that they, too, receive
or can get the source code.  And you must show them these terms so they
know their rights.

  Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.

  For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software.  For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.

  Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so.  This is fundamentally incompatible with the aim of
protecting users' freedom to change the software.  The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable.  Therefore, we
have designed this version of the GPL to prohibit the practice for those
products.  If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.

  Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary.  To prevent this, the GPL assures that
patents cannot be used to render the program non-free.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Use with the GNU Affero General Public License.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:

    <program>  Copyright (C) <year>  <name of author>
    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.

  The GNU General Public License does not permit incorporating your program
into proprietary programs.  If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.  But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

================================================
FILE: README.md
================================================
# NHBooks for Android
![NHBooksLogo](/art/nhbooks.png)

a Material Design NHentai client for Android.
一枚 Material Design 風格的 NHentai Android 客戶端

### 螢幕截圖
![S0](/art/screenshot0.png)

![S1](/art/screenshot1.png)

## 軟體說明
該程式按照 Material Design 設計規範,提供簡潔、美觀的介面,並通過 API 從 NHentai 獲取本子,給你一個輕量、方便的客戶端。

### 特別聲明
該應用程式所供應的內容不適合未成年人觀看,所有內容通過 Jsoup 解析 NHentai 官網獲得,內容有任何異議或造成心理甚至生理上的問題均與本項目無關。

觀看時請留意是否適用於當地法律法規。

### 聯絡我

Google Plus: +Fung Jichun

新浪微博: @某燒餅

### 支持項目

Alipay 支付寶: 316643843@qq.com

### License 開源協議

```
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007

Copyright (C) 2015 FengMoe Team

This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it under certain conditions.
```


================================================
FILE: app/.gitignore
================================================
/build


================================================
FILE: app/build.gradle
================================================
apply plugin: 'com.android.application'

android {
	compileSdkVersion 22
	buildToolsVersion "22.0.1"

	defaultConfig {
		applicationId "moe.feng.nhentai"
		minSdkVersion 15
		targetSdkVersion 22
		versionCode 1
		versionName "1.0"
	}
	buildTypes {
		release {
			minifyEnabled false
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
		}
	}
}

dependencies {
	compile fileTree(dir: 'libs', include: ['*.jar'])
	compile project(':libraries:PersistentSearch')
	compile 'com.android.support:support-v13:22.2.0'
	compile 'com.android.support:design:22.2.0'
	compile 'com.android.support:appcompat-v7:22.2.0'
	compile 'com.android.support:cardview-v7:22.2.0'
	compile 'com.android.support:recyclerview-v7:22.2.0'
	compile 'com.google.code.gson:gson:2.3.1'
	compile 'org.jsoup:jsoup:1.8.2'
	compile 'com.github.chrisbanes.photoview:library:1.2.3'
	compile 'com.squareup.picasso:picasso:2.5.2'
	compile ('com.github.florent37:materialimageloading:1.0.1@aar'){
		transitive = true
	}
}


================================================
FILE: app/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in E:\Feng\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}


================================================
FILE: app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="moe.feng.nhentai" >

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.NHBooks.Light.DarkActionBar" >
        <activity
            android:name=".ui.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.BookDetailsActivity"
            android:label="@string/activity_details" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>

	    <activity
		    android:name=".ui.GalleryActivity"
		    android:label="@string/activity_gallery"
		    android:theme="@style/Theme.NHBooks.Dark">
		    <intent-filter>
			    <action android:name="android.intent.action.MAIN" />
		    </intent-filter>
	    </activity>

        <activity
            android:name=".ui.SearchResultActivity"
            android:label="@string/activity_search_result"
            android:theme="@style/Theme.NHBooks.Light.DarkActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.CategoryActivity"
            android:label="@string/activity_search_result"
            android:theme="@style/Theme.NHBooks.Light.DarkActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>

        <activity
            android:name=".ui.SettingsActivity"
            android:label="@string/settings_main"
            android:theme="@style/Theme.NHBooks.Light.DarkActionBar.Fix">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
        </activity>
    </application>

</manifest>


================================================
FILE: app/src/main/assets/licenses.html
================================================
<html>
<head>
	<style>
		body {
		margin: 1em;
		}
		pre {
		background: #DDD;
		padding: 1em;
		white-space: pre-wrap;
		}
	</style>
</head>
<body>

<h2>Notices for Additional Libraries</h2>

<p>This app contains several libraries that are released under the terms of the following licenses.</p>

<h3>Notices for files:</h3>

<ul>
	<li>Android Support Library (v4, v7, v13, Design Support)</li>
</ul>
	<pre>Copyright (C) 2013 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>

<h3>Notices for files:</h3>

<ul>
	<li>QuickKV</li>
</ul>
	<pre>Copyright 2014-2015 Sumi Makito

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. </pre>

<h3>Notices for files:</h3>

<ul>
	<li>Persistent Search</li>
</ul>
	<pre>Copyright 2015 Kieron Quinn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>

<h3>Notices for files:</h3>

<ul>
	<li>Picasso</li>
</ul>
	<pre>Copyright 2013 Square, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>

<h3>Notices for files:</h3>

<ul>
	<li>Gson</li>
</ul>
	<pre>Copyright 2008 Google, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>

<h3>Notices for files:</h3>

<ul>
	<li>Jsoup</li>
</ul>
	<pre>The MIT License

© 2009-2015, Jonathan Hedley <jonathan@hedley.net>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.</pre>

<h3>Notices for files:</h3>

<ul>
	<li>PhotoView</li>
</ul>
	<pre>Copyright 2011, 2012 Chris Banes

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>

<h3>Notices for files:</h3>

<ul>
	<li>MaterialImageLoading</li>
</ul>
	<pre>Copyright 2015 florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</pre>

</body>
</html>

================================================
FILE: app/src/main/java/moe/feng/nhentai/api/BookApi.java
================================================
package moe.feng.nhentai.api;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

import moe.feng.nhentai.api.common.NHentaiUrl;
import moe.feng.nhentai.cache.file.FileCacheManager;
import moe.feng.nhentai.model.BaseMessage;
import moe.feng.nhentai.model.Book;
import static moe.feng.nhentai.cache.common.Constants.CACHE_COVER;
import static moe.feng.nhentai.cache.common.Constants.CACHE_PAGE_THUMB;
import static moe.feng.nhentai.cache.common.Constants.CACHE_THUMB;

public class BookApi {

	public static final String TAG = BookApi.class.getSimpleName();

	public static BaseMessage getBook(String id) {
		BaseMessage result = new BaseMessage();

		String url = NHentaiUrl.getBookDetailsUrl(id);

		Document doc;
		try {
			doc = Jsoup.connect(url).get();
		} catch (IOException e) {
			result.setCode(403);
			e.printStackTrace();
			return result;
		}

		Book book = new Book();

		Elements info = doc.getElementsByAttributeValue("id", "info");
		Element element = info.get(0);

		/** Get basic info */
		book.title = element.getElementsByTag("h1").get(0).text();
		try {
			book.titleJP = element.getElementsByTag("h2").get(0).text();
		} catch (Exception e) {
			Log.v(TAG, "This book hasn\'t japanese name.");
		}
		book.bookId = id;

		/** Get tags */
		Elements tags = doc.getElementsByClass("field-name");
		for (Element r : tags) {
			if (r.text().contains("Parodies")) {
				String ts = r.getElementsByClass("tagbutton").get(0).text();
				if (ts.contains("(")) {
					ts = ts.substring(0, ts.indexOf("(") - 1);
				}
				book.parodies = ts;
			}
			if (r.text().contains("Tags")) {
				for (Element e : r.getElementsByClass("tagbutton")) {
					String ts = e.text();
					if (ts.contains("(")) {
						ts = ts.substring(0, ts.indexOf("(") - 1);
					}
					book.tags.add(ts);
				}
			}
			if (r.text().contains("Language")) {
				String ts = r.getElementsByClass("tagbutton").get(0).text();
				if (ts.contains("(")) {
					ts = ts.substring(0, ts.indexOf("(") - 1);
				}
				book.language = ts;
			}
			if (r.text().contains("Groups")) {
				String ts = r.getElementsByClass("tagbutton").get(0).text();
				if (ts.contains("(")) {
					ts = ts.substring(0, ts.indexOf("(") - 1);
				}
				book.group = ts;
			}
			if (r.text().contains("Artists")) {
				String ts = r.getElementsByClass("tagbutton").get(0).text();
				if (ts.contains("(")) {
					ts = ts.substring(0, ts.indexOf("(") - 1);
				}
				book.artist = ts;
			}
			if (r.text().contains("Characters")) {
				for (Element e : r.getElementsByClass("tagbutton")) {
					String ts = e.text();
					if (ts.contains("(")) {
						ts = ts.substring(0, ts.indexOf("(") - 1);
					}
					book.characters.add(ts);
				}
			}
		}

		/** Get page count */
		String htmlSrc = element.html();
		try {
			int position = htmlSrc.indexOf("pages");
			String s = htmlSrc.substring(0, position);
			System.out.println(s);
			s = s.substring(s.lastIndexOf("<div>") + "<div>".length(), s.length()).trim();
			System.out.println(s);
			book.pageCount = Integer.valueOf(s);
		} catch (Exception e) {

		}

		/** Get uploaded time */
		try {
			Element timeElement = doc.getElementsByTag("time").get(0);
			book.uploadTime = timeElement.attr("datetime");
			book.uploadTimeText = timeElement.text();
		} catch (Exception e) {

		}

		/** Get gallery id and preview image url */
		Element coverDiv = doc.getElementById("cover").getElementsByTag("a").get(0);
		for (Element e : coverDiv.getElementsByTag("img")) {
			try {
				Log.i(TAG, coverDiv.html());
				String coverUrl = e.attr("src");
				Log.i(TAG, coverUrl);
				coverUrl = coverUrl.substring(0, coverUrl.lastIndexOf("/"));
				String galleryId = coverUrl.substring(coverUrl.lastIndexOf("/") + 1, coverUrl.length());
				book.galleryId = galleryId;
				book.previewImageUrl = NHentaiUrl.getThumbUrl(galleryId);
				book.bigCoverImageUrl = NHentaiUrl.getBigCoverUrl(galleryId);
				break;
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}

		Log.i(TAG, book.toJSONString());

		result.setCode(0);
		result.setData(book);

		return result;
	}
	
	public static Bitmap getCover(Context context, Book book) {
		String url = book.bigCoverImageUrl;
		FileCacheManager m = FileCacheManager.getInstance(context);
		
		if (!m.cacheExistsUrl(CACHE_COVER, url) && !m.createCacheFromNetwork(CACHE_COVER, url)) {
			return null;
		}
		
		return m.getBitmapUrl(CACHE_COVER, url);
	}

	public static Bitmap getThumb(Context context, Book book) {
		String url = book.previewImageUrl;
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_THUMB, url) && !m.createCacheFromNetwork(CACHE_THUMB, url)) {
			return null;
		}

		return m.getBitmapUrl(CACHE_THUMB, url);
	}

	public static Bitmap getPageThumb(Context context, Book book, int position) {
		String url = NHentaiUrl.getThumbPictureUrl(book.galleryId, Integer.toString(position));
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_PAGE_THUMB, url) && !m.createCacheFromNetwork(CACHE_PAGE_THUMB, url)) {
			return null;
		}

		return m.getBitmapUrl(CACHE_PAGE_THUMB, url);
	}

	public static File getCoverFile(Context context, Book book) {
		String url = book.bigCoverImageUrl;
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_COVER, url) && !m.createCacheFromNetwork(CACHE_COVER, url)) {
			return null;
		}

		return m.getBitmapUrlFile(CACHE_COVER, url);
	}

	public static File getThumbFile(Context context, Book book) {
		String url = book.previewImageUrl;
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_THUMB, url) && !m.createCacheFromNetwork(CACHE_THUMB, url)) {
			return null;
		}

		return m.getBitmapUrlFile(CACHE_THUMB, url);
	}

	public static File getPageThumbFile(Context context, Book book, int position) {
		String url = NHentaiUrl.getThumbPictureUrl(book.galleryId, Integer.toString(position));
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_PAGE_THUMB, url) && !m.createCacheFromNetwork(CACHE_PAGE_THUMB, url)) {
			return null;
		}

		return m.getBitmapUrlFile(CACHE_PAGE_THUMB, url);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/api/PageApi.java
================================================
package moe.feng.nhentai.api;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.Log;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;

import moe.feng.nhentai.api.common.NHentaiUrl;
import moe.feng.nhentai.cache.file.FileCacheManager;
import moe.feng.nhentai.model.BaseMessage;
import moe.feng.nhentai.model.Book;

import static moe.feng.nhentai.cache.common.Constants.CACHE_PAGE_IMG;

public class PageApi {

	public static final String TAG = PageApi.class.getSimpleName();

	public static BaseMessage getPageList(String url) {
		BaseMessage result = new BaseMessage();

		Document doc;
		try {
			doc = Jsoup.connect(url).get();
		} catch (IOException e) {
			result.setCode(403);
			e.printStackTrace();
			return result;
		}

		Elements container = doc.getElementsByClass("outer-preview-container");

		ArrayList<Book> books = new ArrayList<>();

		for (Element e : container) {
			Book book = new Book();

			Element caption = e.getElementsByClass("caption").get(0);
			Element titleElement = caption.getElementsByTag("a").get(0);
			String bookId = titleElement.attr("href");
			bookId = bookId.substring(0, bookId.lastIndexOf("/"));
			bookId = bookId.substring(bookId.lastIndexOf("/") + 1, bookId.length());
			book.bookId = bookId;
			book.title = titleElement.text();

			Elements imgs = e.getElementsByTag("img");
			for (Element imge : imgs) {
				if (imge.hasAttr("src")) {
					String thumbUrl = imge.attr("src");
					thumbUrl = thumbUrl.substring(0, thumbUrl.lastIndexOf("/"));
					String galleryId = thumbUrl.substring(thumbUrl.lastIndexOf("/") + 1, thumbUrl.length());
					book.galleryId = galleryId;
					book.bigCoverImageUrl = NHentaiUrl.getBigCoverUrl(galleryId);
					book.previewImageUrl = NHentaiUrl.getThumbUrl(galleryId);
					try {
						book.thumbHeight = Integer.valueOf(imge.attr("height"));
						book.thumbWidth = Integer.valueOf(imge.attr("width"));
					} catch (Exception ex) {

					}
				}
			}

			if (book.bookId != null && !book.bookId.isEmpty()) {
				books.add(book);
			}

			Log.i(TAG, "Get book: " + book.toJSONString());
		}

		result.setCode(0);
		result.setData(books);

		return result;
	}

	public static BaseMessage getHomePageList(int number) {
		return getPageList(NHentaiUrl.getHomePageUrl(number));
	}

	public static BaseMessage getSearchPageList(String keyword, int number) {
		return getPageList(NHentaiUrl.getSearchUrl(keyword, number));
	}

	public static Bitmap getPageOriginImage(Context context, Book book, int page_num) {
		String url = NHentaiUrl.getOriginPictureUrl(book.galleryId, String.valueOf(page_num));
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_PAGE_IMG, url) && !m.createCacheFromNetwork(CACHE_PAGE_IMG, url)) {
			return null;
		}

		return m.getBitmapUrl(CACHE_PAGE_IMG, url);
	}

	public static File getPageOriginImageFile(Context context, Book book, int page_num) {
		String url = NHentaiUrl.getOriginPictureUrl(book.galleryId, String.valueOf(page_num));
		FileCacheManager m = FileCacheManager.getInstance(context);

		if (!m.cacheExistsUrl(CACHE_PAGE_IMG, url) && !m.createCacheFromNetwork(CACHE_PAGE_IMG, url)) {
			return null;
		}

		return m.getBitmapUrlFile(CACHE_PAGE_IMG, url);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/api/common/NHentaiUrl.java
================================================
package moe.feng.nhentai.api.common;

public class NHentaiUrl {

	public static final String NHENTAI_HOME = "http://nhentai.net";
	public static final String NHENTAI_I = "http://i.nhentai.net";

	public static String getSearchUrl(String content) {
		return getSearchUrl(content, 1);
	}

	public static String getSearchUrl(String content, int page_num) {
		String targetContent = content;
		if (targetContent.contains(" ")) {
			targetContent = targetContent.replaceAll(" ", "+");
		}
		return NHENTAI_HOME + "/search/?q=" + targetContent + "&page=" + page_num;
	}

	public static String getBookDetailsUrl(String book_id) {
		return NHENTAI_HOME + "/g/" + book_id;
	}

	public static String getBookPageUrl(String book_id, int page_num) {
		return getBookDetailsUrl(book_id) + "/" + page_num;
	}

	public static String getGalleryUrl(String g_id) {
		return NHENTAI_I + "/galleries/" + g_id;
	}

	public static String getOriginPictureUrl(String g_id, String page_num) {
		return getPictureUrl(g_id, page_num, "jpg");
	}

	public static String getThumbPictureUrl(String g_id, String page_num) {
		return getPictureUrl(g_id, page_num + "t", "jpg");
	}

	public static String getThumbUrl(String g_id) {
		return getPictureUrl(g_id, "thumb", "jpg");
	}

	public static String getBigCoverUrl(String g_id) {
		// TODO Not all covers are jpgs
		return getPictureUrl(g_id, "cover", "jpg");
	}

	public static String getPictureUrl(String g_id, String page_num, String file_type) {
		return getGalleryUrl(g_id) + "/" + page_num + "." + file_type;
	}

	public static String getParodyUrl(String name) {
		String targetName = name;
		if (targetName.contains(" ")) {
			targetName = targetName.replaceAll(" ", "-");
		}
		return NHENTAI_HOME + "/parody/" + targetName;
	}

	public static String getCharacterUrl(String name) {
		String targetName = name;
		if (targetName.contains(" ")) {
			targetName = targetName.replaceAll(" ", "-");
		}
		return NHENTAI_HOME + "/character/" + targetName;
	}

	public static String getTagUrl(String tag) {
		String targetTag = tag;
		if (targetTag.contains(" ")) {
			targetTag = targetTag.replaceAll(" ", "-");
		}
		return NHENTAI_HOME + "/tagged/" + targetTag;
	}

	public static String getArtistUrl(String name) {
		String targetName = name;
		if (targetName.contains(" ")) {
			targetName = targetName.replaceAll(" ", "-");
		}
		return NHENTAI_HOME + "/artist/" + targetName;
	}

	public static String getGroupUrl(String name) {
		String targetName = name;
		if (targetName.contains(" ")) {
			targetName = targetName.replaceAll(" ", "-");
		}
		return NHENTAI_HOME + "/group/" + targetName;
	}

	public static String getLanguageUrl(String name) {
		String targetName = name;
		if (targetName.contains(" ")) {
			targetName = targetName.replaceAll(" ", "-");
		}
		return NHENTAI_HOME + "/language/" + targetName;
	}

	public static String getHomePageUrl(int page) {
		return NHENTAI_HOME + "/?page=" + page;
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/cache/common/Constants.java
================================================
package moe.feng.nhentai.cache.common;

public class Constants {

	public static final String CACHE_COVER = "cover", CACHE_PAGE_IMG = "pages",
			CACHE_PAGE_THUMB = "thumb", CACHE_THUMB = "thumb", CACHE_DOCUMENT = "document";

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/cache/file/FileCacheManager.java
================================================
package moe.feng.nhentai.cache.file;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.net.URL;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;

import static moe.feng.nhentai.BuildConfig.DEBUG;

public class FileCacheManager {

	private static final String TAG = FileCacheManager.class.getSimpleName();
	
	private static FileCacheManager sInstance;
	
	private File mCacheDir;
	
	public static final FileCacheManager getInstance(Context context) {
		if (sInstance == null) {
			sInstance = new FileCacheManager(context);
		}
		
		return sInstance;
	}
	
	private FileCacheManager(Context context) {
		mCacheDir = context.getExternalCacheDir();
	}
	
	public boolean createCacheFromNetwork(String type, String url) {

		if (DEBUG) {
			Log.d(TAG, "requesting cache from " + url);
		}
		
		URL u;
		
		try {
			u = new URL(url);
		} catch (MalformedURLException e) {
			return false;
		}
		
		HttpURLConnection conn;
		
		try {
			conn = (HttpURLConnection) u.openConnection();
		} catch (IOException e) {
			return false;
		}
		
		conn.setConnectTimeout(5000);

		try {
			if (conn.getResponseCode() != 200) {
				if (url.contains("jpg")) {
					try {
						u = new URL(url.replace("jpg", "png"));
					} catch (MalformedURLException ex) {
						return false;
					}
					try {
						conn = (HttpURLConnection) u.openConnection();
					} catch (IOException ex) {
						return false;
					}
				} else {
					return false;
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		try {
			return createCacheFromStrem(type, getCacheName(url), conn.getInputStream());
		} catch (IOException e) {
			return false;
		}
	}
	
	public boolean createCacheFromStrem(String type, String name, InputStream stream) {
		File f = new File(getCachePath(type, name) + "_downloading");
		f.getParentFile().mkdirs();
		f.getParentFile().mkdir();
		
		if (f.exists()) {
			f.delete();
		}
		
		try {
			f.createNewFile();
		} catch (IOException e) {
			return false;
		}
		
		FileOutputStream opt;
		
		try {
			opt = new FileOutputStream(f);
		} catch (FileNotFoundException e) {
			return false;
		}
		
		byte[] buf = new byte[512];
		int len = 0;
		
		try {
			while ((len = stream.read(buf)) != -1) {
				opt.write(buf, 0, len);
			}
		} catch (IOException e) {
			return false;
		}
		
		try {
			stream.close();
			opt.close();
		} catch (IOException e) {
			
		}

		f.renameTo(new File(getCachePath(type, name)));

		return true;
	}
	
	// True if the cache downloaded from url exists
	public boolean cacheExistsUrl(String type, String url) {
		return cacheExists(type, getCacheName(url));
	}
	
	public boolean cacheExists(String type, String name) {
		return new File(getCachePath(type, name)).isFile();
	}

	public boolean deleteCacheUrl(String type, String url) {
		return deleteCache(type, getCacheName(url));
	}

	public boolean deleteCache(String type, String name) {
		if (cacheExists(type, name)) {
			return new File(getCachePath(type, name)).delete();
		} else {
			return false;
		}
	}

	public InputStream openCacheStream(String type, String name) {
		try {
			return new FileInputStream(new File(getCachePath(type, name)));
		} catch (IOException e) {
			return null;
		}
	}
	
	public InputStream openCacheStreamUrl(String type, String url) {
		return openCacheStream(type, getCacheName(url));
	}
	
	public Bitmap getBitmap(String type, String name) {
		InputStream ipt = openCacheStream(type, name);
		
		if (ipt == null) return null;
		
		Bitmap ret = BitmapFactory.decodeStream(ipt);
		
		try {
			ipt.close();
		} catch (IOException e) {
			
		}
		
		return ret;
	}
	
	public Bitmap getBitmapUrl(String type, String url) {
		return getBitmap(type, getCacheName(url));
	}

	public File getBitmapFile(String type, String name) {
		return new File(getCachePath(type, name));
	}

	public File getBitmapUrlFile(String type, String url) {
		return getBitmapFile(type, getCacheName(url));
	}

	private String getCacheName(String url) {
		return url.replaceAll("/", ".").replaceAll(":", "");
	}
	
	private String getCachePath(String type, String name) {
		return mCacheDir.getAbsolutePath() + "/" + type + "/" + name + ".cache";
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/cache/file/OfflineDocumentManager.java
================================================
package moe.feng.nhentai.cache.file;

import android.content.Context;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import moe.feng.nhentai.cache.common.Constants;

public class OfflineDocumentManager {

	private FileCacheManager mCacheManager;

	private static OfflineDocumentManager sInstance;

	public static OfflineDocumentManager getInstance(Context context) {
		if (sInstance == null) {
			sInstance = new OfflineDocumentManager(context);
		}

		return sInstance;
	}

	private OfflineDocumentManager(Context context) {
		mCacheManager = FileCacheManager.getInstance(context);
	}

	public String getOfflineDocument(String url) {
		if (mCacheManager.cacheExistsUrl(Constants.CACHE_DOCUMENT, url)) {
			BufferedReader bf = new BufferedReader(
					new InputStreamReader(mCacheManager.openCacheStreamUrl(Constants.CACHE_DOCUMENT, url))
			);
			StringBuffer buffer = new StringBuffer();
			String line = "";
			try {
				while ((line = bf.readLine()) != null){
					buffer.append(line);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			return buffer.toString();
		} else {
			return null;
		}
	}

	public boolean hasOfflineCache(String url) {
		return mCacheManager.cacheExistsUrl(Constants.CACHE_DOCUMENT, url);
	}

	public boolean createOfflineCache(String url) {
		return mCacheManager.createCacheFromNetwork(Constants.CACHE_DOCUMENT, url);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/dao/CommonPreferences.java
================================================
package moe.feng.nhentai.dao;

import android.content.Context;

import java.util.ArrayList;

import sumimakito.android.quickkv.QuickKV;
import sumimakito.android.quickkv.database.KeyValueDatabase;

public class CommonPreferences {

	private QuickKV mQuickKV;
	private KeyValueDatabase mKVDB;
	private String mDBName;

	private static ArrayList<Instance> sInstances = new ArrayList<>();

	public static CommonPreferences getInstance(Context context, String dbName) {
		CommonPreferences sInstance = null;
		for (Instance i : sInstances) {
			if (i.dbName == dbName) {
				sInstance = i.preferences;
				break;
			}
		}
		if (sInstance == null) {
			sInstance = new CommonPreferences(context, dbName);
			sInstances.add(new Instance(sInstance, dbName));
		}
		return sInstance;
	}

	private CommonPreferences(Context context, String dbName) {
		this.mQuickKV = new QuickKV(context);
		this.mDBName = dbName;
		reload();
	}

	public void sync() {
		this.mKVDB.sync(true);
	}

	public void reload() {
		this.mKVDB = this.mQuickKV.getDatabase("prefs_" + mDBName);
	}

	public Editor edit() {
		return new Editor(mKVDB);
	}

	public int getInt(String key, int defValue) {
		return contains(key) ? (int) mKVDB.get(key) : defValue;
	}

	public String getString(String key, String defValue) {
		return contains(key) ? (String) mKVDB.get(key) : defValue;
	}

	public boolean getBoolean(String key, boolean defValue) {
		return contains(key) ? (boolean) mKVDB.get(key) : defValue;
	}

	public long getLong(String key, long defValue) {
		return contains(key) ? (long) mKVDB.get(key) : defValue;
	}

	public float getFloat(String key, float defValue) {
		return contains(key) ? (float) mKVDB.get(key) : defValue;
	}

	public boolean contains(String key) {
		return mKVDB.containsKey(key);
	}

	public class Editor {

		private KeyValueDatabase mKVDB;

		private Editor(KeyValueDatabase kvdb) {
			this.mKVDB = kvdb;
		}

		public Editor putBoolean(String key, boolean value) {
			this.mKVDB.put(key, value);
			return this;
		}

		public Editor putInt(String key, int value) {
			this.mKVDB.put(key, value);
			return this;
		}

		public Editor putString(String key, String value) {
			this.mKVDB.put(key, value);
			return this;
		}

		public Editor putLong(String key, long value) {
			this.mKVDB.put(key, value);
			return this;
		}

		public Editor putFloat(String key, float value) {
			this.mKVDB.put(key, value);
			return this;
		}

		public Editor remove(String key){
			this.mKVDB.remove(key);
			return this;
		}

		public void clear() {
			this.mKVDB.clear();
			this.mKVDB.persist();
		}

		public boolean commit() {
			return this.mKVDB.persist();
		}

	}

	private static class Instance {

		CommonPreferences preferences;
		String dbName;

		public Instance(CommonPreferences preferences, String dbName) {
			this.preferences = preferences;
			this.dbName = dbName;
		}

	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/dao/SearchHistoryManager.java
================================================
package moe.feng.nhentai.dao;

import android.content.Context;

import com.quinny898.library.persistentsearch.SearchResult;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import sumimakito.android.quickkv.QuickKV;
import sumimakito.android.quickkv.database.KeyValueDatabase;

public class SearchHistoryManager {

	private QuickKV mQuickKV;
	private KeyValueDatabase mDB;
	private String mSectionName;

	private static ArrayList<Instance> sInstances = new ArrayList<>();

	private static final String DATABASE_NAME = "search_history";

	public static SearchHistoryManager getInstance(Context context, String sectionName) {
		SearchHistoryManager sInstance = null;
		for (Instance i : sInstances) {
			if (i.sectionName == sectionName) {
				sInstance = i.manager;
				break;
			}
		}
		if (sInstance == null) {
			sInstance = new SearchHistoryManager(context, sectionName);
			sInstances.add(new Instance(sInstance, sectionName));
		}
		return sInstance;
	}

	public SearchHistoryManager(Context context, String sectionName) {
		this.mQuickKV = new QuickKV(context);
		this.mSectionName = sectionName;
		reloadDatabase();
	}

	public void reloadDatabase() {
		mDB = mQuickKV.getDatabase(DATABASE_NAME + "_" + mSectionName);
	}

	public void add(String keyword) {
		int pos = find(keyword);
		if (pos < 0) {
			pos = 9;
		}
		moveArrayToNext(pos - 1);
		mDB.put("history_0", keyword);
		mDB.persist();
	}

	public String get(int pos) {
		return (String) mDB.get("history_" + pos);
	}

	public int find(String keyword) {
		for (int i = 9; i >= 0; i--) {
			if (mDB.containsKey("history_" + i)) {
				if (mDB.get("history_" + i).equals(keyword)){
					return i;
				}
			}
		}
		return -1;
	}

	private void moveArrayToNext(int end) {
		for (int i = end; i >= 0; i--) {
			if (mDB.containsKey("history_" + i)) {
				mDB.put("history_" + (i + 1), mDB.get("history_" + i));
			}
		}
	}

	public void cleanAll() {
		mDB.clear();
		mDB.persist();
	}

	public String[] getAll() {
		String[] histories = new String[10];
		for (int i = 0; i < 10; i++) {
			histories[i] = (String) mDB.get("history_" + i);
		}
		return histories;
	}

	public ArrayList<SearchResult> getSearchResults() {
		ArrayList<SearchResult> results = new ArrayList<>();
		for (String history : getAll()) {
			if (history == null) continue;
			results.add(new SearchResult(history, R.drawable.ic_history));
		}
		return results;
	}

	private static class Instance {

		SearchHistoryManager manager;
		String sectionName;

		public Instance(SearchHistoryManager manager, String sectionName) {
			this.manager = manager;
			this.sectionName = sectionName;
		}

	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/model/BaseMessage.java
================================================
package moe.feng.nhentai.model;

public class BaseMessage {

	private int code = -1;
	private Object data;

	public BaseMessage(int code, Object data) {
		this.code = code;
		this.data = data;
	}

	public BaseMessage() {

	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public <T> T getData() {
		return (T) data;
	}

	public void setData(Object data) {
		this.data = data;
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/model/Book.java
================================================
package moe.feng.nhentai.model;

import com.google.gson.Gson;

import java.util.ArrayList;

public class Book {

	/** 必须获取到的数据 */
	public String title, other, bookId;

	/** 次要数据 */
	public String previewImageUrl, bigCoverImageUrl, titleJP, galleryId;
	public int pageCount;

	public int thumbHeight = 0, thumbWidth = 0;

	public String parodies, language, artist, group;
	public ArrayList<String> tags = new ArrayList<>();
	public ArrayList<String> characters = new ArrayList<>();

	public String uploadTime, uploadTimeText;

	public Book() {
		this(null, null, null);
	}

	public Book(String title, String other, String bookId) {
		this.title = title;
		this.other = other;
		this.bookId = bookId;
	}

	public Book(String title, String other, String bookId, String previewImageUrl) {
		this.title = title;
		this.other = other;
		this.bookId = bookId;
		this.previewImageUrl = previewImageUrl;
	}

	public String toJSONString() {
		return new Gson().toJson(this);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/BookDetailsActivity.java
================================================
package moe.feng.nhentai.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.ContextThemeWrapper;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.github.florent37.materialimageloading.MaterialImageLoading;
import com.google.gson.Gson;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;

import java.io.File;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.BookApi;
import moe.feng.nhentai.api.common.NHentaiUrl;
import moe.feng.nhentai.cache.common.Constants;
import moe.feng.nhentai.cache.file.FileCacheManager;
import moe.feng.nhentai.model.BaseMessage;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.util.AsyncTask;
import moe.feng.nhentai.util.ColorGenerator;
import moe.feng.nhentai.util.TextDrawable;
import moe.feng.nhentai.view.AutoWrapLayout;
import moe.feng.nhentai.view.WheelProgressView;

public class BookDetailsActivity extends AppCompatActivity {

	private ImageView mImageView;
	private CollapsingToolbarLayout collapsingToolbar;
	private FloatingActionButton mFAB;
	private TextView mTitleText;
	private LinearLayout mTagsLayout;
	private LinearLayout mContentView;
	private WheelProgressView mProgressWheel;

	private Book book;

	private final static String EXTRA_BOOK_DATA = "book_data";
	private final static String TRANSITION_NAME_IMAGE = "BookDetailsActivity:image";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_book_details);

		Intent intent = getIntent();
		book = new Gson().fromJson(intent.getStringExtra(EXTRA_BOOK_DATA), Book.class);

		Toolbar toolbar = $(R.id.toolbar);
		setSupportActionBar(toolbar);
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);

		collapsingToolbar = $(R.id.collapsing_toolbar);
		collapsingToolbar.setTitle(book.title);

		mImageView = $(R.id.app_bar_background);
		ViewCompat.setTransitionName(mImageView, TRANSITION_NAME_IMAGE);

		mFAB = $(R.id.fab);
		mTitleText = $(R.id.tv_title);
		mTagsLayout = $(R.id.book_tags_layout);
		mContentView = $(R.id.book_content);
		mProgressWheel = $(R.id.wheel_progress);

		FileCacheManager cm = FileCacheManager.getInstance(getApplicationContext());
		if (cm.cacheExistsUrl(Constants.CACHE_THUMB, book.previewImageUrl)) {
			Picasso.with(getApplicationContext())
					.load(cm.getBitmapUrlFile(Constants.CACHE_THUMB, book.previewImageUrl))
					.fit()
					.centerCrop()
					.into(mImageView, new Callback() {
						@Override
						public void onSuccess() {
							MaterialImageLoading.animate(mImageView).setDuration(1500).start();
						}

						@Override
						public void onError() {

						}
					});
		} else {
			int color = ColorGenerator.MATERIAL.getColor(book.title);
			TextDrawable drawable = TextDrawable.builder().buildRect(book.title.substring(0, 1), color);
			mImageView.setImageDrawable(drawable);
		}
		if (cm.cacheExistsUrl(Constants.CACHE_COVER, book.bigCoverImageUrl)) {
			Picasso.with(getApplicationContext())
					.load(cm.getBitmapUrlFile(Constants.CACHE_COVER, book.bigCoverImageUrl))
					.fit()
					.centerCrop()
					.into(mImageView, new Callback() {
						@Override
						public void onSuccess() {
							MaterialImageLoading.animate(mImageView).setDuration(1500).start();
						}

						@Override
						public void onError() {

						}
					});
		} else {
			new CoverTask().execute(book);
		}

		startBookGet();
	}

	public static void launch(Activity activity, ImageView imageView, Book book) {
		ActivityOptionsCompat options = ActivityOptionsCompat
				.makeSceneTransitionAnimation(activity, imageView, TRANSITION_NAME_IMAGE);
		Intent intent = new Intent(activity, BookDetailsActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
		intent.putExtra(EXTRA_BOOK_DATA, book.toJSONString());
		ActivityCompat.startActivity(activity, intent, options.toBundle());
	}

	private void updateUIContent() {
		collapsingToolbar.setTitle(book.title);
		collapsingToolbar.invalidate();
		$(R.id.toolbar).invalidate();
		$(R.id.appbar).invalidate();

		mFAB.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View view) {
				GalleryActivity.launch(BookDetailsActivity.this, book, 0);
			}
		});

		updateDetailsContent();
	}

	private void updateDetailsContent() {
		mProgressWheel.setVisibility(View.GONE);
		mContentView.setVisibility(View.VISIBLE);
		mContentView.animate().alphaBy(0f).alpha(1f).setDuration(1500).start();
		mTitleText.setText(TextUtils.isEmpty(book.titleJP) ? book.title : book.titleJP);

		updateTagsContent();
	}

	private void updateTagsContent() {
		int x = getResources().getDimensionPixelSize(R.dimen.tag_margin_x);
		int y = getResources().getDimensionPixelSize(R.dimen.tag_margin_y);
		int min_width = getResources().getDimensionPixelSize(R.dimen.tag_title_width);
		ContextThemeWrapper ctw = new ContextThemeWrapper(this, R.style.TextTag);

		// Add Parodies Tags
		if (!TextUtils.isEmpty(book.parodies)) {
			LinearLayout tagGroupLayout = new LinearLayout(this);
			tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
			AutoWrapLayout tagLayout = new AutoWrapLayout(this);

			TextView groupNameView = new TextView(this);
			groupNameView.setMinWidth(min_width);
			groupNameView.setText(R.string.tag_type_parodies);
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			lp.setMargins(x, y, x, y);
			lp.width = min_width;
			tagGroupLayout.addView(groupNameView, lp);

			TextView tagView = new TextView(ctw);
			tagView.setText(book.parodies);
			tagView.setBackgroundResource(R.color.deep_purple_800);
			tagView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					CategoryActivity.launch(
							BookDetailsActivity.this,
							NHentaiUrl.getParodyUrl(book.parodies),
							getString(R.string.tag_type_parodies).trim() + " " + book.parodies
					);
				}
			});
			AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
			alp.setMargins(x, y, x, y);
			tagLayout.addView(tagView, alp);
			tagGroupLayout.addView(tagLayout);
			mTagsLayout.addView(tagGroupLayout);
		}

		// Add Characters
		if (!book.characters.isEmpty()) {
			LinearLayout tagGroupLayout = new LinearLayout(this);
			tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
			AutoWrapLayout tagLayout = new AutoWrapLayout(this);

			TextView groupNameView = new TextView(this);
			groupNameView.setMinWidth(min_width);
			groupNameView.setText(R.string.tag_type_characters);
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			lp.setMargins(x, y, x, y);
			lp.width = min_width;
			tagGroupLayout.addView(groupNameView, lp);

			for (final String tag : book.characters) {
				TextView tagView = new TextView(ctw);
				tagView.setText(tag);
				tagView.setBackgroundResource(R.color.deep_purple_800);
				tagView.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						CategoryActivity.launch(
								BookDetailsActivity.this,
								NHentaiUrl.getCharacterUrl(tag),
								getString(R.string.tag_type_characters).trim() + " " + tag
						);
					}
				});
				AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
				alp.setMargins(x, y, x, y);
				tagLayout.addView(tagView, alp);
			}
			tagGroupLayout.addView(tagLayout);
			mTagsLayout.addView(tagGroupLayout);
		}

		// Add Tags
		if (!book.tags.isEmpty()) {
			LinearLayout tagGroupLayout = new LinearLayout(this);
			tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
			AutoWrapLayout tagLayout = new AutoWrapLayout(this);

			TextView groupNameView = new TextView(this);
			groupNameView.setMinWidth(min_width);
			groupNameView.setText(R.string.tag_type_tag);
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			lp.setMargins(x, y, x, y);
			lp.width = min_width;
			tagGroupLayout.addView(groupNameView, lp);

			for (final String tag : book.tags) {
				TextView tagView = new TextView(ctw);
				tagView.setText(tag);
				tagView.setBackgroundResource(R.color.deep_purple_800);
				tagView.setOnClickListener(new View.OnClickListener() {
					@Override
					public void onClick(View v) {
						CategoryActivity.launch(
								BookDetailsActivity.this,
								NHentaiUrl.getTagUrl(tag),
								getString(R.string.tag_type_tag).trim() + " " + tag
						);
					}
				});
				AutoWrapLayout.LayoutParams alp1 = new AutoWrapLayout.LayoutParams();
				alp1.setMargins(x, y, x, y);
				tagLayout.addView(tagView, alp1);
			}
			tagGroupLayout.addView(tagLayout);
			mTagsLayout.addView(tagGroupLayout);
		}

		// Add Artist Tag
		if (!TextUtils.isEmpty(book.artist)) {
			LinearLayout tagGroupLayout = new LinearLayout(this);
			tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
			AutoWrapLayout tagLayout = new AutoWrapLayout(this);

			TextView groupNameView = new TextView(this);
			groupNameView.setMinWidth(min_width);
			groupNameView.setText(R.string.tag_type_artists);
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			lp.setMargins(x, y, x, y);
			lp.width = min_width;
			tagGroupLayout.addView(groupNameView, lp);

			TextView tagView = new TextView(ctw);
			tagView.setText(book.artist);
			tagView.setBackgroundResource(R.color.deep_purple_800);
			tagView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					CategoryActivity.launch(
							BookDetailsActivity.this,
							NHentaiUrl.getArtistUrl(book.artist),
							getString(R.string.tag_type_artists).trim() + " " + book.artist
					);
				}
			});
			AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
			alp.setMargins(x, y, x, y);
			tagLayout.addView(tagView, alp);
			tagGroupLayout.addView(tagLayout);
			mTagsLayout.addView(tagGroupLayout);
		}

		// Add Groups Tag
		if (!TextUtils.isEmpty(book.group)) {
			LinearLayout tagGroupLayout = new LinearLayout(this);
			tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
			AutoWrapLayout tagLayout = new AutoWrapLayout(this);

			TextView groupNameView = new TextView(this);
			groupNameView.setMinWidth(min_width);
			groupNameView.setText(R.string.tag_type_group);
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			lp.setMargins(x, y, x, y);
			lp.width = min_width;
			tagGroupLayout.addView(groupNameView, lp);

			TextView tagView = new TextView(ctw);
			tagView.setText(book.group);
			tagView.setBackgroundResource(R.color.deep_purple_800);
			tagView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					CategoryActivity.launch(
							BookDetailsActivity.this,
							NHentaiUrl.getGroupUrl(book.group),
							getString(R.string.tag_type_group).trim() + " " + book.group
					);
				}
			});
			AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
			alp.setMargins(x, y, x, y);
			tagLayout.addView(tagView, alp);
			tagGroupLayout.addView(tagLayout);
			mTagsLayout.addView(tagGroupLayout);
		}

		// Add Language Tag
		if (!TextUtils.isEmpty(book.language)) {
			LinearLayout tagGroupLayout = new LinearLayout(this);
			tagGroupLayout.setOrientation(LinearLayout.HORIZONTAL);
			AutoWrapLayout tagLayout = new AutoWrapLayout(this);

			TextView groupNameView = new TextView(this);
			groupNameView.setText(R.string.tag_type_language);
			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT);
			lp.setMargins(x, y, x, y);
			lp.width = min_width;
			tagGroupLayout.addView(groupNameView, lp);

			TextView tagView = new TextView(ctw);
			tagView.setText(book.language);
			tagView.setBackgroundResource(R.color.deep_purple_800);
			tagView.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					CategoryActivity.launch(
							BookDetailsActivity.this,
							NHentaiUrl.getLanguageUrl(book.language),
							getString(R.string.tag_type_language).trim() + " " + book.language
					);
				}
			});
			AutoWrapLayout.LayoutParams alp = new AutoWrapLayout.LayoutParams();
			alp.setMargins(x, y, x, y);
			tagLayout.addView(tagView, alp);
			tagGroupLayout.addView(tagLayout);
			mTagsLayout.addView(tagGroupLayout);
		}
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int id = item.getItemId();
		if (id == android.R.id.home) {
			this.onBackPressed();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	private void startBookGet() {
		mContentView.setVisibility(View.GONE);
		mProgressWheel.setVisibility(View.VISIBLE);
		mProgressWheel.spin();

		new BookGetTask().execute(book.bookId);
	}

	private class BookGetTask extends AsyncTask<String, Void, BaseMessage> {

		@Override
		protected BaseMessage doInBackground(String... params) {
			return BookApi.getBook(params[0]);
		}

		@Override
		protected void onPostExecute(BaseMessage result) {
			if (result.getCode() == 0) {
				book = result.getData();
				updateUIContent();
			} else {
				mProgressWheel.setVisibility(View.GONE);

				Snackbar.make(
						$(R.id.main_content),
						R.string.tips_network_error,
						Snackbar.LENGTH_LONG
				).setAction(
						R.string.snack_action_try_again,
						new View.OnClickListener() {
							@Override
							public void onClick(View view) {
								startBookGet();
							}
				}).show();
			}
		}

	}
	
	private class CoverTask extends AsyncTask<Book, Void, File> {

		@Override
		protected File doInBackground(Book... params) {
			return BookApi.getCoverFile(BookDetailsActivity.this, params[0]);
		}

		@Override
		protected void onPostExecute(File result) {
			Picasso.with(getApplicationContext())
					.load(result)
					.into(mImageView, new Callback() {
						@Override
						public void onSuccess() {
							MaterialImageLoading.animate(mImageView).setDuration(1500).start();
						}

						@Override
						public void onError() {

						}
					});
		}
	}

	protected <T extends View> T $(int id) {
		return (T) findViewById(id);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/CategoryActivity.java
================================================
package moe.feng.nhentai.ui;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.PageApi;
import moe.feng.nhentai.model.BaseMessage;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;
import moe.feng.nhentai.ui.common.AbsActivity;
import moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;
import moe.feng.nhentai.util.AsyncTask;

public class CategoryActivity extends AbsActivity {

	private RecyclerView mRecyclerView;
	private BookListRecyclerAdapter mAdapter;
	private StaggeredGridLayoutManager mLayoutManager;

	private SwipeRefreshLayout mSwipeRefreshLayout;

	private ArrayList<Book> mBooks;

	private int mNowPage = 1;
	private String url, title;

	private static final String EXTRA_URL = "url", EXTRA_TITLE = "title";

	public static final String TAG = CategoryActivity.class.getSimpleName();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Intent intent = getIntent();
		url = intent.getStringExtra(EXTRA_URL);
		title = intent.getStringExtra(EXTRA_TITLE);

		setContentView(R.layout.activity_search_result);

		mActionBar.setDisplayHomeAsUpEnabled(true);
		mActionBar.setTitle(title);
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			mActionBar.setElevation(getResources().getDimension(R.dimen.appbar_elevation));
		}

		mSwipeRefreshLayout.setRefreshing(true);
		new PageGetTask().execute(mNowPage);
	}

	@Override
	protected void setUpViews() {
		mRecyclerView = $(R.id.recycler_view);
		mSwipeRefreshLayout = $(R.id.swipe_refresh_layout);

		mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
		mRecyclerView.setLayoutManager(mLayoutManager);
		mRecyclerView.setHasFixedSize(true);

		mBooks = new ArrayList<>();
		mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
		setRecyclerViewAdapter(mAdapter);

		mSwipeRefreshLayout.setColorSchemeResources(
				R.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,
				R.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500
		);
		mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (!mSwipeRefreshLayout.isRefreshing()) {
					mSwipeRefreshLayout.setRefreshing(true);
				}

				mBooks = new ArrayList<>();
				mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
				setRecyclerViewAdapter(mAdapter);
				new PageGetTask().execute(mNowPage = 1);
			}
		});
	}


	private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
		adapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
				BookDetailsActivity.launch(CategoryActivity.this, holder.mPreviewImageView, holder.book);
			}
		});
		adapter.addOnScrollListener(new RecyclerView.OnScrollListener() {
			@Override
			public void onScrolled(RecyclerView rv, int dx, int dy) {
				if (!mSwipeRefreshLayout.isRefreshing() && mLayoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >= mAdapter.getItemCount() - 2) {
					mSwipeRefreshLayout.setRefreshing(true);
					new PageGetTask().execute(++mNowPage);
				}
			}
		});

		mRecyclerView.setAdapter(adapter);
	}

	private class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {

		@Override
		protected BaseMessage doInBackground(Integer... params) {
			return PageApi.getPageList(url + "/?page=" + mNowPage);
		}

		@Override
		protected void onPostExecute(BaseMessage msg) {
			mSwipeRefreshLayout.setRefreshing(false);
			if (msg != null) {
				if (msg.getCode() == 0 && msg.getData() != null) {
					if (!((ArrayList<Book>) msg.getData()).isEmpty()) {
						mBooks.addAll((ArrayList<Book>) msg.getData());
						mAdapter.notifyDataSetChanged();
						if (mNowPage == 1) {
							mRecyclerView.setAdapter(mAdapter);
						}
					} else {
						Snackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();
					}
				} else if (mNowPage == 1) {
					Snackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();
				}
			}
		}

	}

	public static void launch(AppCompatActivity activity, String url, String title) {
		Intent intent = new Intent(activity, CategoryActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.putExtra(EXTRA_URL, url);
		intent.putExtra(EXTRA_TITLE, title);
		activity.startActivity(intent);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/GalleryActivity.java
================================================
package moe.feng.nhentai.ui;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.WindowManager;

import com.google.gson.Gson;

import moe.feng.nhentai.R;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.adapter.GalleryPagerAdapter;
import moe.feng.nhentai.ui.common.AbsActivity;
import moe.feng.nhentai.util.FullScreenHelper;

public class GalleryActivity extends AbsActivity {

	private Book book;
	private int page_num;

	private ViewPager mPager;
	private GalleryPagerAdapter mPagerAdpater;
	private View mAppBar;

	private FullScreenHelper mFullScreenHelper;

	private static final String EXTRA_BOOK_DATA = "book_data", EXTRA_FISRT_PAGE = "first_page";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		if (Build.VERSION.SDK_INT >= 21) {
			getWindow().setStatusBarColor(Color.TRANSPARENT);
			getWindow().setNavigationBarColor(Color.TRANSPARENT);
		}

		mFullScreenHelper = new FullScreenHelper(this);
		// 别问我为什么这么干 让我先冷静一下→_→
		mFullScreenHelper.setFullScreen(true);
		mFullScreenHelper.setFullScreen(false);

		Intent intent = getIntent();
		book = new Gson().fromJson(intent.getStringExtra(EXTRA_BOOK_DATA), Book.class);
		page_num = intent.getIntExtra(EXTRA_FISRT_PAGE, 0);

		setContentView(R.layout.activity_gallery);
	}

	@Override
	protected void setUpViews() {
		getSupportActionBar().setDisplayHomeAsUpEnabled(true);
		getSupportActionBar().setTitle(book.titleJP != null ? book.titleJP : book.title);

		mAppBar = $(R.id.my_app_bar);
		mPager = $(R.id.pager);
		mPagerAdpater = new GalleryPagerAdapter(getFragmentManager(), book);
		mPager.setAdapter(mPagerAdpater);
		mPager.setCurrentItem(page_num, false);
	}

	public static void launch(Activity activity, Book book, int firstPageNum) {
		Intent intent = new Intent(activity, GalleryActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
		intent.putExtra(EXTRA_BOOK_DATA, book.toJSONString());
		intent.putExtra(EXTRA_FISRT_PAGE, firstPageNum);
		activity.startActivity(intent);
	}

	public void toggleControlBar() {
		if (mAppBar.getAlpha() != 0f) {
			mAppBar.animate().alpha(0f).start();
			mFullScreenHelper.setFullScreen(true);
		} else if (mAppBar.getAlpha() != 1f) {
			mAppBar.animate().alpha(1f).start();
			mFullScreenHelper.setFullScreen(false);
		}
	}

	@Override
	public void onBackPressed() {
		if (mAppBar.getAlpha() != 1f) {
			toggleControlBar();
		} else {
			super.onBackPressed();
		}
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/MainActivity.java
================================================
package moe.feng.nhentai.ui;

import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.quinny898.library.persistentsearch.SearchBox;

import moe.feng.nhentai.R;
import moe.feng.nhentai.dao.SearchHistoryManager;
import moe.feng.nhentai.ui.adapter.HomePagerAdapter;
import moe.feng.nhentai.ui.common.AbsActivity;

public class MainActivity extends AbsActivity implements NavigationView.OnNavigationItemSelectedListener {

	private ViewPager mPager;
	private HomePagerAdapter mPagerAdapter;
	private TabLayout mTabLayout;
	private SearchBox mSearchBox;
	private DrawerLayout mDrawerLayout;
	private NavigationView mNavigationView;
	private ActionBarDrawerToggle mDrawerToggle;

	private SearchHistoryManager mSearchHistoryManager;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState, false);

		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			getWindow().setStatusBarColor(getResources().getColor(R.color.deep_purple_800));
		}

		setContentView(R.layout.activity_main);

		mActionBar.setDisplayHomeAsUpEnabled(true);

		mSearchHistoryManager = SearchHistoryManager.getInstance(getApplicationContext(), "all");
	}

	@Override
	protected void setUpViews() {
		mPager = $(R.id.viewpager);
		mTabLayout = $(R.id.tabs);
		mSearchBox = $(R.id.search_box);

		mDrawerLayout = $(R.id.drawer_layout);
		mNavigationView = $(R.id.navigation_view);
		mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
			@Override
			public void onDrawerOpened(View drawerView) {
				mDrawerToggle.onDrawerOpened(drawerView);
			}

			@Override
			public void onDrawerClosed(View drawerView) {
				mDrawerToggle.onDrawerClosed(drawerView);
			}

			@Override
			public void onDrawerSlide(View drawerView, float slideOffset) {
				mDrawerToggle.onDrawerSlide(drawerView, slideOffset);
			}

			@Override
			public void onDrawerStateChanged(int newState) {
				mDrawerToggle.onDrawerStateChanged(newState);
			}
		});
		mNavigationView.setNavigationItemSelectedListener(this);

		mDrawerToggle = new ActionBarDrawerToggle(this,
				mDrawerLayout,
				R.string.abc_action_bar_home_description,
				R.string.abc_action_bar_home_description
		) {
			@Override
			public void onDrawerClosed(View drawerView) {
				super.onDrawerClosed(drawerView);
				invalidateOptionsMenu();
			}

			@Override
			public void onDrawerOpened(View drawerView) {
				super.onDrawerOpened(drawerView);
				invalidateOptionsMenu();
			}
		};

		mDrawerLayout.post(new Runnable() {
			@Override
			public void run() {
				mDrawerToggle.syncState();
			}
		});

		mDrawerLayout.setDrawerListener(mDrawerToggle);

		mPagerAdapter = new HomePagerAdapter(getApplicationContext(), getFragmentManager());
		mPager.setAdapter(mPagerAdapter);
		mTabLayout.setupWithViewPager(mPager);
		mSearchBox.setLogoText("");
		mSearchBox.setSearchListener(new SearchBox.SearchListener() {
			@Override
			public void onSearchOpened() {

			}

			@Override
			public void onSearchCleared() {

			}

			@Override
			public void onSearchClosed() {
				closeSearchBox();
			}

			@Override
			public void onSearchTermChanged() {

			}

			@Override
			public void onSearch(String result) {
				mSearchHistoryManager.add(result);
				SearchResultActivity.launch(MainActivity.this, result);
			}
		});
	}

	private void openSearchBox() {
		mSearchBox.setVisibility(View.VISIBLE);
		mSearchBox.setSearchables(mSearchHistoryManager.getSearchResults());
		mSearchBox.setSearchString("");

		mSearchBox.revealFromMenuItem(R.id.action_search, this);
	}

	private void closeSearchBox() {
		mSearchBox.hideCircularly(this);

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				runOnUiThread(new Runnable() {
					@Override
					public void run() {
						mSearchBox.setVisibility(View.INVISIBLE);
					}
				});
			}
		}, 250);
	}

	@Override
	protected void onPostCreate(Bundle savedInstanceState) {
		super.onPostCreate(savedInstanceState);
		mDrawerToggle.syncState();
	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		mDrawerToggle.onConfigurationChanged(newConfig);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.menu_main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (mDrawerToggle.onOptionsItemSelected(item)) {
			return true;
		}

		int id = item.getItemId();
		if (id == R.id.action_search) {
			openSearchBox();
			return true;
		}
		if (id == R.id.action_settings) {
			SettingsActivity.launchActivity(this, SettingsActivity.FLAG_MAIN);
			return true;
		}

		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onBackPressed() {
		if (mSearchBox.isSearchOpened()) {
			mSearchBox.toggleSearch();
		} else {
			super.onBackPressed();
		}
	}

	@Override
	public boolean onNavigationItemSelected(MenuItem menuItem) {
		mDrawerLayout.closeDrawer(mNavigationView);
		switch (menuItem.getItemId()) {
			// TODO Update page
			case R.id.navigation_item_home:
				menuItem.setChecked(true);
				return true;
			case R.id.navigation_item_tag:
				return true;
			case R.id.navigation_item_character:
				return true;
		}
		return false;
	}
}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/SearchResultActivity.java
================================================
package moe.feng.nhentai.ui;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.PageApi;
import moe.feng.nhentai.model.BaseMessage;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;
import moe.feng.nhentai.ui.common.AbsActivity;
import moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;
import moe.feng.nhentai.util.AsyncTask;

public class SearchResultActivity extends AbsActivity {

	private RecyclerView mRecyclerView;
	private BookListRecyclerAdapter mAdapter;
	private StaggeredGridLayoutManager mLayoutManager;

	private SwipeRefreshLayout mSwipeRefreshLayout;

	private ArrayList<Book> mBooks;

	private int mNowPage = 1;
	private String keyword;

	private static final String EXTRA_KEYWORD = "keyword";

	public static final String TAG = SearchResultActivity.class.getSimpleName();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Intent intent = getIntent();
		keyword = intent.getStringExtra(EXTRA_KEYWORD);

		setContentView(R.layout.activity_search_result);

		mActionBar.setDisplayHomeAsUpEnabled(true);
		mActionBar.setTitle(String.format(getString(R.string.title_search_result), keyword));
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
			mActionBar.setElevation(getResources().getDimension(R.dimen.appbar_elevation));
		}

		mSwipeRefreshLayout.setRefreshing(true);
		new PageGetTask().execute(mNowPage);
	}

	@Override
	protected void setUpViews() {
		mRecyclerView = $(R.id.recycler_view);
		mSwipeRefreshLayout = $(R.id.swipe_refresh_layout);

		mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
		mRecyclerView.setLayoutManager(mLayoutManager);
		mRecyclerView.setHasFixedSize(true);

		mBooks = new ArrayList<>();
		mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
		setRecyclerViewAdapter(mAdapter);

		mSwipeRefreshLayout.setColorSchemeResources(
				R.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,
				R.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500
		);
		mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (!mSwipeRefreshLayout.isRefreshing()) {
					mSwipeRefreshLayout.setRefreshing(true);
				}

				mBooks = new ArrayList<>();
				mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
				setRecyclerViewAdapter(mAdapter);
				new PageGetTask().execute(mNowPage = 1);
			}
		});
	}


	private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
		adapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
				BookDetailsActivity.launch(SearchResultActivity.this, holder.mPreviewImageView, holder.book);
			}
		});
		adapter.addOnScrollListener(new RecyclerView.OnScrollListener() {
			@Override
			public void onScrolled(RecyclerView rv, int dx, int dy) {
				if (!mSwipeRefreshLayout.isRefreshing() && mLayoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >= mAdapter.getItemCount() - 2) {
					mSwipeRefreshLayout.setRefreshing(true);
					new PageGetTask().execute(++mNowPage);
				}
			}
		});

		mRecyclerView.setAdapter(adapter);
	}

	private class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {

		@Override
		protected BaseMessage doInBackground(Integer... params) {
			return PageApi.getSearchPageList(keyword, params[0]);
		}

		@Override
		protected void onPostExecute(BaseMessage msg) {
			mSwipeRefreshLayout.setRefreshing(false);
			if (msg != null) {
				if (msg.getCode() == 0 && msg.getData() != null) {
					if (!((ArrayList<Book>) msg.getData()).isEmpty()) {
						mBooks.addAll((ArrayList<Book>) msg.getData());
						mAdapter.notifyDataSetChanged();
						if (mNowPage == 1) {
							mRecyclerView.setAdapter(mAdapter);
						}
					} else {
						Snackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();
					}
				} else if (mNowPage == 1) {
					Snackbar.make(mRecyclerView, R.string.tips_no_result, Snackbar.LENGTH_LONG).show();
				}
			}
		}

	}

	public static void launch(AppCompatActivity activity, String keyword) {
		Intent intent = new Intent(activity, SearchResultActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
		intent.putExtra(EXTRA_KEYWORD, keyword);
		activity.startActivity(intent);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/SettingsActivity.java
================================================
package moe.feng.nhentai.ui;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewCompat;

import moe.feng.nhentai.R;
import moe.feng.nhentai.ui.common.AbsActivity;
import moe.feng.nhentai.ui.fragment.settings.SettingsLicense;
import moe.feng.nhentai.ui.fragment.settings.SettingsMain;

public class SettingsActivity extends AbsActivity {

	private Fragment mFragment;
	private int flag;

	public static final String EXTRA_FLAG = "flag";
	public static final int FLAG_MAIN = 0, FLAG_LICENSE = 1, FLAG_GUI = 2, FLAG_NETWORK = 3;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Intent intent = getIntent();
		flag = intent.getIntExtra(EXTRA_FLAG, FLAG_MAIN);

		setContentView(R.layout.activity_settings);

		mActionBar.setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public void setUpViews() {
		ViewCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.appbar_elevation));

		switch (flag) {
			case FLAG_MAIN:
				mFragment = new SettingsMain();
				break;
			case FLAG_LICENSE:
				mFragment = new SettingsLicense();
				break;
		}
		getFragmentManager().beginTransaction()
				.replace(R.id.container, mFragment)
				.commit();
	}


	public static void launchActivity(Activity mActivity, int flag) {
		Intent intent = new Intent(mActivity, SettingsActivity.class);
		intent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
		intent.putExtra(EXTRA_FLAG, flag);
		mActivity.startActivity(intent);
	}

}

================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/BookListRecyclerAdapter.java
================================================
package moe.feng.nhentai.ui.adapter;

import android.graphics.Bitmap;
import android.support.v7.widget.ListPopupWindow;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.BookApi;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;
import moe.feng.nhentai.util.AsyncTask;
import moe.feng.nhentai.util.ColorGenerator;
import moe.feng.nhentai.util.TextDrawable;
import moe.feng.nhentai.util.Utility;

public class BookListRecyclerAdapter extends AbsRecyclerViewAdapter {

	private ArrayList<Book> data;

	private ColorGenerator mColorGenerator;

	public static final String TAG = BookListRecyclerAdapter.class.getSimpleName();

	public BookListRecyclerAdapter(RecyclerView recyclerView, ArrayList<Book> data) {
		super(recyclerView);
		this.data = data;
		mColorGenerator = ColorGenerator.MATERIAL;
	}

	@Override
	public ClickableViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
		bindContext(viewGroup.getContext());
		View view = LayoutInflater.from(getContext()).inflate(R.layout.list_item_book_card, viewGroup, false);
		return new ViewHolder(view);
	}
	
	@Override
	public void onBindViewHolder(ClickableViewHolder holder, final int position) {
		super.onBindViewHolder(holder, position);
		if (holder instanceof ViewHolder) {
			final ViewHolder mHolder = (ViewHolder) holder;
			mHolder.mTitleTextView.setText(data.get(position).title);
			String previewImageUrl = data.get(position).previewImageUrl;

			int color = mColorGenerator.getColor(data.get(position).title);
			TextDrawable drawable = TextDrawable.builder().buildRect(Utility.getFirstCharacter(data.get(position).title), color);
			mHolder.mPreviewImageView.setImageDrawable(drawable);

			if (previewImageUrl != null) {
				switch (previewImageUrl) {
					case "0":
						mHolder.mPreviewImageView.setImageResource(R.drawable.holder_0);
						break;
					case "1":
						mHolder.mPreviewImageView.setImageResource(R.drawable.holder_1);
						break;
					case "2":
						mHolder.mPreviewImageView.setImageResource(R.drawable.holder_2);
						break;
					default:
						ViewTreeObserver vto = mHolder.mPreviewImageView.getViewTreeObserver();
						vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
							@Override
							public void onGlobalLayout() {
								int thumbWidth = data.get(position).thumbWidth;
								int thumbHeight = data.get(position).thumbHeight;
								if (thumbWidth > 0 && thumbHeight > 0) {
									int width = mHolder.mPreviewImageView.getMeasuredWidth();
									int height = Math.round(width * ((float) thumbHeight / thumbWidth));
									mHolder.mPreviewImageView.getLayoutParams().height = height;
									mHolder.mPreviewImageView.setMinimumHeight(height);
								}
								mHolder.mPreviewImageView.getViewTreeObserver().removeGlobalOnLayoutListener(this);

							}
						});
						new ImageDownloader().execute(mHolder.getParentView());
				}
			}

			mHolder.book = data.get(position);
		}
	}

	@Override
	public int getItemCount() {
		return data.size();
	}

	private class ImageDownloader extends AsyncTask<Object, Object, Void> {

		@Override
		protected Void doInBackground(Object[] params) {
			View v = (View) params[0];
			ViewHolder h = (ViewHolder) v.getTag();
			Book book = h.book;

			if (v != null && !TextUtils.isEmpty(book.previewImageUrl)) {
				ImageView imgView = h.mPreviewImageView;

				Bitmap img = BookApi.getThumb(getContext(), book);

				if (img != null) {
					publishProgress(new Object[]{v, img, imgView, book});
				}
			}

			return null;
		}

		@Override
		protected void onProgressUpdate(Object[] values) {
			super.onProgressUpdate(values);

			View v = (View) values[0];

			if (!(v.getTag() instanceof ViewHolder) || (((ViewHolder) v.getTag()).book != null &&
					((ViewHolder) v.getTag()).book.bookId != ((Book) values[3]).bookId)) {
				return;
			}

			Bitmap img = (Bitmap) values[1];
			ImageView iv = (ImageView) values[2];
			iv.setVisibility(View.VISIBLE);
			iv.setImageBitmap(img);
			iv.setTag(false);
		}


	}

	public class ViewHolder extends ClickableViewHolder {

		public ImageView mPreviewImageView;
		public TextView mTitleTextView;

		public Book book;

		public ViewHolder(View itemView) {
			super(itemView);
			mPreviewImageView = (ImageView) itemView.findViewById(R.id.book_preview);
			mTitleTextView = (TextView) itemView.findViewById(R.id.book_title);

			itemView.setTag(this);
		}

	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/BookPreviewGridAdapter.java
================================================
package moe.feng.nhentai.ui.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.BookApi;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.util.AsyncTask;

public class BookPreviewGridAdapter extends BaseAdapter {

	private Book book;
	private Context mContext;

	public BookPreviewGridAdapter(Context context, Book book) {
		super();
		this.mContext = context;
		this.book = book;
	}

	@Override
	public int getCount() {
		return book.pageCount;
	}

	@Override
	public Object getItem(int i) {
		return null;
	}

	@Override
	public long getItemId(int i) {
		return 0;
	}

	@Override
	public View getView(int position, View view, ViewGroup viewGroup) {
		ViewHolder holder;
		if (view == null) {
			view = View.inflate(mContext, R.layout.list_item_book_picture_thumb, null);

			holder = new ViewHolder(view);
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}

		holder.mImageView.setLayoutParams(new GridView.LayoutParams(300, 100));
		holder.mNumberText.setText(position);

		new ImageDownloader().execute(holder.mImageView, position);

		return view;
	}

	private class ViewHolder {

		View mParentView;
		ImageView mImageView;
		TextView mNumberText;

		public ViewHolder(View itemView) {
			this.mParentView = itemView;
			this.mImageView = (ImageView) itemView.findViewById(R.id.image_view);
			this.mNumberText = (TextView) itemView.findViewById(R.id.number_text);
		}

	}

	private class ImageDownloader extends AsyncTask<Object, Object, Void> {

		@Override
		protected Void doInBackground(Object[] params) {
			View v = (View) params[0];
			ViewHolder h = (ViewHolder) v.getTag();

			if (v != null && !TextUtils.isEmpty(book.previewImageUrl)) {
				ImageView imgView = h.mImageView;

				Bitmap img = BookApi.getPageThumb(mContext, book, (int) params[1]);

				if (img != null) {
					publishProgress(new Object[]{v, img, imgView, book});
				}
			}

			return null;
		}

		@Override
		protected void onProgressUpdate(Object[] values) {
			super.onProgressUpdate(values);

			View v = (View) values[0];

			if (!(v.getTag() instanceof ViewHolder)) {
				return;
			}

			Bitmap img = (Bitmap) values[1];
			ImageView iv = (ImageView) values[2];
			iv.setVisibility(View.VISIBLE);
			iv.setImageBitmap(img);
			iv.setTag(false);
		}


	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/GalleryPagerAdapter.java
================================================
package moe.feng.nhentai.ui.adapter;

import android.app.Fragment;
import android.app.FragmentManager;
import android.support.v13.app.FragmentPagerAdapter;

import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.fragment.BookPageFragment;

public class GalleryPagerAdapter extends FragmentPagerAdapter {

	private Book book;
	private Fragment[] fragments;

	public GalleryPagerAdapter(FragmentManager fm, Book book) {
		super(fm);
		this.book = book;
		this.fragments = new Fragment[book.pageCount];
	}

	@Override
	public Fragment getItem(int position) {
		if (fragments[position] == null) {
			fragments[position] = BookPageFragment.newInstance(book, position + 1);
		}
		return fragments[position];
	}

	@Override
	public int getCount() {
		return book.pageCount;
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/HomePagerAdapter.java
================================================
package moe.feng.nhentai.ui.adapter;

import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.support.v13.app.FragmentPagerAdapter;

import moe.feng.nhentai.R;
import moe.feng.nhentai.ui.fragment.main.DownloadManagerFragment;
import moe.feng.nhentai.ui.fragment.main.FavoriteFragment;
import moe.feng.nhentai.ui.fragment.main.HomeFragment;

public class HomePagerAdapter extends FragmentPagerAdapter {

	private HomeFragment homeFragment;
	private DownloadManagerFragment downloadManagerFragment;
	private FavoriteFragment favoriteFragment;

	private String[] titles;

	public HomePagerAdapter(Context context, FragmentManager fm) {
		super(fm);
		titles = context.getResources().getStringArray(R.array.page_titles);
		homeFragment = new HomeFragment();
		downloadManagerFragment = new DownloadManagerFragment();
		favoriteFragment = new FavoriteFragment();
	}

	@Override
	public Fragment getItem(int position) {
		switch (position) {
			case 0:
				return homeFragment;
			case 1:
				return downloadManagerFragment;
			case 2:
				return favoriteFragment;
			default:
				return null;
		}
	}

	@Override
	public int getCount() {
		return 3;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return titles[position];
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/common/AbsActivity.java
================================================
package moe.feng.nhentai.ui.common;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;

import moe.feng.nhentai.R;
import moe.feng.nhentai.util.Utility;

public abstract class AbsActivity extends AppCompatActivity {

	protected Toolbar mToolbar;
	protected ActionBar mActionBar;

	protected int statusBarHeight = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		this.onCreate(savedInstanceState, true);
	}

	protected void onCreate(Bundle savedInstanceState, boolean statusBarTranslucent) {
		/** Set up translucent status bar */
		if (statusBarTranslucent) {
			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && !Utility.isChrome()) {
				getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
				statusBarHeight = Utility.getStatusBarHeight(getApplicationContext());
			}

			if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
				getWindow().setStatusBarColor(Color.TRANSPARENT);
				getWindow().setNavigationBarColor(getResources().getColor(R.color.deep_purple_800));
			}
		}

		super.onCreate(savedInstanceState);
	}

	protected abstract void setUpViews();

	@Override
	public void setContentView(@LayoutRes int layoutResId) {
		super.setContentView(layoutResId);

		try {
			View statusHeaderView = $(R.id.status_bar_header);
			statusHeaderView.getLayoutParams().height = statusBarHeight;
		} catch (NullPointerException e) {
			Log.e("setContentView", "Cannot find status header.");
		}

		try {
			mToolbar = $(R.id.toolbar);
			setSupportActionBar(mToolbar);
		} catch (Exception e) {
			Log.e("setContentView", "Cannot find toolbar.");
		}
		mActionBar = getSupportActionBar();

		setUpViews();
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		if (item.getItemId() == android.R.id.home) {
			this.onBackPressed();
			return true;
		}

		return super.onOptionsItemSelected(item);
	}

	protected <T extends View> T $(int id) {
		return (T) findViewById(id);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/common/AbsRecyclerViewAdapter.java
================================================
package moe.feng.nhentai.ui.common;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

public abstract class AbsRecyclerViewAdapter extends RecyclerView.Adapter<AbsRecyclerViewAdapter.ClickableViewHolder> {

	private Context context;

	protected RecyclerView mRecyclerView;
	protected List<RecyclerView.OnScrollListener> mListeners = new ArrayList<RecyclerView.OnScrollListener>();

	public AbsRecyclerViewAdapter(RecyclerView recyclerView) {
		this.mRecyclerView = recyclerView;
		this.mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
			@Override
			public void onScrollStateChanged(RecyclerView rv, int newState) {
				for (RecyclerView.OnScrollListener listener : mListeners) {
					listener.onScrollStateChanged(rv, newState);
				}
			}

			@Override
			public void onScrolled(RecyclerView rv, int dx, int dy) {
				for (RecyclerView.OnScrollListener listener : mListeners) {
					listener.onScrolled(rv, dx, dy);
				}
			}
		});
	}

	public void addOnScrollListener(RecyclerView.OnScrollListener listener) {
		mListeners.add(listener);
	}

	public interface OnItemClickListener {
		public void onItemClick(int position, ClickableViewHolder holder);
	}

	public interface OnItemLongClickListener {
		public boolean onItemLongClick(int position, ClickableViewHolder holder);
	}

	private OnItemClickListener itemClickListener;
	private OnItemLongClickListener itemLongClickListener;

	public void setOnItemClickListener(OnItemClickListener listener) {
		this.itemClickListener = listener;
	}

	public void setOnItemLongClickListener(OnItemLongClickListener listener) {
		this.itemLongClickListener = listener;
	}

	public void bindContext(Context context) {
		this.context = context;
	}

	public Context getContext() {
		return this.context;
	}

	@Override
	public void onBindViewHolder(final ClickableViewHolder holder, final int position) {
		holder.getParentView().setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (itemClickListener != null) {
					itemClickListener.onItemClick(position, holder);
				}
			}
		});
		holder.getParentView().setOnLongClickListener(new View.OnLongClickListener() {
			@Override
			public boolean onLongClick(View v) {
				if (itemLongClickListener != null) {
					return itemLongClickListener.onItemLongClick(position, holder);
				} else {
					return false;
				}
			}
		});
	}

	public class ClickableViewHolder extends RecyclerView.ViewHolder {

		private View parentView;

		public ClickableViewHolder(View itemView) {
			super(itemView);
			this.parentView = itemView;
		}

		public View getParentView() {
			return parentView;
		}

	}

}

================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/BookPageFragment.java
================================================
package moe.feng.nhentai.ui.fragment;

import android.app.Fragment;
import android.graphics.Bitmap;
import android.graphics.PointF;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.github.florent37.materialimageloading.MaterialImageLoading;
import com.google.gson.Gson;
import com.squareup.picasso.Callback;
import com.squareup.picasso.Picasso;

import java.io.File;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.PageApi;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.GalleryActivity;
import moe.feng.nhentai.util.AsyncTask;
import uk.co.senab.photoview.PhotoViewAttacher;

public class BookPageFragment extends Fragment {

	private Book book;
	private int pageNum;
	private ImageView mImageView;
	private PhotoViewAttacher mPhotoViewAttacher;

	private static final String ARG_BOOK_DATA = "arg_book_data", ARG_PAGE_NUM = "arg_page_num";

	public static final String TAG = BookPageFragment.class.getSimpleName();

	public static BookPageFragment newInstance(Book book, int pageNum) {
		BookPageFragment fragment = new BookPageFragment();
		Bundle data = new Bundle();
		data.putString(ARG_BOOK_DATA, book.toJSONString());
		data.putInt(ARG_PAGE_NUM, pageNum);
		fragment.setArguments(data);
		return fragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Bundle data = getArguments();
		book = new Gson().fromJson(data.getString(ARG_BOOK_DATA), Book.class);
		pageNum = data.getInt(ARG_PAGE_NUM);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
		View view = inflater.inflate(R.layout.fragment_book_page, container, false);

		mImageView = (ImageView) view.findViewById(R.id.image_view);
		mPhotoViewAttacher = new PhotoViewAttacher(mImageView);
		new DownloadTask().execute();

		return view;
	}

	private class DownloadTask extends AsyncTask<Void, Void, File> {

		@Override
		protected File doInBackground(Void... params) {
			return PageApi.getPageOriginImageFile(getActivity().getApplicationContext(), book, pageNum);
		}

		@Override
		protected void onPostExecute(File result) {
			super.onPostExecute(result);

			if (result != null) {
				Picasso.with(getActivity().getApplicationContext())
						.load(result)
						.into(mImageView, new Callback() {
							@Override
							public void onSuccess() {
								MaterialImageLoading.animate(mImageView).setDuration(700).start();
								mPhotoViewAttacher.update();
								mPhotoViewAttacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {
									@Override
									public void onViewTap(View view, float v, float v1) {
										((GalleryActivity) getActivity()).toggleControlBar();
									}
								});
							}

							@Override
							public void onError() {

							}
						});
			}
		}

	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/main/DownloadManagerFragment.java
================================================
package moe.feng.nhentai.ui.fragment.main;

import android.app.Fragment;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.BookDetailsActivity;
import moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;
import moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;

public class DownloadManagerFragment extends Fragment {

	private RecyclerView mRecyclerView;
	private BookListRecyclerAdapter mAdapter;

	public static final String TAG = DownloadManagerFragment.class.getSimpleName();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
		View view = inflater.inflate(R.layout.fragment_home, container, false);

		mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
		mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
		mRecyclerView.setHasFixedSize(false);

		ArrayList<Book> books = new ArrayList<>();

		mAdapter = new BookListRecyclerAdapter(mRecyclerView, books);
		mAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				if (viewHolder instanceof BookListRecyclerAdapter.ViewHolder) {
					BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
					Log.i(TAG, "You clicked position no." + position + " item, " +
							"its name is " + holder.mTitleTextView.getText().toString());
				}
			}
		});
		setRecyclerViewAdapter(mAdapter);

		return view;
	}


	private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
		mRecyclerView.setAdapter(mAdapter);
		mAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
				Log.i(TAG, "You clicked position no." + position + " item, " +
						"its name is " + holder.mTitleTextView.getText().toString());
				BookDetailsActivity.launch(getActivity(), holder.mPreviewImageView, holder.book);
			}
		});
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/main/FavoriteFragment.java
================================================
package moe.feng.nhentai.ui.fragment.main;

import android.app.Fragment;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.BookDetailsActivity;
import moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;
import moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;

public class FavoriteFragment extends Fragment {

	private RecyclerView mRecyclerView;
	private BookListRecyclerAdapter mAdapter;

	public static final String TAG = FavoriteFragment.class.getSimpleName();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
		View view = inflater.inflate(R.layout.fragment_home, container, false);

		mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
		mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
		mRecyclerView.setHasFixedSize(false);

		ArrayList<Book> books = new ArrayList<>();

		mAdapter = new BookListRecyclerAdapter(mRecyclerView, books);
		mAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				if (viewHolder instanceof BookListRecyclerAdapter.ViewHolder) {
					BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
					Log.i(TAG, "You clicked position no." + position + " item, " +
							"its name is " + holder.mTitleTextView.getText().toString());
				}
			}
		});
		setRecyclerViewAdapter(mAdapter);

		return view;
	}


	private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
		mRecyclerView.setAdapter(mAdapter);
		mAdapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
				Log.i(TAG, "You clicked position no." + position + " item, " +
						"its name is " + holder.mTitleTextView.getText().toString());
				BookDetailsActivity.launch(getActivity(), holder.mPreviewImageView, holder.book);
			}
		});
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/main/HomeFragment.java
================================================
package moe.feng.nhentai.ui.fragment.main;

import android.app.Fragment;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import moe.feng.nhentai.R;
import moe.feng.nhentai.api.PageApi;
import moe.feng.nhentai.model.BaseMessage;
import moe.feng.nhentai.model.Book;
import moe.feng.nhentai.ui.BookDetailsActivity;
import moe.feng.nhentai.ui.adapter.BookListRecyclerAdapter;
import moe.feng.nhentai.ui.common.AbsRecyclerViewAdapter;
import moe.feng.nhentai.util.AsyncTask;

public class HomeFragment extends Fragment {

	private RecyclerView mRecyclerView;
	private BookListRecyclerAdapter mAdapter;
	private StaggeredGridLayoutManager mLayoutManager;

	private SwipeRefreshLayout mSwipeRefreshLayout;

	private ArrayList<Book> mBooks;

	private int mNowPage = 1;

	public static final String TAG = HomeFragment.class.getSimpleName();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
		View view = inflater.inflate(R.layout.fragment_home, container, false);

		mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipe_refresh_layout);
		mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view);
		mLayoutManager = new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL);
		mRecyclerView.setLayoutManager(mLayoutManager);
		mRecyclerView.setHasFixedSize(true);

		mBooks = new ArrayList<>();
		mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
		setRecyclerViewAdapter(mAdapter);

		mSwipeRefreshLayout.setColorSchemeResources(
				R.color.deep_purple_500, R.color.pink_500, R.color.orange_500, R.color.brown_500,
				R.color.indigo_500, R.color.blue_500, R.color.teal_500, R.color.green_500
		);
		mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
			@Override
			public void onRefresh() {
				if (!mSwipeRefreshLayout.isRefreshing()) {
					mSwipeRefreshLayout.setRefreshing(true);
				}

				mBooks = new ArrayList<>();
				mAdapter = new BookListRecyclerAdapter(mRecyclerView, mBooks);
				setRecyclerViewAdapter(mAdapter);
				new PageGetTask().execute(mNowPage = 1);
			}
		});

		new PageGetTask().execute(mNowPage);

		return view;
	}

	private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
		adapter.setOnItemClickListener(new AbsRecyclerViewAdapter.OnItemClickListener() {
			@Override
			public void onItemClick(int position, AbsRecyclerViewAdapter.ClickableViewHolder viewHolder) {
				BookListRecyclerAdapter.ViewHolder holder = (BookListRecyclerAdapter.ViewHolder) viewHolder;
				Log.i(TAG, "You clicked position no." + position + " item, " +
						"its name is " + holder.mTitleTextView.getText().toString());
				BookDetailsActivity.launch(getActivity(), holder.mPreviewImageView, holder.book);
			}
		});
		adapter.addOnScrollListener(new RecyclerView.OnScrollListener() {
			@Override
			public void onScrolled(RecyclerView rv, int dx, int dy) {
				if (!mSwipeRefreshLayout.isRefreshing() && mLayoutManager.findLastCompletelyVisibleItemPositions(new int[2])[1] >= mAdapter.getItemCount() - 2) {
					mSwipeRefreshLayout.setRefreshing(true);
					new PageGetTask().execute(++mNowPage);
				}
			}
		});

		mRecyclerView.setAdapter(adapter);
	}

	private class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {

		@Override
		protected BaseMessage doInBackground(Integer... params) {
			return PageApi.getHomePageList(params[0]);
		}

		@Override
		protected void onPostExecute(BaseMessage msg) {
			mSwipeRefreshLayout.setRefreshing(false);
			if (msg != null) {
				if (msg.getCode() == 0 && msg.getData() != null) {
					if (!((ArrayList<Book>) msg.getData()).isEmpty()) {
						mBooks.addAll((ArrayList<Book>) msg.getData());
						mAdapter.notifyDataSetChanged();
					}
				} else if (mNowPage == 1) {
					Snackbar.make(
							mRecyclerView,
							R.string.tips_network_error,
							Snackbar.LENGTH_LONG
					).setAction(
							R.string.snack_action_try_again,
							new View.OnClickListener() {
								@Override
								public void onClick(View view) {
									mSwipeRefreshLayout.setRefreshing(true);
									new PageGetTask().execute(mNowPage);
								}
							}
					).show();
				}
			}
		}

	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsLicense.java
================================================
package moe.feng.nhentai.ui.fragment.settings;

import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import moe.feng.nhentai.R;

public class SettingsLicense extends Fragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup group, Bundle bundle) {
		WebView webView = new WebView(inflater.getContext());
		webView.loadUrl("file:///android_asset/licenses.html");

		getActivity().setTitle(R.string.settings_license);

		return webView;
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsMain.java
================================================
package moe.feng.nhentai.ui.fragment.settings;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceFragment;

import moe.feng.nhentai.R;
import moe.feng.nhentai.ui.SettingsActivity;
import moe.feng.nhentai.view.pref.Preference;

public class SettingsMain extends PreferenceFragment implements Preference.OnPreferenceClickListener {

	private Preference mVersionPref;
	private Preference mLicensePref;
	private Preference mWeiboPref;
	private Preference mGooglePlusPref;
	private Preference mGithubPref;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.settings_main);

		mVersionPref = (Preference) findPreference("version");
		mLicensePref = (Preference) findPreference("license");
		mWeiboPref = (Preference) findPreference("weibo");
		mGooglePlusPref = (Preference) findPreference("google_plus");
		mGithubPref = (Preference) findPreference("github");

		String version = "Unknown";
		try {
			version = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName;
			version += " (" + getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionCode + ")";
		} catch (Exception e) {

		}
		mVersionPref.setSummary(version);

		mLicensePref.setOnPreferenceClickListener(this);
		mWeiboPref.setOnPreferenceClickListener(this);
		mGooglePlusPref.setOnPreferenceClickListener(this);
		mGithubPref.setOnPreferenceClickListener(this);
	}

	@Override
	public boolean onPreferenceClick(android.preference.Preference pref) {
		if (pref == mLicensePref) {
			SettingsActivity.launchActivity(getActivity(), SettingsActivity.FLAG_LICENSE);
			return true;
		}
		if (pref == mWeiboPref) {
			openWebUrl("http://weibo.com/fython");
			return true;
		}
		if (pref == mGooglePlusPref) {
			openWebUrl("https://plus.google.com/+FungJichun");
			return true;
		}
		if (pref == mGithubPref) {
			openWebUrl(getString(R.string.set_title_github_website));
		}
		return false;
	}

	private void openWebUrl(String url) {
		Uri uri = Uri.parse(url);
		startActivity(new Intent(Intent.ACTION_VIEW, uri));
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/util/AsyncTask.java
================================================
package moe.feng.nhentai.util;


import android.os.Handler;
import android.os.Message;
import android.util.Log;

import static moe.feng.nhentai.BuildConfig.DEBUG;

/*
 Real AsyncTask
 */

public abstract class AsyncTask<Params, Progress, Result>
{
	private static final String TAG = AsyncTask.class.getSimpleName();

	private static class AsyncResult<Data> {
		public AsyncTask task;
		public Data[] data;

		public AsyncResult(AsyncTask task, Data... data) {
			this.task = task;
			this.data = data;
		}
	}

	private static final int MSG_FINISH = 1000;
	private static final int MSG_PROGRESS = 1001;

	private static Handler sInternalHandler = new Handler() {
		@SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
		@Override
		public void handleMessage(Message msg) {
			AsyncResult result = (AsyncResult) msg.obj;
			switch (msg.what) {
				case MSG_FINISH:
					result.task.onPostExecute(result.data[0]);
					break;
				case MSG_PROGRESS:
					result.task.onProgressUpdate(result.data);
					break;
			}
		}
	};

	private Params[] mParams;

	private Thread mThread = new Thread(new Runnable() {
			@Override
			public void run() {
				// TODO: CrashHandler.register();

				try {
					Result result = doInBackground(mParams);
					sInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_FINISH, new AsyncResult<Result>(AsyncTask.this, result)));
				} catch (Exception e) {
					// Don't crash the whole app
					if (DEBUG) {
						Log.d(TAG, e.getClass().getSimpleName() + " caught when running background task. Printing stack trace.");
						Log.d(TAG, Log.getStackTraceString(e));
					}
				}

				Thread.currentThread().interrupt();
			}
		});

	protected void onPostExecute(Result result) {}

	protected abstract Result doInBackground(Params... params);

	protected void onPreExecute() {}

	protected void onProgressUpdate(Progress... progress) {}

	protected void publishProgress(Progress... progress) {
		sInternalHandler.sendMessage(sInternalHandler.obtainMessage(MSG_PROGRESS, new AsyncResult<Progress>(this, progress)));
	}

	public void execute(Params... params) {
		onPreExecute();
		mParams = params;
		mThread.start();
	}
}



================================================
FILE: app/src/main/java/moe/feng/nhentai/util/ColorGenerator.java
================================================
package moe.feng.nhentai.util;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

/**
 * @author amulya
 * @datetime 14 Oct 2014, 5:20 PM
 */
public class ColorGenerator {

	public static ColorGenerator DEFAULT;

	public static ColorGenerator MATERIAL;

	static {
		DEFAULT = create(Arrays.asList(
				0xfff16364,
				0xfff58559,
				0xfff9a43e,
				0xffe4c62e,
				0xff67bf74,
				0xff59a2be,
				0xff2093cd,
				0xffad62a7,
				0xff805781
		));
		MATERIAL = create(Arrays.asList(
				0xffe57373,
				0xfff06292,
				0xffba68c8,
				0xff9575cd,
				0xff7986cb,
				0xff64b5f6,
				0xff4fc3f7,
				0xff4dd0e1,
				0xff4db6ac,
				0xff81c784,
				0xffaed581,
				0xffff8a65,
				0xffd4e157,
				0xffffd54f,
				0xffffb74d,
				0xffa1887f,
				0xff90a4ae
		));
	}

	private final List<Integer> mColors;
	private final Random mRandom;

	public static ColorGenerator create(List<Integer> colorList) {
		return new ColorGenerator(colorList);
	}

	private ColorGenerator(List<Integer> colorList) {
		mColors = colorList;
		mRandom = new Random(System.currentTimeMillis());
	}

	public int getRandomColor() {
		return mColors.get(mRandom.nextInt(mColors.size()));
	}

	public int getColor(Object key) {
		return mColors.get(Math.abs(key.hashCode()) % mColors.size());
	}
}


================================================
FILE: app/src/main/java/moe/feng/nhentai/util/FullScreenHelper.java
================================================
package moe.feng.nhentai.util;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Build;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowManager;

@SuppressLint("InlinedApi")
public final class FullScreenHelper implements View.OnSystemUiVisibilityChangeListener {

	private static final String TAG = FullScreenHelper.class.getSimpleName();

	private final int NOT_FULL_SCREEN_JELLY_BEAN =
			View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
					View.SYSTEM_UI_FLAG_LAYOUT_STABLE;

	private final int FULL_SCREEN_JELLY_BEAN =
			NOT_FULL_SCREEN_JELLY_BEAN |
					View.SYSTEM_UI_FLAG_LOW_PROFILE |
					View.SYSTEM_UI_FLAG_FULLSCREEN;

	private final int FULL_SCREEN_FLAG_JELLY_BEAN =
			View.SYSTEM_UI_FLAG_LOW_PROFILE |
					View.SYSTEM_UI_FLAG_FULLSCREEN;

	private final int NOT_FULL_SCREEN_KITKAT =
			NOT_FULL_SCREEN_JELLY_BEAN |
					View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION;

	private final int FULL_SCREEN_KITKAT =
			NOT_FULL_SCREEN_KITKAT |
					View.SYSTEM_UI_FLAG_LOW_PROFILE |
					View.SYSTEM_UI_FLAG_FULLSCREEN |
					View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
					View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;

	private boolean mFullScreen;
	private final Activity mActivity;
	private final Window mWindow;
	private final View mDecorView;

	private boolean mHasNavBar;

	private OnFullScreenBrokenListener mListener;

	private final int TEST_SDK = Build.VERSION.SDK_INT;

	public interface OnFullScreenBrokenListener {

		/**
		 * FullScreen state should be fullScreen or not,
		 * but user or system broke it
		 *
		 * @param fullScreen support to be
		 */
		public void onFullScreenBroken(boolean fullScreen);

	}

	public FullScreenHelper(Activity activity) {
		mFullScreen = false;
		mActivity = activity;
		mWindow = mActivity.getWindow();
		mDecorView = mWindow.getDecorView();
		mDecorView.setOnSystemUiVisibilityChangeListener(this);

		String mainKey = Utility.getSystemProperties("qemu.hw.mainkeys");
		int resourceId = activity.getResources().getIdentifier("config_showNavigationBar", "bool", "android");
		if (resourceId != 0) {
			mHasNavBar = activity.getResources().getBoolean(resourceId);
			// check override flag (see static block)
			if ("1".equals(mainKey)) {
				mHasNavBar = false;
			} else if ("0".equals(mainKey)) {
				mHasNavBar = true;
			}
		} else {
			mHasNavBar = !ViewConfiguration.get(activity).hasPermanentMenuKey();
		}
	}

	public boolean willHideNavBar() {
		if (TEST_SDK >= Build.VERSION_CODES.KITKAT && mHasNavBar)
			return true;
		else
			return false;
	}

	@Override
	public void onSystemUiVisibilityChange(int visibility) {
		if (TEST_SDK >= Build.VERSION_CODES.JELLY_BEAN &&
				TEST_SDK < Build.VERSION_CODES.KITKAT) {
			if ((mFullScreen && visibility != FULL_SCREEN_FLAG_JELLY_BEAN) ||
					(!mFullScreen && visibility != 0)) {
				// User or system change visibility
				if (mListener != null)
					mListener.onFullScreenBroken(mFullScreen);
			}
		}
	}

	public void setOnFullScreenBrokenListener(OnFullScreenBrokenListener l) {
		mListener = l;
	}

	public boolean getFullScreen() {
		return mFullScreen;
	}

	public void setFullScreen(boolean fullScreen) {
		mFullScreen = fullScreen;
		if (fullScreen) {
			if (TEST_SDK < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
				// Empty
			} else if (TEST_SDK < Build.VERSION_CODES.JELLY_BEAN) {
				mWindow.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
						WindowManager.LayoutParams.FLAG_FULLSCREEN);

			} else if (TEST_SDK < Build.VERSION_CODES.KITKAT) {
				mDecorView.setSystemUiVisibility(FULL_SCREEN_JELLY_BEAN);

			} else {
				mDecorView.setSystemUiVisibility(FULL_SCREEN_KITKAT);
			}
		} else {
			if (TEST_SDK < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
				// Empty
			} else if (TEST_SDK < Build.VERSION_CODES.JELLY_BEAN) {
				mWindow.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

			} else if (TEST_SDK < Build.VERSION_CODES.KITKAT) {
				mDecorView.setSystemUiVisibility(NOT_FULL_SCREEN_JELLY_BEAN);

			} else {
				mDecorView.setSystemUiVisibility(NOT_FULL_SCREEN_KITKAT);
			}
		}
	}

}

================================================
FILE: app/src/main/java/moe/feng/nhentai/util/HttpTools.java
================================================
package moe.feng.nhentai.util;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;

public class HttpTools {

	public static HttpURLConnection openConnection(String url) throws IOException {
		URL u = new URL(url);
		HttpURLConnection conn = (HttpURLConnection) u.openConnection();
		conn.setConnectTimeout(5000);
		conn.setRequestMethod("GET");
		conn.setRequestProperty("Accept-Encoding", "identity");
		conn.setRequestProperty("Referer", URLEncoder.encode(url, "UTF-8"));
		conn.setRequestProperty("Charset", "UTF-8");
		conn.setRequestProperty("Connection", "Keep-Alive");
		return conn;
	}

	public static long getTargetContentSize(String url) throws IOException {
		HttpURLConnection conn = openConnection(url);
		if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
			return conn.getContentLength();
		}
		return -1;
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/util/Settings.java
================================================
package moe.feng.nhentai.util;

import android.content.Context;

import moe.feng.nhentai.dao.CommonPreferences;

public class Settings {

	public static final String PREFERENCES_NAME = "settings";

	private static Settings sInstance;

	private CommonPreferences mPrefs;

	public static Settings getInstance(Context context) {
		if (sInstance == null) {
			sInstance = new Settings(context);
		}
		return sInstance;
	}

	private Settings(Context context) {
		mPrefs = CommonPreferences.getInstance(context, PREFERENCES_NAME);
	}

	public Settings putBoolean(String key, boolean value) {
		mPrefs.edit().putBoolean(key, value).commit();
		return this;
	}

	public boolean getBoolean(String key, boolean def) {
		return mPrefs.getBoolean(key, def);
	}

	public Settings putInt(String key, int value) {
		mPrefs.edit().putInt(key, value).commit();
		return this;
	}

	public int getInt(String key, int defValue) {
		return mPrefs.getInt(key, defValue);
	}


	public Settings putString(String key, String value) {
		mPrefs.edit().putString(key, value).commit();
		return this;
	}

	public String getString(String key, String defValue) {
		return mPrefs.getString(key, defValue);
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/util/TextDrawable.java
================================================
package moe.feng.nhentai.util;

import android.graphics.*;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.RectShape;
import android.graphics.drawable.shapes.RoundRectShape;

/**
 * @author amulya
 * @datetime 14 Oct 2014, 3:53 PM
 */
public class TextDrawable extends ShapeDrawable {

	private final Paint textPaint;
	private final Paint borderPaint;
	private static final float SHADE_FACTOR = 0.9f;
	private final String text;
	private final int color;
	private final RectShape shape;
	private final int height;
	private final int width;
	private final int fontSize;
	private final float radius;
	private final int borderThickness;

	private TextDrawable(Builder builder) {
		super(builder.shape);

		// shape properties
		shape = builder.shape;
		height = builder.height;
		width = builder.width;
		radius = builder.radius;

		// text and color
		text = builder.toUpperCase ? builder.text.toUpperCase() : builder.text;
		color = builder.color;

		// text paint settings
		fontSize = builder.fontSize;
		textPaint = new Paint();
		textPaint.setColor(builder.textColor);
		textPaint.setAntiAlias(true);
		textPaint.setFakeBoldText(builder.isBold);
		textPaint.setStyle(Paint.Style.FILL);
		textPaint.setTypeface(builder.font);
		textPaint.setTextAlign(Paint.Align.CENTER);
		textPaint.setStrokeWidth(builder.borderThickness);

		// border paint settings
		borderThickness = builder.borderThickness;
		borderPaint = new Paint();
		borderPaint.setColor(getDarkerShade(color));
		borderPaint.setStyle(Paint.Style.STROKE);
		borderPaint.setStrokeWidth(borderThickness);

		// drawable paint color
		Paint paint = getPaint();
		paint.setColor(color);

	}

	private int getDarkerShade(int color) {
		return Color.rgb((int)(SHADE_FACTOR * Color.red(color)),
				(int)(SHADE_FACTOR * Color.green(color)),
				(int)(SHADE_FACTOR * Color.blue(color)));
	}

	@Override
	public void draw(Canvas canvas) {
		super.draw(canvas);
		Rect r = getBounds();


		// draw border
		if (borderThickness > 0) {
			drawBorder(canvas);
		}

		int count = canvas.save();
		canvas.translate(r.left, r.top);

		// draw text
		int width = this.width < 0 ? r.width() : this.width;
		int height = this.height < 0 ? r.height() : this.height;
		int fontSize = this.fontSize < 0 ? (Math.min(width, height) / 2) : this.fontSize;
		textPaint.setTextSize(fontSize);
		canvas.drawText(text, width / 2, height / 2 - ((textPaint.descent() + textPaint.ascent()) / 2), textPaint);

		canvas.restoreToCount(count);

	}

	private void drawBorder(Canvas canvas) {
		RectF rect = new RectF(getBounds());
		rect.inset(borderThickness/2, borderThickness/2);

		if (shape instanceof OvalShape) {
			canvas.drawOval(rect, borderPaint);
		}
		else if (shape instanceof RoundRectShape) {
			canvas.drawRoundRect(rect, radius, radius, borderPaint);
		}
		else {
			canvas.drawRect(rect, borderPaint);
		}
	}

	@Override
	public void setAlpha(int alpha) {
		textPaint.setAlpha(alpha);
	}

	@Override
	public void setColorFilter(ColorFilter cf) {
		textPaint.setColorFilter(cf);
	}

	@Override
	public int getOpacity() {
		return PixelFormat.TRANSLUCENT;
	}

	@Override
	public int getIntrinsicWidth() {
		return width;
	}

	@Override
	public int getIntrinsicHeight() {
		return height;
	}

	public static IShapeBuilder builder() {
		return new Builder();
	}

	public static class Builder implements IConfigBuilder, IShapeBuilder, IBuilder {

		private String text;

		private int color;

		private int borderThickness;

		private int width;

		private int height;

		private Typeface font;

		private RectShape shape;

		public int textColor;

		private int fontSize;

		private boolean isBold;

		private boolean toUpperCase;

		public float radius;

		private Builder() {
			text = "";
			color = Color.GRAY;
			textColor = Color.WHITE;
			borderThickness = 0;
			width = -1;
			height = -1;
			shape = new RectShape();
			font = Typeface.create("sans-serif-light", Typeface.NORMAL);
			fontSize = -1;
			isBold = false;
			toUpperCase = false;
		}

		public IConfigBuilder width(int width) {
			this.width = width;
			return this;
		}

		public IConfigBuilder height(int height) {
			this.height = height;
			return this;
		}

		public IConfigBuilder textColor(int color) {
			this.textColor = color;
			return this;
		}

		public IConfigBuilder withBorder(int thickness) {
			this.borderThickness = thickness;
			return this;
		}

		public IConfigBuilder useFont(Typeface font) {
			this.font = font;
			return this;
		}

		public IConfigBuilder fontSize(int size) {
			this.fontSize = size;
			return this;
		}

		public IConfigBuilder bold() {
			this.isBold = true;
			return this;
		}

		public IConfigBuilder toUpperCase() {
			this.toUpperCase = true;
			return this;
		}

		@Override
		public IConfigBuilder beginConfig() {
			return this;
		}

		@Override
		public IShapeBuilder endConfig() {
			return this;
		}

		@Override
		public IBuilder rect() {
			this.shape = new RectShape();
			return this;
		}

		@Override
		public IBuilder round() {
			this.shape = new OvalShape();
			return this;
		}

		@Override
		public IBuilder roundRect(int radius) {
			this.radius = radius;
			float[] radii = {radius, radius, radius, radius, radius, radius, radius, radius};
			this.shape = new RoundRectShape(radii, null, null);
			return this;
		}

		@Override
		public TextDrawable buildRect(String text, int color) {
			rect();
			return build(text, color);
		}

		@Override
		public TextDrawable buildRoundRect(String text, int color, int radius) {
			roundRect(radius);
			return build(text, color);
		}

		@Override
		public TextDrawable buildRound(String text, int color) {
			round();
			return build(text, color);
		}

		@Override
		public TextDrawable build(String text, int color) {
			this.color = color;
			this.text = text;
			return new TextDrawable(this);
		}
	}

	public interface IConfigBuilder {
		public IConfigBuilder width(int width);

		public IConfigBuilder height(int height);

		public IConfigBuilder textColor(int color);

		public IConfigBuilder withBorder(int thickness);

		public IConfigBuilder useFont(Typeface font);

		public IConfigBuilder fontSize(int size);

		public IConfigBuilder bold();

		public IConfigBuilder toUpperCase();

		public IShapeBuilder endConfig();
	}

	public static interface IBuilder {

		public TextDrawable build(String text, int color);
	}

	public static interface IShapeBuilder {

		public IConfigBuilder beginConfig();

		public IBuilder rect();

		public IBuilder round();

		public IBuilder roundRect(int radius);

		public TextDrawable buildRect(String text, int color);

		public TextDrawable buildRoundRect(String text, int color, int radius);

		public TextDrawable buildRound(String text, int color);
	}
}

================================================
FILE: app/src/main/java/moe/feng/nhentai/util/Utility.java
================================================
package moe.feng.nhentai.util;

import android.content.Context;
import android.os.Build;

import java.lang.reflect.Method;

public class Utility {

	public static boolean isChrome() {
		return Build.BRAND.equals("chromium") || Build.BRAND.equals("chrome");
	}

	public static int getStatusBarHeight(Context context) {
		int result = 0;
		int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
		if (resourceId > 0) {
			result = context.getResources().getDimensionPixelSize(resourceId);
		}
		return result;
	}

	public static String getFirstCharacter(String sentence) {
		for (int i = 0; i < sentence.length(); i++) {
			String s = sentence.substring(i, i+1);
			if (s.equals("[") || s.equals("]")) continue;
			if (s.equals("{") || s.equals("}")) continue;
			if (s.equals("(") || s.equals(")")) continue;
			if (s.equals(",") || s.equals(".")) continue;
			if (s.equals("<") || s.equals(">")) continue;
			if (s.equals("《") || s.equals("》")) continue;
			if (s.equals("【") || s.equals("】")) continue;
			if (s.equals("{") || s.equals("}")) continue;
			return s;
		}
		return null;
	}

	public static String getSystemProperties(String key) {
		try {
			Class c = Class.forName("android.os.SystemProperties");
			Method m = c.getDeclaredMethod("get", String.class);
			m.setAccessible(true);
			return (String) m.invoke(null, key);
		} catch (Throwable e) {
			return "";
		}
	}

}


================================================
FILE: app/src/main/java/moe/feng/nhentai/view/AutoWrapLayout.java
================================================
package moe.feng.nhentai.view;

import java.util.ArrayList;
import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;

import moe.feng.nhentai.R;

/**
 * A ViewGroup that can layout views in line and auto wrap
 *
 * @author Hippo
 *
 */
public class AutoWrapLayout extends ViewGroup {
	@SuppressWarnings("unused")
	private final static String TAG = "AutoWrapLayout";
	private final List<Rect> rectList = new ArrayList<Rect>();

	private Alignment mAlignment;

	private static final Alignment[] sBaseLineArray = { Alignment.TOP,
			Alignment.CENTER, Alignment.BOTTOM };


	public enum Alignment {
		TOP(0),
		CENTER(1),
		BOTTOM(2);

		Alignment(int ni) {
			nativeInt = ni;
		}

		final int nativeInt;
	}

	public AutoWrapLayout(Context context) {
		super(context);
	}
	public AutoWrapLayout(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}
	public AutoWrapLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);

		TypedArray a = context.obtainStyledAttributes(attrs,
				R.styleable.AutoWrapLayout, defStyle, 0);

		int index = a.getInt(R.styleable.AutoWrapLayout_alignment, -1);
		if (index >= 0)
			setAlignment(sBaseLineArray[index]);

		a.recycle();
	}

	public void setAlignment(Alignment baseLine) {
		if (baseLine == null)
			return;

		if (mAlignment != baseLine) {
			mAlignment = baseLine;

			requestLayout();
			invalidate();
		}
	}

	public Alignment getScaleType() {
		return mAlignment;
	}

	private void adjustBaseLine(int lineHeight, int startIndex, int endIndex) {
		if (mAlignment == Alignment.TOP)
			return;

		for (int index = startIndex; index < endIndex; index++) {
			final View child = getChildAt(index);
			final AutoWrapLayout.LayoutParams lp =
					(AutoWrapLayout.LayoutParams)child.getLayoutParams();
			Rect rect = rectList.get(index);
			int offsetRaw = lineHeight - rect.height() - lp.topMargin - lp.bottomMargin;
			if (mAlignment == Alignment.CENTER)
				rect.offset(0, offsetRaw/2);
			else if (mAlignment == Alignment.BOTTOM)
				rect.offset(0, offsetRaw);
		}
	}


	// TODO Take vertical mode
	/**
	 * each row or line at least show one child
	 *
	 * horizontal only show child can show or partly show in parent
	 */
	@SuppressLint("DrawAllocation")
	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		int widthMode = MeasureSpec.getMode(widthMeasureSpec);
		int heightMode = MeasureSpec.getMode(heightMeasureSpec);

		int maxWidth = MeasureSpec.getSize(widthMeasureSpec);
		int maxHeight = MeasureSpec.getSize(heightMeasureSpec);

		if (widthMode == MeasureSpec.UNSPECIFIED)
			maxWidth = Integer.MAX_VALUE;
		if (heightMode == MeasureSpec.UNSPECIFIED)
			maxHeight = Integer.MAX_VALUE;

		int paddingLeft = getPaddingLeft();
		int paddingTop = getPaddingTop();
		int paddingRight = getPaddingRight();
		int paddingBottom = getPaddingBottom();

		int maxRightBound = maxWidth - paddingRight;
		int maxBottomBound = maxHeight - paddingBottom;

		int left;
		int top;
		int right;
		int bottom;
		int rightBound = paddingLeft;
		int maxRightNoPadding = rightBound;
		int bottomBound;
		int lastMaxBottom = paddingTop;
		int maxBottom = lastMaxBottom;
		int childWidth;
		int childHeight;

		int lineStartIndex = 0;
		int lineEndIndex = 0; // endIndex + 1

		rectList.clear();
		int childCount = getChildCount();
		for (int index = 0; index < childCount; index++) {
			final View child = getChildAt(index);
			child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
			if (child.getVisibility() == View.GONE)
				continue;
			final AutoWrapLayout.LayoutParams lp =
					(AutoWrapLayout.LayoutParams)child.getLayoutParams();
			childWidth = child.getMeasuredWidth();
			childHeight = child.getMeasuredHeight();

			left = rightBound + lp.leftMargin;
			right = left + childWidth;
			rightBound = right + lp.rightMargin;
			if (rightBound > maxRightBound) { // Go to next row
				lineEndIndex = index;
				// Adjust child position base on baseline
				adjustBaseLine(maxBottom - lastMaxBottom, lineStartIndex, lineEndIndex);

				// If child can't show in parent begin this line
				if (maxBottom >= maxBottomBound)
					break;

				// If it is first item in line, try to show it all
				if (lineEndIndex == lineStartIndex) {
					child.measure(MeasureSpec.makeMeasureSpec(
									maxWidth - paddingLeft - paddingRight
											- lp.leftMargin - lp.rightMargin, MeasureSpec.AT_MOST),
							MeasureSpec.UNSPECIFIED);
					childWidth = child.getMeasuredWidth();
					childHeight = child.getMeasuredHeight();
				}
				left = paddingLeft + lp.leftMargin;
				right = left + childWidth;
				rightBound = right + lp.rightMargin;

				lastMaxBottom = maxBottom;
				top = lastMaxBottom + lp.topMargin;
				bottom = top + childHeight;
				bottomBound = bottom + lp.bottomMargin;

				lineStartIndex = index;
			} else {
				top = lastMaxBottom + lp.topMargin;
				bottom = top + childHeight;
				bottomBound = bottom + lp.bottomMargin;
			}
			// Update max
			if (rightBound > maxRightNoPadding)
				maxRightNoPadding = rightBound;
			if (bottomBound > maxBottom)
				maxBottom = bottomBound;
			Rect rect = new Rect();
			rect.left = left;
			rect.top = top;
			rect.right = right;
			rect.bottom = bottom;
			rectList.add(rect);
		}

		// Handle last line baseline
		adjustBaseLine(maxBottom - lastMaxBottom, lineStartIndex, rectList.size());

		int measuredWidth;
		int measuredHeight;

		if (widthMode == MeasureSpec.EXACTLY)
			measuredWidth = maxWidth;
		else
			measuredWidth = maxRightNoPadding + paddingRight;
		if (heightMode == MeasureSpec.EXACTLY)
			measuredHeight = maxHeight;
		else {
			measuredHeight = maxBottom + paddingBottom;
			if (heightMode == MeasureSpec.AT_MOST)
				measuredHeight = measuredHeight > maxHeight ? maxHeight : measuredHeight;
		}

		setMeasuredDimension(measuredWidth, measuredHeight);
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		final int count = rectList.size();
		for(int i = 0; i < count; i++){
			final View child = this.getChildAt(i);
			if (child.getVisibility() == View.GONE)
				continue;
			Rect rect = rectList.get(i);
			child.layout(rect.left, rect.top, rect.right, rect.bottom);
		}
	}

	@Override
	public LayoutParams generateLayoutParams(AttributeSet attrs) {
		return new AutoWrapLayout.LayoutParams(getContext(), attrs);
	}

	@Override
	protected LayoutParams generateDefaultLayoutParams() {
		return new AutoWrapLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	}

	@Override
	protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
		return new LayoutParams(p);
	}

	public static class LayoutParams extends ViewGroup.MarginLayoutParams {
		public LayoutParams() {
			this(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		}
		public LayoutParams(Context c, AttributeSet attrs) {
			super(c, attrs);
		}
		public LayoutParams(int width, int height) {
			super(width, height);
		}
		public LayoutParams(android.view.ViewGroup.LayoutParams source) {
			super(source);
		}
		public LayoutParams(MarginLayoutParams source) {
			super(source);
		}
	}
}

================================================
FILE: app/src/main/java/moe/feng/nhentai/view/ExpandableHeightGridView.java
================================================
package moe.feng.nhentai.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.GridView;

public class ExpandableHeightGridView extends GridView {

	private boolean expanded = false;

	public ExpandableHeightGridView(Context context) {
		super(context);
	}

	public ExpandableHeightGridView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public ExpandableHeightGridView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public boolean isExpanded() {
		return expanded;
	}

	@Override
	public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		if (isExpanded()) {
			int expandSpec = MeasureSpec.makeMeasureSpec(
					Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
			super.onMeasure(widthMeasureSpec, expandSpec);

			ViewGroup.LayoutParams params = getLayoutParams();
			params.height = getMeasuredHeight();
		} else {
			super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		}
	}

	public void setExpanded(boolean expanded) {
		this.expanded = expanded;
	}

}

================================================
FILE: app/src/main/java/moe/feng/nhentai/view/WheelProgressView.java
================================================
package moe.feng.nhentai.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.RectF;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.SystemClock;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;

import moe.feng.nhentai.R;

/**
 * A Material style progress wheel, compatible up to 2.2.
 * Todd Davies' Progress Wheel https://github.com/Todd-Davies/ProgressWheel
 *
 * @author Nico Hormazabal
 *         <p/>
 *         Licensed under the Apache License 2.0 license see:
 *         http://www.apache.org/licenses/LICENSE-2.0
 */
public class WheelProgressView extends View {

	private static final String TAG = WheelProgressView.class.getSimpleName();

	private int circleRadius = 28;
	private int barWidth = 4;
	private int rimWidth = 4;

	private final int barLength = 16;
	private final int barMaxLength = 270;

	private boolean fillRadius = false;

	private double timeStartGrowing = 0;
	private double barSpinCycleTime = 460;
	private float barExtraLength = 0;
	private boolean barGrowingFromFront = true;

	private long pausedTimeWithoutGrowing = 0;
	private final long pauseGrowingTime = 200;

	private int barColor = 0xAA000000;
	private int rimColor = 0x00FFFFFF;

	private Paint barPaint = new Paint();
	private Paint rimPaint = new Paint();

	private RectF circleBounds = new RectF();

	private float spinSpeed = 230.0f;
	private long lastTimeAnimated = 0;

	private boolean linearProgress;

	private float mProgress = 0.0f;
	private float mTargetProgress = 0.0f;
	private boolean isSpinning = false;

	private ProgressCallback callback;

	/**
	 * The constructor for the ProgressWheel
	 *
	 * @param context
	 * @param attrs
	 */
	public WheelProgressView(Context context, AttributeSet attrs) {
		super(context, attrs);

		parseAttributes(context.obtainStyledAttributes(attrs,
				R.styleable.WheelProgressView));
	}

	/**
	 * The constructor for the ProgressWheel
	 *
	 * @param context
	 */
	public WheelProgressView(Context context) {
		super(context);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);

		int viewWidth = circleRadius + this.getPaddingLeft() + this.getPaddingRight();
		int viewHeight = circleRadius + this.getPaddingTop() + this.getPaddingBottom();

		int widthMode = MeasureSpec.getMode(widthMeasureSpec);
		int widthSize = MeasureSpec.getSize(widthMeasureSpec);
		int heightMode = MeasureSpec.getMode(heightMeasureSpec);
		int heightSize = MeasureSpec.getSize(heightMeasureSpec);

		int width;
		int height;

		if (widthMode == MeasureSpec.EXACTLY) {
			width = widthSize;
		} else if (widthMode == MeasureSpec.AT_MOST) {
			width = Math.min(viewWidth, widthSize);
		} else {
			width = viewWidth;
		}

		if (heightMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.EXACTLY) {
			height = heightSize;
		} else if (heightMode == MeasureSpec.AT_MOST) {
			height = Math.min(viewHeight, heightSize);
		} else {
			height = viewHeight;
		}

		setMeasuredDimension(width, height);
	}

	/**
	 * Use onSizeChanged instead of onAttachedToWindow to get the dimensions of the view,
	 * because this method is called after measuring the dimensions of MATCH_PARENT & WRAP_CONTENT.
	 * Use this dimensions to setup the bounds and paints.
	 */
	@Override
	protected void onSizeChanged(int w, int h, int oldw, int oldh) {
		super.onSizeChanged(w, h, oldw, oldh);

		setupBounds(w, h);
		setupPaints();
		invalidate();
	}

	/**
	 * Set the properties of the paints we're using to
	 * draw the progress wheel
	 */
	private void setupPaints() {
		barPaint.setColor(barColor);
		barPaint.setAntiAlias(true);
		barPaint.setStyle(Style.STROKE);
		barPaint.setStrokeWidth(barWidth);

		rimPaint.setColor(rimColor);
		rimPaint.setAntiAlias(true);
		rimPaint.setStyle(Style.STROKE);
		rimPaint.setStrokeWidth(rimWidth);
	}

	/**
	 * Set the bounds of the component
	 */
	private void setupBounds(int layout_width, int layout_height) {
		int paddingTop = getPaddingTop();
		int paddingBottom = getPaddingBottom();
		int paddingLeft = getPaddingLeft();
		int paddingRight = getPaddingRight();

		if (!fillRadius) {
			int minValue = Math.min(layout_width - paddingLeft - paddingRight,
					layout_height - paddingBottom - paddingTop);

			int circleDiameter = Math.min(minValue, circleRadius * 2 - barWidth * 2);

			int xOffset = (layout_width - paddingLeft - paddingRight - circleDiameter) / 2 + paddingLeft;
			int yOffset = (layout_height - paddingTop - paddingBottom - circleDiameter) / 2 + paddingTop;

			circleBounds = new RectF(xOffset + barWidth,
					yOffset + barWidth,
					xOffset + circleDiameter - barWidth,
					yOffset + circleDiameter - barWidth);
		} else {
			circleBounds = new RectF(paddingLeft + barWidth,
					paddingTop + barWidth,
					layout_width - paddingRight - barWidth,
					layout_height - paddingBottom - barWidth);
		}
	}

	/**
	 * Parse the attributes passed to the view from the XML
	 *
	 * @param a the attributes to parse
	 */
	private void parseAttributes(TypedArray a) {
		DisplayMetrics metrics = getContext().getResources().getDisplayMetrics();
		barWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, barWidth, metrics);
		rimWidth = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rimWidth, metrics);
		circleRadius = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, circleRadius, metrics);

		circleRadius = (int) a.getDimension(R.styleable.WheelProgressView_matProg_circleRadius, circleRadius);

		fillRadius = a.getBoolean(R.styleable.WheelProgressView_matProg_fillRadius, false);

		barWidth = (int) a.getDimension(R.styleable.WheelProgressView_matProg_barWidth, barWidth);

		rimWidth = (int) a.getDimension(R.styleable.WheelProgressView_matProg_rimWidth, rimWidth);

		float baseSpinSpeed = a.getFloat(R.styleable.WheelProgressView_matProg_spinSpeed, spinSpeed / 360.0f);
		spinSpeed = baseSpinSpeed * 360;

		barSpinCycleTime = a.getInt(R.styleable.WheelProgressView_matProg_barSpinCycleTime, (int) barSpinCycleTime);

		barColor = a.getColor(R.styleable.WheelProgressView_matProg_barColor, barColor);

		rimColor = a.getColor(R.styleable.WheelProgressView_matProg_rimColor, rimColor);

		linearProgress = a.getBoolean(R.styleable.WheelProgressView_matProg_linearProgress, false);

		if (a.getBoolean(R.styleable.WheelProgressView_matProg_progressIndeterminate, false)) {
			spin();
		}

		a.recycle();
	}

	public void setCallback(ProgressCallback progressCallback) {
		callback = progressCallback;

		if (!isSpinning) {
			runCallback();
		}
	}

	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);

		canvas.drawArc(circleBounds, 360, 360, false, rimPaint);

		boolean mustInvalidate = false;

		if (isSpinning) {
			mustInvalidate = true;

			long deltaTime = (SystemClock.uptimeMillis() - lastTimeAnimated);
			float deltaNormalized = deltaTime * spinSpeed / 1000.0f;

			updateBarLength(deltaTime);

			mProgress += deltaNormalized;
			if (mProgress > 360) {
				mProgress -= 360f;

				runCallback(-1.0f);
			}
			lastTimeAnimated = SystemClock.uptimeMillis();

			float from = mProgress - 90;
			float length = barLength + barExtraLength;

			if (isInEditMode()) {
				from = 0;
				length = 135;
			}

			canvas.drawArc(circleBounds, from, length, false,
					barPaint);
		} else {
			float oldProgress = mProgress;

			if (mProgress != mTargetProgress) {
				mustInvalidate = true;

				float deltaTime = (float) (SystemClock.uptimeMillis() - lastTimeAnimated) / 1000;
				float deltaNormalized = deltaTime * spinSpeed;

				mProgress = Math.min(mProgress + deltaNormalized, mTargetProgress);
				lastTimeAnimated = SystemClock.uptimeMillis();
			}

			if (oldProgress != mProgress) {
				runCallback();
			}

			float offset = 0.0f;
			float progress = mProgress;
			if (!linearProgress) {
				float factor = 2.0f;
				offset = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, 2.0f * factor)) * 360.0f;
				progress = (float) (1.0f - Math.pow(1.0f - mProgress / 360.0f, factor)) * 360.0f;
			}

			if (isInEditMode()) {
				progress = 360;
			}

			canvas.drawArc(circleBounds, offset - 90, progress, false, barPaint);
		}

		if (mustInvalidate) {
			invalidate();
		}
	}

	@Override
	protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
		super.onVisibilityChanged(changedView, visibility);

		if (visibility == VISIBLE) {
			lastTimeAnimated = SystemClock.uptimeMillis();
		}
	}

	private void updateBarLength(long deltaTimeInMilliSeconds) {
		if (pausedTimeWithoutGrowing >= pauseGrowingTime) {
			timeStartGrowing += deltaTimeInMilliSeconds;

			if (timeStartGrowing > barSpinCycleTime) {
				timeStartGrowing -= barSpinCycleTime;
				pausedTimeWithoutGrowing = 0;
				barGrowingFromFront = !barGrowingFromFront;
			}

			float distance = (float) Math.cos((timeStartGrowing / barSpinCycleTime + 1) * Math.PI) / 2 + 0.5f;
			float destLength = (barMaxLength - barLength);

			if (barGrowingFromFront) {
				barExtraLength = distance * destLength;
			} else {
				float newLength = destLength * (1 - distance);
				mProgress += (barExtraLength - newLength);
				barExtraLength = newLength;
			}
		} else {
			pausedTimeWithoutGrowing += deltaTimeInMilliSeconds;
		}
	}

	/**
	 * Check if the wheel is currently spinning
	 */

	public boolean isSpinning() {
		return isSpinning;
	}

	/**
	 * Reset the count (in increment mode)
	 */
	public void resetCount() {
		mProgress = 0.0f;
		mTargetProgress = 0.0f;
		invalidate();
	}

	/**
	 * Turn off spin mode
	 */
	public void stopSpinning() {
		isSpinning = false;
		mProgress = 0.0f;
		mTargetProgress = 0.0f;
		invalidate();
	}

	/**
	 * Puts the view on spin mode
	 */
	public void spin() {
		lastTimeAnimated = SystemClock.uptimeMillis();
		isSpinning = true;
		invalidate();
	}

	private void runCallback(float value) {
		if (callback != null) {
			callback.onProgressUpdate(value);
		}
	}

	private void runCallback() {
		if (callback != null) {
			float normalizedProgress = (float) Math.round(mProgress * 100 / 360.0f) / 100;
			callback.onProgressUpdate(normalizedProgress);
		}
	}

	/**
	 * Set the progress to a specific value,
	 * the bar will smoothly animate until that value
	 *
	 * @param progress the progress between 0 and 1
	 */
	public void setProgress(float progress) {
		if (isSpinning) {
			mProgress = 0.0f;
			isSpinning = false;

			runCallback();
		}

		if (progress > 1.0f) {
			progress -= 1.0f;
		} else if (progress < 0) {
			progress = 0;
		}

		if (progress == mTargetProgress) {
			return;
		}

		if (mProgress == mTargetProgress) {
			lastTimeAnimated = SystemClock.uptimeMillis();
		}

		mTargetProgress = Math.min(progress * 360.0f, 360.0f);

		invalidate();
	}

	/**
	 * Set the progress to a specific value,
	 * the bar will be set instantly to that value
	 *
	 * @param progress the progress between 0 and 1
	 */
	public void setInstantProgress(float progress) {
		if (isSpinning) {
			mProgress = 0.0f;
			isSpinning = false;
		}

		if (progress > 1.0f) {
			progress -= 1.0f;
		} else if (progress < 0) {
			progress = 0;
		}

		if (progress == mTargetProgress) {
			return;
		}

		mTargetProgress = Math.min(progress * 360.0f, 360.0f);
		mProgress = mTargetProgress;
		lastTimeAnimated = SystemClock.uptimeMillis();
		invalidate();
	}

	@Override
	public Parcelable onSaveInstanceState() {
		Parcelable superState = super.onSaveInstanceState();

		WheelSavedState ss = new WheelSavedState(superState);

		ss.mProgress = this.mProgress;
		ss.mTargetProgress = this.mTargetProgress;
		ss.isSpinning = this.isSpinning;
		ss.spinSpeed = this.spinSpeed;
		ss.barWidth = this.barWidth;
		ss.barColor = this.barColor;
		ss.rimWidth = this.rimWidth;
		ss.rimColor = this.rimColor;
		ss.circleRadius = this.circleRadius;
		ss.linearProgress = this.linearProgress;
		ss.fillRadius = this.fillRadius;

		return ss;
	}

	@Override
	public void onRestoreInstanceState(Parcelable state) {
		if (!(state instanceof WheelSavedState)) {
			super.onRestoreInstanceState(state);
			return;
		}

		WheelSavedState ss = (WheelSavedState) state;
		super.onRestoreInstanceState(ss.getSuperState());

		this.mProgress = ss.mProgress;
		this.mTargetProgress = ss.mTargetProgress;
		this.isSpinning = ss.isSpinning;
		this.spinSpeed = ss.spinSpeed;
		this.barWidth = ss.barWidth;
		this.barColor = ss.barColor;
		this.rimWidth = ss.rimWidth;
		this.rimColor = ss.rimColor;
		this.circleRadius = ss.circleRadius;
		this.linearProgress = ss.linearProgress;
		this.fillRadius = ss.fillRadius;

		this.lastTimeAnimated = SystemClock.uptimeMillis();
	}

	/**
	 * @return the current progress between 0.0 and 1.0,
	 * if the wheel is indeterminate, then the result is -1
	 */
	public float getProgress() {
		return isSpinning ? -1 : mProgress / 360.0f;
	}

	/**
	 * Sets the determinate progress mode
	 *
	 * @param isLinear if the progress should increase linearly
	 */
	public void setLinearProgress(boolean isLinear) {
		linearProgress = isLinear;
		if (!isSpinning) {
			invalidate();
		}
	}

	/**
	 * @return the radius of the wheel in pixels
	 */
	public int getCircleRadius() {
		return circleRadius;
	}

	/**
	 * Sets the radius of the wheel
	 *
	 * @param circleRadius the expected radius, in pixels
	 */
	public void setCircleRadius(int circleRadius) {
		this.circleRadius = circleRadius;
		if (!isSpinning) {
			invalidate();
		}
	}

	/**
	 * @return the width of the spinning bar
	 */
	public int getBarWidth() {
		return barWidth;
	}

	/**
	 * Sets the width of the spinning bar
	 *
	 * @param barWidth the spinning bar width in pixels
	 */
	public void setBarWidth(int barWidth) {
		this.barWidth = barWidth;
		if (!isSpinning) {
			invalidate();
		}
	}

	/**
	 * @return the color of the spinning bar
	 */
	public int getBarColor() {
		return barColor;
	}

	/**
	 * Sets the color of the spinning bar
	 *
	 * @param barColor The spinning bar color
	 */
	public void setBarColor(int barColor) {
		this.barColor = barColor;
		setupPaints();
		if (!isSpinning) {
			invalidate();
		}
	}

	/**
	 * @return the color of the wheel's contour
	 */
	public int getRimColor() {
		return rimColor;
	}

	/**
	 * Sets the color of the wheel's contour
	 *
	 * @param rimColor the color for the wheel
	 */
	public void setRimColor(int rimColor) {
		this.rimColor = rimColor;
		setupPaints();
		if (!isSpinning) {
			invalidate();
		}
	}

	/**
	 * @return the base spinning speed, in full circle turns per second
	 * (1.0 equals on full turn in one second), this value also is applied for
	 * the smoothness when setting a progress
	 */
	public float getSpinSpeed() {
		return spinSpeed / 360.0f;
	}

	/**
	 * Sets the base spinning speed, in full circle turns per second
	 * (1.0 equals on full turn in one second), this value also is applied for
	 * the smoothness when setting a progress
	 *
	 * @param spinSpeed the desired base speed in full turns per second
	 */
	public void setSpinSpeed(float spinSpeed) {
		this.spinSpeed = spinSpeed * 360.0f;
	}

	/**
	 * @return the width of the wheel's contour in pixels
	 */
	public int getRimWidth() {
		return rimWidth;
	}

	/**
	 * Sets the width of the wheel's contour
	 *
	 * @param rimWidth the width in pixels
	 */
	public void setRimWidth(int rimWidth) {
		this.rimWidth = rimWidth;
		if (!isSpinning) {
			invalidate();
		}
	}

	static class WheelSavedState extends BaseSavedState {
		float mProgress;
		float mTargetProgress;
		boolean isSpinning;
		float spinSpeed;
		int barWidth;
		int barColor;
		int rimWidth;
		int rimColor;
		int circleRadius;
		boolean linearProgress;
		boolean fillRadius;

		WheelSavedState(Parcelable superState) {
			super(superState);
		}

		private WheelSavedState(Parcel in) {
			super(in);
			this.mProgress = in.readFloat();
			this.mTargetProgress = in.readFloat();
			this.isSpinning = in.readByte() != 0;
			this.spinSpeed = in.readFloat();
			this.barWidth = in.readInt();
			this.barColor = in.readInt();
			this.rimWidth = in.readInt();
			this.rimColor = in.readInt();
			this.circleRadius = in.readInt();
			this.linearProgress = in.readByte() != 0;
			this.fillRadius = in.readByte() != 0;
		}

		@Override
		public void writeToParcel(Parcel out, int flags) {
			super.writeToParcel(out, flags);
			out.writeFloat(this.mProgress);
			out.writeFloat(this.mTargetProgress);
			out.writeByte((byte) (isSpinning ? 1 : 0));
			out.writeFloat(this.spinSpeed);
			out.writeInt(this.barWidth);
			out.writeInt(this.barColor);
			out.writeInt(this.rimWidth);
			out.writeInt(this.rimColor);
			out.writeInt(this.circleRadius);
			out.writeByte((byte) (linearProgress ? 1 : 0));
			out.writeByte((byte) (fillRadius ? 1 : 0));
		}

		public static final Parcelable.Creator<WheelSavedState> CREATOR =
				new Parcelable.Creator<WheelSavedState>() {
					public WheelSavedState createFromParcel(Parcel in) {
						return new WheelSavedState(in);
					}

					public WheelSavedState[] newArray(int size) {
						return new WheelSavedState[size];
					}
				};
	}

	public interface ProgressCallback {
		/**
		 * Method to call when the progress reaches a value
		 * in order to avoid float precision issues, the progress
		 * is rounded to a float with two decimals.
		 *
		 * In indeterminate mode, the callback is called each time
		 * the wheel completes an animation cycle, with, the progress value is -1.0f
		 *
		 * @param progress a double value between 0.00 and 1.00 both included
		 */
		public void onProgressUpdate(float progress);
	}
}

================================================
FILE: app/src/main/java/moe/feng/nhentai/view/pref/Preference.java
================================================
package moe.feng.nhentai.view.pref;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build.VERSION_CODES;
import android.util.AttributeSet;

import moe.feng.nhentai.R;

public class Preference extends android.preference.Preference {

	private boolean _isInitialized = false;

	protected void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		setLayoutResource(R.layout.custom_preference);
	}

	@TargetApi(VERSION_CODES.LOLLIPOP)
	public Preference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		super(context, attrs, defStyleAttr, defStyleRes);
		if (!_isInitialized) {
			_isInitialized = true;
			init(context, attrs, defStyleAttr, defStyleRes);
		}
	}

	public Preference(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		if (!_isInitialized) {
			_isInitialized = true;
			init(context, attrs, defStyleAttr, 0);
		}
	}

	public Preference(Context context, AttributeSet attrs) {
		super(context, attrs);
		if (!_isInitialized) {
			_isInitialized = true;
			init(context, attrs, 0, 0);
		}
	}

	public Preference(Context context) {
		super(context);
		if (!_isInitialized) {
			_isInitialized = true;
			init(context, null, 0, 0);
		}
	}

}

================================================
FILE: app/src/main/java/moe/feng/nhentai/view/pref/SwitchPreference.java
================================================
package moe.feng.nhentai.view.pref;

import android.content.Context;
import android.content.res.TypedArray;
import android.support.v7.widget.SwitchCompat;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Checkable;
import android.widget.CompoundButton;

import moe.feng.nhentai.R;

/**
 * A {@link Preference} that provides a two-state toggleable option.
 * <p/>
 * This preference will store a boolean into the SharedPreferences.
 *
 * @attr ref android.R.styleable#SwitchPreference_summaryOff
 * @attr ref android.R.styleable#SwitchPreference_summaryOn
 * @attr ref android.R.styleable#SwitchPreference_switchTextOff
 * @attr ref android.R.styleable#SwitchPreference_switchTextOn
 * @attr ref android.R.styleable#SwitchPreference_disableDependentsState
 */
public class SwitchPreference extends TwoStatePreference
{
	private final Listener mListener = new Listener();

	private CharSequence mSwitchOn;
	private CharSequence mSwitchOff;

	private class Listener implements CompoundButton.OnCheckedChangeListener {
		@Override
		public void onCheckedChanged (CompoundButton buttonView, boolean isChecked) {
			if (!callChangeListener(isChecked)) {
				buttonView.setChecked(!isChecked);
				return;
			}
			SwitchPreference.this.setChecked(isChecked);
		}
	}

	/**
	 * Construct a new SwitchPreference with the given style options.
	 *
	 * @param context      The Context that will style this preference
	 * @param attrs        Style attributes that differ from the default
	 * @param defStyleAttr An attribute in the current theme that contains a
	 *                     reference to a style resource that supplies default values for
	 *                     the view. Can be 0 to not look for defaults.
	 * @param defStyleRes  A resource identifier of a style resource that
	 *                     supplies default values for the view, used only if
	 *                     defStyleAttr is 0 or can not be found in the theme. Can be 0
	 *                     to not look for defaults.
	 */
	public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		super(context, attrs, defStyleAttr, defStyleRes);
	}

	/**
	 * Construct a new SwitchPreference with the given style options.
	 *
	 * @param context      The Context that will style this preference
	 * @param attrs        Style attributes that differ from the default
	 * @param defStyleAttr An attribute in the current theme that contains a
	 *                     reference to a style resource that supplies default values for
	 *                     the view. Can be 0 to not look for defaults.
	 */
	public SwitchPreference(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}

	/**
	 * Construct a new SwitchPreference with the given style options.
	 *
	 * @param context The Context that will style this preference
	 * @param attrs   Style attributes that differ from the default
	 */
	public SwitchPreference(Context context,AttributeSet attrs) {
		this(context, attrs, R.attr.switchPreferenceStyle);
	}

	/**
	 * Construct a new SwitchPreference with default style options.
	 *
	 * @param context The Context that will style this preference
	 */
	public SwitchPreference(Context context) {
		this(context, null);
	}

	@Override
	protected void init(final Context context,final AttributeSet attrs,final int defStyleAttr,final int defStyleRes) {
		super.init(context,attrs,defStyleAttr,defStyleRes);
		this.setWidgetLayoutResource(R.layout.custom_preference_widget_switch);

		TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SwitchPreference, defStyleAttr, defStyleRes);
		setSummaryOn(a.getString(R.styleable.SwitchPreference_summaryOn));
		setSummaryOff(a.getString(R.styleable.SwitchPreference_summaryOff));
		setSwitchTextOn(a.getString(R.styleable.SwitchPreference_switchTextOn));
		setSwitchTextOff(a.getString(R.styleable.SwitchPreference_switchTextOff));
		setDisableDependentsState(a.getBoolean(R.styleable.SwitchPreference_disableDependentsState, false));
		a.recycle();
	}

	@Override
	protected void onBindView(View view) {
		super.onBindView(view);
		View checkableView = view.findViewById(android.R.id.checkbox);
		if (checkableView != null && checkableView instanceof Checkable) {
			if (checkableView instanceof SwitchCompat) {
				final SwitchCompat switchView = (SwitchCompat) checkableView;
				switchView.setOnCheckedChangeListener(null);
			}

			((Checkable) checkableView).setChecked(mChecked);

			if (checkableView instanceof SwitchCompat) {
				final SwitchCompat switchView = (SwitchCompat) checkableView;
				switchView.setTextOn(mSwitchOn);
				switchView.setTextOff(mSwitchOff);
				switchView.setOnCheckedChangeListener(mListener);
			}
		}

		syncSummaryView(view);
	}

	/**
	 * Set the text displayed on the switch widget in the on state.
	 * This should be a very short string; one word if possible.
	 *
	 * @param onText Text to display in the on state
	 */
	public void setSwitchTextOn(CharSequence onText) {
		mSwitchOn = onText;
		notifyChanged();
	}

	/**
	 * Set the text displayed on the switch widget in the off state.
	 * This should be a very short string; one word if possible.
	 *
	 * @param offText Text to display in the off state
	 */
	public void setSwitchTextOff(CharSequence offText) {
		mSwitchOff = offText;
		notifyChanged();
	}

	/**
	 * Set the text displayed on the switch widget in the on state.
	 * This should be a very short string; one word if possible.
	 *
	 * @param resId The text as a string resource ID
	 */
	public void setSwitchTextOn(int resId) {
		setSwitchTextOn(getContext().getString(resId));
	}

	/**
	 * Set the text displayed on the switch widget in the off state.
	 * This should be a very short string; one word if possible.
	 *
	 * @param resId The text as a string resource ID
	 */
	public void setSwitchTextOff(int resId) {
		setSwitchTextOff(getContext().getString(resId));
	}

	/**
	 * @return The text that will be displayed on the switch widget in the on state
	 */
	public CharSequence getSwitchTextOn() {
		return mSwitchOn;
	}

	/**
	 * @return The text that will be displayed on the switch widget in the off state
	 */
	public CharSequence getSwitchTextOff() {
		return mSwitchOff;
	}

}

================================================
FILE: app/src/main/java/moe/feng/nhentai/view/pref/TwoStatePreference.java
================================================
package moe.feng.nhentai.view.pref;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

/**
 * Common base class for preferences that have two selectable states, persist a
 * boolean value in SharedPreferences, and may have dependent preferences that are
 * enabled/disabled based on the current state.
 */
public abstract class TwoStatePreference extends Preference {
	private CharSequence mSummaryOn;
	private CharSequence mSummaryOff;
	boolean mChecked;
	private boolean mCheckedSet;
	private boolean mDisableDependentsState;

	public TwoStatePreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
		super(context, attrs, defStyleAttr, defStyleRes);
	}

	public TwoStatePreference(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
	}

	public TwoStatePreference(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public TwoStatePreference(Context context) {
		this(context, null);
	}

	@Override
	protected void onClick() {
		super.onClick();
		final boolean newValue = !isChecked();
		if (callChangeListener(newValue))  {
			setChecked(newValue);
		}
	}

	/**
	 * Sets the checked state and saves it to the {@link SharedPreferences}.
	 *
	 * @param checked The checked state.
	 */
	public void setChecked(boolean checked) {
		final boolean changed = mChecked != checked;
		if (changed || !mCheckedSet) {
			mChecked = checked;
			mCheckedSet = true;
			persistBoolean(checked);
			if (changed) {
				notifyDependencyChange(shouldDisableDependents());
				notifyChanged();
			}
		}
	}

	/**
	 * Returns the checked state.
	 *
	 * @return The checked state.
	 */
	public boolean isChecked() {
		return mChecked;
	}

	@Override
	public boolean shouldDisableDependents() {
		boolean shouldDisable = mDisableDependentsState?mChecked:!mChecked;
		return shouldDisable || super.shouldDisableDependents();
	}

	/**
	 * Sets the summary to be shown when checked.
	 *
	 * @param summary The summary to be shown when checked.
	 */
	public void setSummaryOn(CharSequence summary) {
		mSummaryOn = summary;
		if (isChecked()) {
			notifyChanged();
		}
	}

	/**
	 * @param summaryResId The summary as a resource.
	 * @see #setSummaryOn(CharSequence)
	 */
	public void setSummaryOn(int summaryResId) {
		setSummaryOn(getContext().getString(summaryResId));
	}

	/**
	 * Returns the summary to be shown when checked.
	 *
	 * @return The summary.
	 */
	public CharSequence getSummaryOn() {
		return mSummaryOn;
	}

	/**
	 * Sets the summary to be shown when unchecked.
	 *
	 * @param summary The summary to be shown when unchecked.
	 */
	public void setSummaryOff(CharSequence summary) {
		mSummaryOff = summary;
		if (!isChecked()) {
			notifyChanged();
		}
	}

	/**
	 * @param summaryResId The summary as a resource.
	 * @see #setSummaryOff(CharSequence)
	 */
	public void setSummaryOff(int summaryResId) {
		setSummaryOff(getContext().getString(summaryResId));
	}

	/**
	 * Returns the summary to be shown when unchecked.
	 *
	 * @return The summary.
	 */
	public CharSequence getSummaryOff() {
		return mSummaryOff;
	}

	/**
	 * Returns whether dependents are disabled when this preference is on ({@code true})
	 * or when this preference is off ({@code false}).
	 *
	 * @return Whether dependents are disabled when this preference is on ({@code true})
	 * or when this preference is off ({@code false}).
	 */
	public boolean getDisableDependentsState() {
		return mDisableDependentsState;
	}

	/**
	 * Sets whether dependents are disabled when this preference is on ({@code true})
	 * or wh
Download .txt
gitextract_wd0zl69i/

├── .gitignore
├── LICENSE
├── README.md
├── app/
│   ├── .gitignore
│   ├── app-release.apk
│   ├── build.gradle
│   ├── proguard-rules.pro
│   └── src/
│       └── main/
│           ├── AndroidManifest.xml
│           ├── assets/
│           │   └── licenses.html
│           ├── java/
│           │   ├── moe/
│           │   │   └── feng/
│           │   │       └── nhentai/
│           │   │           ├── api/
│           │   │           │   ├── BookApi.java
│           │   │           │   ├── PageApi.java
│           │   │           │   └── common/
│           │   │           │       └── NHentaiUrl.java
│           │   │           ├── cache/
│           │   │           │   ├── common/
│           │   │           │   │   └── Constants.java
│           │   │           │   └── file/
│           │   │           │       ├── FileCacheManager.java
│           │   │           │       └── OfflineDocumentManager.java
│           │   │           ├── dao/
│           │   │           │   ├── CommonPreferences.java
│           │   │           │   └── SearchHistoryManager.java
│           │   │           ├── model/
│           │   │           │   ├── BaseMessage.java
│           │   │           │   └── Book.java
│           │   │           ├── ui/
│           │   │           │   ├── BookDetailsActivity.java
│           │   │           │   ├── CategoryActivity.java
│           │   │           │   ├── GalleryActivity.java
│           │   │           │   ├── MainActivity.java
│           │   │           │   ├── SearchResultActivity.java
│           │   │           │   ├── SettingsActivity.java
│           │   │           │   ├── adapter/
│           │   │           │   │   ├── BookListRecyclerAdapter.java
│           │   │           │   │   ├── BookPreviewGridAdapter.java
│           │   │           │   │   ├── GalleryPagerAdapter.java
│           │   │           │   │   └── HomePagerAdapter.java
│           │   │           │   ├── common/
│           │   │           │   │   ├── AbsActivity.java
│           │   │           │   │   └── AbsRecyclerViewAdapter.java
│           │   │           │   └── fragment/
│           │   │           │       ├── BookPageFragment.java
│           │   │           │       ├── main/
│           │   │           │       │   ├── DownloadManagerFragment.java
│           │   │           │       │   ├── FavoriteFragment.java
│           │   │           │       │   └── HomeFragment.java
│           │   │           │       └── settings/
│           │   │           │           ├── SettingsLicense.java
│           │   │           │           └── SettingsMain.java
│           │   │           ├── util/
│           │   │           │   ├── AsyncTask.java
│           │   │           │   ├── ColorGenerator.java
│           │   │           │   ├── FullScreenHelper.java
│           │   │           │   ├── HttpTools.java
│           │   │           │   ├── Settings.java
│           │   │           │   ├── TextDrawable.java
│           │   │           │   └── Utility.java
│           │   │           └── view/
│           │   │               ├── AutoWrapLayout.java
│           │   │               ├── ExpandableHeightGridView.java
│           │   │               ├── WheelProgressView.java
│           │   │               └── pref/
│           │   │                   ├── Preference.java
│           │   │                   ├── SwitchPreference.java
│           │   │                   └── TwoStatePreference.java
│           │   └── sumimakito/
│           │       └── android/
│           │           └── quickkv/
│           │               ├── DataProcessor.java
│           │               ├── QKVConfig.java
│           │               ├── QKVFSReader.java
│           │               ├── QKVLogger.java
│           │               ├── QuickKV.java
│           │               ├── database/
│           │               │   ├── KeyValueDatabase.java
│           │               │   └── QKVDatabase.java
│           │               └── security/
│           │                   └── AES256.java
│           └── res/
│               ├── color/
│               │   └── drawer_item_color.xml
│               ├── drawable/
│               │   ├── shadow_gradient.xml
│               │   ├── shadow_gradient_reserve.xml
│               │   ├── shadow_normal.xml
│               │   └── shadow_normal_reserve.xml
│               ├── layout/
│               │   ├── activity_book_details.xml
│               │   ├── activity_gallery.xml
│               │   ├── activity_main.xml
│               │   ├── activity_search_result.xml
│               │   ├── activity_settings.xml
│               │   ├── custom_preference.xml
│               │   ├── custom_preference_widget_switch.xml
│               │   ├── fragment_book_page.xml
│               │   ├── fragment_download.xml
│               │   ├── fragment_favorite.xml
│               │   ├── fragment_home.xml
│               │   ├── list_item_book_card.xml
│               │   ├── list_item_book_picture_thumb.xml
│               │   ├── list_item_menu_row.xml
│               │   └── navigation_header.xml
│               ├── menu/
│               │   ├── menu_main.xml
│               │   └── navigation_menu.xml
│               ├── values/
│               │   ├── attrs.xml
│               │   ├── color.xml
│               │   ├── dimen.xml
│               │   ├── strings.xml
│               │   └── styles.xml
│               ├── values-v21/
│               │   └── styles.xml
│               ├── values-zh-rCN/
│               │   └── strings.xml
│               ├── values-zh-rTW/
│               │   └── strings.xml
│               └── xml/
│                   └── settings_main.xml
├── build.gradle
├── gradle/
│   └── wrapper/
│       ├── gradle-wrapper.jar
│       └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── libraries/
│   └── PersistentSearch/
│       ├── .gitignore
│       ├── build.gradle
│       ├── gradle.properties
│       ├── proguard-rules.pro
│       └── src/
│           └── main/
│               ├── AndroidManifest.xml
│               ├── java/
│               │   ├── com/
│               │   │   ├── balysv/
│               │   │   │   └── materialmenu/
│               │   │   │       ├── MaterialMenu.java
│               │   │   │       ├── MaterialMenuDrawable.java
│               │   │   │       └── MaterialMenuView.java
│               │   │   └── quinny898/
│               │   │       └── library/
│               │   │           └── persistentsearch/
│               │   │               ├── SearchBox.java
│               │   │               └── SearchResult.java
│               │   └── io/
│               │       └── codetail/
│               │           ├── animation/
│               │           │   ├── RevealAnimator.java
│               │           │   ├── ReverseInterpolator.java
│               │           │   ├── SupportAnimator.java
│               │           │   ├── SupportAnimatorLollipop.java
│               │           │   ├── SupportAnimatorPreL.java
│               │           │   └── ViewAnimationUtils.java
│               │           └── widget/
│               │               ├── RevealFrameLayout.java
│               │               └── RevealLinearLayout.java
│               └── res/
│                   ├── anim/
│                   │   └── anim_down.xml
│                   ├── layout/
│                   │   ├── search_option.xml
│                   │   └── searchbox.xml
│                   └── values/
│                       ├── strings.xml
│                       └── styles.xml
└── settings.gradle
Download .txt
SYMBOL INDEX (755 symbols across 62 files)

FILE: app/src/main/java/moe/feng/nhentai/api/BookApi.java
  class BookApi (line 23) | public class BookApi {
    method getBook (line 27) | public static BaseMessage getBook(String id) {
    method getCover (line 154) | public static Bitmap getCover(Context context, Book book) {
    method getThumb (line 165) | public static Bitmap getThumb(Context context, Book book) {
    method getPageThumb (line 176) | public static Bitmap getPageThumb(Context context, Book book, int posi...
    method getCoverFile (line 187) | public static File getCoverFile(Context context, Book book) {
    method getThumbFile (line 198) | public static File getThumbFile(Context context, Book book) {
    method getPageThumbFile (line 209) | public static File getPageThumbFile(Context context, Book book, int po...

FILE: app/src/main/java/moe/feng/nhentai/api/PageApi.java
  class PageApi (line 23) | public class PageApi {
    method getPageList (line 27) | public static BaseMessage getPageList(String url) {
    method getHomePageList (line 85) | public static BaseMessage getHomePageList(int number) {
    method getSearchPageList (line 89) | public static BaseMessage getSearchPageList(String keyword, int number) {
    method getPageOriginImage (line 93) | public static Bitmap getPageOriginImage(Context context, Book book, in...
    method getPageOriginImageFile (line 104) | public static File getPageOriginImageFile(Context context, Book book, ...

FILE: app/src/main/java/moe/feng/nhentai/api/common/NHentaiUrl.java
  class NHentaiUrl (line 3) | public class NHentaiUrl {
    method getSearchUrl (line 8) | public static String getSearchUrl(String content) {
    method getSearchUrl (line 12) | public static String getSearchUrl(String content, int page_num) {
    method getBookDetailsUrl (line 20) | public static String getBookDetailsUrl(String book_id) {
    method getBookPageUrl (line 24) | public static String getBookPageUrl(String book_id, int page_num) {
    method getGalleryUrl (line 28) | public static String getGalleryUrl(String g_id) {
    method getOriginPictureUrl (line 32) | public static String getOriginPictureUrl(String g_id, String page_num) {
    method getThumbPictureUrl (line 36) | public static String getThumbPictureUrl(String g_id, String page_num) {
    method getThumbUrl (line 40) | public static String getThumbUrl(String g_id) {
    method getBigCoverUrl (line 44) | public static String getBigCoverUrl(String g_id) {
    method getPictureUrl (line 49) | public static String getPictureUrl(String g_id, String page_num, Strin...
    method getParodyUrl (line 53) | public static String getParodyUrl(String name) {
    method getCharacterUrl (line 61) | public static String getCharacterUrl(String name) {
    method getTagUrl (line 69) | public static String getTagUrl(String tag) {
    method getArtistUrl (line 77) | public static String getArtistUrl(String name) {
    method getGroupUrl (line 85) | public static String getGroupUrl(String name) {
    method getLanguageUrl (line 93) | public static String getLanguageUrl(String name) {
    method getHomePageUrl (line 101) | public static String getHomePageUrl(int page) {

FILE: app/src/main/java/moe/feng/nhentai/cache/common/Constants.java
  class Constants (line 3) | public class Constants {

FILE: app/src/main/java/moe/feng/nhentai/cache/file/FileCacheManager.java
  class FileCacheManager (line 20) | public class FileCacheManager {
    method getInstance (line 28) | public static final FileCacheManager getInstance(Context context) {
    method FileCacheManager (line 36) | private FileCacheManager(Context context) {
    method createCacheFromNetwork (line 40) | public boolean createCacheFromNetwork(String type, String url) {
    method createCacheFromStrem (line 92) | public boolean createCacheFromStrem(String type, String name, InputStr...
    method cacheExistsUrl (line 139) | public boolean cacheExistsUrl(String type, String url) {
    method cacheExists (line 143) | public boolean cacheExists(String type, String name) {
    method deleteCacheUrl (line 147) | public boolean deleteCacheUrl(String type, String url) {
    method deleteCache (line 151) | public boolean deleteCache(String type, String name) {
    method openCacheStream (line 159) | public InputStream openCacheStream(String type, String name) {
    method openCacheStreamUrl (line 167) | public InputStream openCacheStreamUrl(String type, String url) {
    method getBitmap (line 171) | public Bitmap getBitmap(String type, String name) {
    method getBitmapUrl (line 187) | public Bitmap getBitmapUrl(String type, String url) {
    method getBitmapFile (line 191) | public File getBitmapFile(String type, String name) {
    method getBitmapUrlFile (line 195) | public File getBitmapUrlFile(String type, String url) {
    method getCacheName (line 199) | private String getCacheName(String url) {
    method getCachePath (line 203) | private String getCachePath(String type, String name) {

FILE: app/src/main/java/moe/feng/nhentai/cache/file/OfflineDocumentManager.java
  class OfflineDocumentManager (line 11) | public class OfflineDocumentManager {
    method getInstance (line 17) | public static OfflineDocumentManager getInstance(Context context) {
    method OfflineDocumentManager (line 25) | private OfflineDocumentManager(Context context) {
    method getOfflineDocument (line 29) | public String getOfflineDocument(String url) {
    method hasOfflineCache (line 49) | public boolean hasOfflineCache(String url) {
    method createOfflineCache (line 53) | public boolean createOfflineCache(String url) {

FILE: app/src/main/java/moe/feng/nhentai/dao/CommonPreferences.java
  class CommonPreferences (line 10) | public class CommonPreferences {
    method getInstance (line 18) | public static CommonPreferences getInstance(Context context, String db...
    method CommonPreferences (line 33) | private CommonPreferences(Context context, String dbName) {
    method sync (line 39) | public void sync() {
    method reload (line 43) | public void reload() {
    method edit (line 47) | public Editor edit() {
    method getInt (line 51) | public int getInt(String key, int defValue) {
    method getString (line 55) | public String getString(String key, String defValue) {
    method getBoolean (line 59) | public boolean getBoolean(String key, boolean defValue) {
    method getLong (line 63) | public long getLong(String key, long defValue) {
    method getFloat (line 67) | public float getFloat(String key, float defValue) {
    method contains (line 71) | public boolean contains(String key) {
    class Editor (line 75) | public class Editor {
      method Editor (line 79) | private Editor(KeyValueDatabase kvdb) {
      method putBoolean (line 83) | public Editor putBoolean(String key, boolean value) {
      method putInt (line 88) | public Editor putInt(String key, int value) {
      method putString (line 93) | public Editor putString(String key, String value) {
      method putLong (line 98) | public Editor putLong(String key, long value) {
      method putFloat (line 103) | public Editor putFloat(String key, float value) {
      method remove (line 108) | public Editor remove(String key){
      method clear (line 113) | public void clear() {
      method commit (line 118) | public boolean commit() {
    class Instance (line 124) | private static class Instance {
      method Instance (line 129) | public Instance(CommonPreferences preferences, String dbName) {

FILE: app/src/main/java/moe/feng/nhentai/dao/SearchHistoryManager.java
  class SearchHistoryManager (line 13) | public class SearchHistoryManager {
    method getInstance (line 23) | public static SearchHistoryManager getInstance(Context context, String...
    method SearchHistoryManager (line 38) | public SearchHistoryManager(Context context, String sectionName) {
    method reloadDatabase (line 44) | public void reloadDatabase() {
    method add (line 48) | public void add(String keyword) {
    method get (line 58) | public String get(int pos) {
    method find (line 62) | public int find(String keyword) {
    method moveArrayToNext (line 73) | private void moveArrayToNext(int end) {
    method cleanAll (line 81) | public void cleanAll() {
    method getAll (line 86) | public String[] getAll() {
    method getSearchResults (line 94) | public ArrayList<SearchResult> getSearchResults() {
    class Instance (line 103) | private static class Instance {
      method Instance (line 108) | public Instance(SearchHistoryManager manager, String sectionName) {

FILE: app/src/main/java/moe/feng/nhentai/model/BaseMessage.java
  class BaseMessage (line 3) | public class BaseMessage {
    method BaseMessage (line 8) | public BaseMessage(int code, Object data) {
    method BaseMessage (line 13) | public BaseMessage() {
    method getCode (line 17) | public int getCode() {
    method setCode (line 21) | public void setCode(int code) {
    method getData (line 25) | public <T> T getData() {
    method setData (line 29) | public void setData(Object data) {

FILE: app/src/main/java/moe/feng/nhentai/model/Book.java
  class Book (line 7) | public class Book {
    method Book (line 24) | public Book() {
    method Book (line 28) | public Book(String title, String other, String bookId) {
    method Book (line 34) | public Book(String title, String other, String bookId, String previewI...
    method toJSONString (line 41) | public String toJSONString() {

FILE: app/src/main/java/moe/feng/nhentai/ui/BookDetailsActivity.java
  class BookDetailsActivity (line 42) | public class BookDetailsActivity extends AppCompatActivity {
    method onCreate (line 57) | @Override
    method launch (line 126) | public static void launch(Activity activity, ImageView imageView, Book...
    method updateUIContent (line 135) | private void updateUIContent() {
    method updateDetailsContent (line 151) | private void updateDetailsContent() {
    method updateTagsContent (line 160) | private void updateTagsContent() {
    method onOptionsItemSelected (line 386) | @Override
    method startBookGet (line 396) | private void startBookGet() {
    class BookGetTask (line 404) | private class BookGetTask extends AsyncTask<String, Void, BaseMessage> {
      method doInBackground (line 406) | @Override
      method onPostExecute (line 411) | @Override
    class CoverTask (line 436) | private class CoverTask extends AsyncTask<Book, Void, File> {
      method doInBackground (line 438) | @Override
      method onPostExecute (line 443) | @Override
    method $ (line 461) | protected <T extends View> T $(int id) {

FILE: app/src/main/java/moe/feng/nhentai/ui/CategoryActivity.java
  class CategoryActivity (line 23) | public class CategoryActivity extends AbsActivity {
    method onCreate (line 40) | @Override
    method setUpViews (line 60) | @Override
    method setRecyclerViewAdapter (line 93) | private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
    class PageGetTask (line 114) | private class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {
      method doInBackground (line 116) | @Override
      method onPostExecute (line 121) | @Override
    method launch (line 143) | public static void launch(AppCompatActivity activity, String url, Stri...

FILE: app/src/main/java/moe/feng/nhentai/ui/GalleryActivity.java
  class GalleryActivity (line 20) | public class GalleryActivity extends AbsActivity {
    method onCreate (line 33) | @Override
    method setUpViews (line 54) | @Override
    method launch (line 66) | public static void launch(Activity activity, Book book, int firstPageN...
    method toggleControlBar (line 74) | public void toggleControlBar() {
    method onBackPressed (line 84) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/MainActivity.java
  class MainActivity (line 23) | public class MainActivity extends AbsActivity implements NavigationView....
    method onCreate (line 35) | @Override
    method setUpViews (line 50) | @Override
    method openSearchBox (line 141) | private void openSearchBox() {
    method closeSearchBox (line 149) | private void closeSearchBox() {
    method onPostCreate (line 165) | @Override
    method onConfigurationChanged (line 171) | @Override
    method onCreateOptionsMenu (line 177) | @Override
    method onOptionsItemSelected (line 183) | @Override
    method onBackPressed (line 202) | @Override
    method onNavigationItemSelected (line 211) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/SearchResultActivity.java
  class SearchResultActivity (line 23) | public class SearchResultActivity extends AbsActivity {
    method onCreate (line 40) | @Override
    method setUpViews (line 59) | @Override
    method setRecyclerViewAdapter (line 92) | private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
    class PageGetTask (line 113) | private class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {
      method doInBackground (line 115) | @Override
      method onPostExecute (line 120) | @Override
    method launch (line 142) | public static void launch(AppCompatActivity activity, String keyword) {

FILE: app/src/main/java/moe/feng/nhentai/ui/SettingsActivity.java
  class SettingsActivity (line 14) | public class SettingsActivity extends AbsActivity {
    method onCreate (line 22) | @Override
    method setUpViews (line 34) | @Override
    method launchActivity (line 52) | public static void launchActivity(Activity mActivity, int flag) {

FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/BookListRecyclerAdapter.java
  class BookListRecyclerAdapter (line 27) | public class BookListRecyclerAdapter extends AbsRecyclerViewAdapter {
    method BookListRecyclerAdapter (line 35) | public BookListRecyclerAdapter(RecyclerView recyclerView, ArrayList<Bo...
    method onCreateViewHolder (line 41) | @Override
    method onBindViewHolder (line 48) | @Override
    method getItemCount (line 96) | @Override
    class ImageDownloader (line 101) | private class ImageDownloader extends AsyncTask<Object, Object, Void> {
      method doInBackground (line 103) | @Override
      method onProgressUpdate (line 122) | @Override
    class ViewHolder (line 143) | public class ViewHolder extends ClickableViewHolder {
      method ViewHolder (line 150) | public ViewHolder(View itemView) {

FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/BookPreviewGridAdapter.java
  class BookPreviewGridAdapter (line 18) | public class BookPreviewGridAdapter extends BaseAdapter {
    method BookPreviewGridAdapter (line 23) | public BookPreviewGridAdapter(Context context, Book book) {
    method getCount (line 29) | @Override
    method getItem (line 34) | @Override
    method getItemId (line 39) | @Override
    method getView (line 44) | @Override
    class ViewHolder (line 64) | private class ViewHolder {
      method ViewHolder (line 70) | public ViewHolder(View itemView) {
    class ImageDownloader (line 78) | private class ImageDownloader extends AsyncTask<Object, Object, Void> {
      method doInBackground (line 80) | @Override
      method onProgressUpdate (line 98) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/GalleryPagerAdapter.java
  class GalleryPagerAdapter (line 10) | public class GalleryPagerAdapter extends FragmentPagerAdapter {
    method GalleryPagerAdapter (line 15) | public GalleryPagerAdapter(FragmentManager fm, Book book) {
    method getItem (line 21) | @Override
    method getCount (line 29) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/adapter/HomePagerAdapter.java
  class HomePagerAdapter (line 13) | public class HomePagerAdapter extends FragmentPagerAdapter {
    method HomePagerAdapter (line 21) | public HomePagerAdapter(Context context, FragmentManager fm) {
    method getItem (line 29) | @Override
    method getCount (line 43) | @Override
    method getPageTitle (line 48) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/common/AbsActivity.java
  class AbsActivity (line 17) | public abstract class AbsActivity extends AppCompatActivity {
    method onCreate (line 24) | @Override
    method onCreate (line 29) | protected void onCreate(Bundle savedInstanceState, boolean statusBarTr...
    method setUpViews (line 46) | protected abstract void setUpViews();
    method setContentView (line 48) | @Override
    method onOptionsItemSelected (line 70) | @Override
    method $ (line 80) | protected <T extends View> T $(int id) {

FILE: app/src/main/java/moe/feng/nhentai/ui/common/AbsRecyclerViewAdapter.java
  class AbsRecyclerViewAdapter (line 10) | public abstract class AbsRecyclerViewAdapter extends RecyclerView.Adapte...
    method AbsRecyclerViewAdapter (line 17) | public AbsRecyclerViewAdapter(RecyclerView recyclerView) {
    method addOnScrollListener (line 36) | public void addOnScrollListener(RecyclerView.OnScrollListener listener) {
    type OnItemClickListener (line 40) | public interface OnItemClickListener {
      method onItemClick (line 41) | public void onItemClick(int position, ClickableViewHolder holder);
    type OnItemLongClickListener (line 44) | public interface OnItemLongClickListener {
      method onItemLongClick (line 45) | public boolean onItemLongClick(int position, ClickableViewHolder hol...
    method setOnItemClickListener (line 51) | public void setOnItemClickListener(OnItemClickListener listener) {
    method setOnItemLongClickListener (line 55) | public void setOnItemLongClickListener(OnItemLongClickListener listene...
    method bindContext (line 59) | public void bindContext(Context context) {
    method getContext (line 63) | public Context getContext() {
    method onBindViewHolder (line 67) | @Override
    class ClickableViewHolder (line 89) | public class ClickableViewHolder extends RecyclerView.ViewHolder {
      method ClickableViewHolder (line 93) | public ClickableViewHolder(View itemView) {
      method getParentView (line 98) | public View getParentView() {

FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/BookPageFragment.java
  class BookPageFragment (line 27) | public class BookPageFragment extends Fragment {
    method newInstance (line 38) | public static BookPageFragment newInstance(Book book, int pageNum) {
    method onCreate (line 47) | @Override
    method onCreateView (line 55) | @Override
    class DownloadTask (line 66) | private class DownloadTask extends AsyncTask<Void, Void, File> {
      method doInBackground (line 68) | @Override
      method onPostExecute (line 73) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/main/DownloadManagerFragment.java
  class DownloadManagerFragment (line 20) | public class DownloadManagerFragment extends Fragment {
    method onCreateView (line 27) | @Override
    method setRecyclerViewAdapter (line 54) | private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {

FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/main/FavoriteFragment.java
  class FavoriteFragment (line 20) | public class FavoriteFragment extends Fragment {
    method onCreateView (line 27) | @Override
    method setRecyclerViewAdapter (line 54) | private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {

FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/main/HomeFragment.java
  class HomeFragment (line 25) | public class HomeFragment extends Fragment {
    method onCreateView (line 39) | @Override
    method setRecyclerViewAdapter (line 76) | private void setRecyclerViewAdapter(BookListRecyclerAdapter adapter) {
    class PageGetTask (line 99) | private class PageGetTask extends AsyncTask<Integer, Void, BaseMessage> {
      method doInBackground (line 101) | @Override
      method onPostExecute (line 106) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsLicense.java
  class SettingsLicense (line 12) | public class SettingsLicense extends Fragment {
    method onCreateView (line 14) | @Override

FILE: app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsMain.java
  class SettingsMain (line 12) | public class SettingsMain extends PreferenceFragment implements Preferen...
    method onCreate (line 20) | @Override
    method onPreferenceClick (line 46) | @Override
    method openWebUrl (line 66) | private void openWebUrl(String url) {

FILE: app/src/main/java/moe/feng/nhentai/util/AsyncTask.java
  class AsyncTask (line 14) | public abstract class AsyncTask<Params, Progress, Result>
    class AsyncResult (line 18) | private static class AsyncResult<Data> {
      method AsyncResult (line 22) | public AsyncResult(AsyncTask task, Data... data) {
    method handleMessage (line 32) | @SuppressWarnings({"unchecked", "RawUseOfParameterizedType"})
    method run (line 50) | @Override
    method onPostExecute (line 69) | protected void onPostExecute(Result result) {}
    method doInBackground (line 71) | protected abstract Result doInBackground(Params... params);
    method onPreExecute (line 73) | protected void onPreExecute() {}
    method onProgressUpdate (line 75) | protected void onProgressUpdate(Progress... progress) {}
    method publishProgress (line 77) | protected void publishProgress(Progress... progress) {
    method execute (line 81) | public void execute(Params... params) {

FILE: app/src/main/java/moe/feng/nhentai/util/ColorGenerator.java
  class ColorGenerator (line 11) | public class ColorGenerator {
    method create (line 53) | public static ColorGenerator create(List<Integer> colorList) {
    method ColorGenerator (line 57) | private ColorGenerator(List<Integer> colorList) {
    method getRandomColor (line 62) | public int getRandomColor() {
    method getColor (line 66) | public int getColor(Object key) {

FILE: app/src/main/java/moe/feng/nhentai/util/FullScreenHelper.java
  class FullScreenHelper (line 11) | @SuppressLint("InlinedApi")
    type OnFullScreenBrokenListener (line 51) | public interface OnFullScreenBrokenListener {
      method onFullScreenBroken (line 59) | public void onFullScreenBroken(boolean fullScreen);
    method FullScreenHelper (line 63) | public FullScreenHelper(Activity activity) {
    method willHideNavBar (line 85) | public boolean willHideNavBar() {
    method onSystemUiVisibilityChange (line 92) | @Override
    method setOnFullScreenBrokenListener (line 105) | public void setOnFullScreenBrokenListener(OnFullScreenBrokenListener l) {
    method getFullScreen (line 109) | public boolean getFullScreen() {
    method setFullScreen (line 113) | public void setFullScreen(boolean fullScreen) {

FILE: app/src/main/java/moe/feng/nhentai/util/HttpTools.java
  class HttpTools (line 8) | public class HttpTools {
    method openConnection (line 10) | public static HttpURLConnection openConnection(String url) throws IOEx...
    method getTargetContentSize (line 22) | public static long getTargetContentSize(String url) throws IOException {

FILE: app/src/main/java/moe/feng/nhentai/util/Settings.java
  class Settings (line 7) | public class Settings {
    method getInstance (line 15) | public static Settings getInstance(Context context) {
    method Settings (line 22) | private Settings(Context context) {
    method putBoolean (line 26) | public Settings putBoolean(String key, boolean value) {
    method getBoolean (line 31) | public boolean getBoolean(String key, boolean def) {
    method putInt (line 35) | public Settings putInt(String key, int value) {
    method getInt (line 40) | public int getInt(String key, int defValue) {
    method putString (line 45) | public Settings putString(String key, String value) {
    method getString (line 50) | public String getString(String key, String defValue) {

FILE: app/src/main/java/moe/feng/nhentai/util/TextDrawable.java
  class TextDrawable (line 13) | public class TextDrawable extends ShapeDrawable {
    method TextDrawable (line 27) | private TextDrawable(Builder builder) {
    method getDarkerShade (line 64) | private int getDarkerShade(int color) {
    method draw (line 70) | @Override
    method drawBorder (line 95) | private void drawBorder(Canvas canvas) {
    method setAlpha (line 110) | @Override
    method setColorFilter (line 115) | @Override
    method getOpacity (line 120) | @Override
    method getIntrinsicWidth (line 125) | @Override
    method getIntrinsicHeight (line 130) | @Override
    method builder (line 135) | public static IShapeBuilder builder() {
    class Builder (line 139) | public static class Builder implements IConfigBuilder, IShapeBuilder, ...
      method Builder (line 165) | private Builder() {
      method width (line 179) | public IConfigBuilder width(int width) {
      method height (line 184) | public IConfigBuilder height(int height) {
      method textColor (line 189) | public IConfigBuilder textColor(int color) {
      method withBorder (line 194) | public IConfigBuilder withBorder(int thickness) {
      method useFont (line 199) | public IConfigBuilder useFont(Typeface font) {
      method fontSize (line 204) | public IConfigBuilder fontSize(int size) {
      method bold (line 209) | public IConfigBuilder bold() {
      method toUpperCase (line 214) | public IConfigBuilder toUpperCase() {
      method beginConfig (line 219) | @Override
      method endConfig (line 224) | @Override
      method rect (line 229) | @Override
      method round (line 235) | @Override
      method roundRect (line 241) | @Override
      method buildRect (line 249) | @Override
      method buildRoundRect (line 255) | @Override
      method buildRound (line 261) | @Override
      method build (line 267) | @Override
    type IConfigBuilder (line 275) | public interface IConfigBuilder {
      method width (line 276) | public IConfigBuilder width(int width);
      method height (line 278) | public IConfigBuilder height(int height);
      method textColor (line 280) | public IConfigBuilder textColor(int color);
      method withBorder (line 282) | public IConfigBuilder withBorder(int thickness);
      method useFont (line 284) | public IConfigBuilder useFont(Typeface font);
      method fontSize (line 286) | public IConfigBuilder fontSize(int size);
      method bold (line 288) | public IConfigBuilder bold();
      method toUpperCase (line 290) | public IConfigBuilder toUpperCase();
      method endConfig (line 292) | public IShapeBuilder endConfig();
    type IBuilder (line 295) | public static interface IBuilder {
      method build (line 297) | public TextDrawable build(String text, int color);
    type IShapeBuilder (line 300) | public static interface IShapeBuilder {
      method beginConfig (line 302) | public IConfigBuilder beginConfig();
      method rect (line 304) | public IBuilder rect();
      method round (line 306) | public IBuilder round();
      method roundRect (line 308) | public IBuilder roundRect(int radius);
      method buildRect (line 310) | public TextDrawable buildRect(String text, int color);
      method buildRoundRect (line 312) | public TextDrawable buildRoundRect(String text, int color, int radius);
      method buildRound (line 314) | public TextDrawable buildRound(String text, int color);

FILE: app/src/main/java/moe/feng/nhentai/util/Utility.java
  class Utility (line 8) | public class Utility {
    method isChrome (line 10) | public static boolean isChrome() {
    method getStatusBarHeight (line 14) | public static int getStatusBarHeight(Context context) {
    method getFirstCharacter (line 23) | public static String getFirstCharacter(String sentence) {
    method getSystemProperties (line 39) | public static String getSystemProperties(String key) {

FILE: app/src/main/java/moe/feng/nhentai/view/AutoWrapLayout.java
  class AutoWrapLayout (line 22) | public class AutoWrapLayout extends ViewGroup {
    type Alignment (line 33) | public enum Alignment {
      method Alignment (line 38) | Alignment(int ni) {
    method AutoWrapLayout (line 45) | public AutoWrapLayout(Context context) {
    method AutoWrapLayout (line 48) | public AutoWrapLayout(Context context, AttributeSet attrs) {
    method AutoWrapLayout (line 51) | public AutoWrapLayout(Context context, AttributeSet attrs, int defStyl...
    method setAlignment (line 64) | public void setAlignment(Alignment baseLine) {
    method getScaleType (line 76) | public Alignment getScaleType() {
    method adjustBaseLine (line 80) | private void adjustBaseLine(int lineHeight, int startIndex, int endInd...
    method onMeasure (line 104) | @SuppressLint("DrawAllocation")
    method onLayout (line 223) | @Override
    method generateLayoutParams (line 235) | @Override
    method generateDefaultLayoutParams (line 240) | @Override
    method generateLayoutParams (line 245) | @Override
    class LayoutParams (line 250) | public static class LayoutParams extends ViewGroup.MarginLayoutParams {
      method LayoutParams (line 251) | public LayoutParams() {
      method LayoutParams (line 254) | public LayoutParams(Context c, AttributeSet attrs) {
      method LayoutParams (line 257) | public LayoutParams(int width, int height) {
      method LayoutParams (line 260) | public LayoutParams(android.view.ViewGroup.LayoutParams source) {
      method LayoutParams (line 263) | public LayoutParams(MarginLayoutParams source) {

FILE: app/src/main/java/moe/feng/nhentai/view/ExpandableHeightGridView.java
  class ExpandableHeightGridView (line 8) | public class ExpandableHeightGridView extends GridView {
    method ExpandableHeightGridView (line 12) | public ExpandableHeightGridView(Context context) {
    method ExpandableHeightGridView (line 16) | public ExpandableHeightGridView(Context context, AttributeSet attrs) {
    method ExpandableHeightGridView (line 20) | public ExpandableHeightGridView(Context context, AttributeSet attrs, i...
    method isExpanded (line 24) | public boolean isExpanded() {
    method onMeasure (line 28) | @Override
    method setExpanded (line 42) | public void setExpanded(boolean expanded) {

FILE: app/src/main/java/moe/feng/nhentai/view/WheelProgressView.java
  class WheelProgressView (line 29) | public class WheelProgressView extends View {
    method WheelProgressView (line 75) | public WheelProgressView(Context context, AttributeSet attrs) {
    method WheelProgressView (line 87) | public WheelProgressView(Context context) {
    method onMeasure (line 91) | @Override
    method onSizeChanged (line 130) | @Override
    method setupPaints (line 143) | private void setupPaints() {
    method setupBounds (line 158) | private void setupBounds(int layout_width, int layout_height) {
    method parseAttributes (line 190) | private void parseAttributes(TypedArray a) {
    method setCallback (line 222) | public void setCallback(ProgressCallback progressCallback) {
    method onDraw (line 230) | protected void onDraw(Canvas canvas) {
    method onVisibilityChanged (line 300) | @Override
    method updateBarLength (line 309) | private void updateBarLength(long deltaTimeInMilliSeconds) {
    method isSpinning (line 338) | public boolean isSpinning() {
    method resetCount (line 345) | public void resetCount() {
    method stopSpinning (line 354) | public void stopSpinning() {
    method spin (line 364) | public void spin() {
    method runCallback (line 370) | private void runCallback(float value) {
    method runCallback (line 376) | private void runCallback() {
    method setProgress (line 389) | public void setProgress(float progress) {
    method setInstantProgress (line 422) | public void setInstantProgress(float progress) {
    method onSaveInstanceState (line 444) | @Override
    method onRestoreInstanceState (line 465) | @Override
    method getProgress (line 494) | public float getProgress() {
    method setLinearProgress (line 503) | public void setLinearProgress(boolean isLinear) {
    method getCircleRadius (line 513) | public int getCircleRadius() {
    method setCircleRadius (line 522) | public void setCircleRadius(int circleRadius) {
    method getBarWidth (line 532) | public int getBarWidth() {
    method setBarWidth (line 541) | public void setBarWidth(int barWidth) {
    method getBarColor (line 551) | public int getBarColor() {
    method setBarColor (line 560) | public void setBarColor(int barColor) {
    method getRimColor (line 571) | public int getRimColor() {
    method setRimColor (line 580) | public void setRimColor(int rimColor) {
    method getSpinSpeed (line 593) | public float getSpinSpeed() {
    method setSpinSpeed (line 604) | public void setSpinSpeed(float spinSpeed) {
    method getRimWidth (line 611) | public int getRimWidth() {
    method setRimWidth (line 620) | public void setRimWidth(int rimWidth) {
    class WheelSavedState (line 627) | static class WheelSavedState extends BaseSavedState {
      method WheelSavedState (line 640) | WheelSavedState(Parcelable superState) {
      method WheelSavedState (line 644) | private WheelSavedState(Parcel in) {
      method writeToParcel (line 659) | @Override
      method createFromParcel (line 677) | public WheelSavedState createFromParcel(Parcel in) {
      method newArray (line 681) | public WheelSavedState[] newArray(int size) {
    type ProgressCallback (line 687) | public interface ProgressCallback {
      method onProgressUpdate (line 698) | public void onProgressUpdate(float progress);

FILE: app/src/main/java/moe/feng/nhentai/view/pref/Preference.java
  class Preference (line 10) | public class Preference extends android.preference.Preference {
    method init (line 14) | protected void init(Context context, AttributeSet attrs, int defStyleA...
    method Preference (line 18) | @TargetApi(VERSION_CODES.LOLLIPOP)
    method Preference (line 27) | public Preference(Context context, AttributeSet attrs, int defStyleAtt...
    method Preference (line 35) | public Preference(Context context, AttributeSet attrs) {
    method Preference (line 43) | public Preference(Context context) {

FILE: app/src/main/java/moe/feng/nhentai/view/pref/SwitchPreference.java
  class SwitchPreference (line 24) | public class SwitchPreference extends TwoStatePreference
    class Listener (line 31) | private class Listener implements CompoundButton.OnCheckedChangeListen...
      method onCheckedChanged (line 32) | @Override
    method SwitchPreference (line 55) | public SwitchPreference(Context context, AttributeSet attrs, int defSt...
    method SwitchPreference (line 68) | public SwitchPreference(Context context, AttributeSet attrs, int defSt...
    method SwitchPreference (line 78) | public SwitchPreference(Context context,AttributeSet attrs) {
    method SwitchPreference (line 87) | public SwitchPreference(Context context) {
    method init (line 91) | @Override
    method onBindView (line 105) | @Override
    method setSwitchTextOn (line 134) | public void setSwitchTextOn(CharSequence onText) {
    method setSwitchTextOff (line 145) | public void setSwitchTextOff(CharSequence offText) {
    method setSwitchTextOn (line 156) | public void setSwitchTextOn(int resId) {
    method setSwitchTextOff (line 166) | public void setSwitchTextOff(int resId) {
    method getSwitchTextOn (line 173) | public CharSequence getSwitchTextOn() {
    method getSwitchTextOff (line 180) | public CharSequence getSwitchTextOff() {

FILE: app/src/main/java/moe/feng/nhentai/view/pref/TwoStatePreference.java
  class TwoStatePreference (line 18) | public abstract class TwoStatePreference extends Preference {
    method TwoStatePreference (line 25) | public TwoStatePreference(Context context, AttributeSet attrs, int def...
    method TwoStatePreference (line 29) | public TwoStatePreference(Context context, AttributeSet attrs, int def...
    method TwoStatePreference (line 33) | public TwoStatePreference(Context context, AttributeSet attrs) {
    method TwoStatePreference (line 37) | public TwoStatePreference(Context context) {
    method onClick (line 41) | @Override
    method setChecked (line 55) | public void setChecked(boolean checked) {
    method isChecked (line 73) | public boolean isChecked() {
    method shouldDisableDependents (line 77) | @Override
    method setSummaryOn (line 88) | public void setSummaryOn(CharSequence summary) {
    method setSummaryOn (line 99) | public void setSummaryOn(int summaryResId) {
    method getSummaryOn (line 108) | public CharSequence getSummaryOn() {
    method setSummaryOff (line 117) | public void setSummaryOff(CharSequence summary) {
    method setSummaryOff (line 128) | public void setSummaryOff(int summaryResId) {
    method getSummaryOff (line 137) | public CharSequence getSummaryOff() {
    method getDisableDependentsState (line 148) | public boolean getDisableDependentsState() {
    method setDisableDependentsState (line 158) | public void setDisableDependentsState(boolean disableDependentsState) {
    method onGetDefaultValue (line 162) | @Override
    method onSetInitialValue (line 167) | @Override
    method syncSummaryView (line 177) | void syncSummaryView(View view) {
    method onSaveInstanceState (line 208) | @Override
    method onRestoreInstanceState (line 220) | @Override
    class SavedState (line 232) | static class SavedState extends BaseSavedState {
      method SavedState (line 236) | public SavedState(Parcel source) {
      method writeToParcel (line 241) | @Override
      method SavedState (line 247) | public SavedState(Parcelable superState) {
      method createFromParcel (line 252) | public SavedState createFromParcel(Parcel in) {
      method newArray (line 256) | public SavedState[] newArray(int size) {

FILE: app/src/main/java/sumimakito/android/quickkv/DataProcessor.java
  class DataProcessor (line 15) | public class DataProcessor
    class Persistable (line 17) | public static class Persistable
      method dePrefix (line 19) | public static Object dePrefix(String k) throws JSONException
      method isValidDataType (line 59) | public static boolean isValidDataType(Object obj)
      method addPrefix (line 78) | public static String addPrefix(Object obj)

FILE: app/src/main/java/sumimakito/android/quickkv/QKVConfig.java
  class QKVConfig (line 11) | public class QKVConfig

FILE: app/src/main/java/sumimakito/android/quickkv/QKVFSReader.java
  class QKVFSReader (line 22) | public class QKVFSReader
    method readFileBFD (line 24) | public static String readFileBFD(String pFileAbsPath) throws IOExcepti...
    method readFileNIO (line 28) | public static String readFileNIO(String pFileAbsPath) throws IOException{
    method bfd (line 32) | private static String bfd(String pFilePath) throws FileNotFoundExcepti...
    method nio (line 42) | private static String nio(String pFilePath) throws FileNotFoundExcepti...

FILE: app/src/main/java/sumimakito/android/quickkv/QKVLogger.java
  class QKVLogger (line 13) | public class QKVLogger
    method log (line 15) | public static void log(String level, String msg)
    method ex (line 29) | public static void ex(Exception e)

FILE: app/src/main/java/sumimakito/android/quickkv/QuickKV.java
  class QuickKV (line 17) | public class QuickKV
    method QuickKV (line 22) | public QuickKV(Context context)
    method getDatabase (line 28) | public KeyValueDatabase getDatabase()
    method getDatabase (line 37) | public KeyValueDatabase getDatabase(String dbAlias)
    method getDatabase (line 63) | public KeyValueDatabase getDatabase(String dbAlias, String key)
    method isDatabaseOpened (line 89) | public boolean isDatabaseOpened()
    method isDatabaseOpened (line 94) | public boolean isDatabaseOpened(String dbAlias)
    method releaseDatabase (line 115) | public boolean releaseDatabase()
    method releaseDatabase (line 125) | public boolean releaseDatabase(String dbAlias)
    method releaseAllDatabases (line 136) | public void releaseAllDatabases()

FILE: app/src/main/java/sumimakito/android/quickkv/database/KeyValueDatabase.java
  class KeyValueDatabase (line 20) | public class KeyValueDatabase implements QKVDatabase
    method KeyValueDatabase (line 27) | public KeyValueDatabase(Context context)
    method KeyValueDatabase (line 36) | public KeyValueDatabase(Context context, String dbAlias)
    method KeyValueDatabase (line 45) | public KeyValueDatabase(Context context, String dbAlias, String key)
    method put (line 55) | @Override
    method get (line 66) | @Override
    method containsKey (line 77) | @Override
    method containsValue (line 84) | @Override
    method remove (line 91) | @Override
    method remove (line 106) | @Override
    method clear (line 126) | @Override
    method size (line 132) | @Override
    method getKeys (line 138) | public List<Object> getKeys()
    method getValues (line 154) | public List<Object> getValues()
    method persist (line 170) | public boolean persist()
    method persist (line 210) | public void persist(final Callback callback)
    method sync (line 225) | public boolean sync()
    method sync (line 230) | public boolean sync(boolean merge)
    method sync (line 255) | public void sync(final Callback callback)
    method sync (line 270) | public void sync(final boolean merge, final Callback callback)
    method enableEncryption (line 285) | public boolean enableEncryption(String key)
    method disableEncryption (line 296) | public void disableEncryption()
    method parseKVJS (line 302) | private boolean parseKVJS(JSONObject json)
    type Callback (line 333) | public interface Callback
      method onSuccess (line 335) | public void onSuccess();
      method onFailed (line 336) | public void onFailed();

FILE: app/src/main/java/sumimakito/android/quickkv/database/QKVDatabase.java
  type QKVDatabase (line 11) | public interface QKVDatabase
    method put (line 13) | <K, V> boolean put(K k, V v);
    method get (line 14) | <K> Object get(K k);
    method containsKey (line 15) | <K> boolean containsKey(K k);
    method containsValue (line 16) | <V> boolean containsValue(V v);
    method remove (line 17) | <K> boolean remove(K k);
    method remove (line 18) | <K> boolean remove(K[] k);
    method clear (line 19) | void clear();
    method size (line 20) | int size();

FILE: app/src/main/java/sumimakito/android/quickkv/security/AES256.java
  class AES256 (line 24) | public class AES256
    method encode (line 26) | public static String encode(String ePasK, String eConT){
    method decode (line 57) | public static String decode(String ePasK, String eConT){
    method getKey (line 84) | private static SecretKeySpec getKey(String password) throws Unsupporte...

FILE: libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenu.java
  type MaterialMenu (line 28) | public interface MaterialMenu {
    method setState (line 34) | public void setState(IconState state);
    method getState (line 41) | public IconState getState();
    method animateState (line 48) | public void animateState(IconState state);
    method animatePressedState (line 55) | public void animatePressedState(IconState state);
    method setColor (line 62) | public void setColor(int color);
    method setTransformationDuration (line 69) | public void setTransformationDuration(int duration);
    method setPressedDuration (line 76) | public void setPressedDuration(int duration);
    method setInterpolator (line 83) | public void setInterpolator(Interpolator interpolator);
    method setAnimationListener (line 90) | public void setAnimationListener(Animator.AnimatorListener listener);
    method setRTLEnabled (line 97) | public void setRTLEnabled(boolean rtlEnabled);
    method setTransformationOffset (line 106) | public void setTransformationOffset(MaterialMenuDrawable.AnimationStat...
    method getDrawable (line 111) | public MaterialMenuDrawable getDrawable();

FILE: libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java
  class MaterialMenuDrawable (line 42) | public class MaterialMenuDrawable extends Drawable implements Animatable {
    type IconState (line 44) | public enum IconState {
    type AnimationState (line 48) | public enum AnimationState {
      method getFirstState (line 51) | public IconState getFirstState() {
      method getSecondState (line 70) | public IconState getSecondState() {
    type Stroke (line 90) | public enum Stroke {
      method Stroke (line 106) | Stroke(int strokeWidth) {
      method valueOf (line 110) | protected static Stroke valueOf(int strokeWidth) {
    method MaterialMenuDrawable (line 190) | public MaterialMenuDrawable(Context context, int color, Stroke stroke) {
    method MaterialMenuDrawable (line 194) | public MaterialMenuDrawable(Context context, int color, Stroke stroke,...
    method MaterialMenuDrawable (line 198) | public MaterialMenuDrawable(Context context, int color, Stroke stroke,...
    method MaterialMenuDrawable (line 225) | private MaterialMenuDrawable(int color, Stroke stroke, long transformD...
    method initPaint (line 250) | private void initPaint(int color) {
    method draw (line 268) | @Override public void draw(Canvas canvas) {
    method drawTouchCircle (line 288) | private void drawTouchCircle(Canvas canvas) {
    method drawMiddleLine (line 293) | private void drawMiddleLine(Canvas canvas, float ratio) {
    method drawTopLine (line 365) | private void drawTopLine(Canvas canvas, float ratio) {
    method drawBottomLine (line 460) | private void drawBottomLine(Canvas canvas, float ratio) {
    method isMorphingForward (line 567) | private boolean isMorphingForward() {
    method resolveStrokeModifier (line 571) | private float resolveStrokeModifier(float ratio) {
    method setAlpha (line 592) | @Override public void setAlpha(int alpha) {
    method setColorFilter (line 596) | @Override public void setColorFilter(ColorFilter cf) {
    method getOpacity (line 600) | @Override public int getOpacity() {
    method setColor (line 608) | public void setColor(int color) {
    method setTransformationDuration (line 614) | public void setTransformationDuration(int duration) {
    method setPressedDuration (line 618) | public void setPressedDuration(int duration) {
    method setInterpolator (line 622) | public void setInterpolator(Interpolator interpolator) {
    method setAnimationListener (line 626) | public void setAnimationListener(AnimatorListener listener) {
    method setNeverDrawTouch (line 638) | public void setNeverDrawTouch(boolean neverDrawTouch) {
    method setIconState (line 642) | public void setIconState(IconState iconState) {
    method animateIconState (line 673) | public void animateIconState(IconState state, boolean drawTouch) {
    method setTransformationOffset (line 685) | public IconState setTransformationOffset(AnimationState animationState...
    method setRTLEnabled (line 704) | public void setRTLEnabled(boolean rtlEnabled) {
    method getIconState (line 709) | public IconState getIconState() {
    method get (line 718) | @Override
    method set (line 723) | @Override
    method get (line 731) | @Override
    method set (line 736) | @Override
    method getTransformationValue (line 742) | public Float getTransformationValue() {
    method setTransformationValue (line 746) | public void setTransformationValue(Float value) {
    method getPressedProgress (line 751) | public Float getPressedProgress() {
    method setPressedProgress (line 755) | public void setPressedProgress(Float value) {
    method initAnimations (line 761) | private void initAnimations(int transformDuration, int pressedDuration) {
    method resolveTransformation (line 787) | private boolean resolveTransformation() {
    method start (line 832) | @Override public void start() {
    method stop (line 857) | @Override public void stop() {
    method isRunning (line 866) | @Override public boolean isRunning() {
    method getIntrinsicWidth (line 870) | @Override
    method getIntrinsicHeight (line 875) | @Override
    method getConstantState (line 881) | @Override
    method mutate (line 887) | @Override
    class MaterialMenuState (line 893) | private final class MaterialMenuState extends ConstantState {
      method MaterialMenuState (line 896) | private MaterialMenuState() {
      method newDrawable (line 899) | @Override
      method getChangingConfigurations (line 910) | @Override
    method dpToPx (line 916) | static float dpToPx(Resources resources, float dp) {

FILE: libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenuView.java
  class MaterialMenuView (line 45) | public class MaterialMenuView extends View implements MaterialMenu {
    method MaterialMenuView (line 51) | public MaterialMenuView(Context context) {
    method MaterialMenuView (line 55) | public MaterialMenuView(Context context, AttributeSet attrs) {
    method MaterialMenuView (line 59) | public MaterialMenuView(Context context, AttributeSet attrs, int defSt...
    method init (line 64) | private void init(Context context, AttributeSet attributeSet) {
    method draw (line 84) | @Override
    method setPadding (line 98) | @Override
    method verifyDrawable (line 104) | @Override
    method setState (line 109) | @Override
    method getState (line 115) | @Override
    method animateState (line 120) | @Override
    method animatePressedState (line 126) | @Override
    method setColor (line 132) | @Override
    method setTransformationDuration (line 137) | @Override
    method setPressedDuration (line 142) | @Override
    method setInterpolator (line 147) | @Override
    method setAnimationListener (line 152) | @Override
    method setRTLEnabled (line 157) | @Override
    method setTransformationOffset (line 162) | @Override
    method getDrawable (line 167) | @Override
    method onMeasure (line 172) | @Override
    method onSizeChanged (line 186) | @Override
    method onSaveInstanceState (line 192) | @Override
    method onRestoreInstanceState (line 200) | @Override
    method adjustDrawablePadding (line 207) | private void adjustDrawablePadding() {
    method getTypedArray (line 217) | private TypedArray getTypedArray(Context context, AttributeSet attribu...
    class SavedState (line 221) | private static class SavedState extends BaseSavedState {
      method SavedState (line 224) | SavedState(Parcelable superState) {
      method SavedState (line 228) | private SavedState(Parcel in) {
      method writeToParcel (line 233) | @Override
      method createFromParcel (line 240) | @Override
      method newArray (line 245) | @Override

FILE: libraries/PersistentSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
  class SearchBox (line 53) | public class SearchBox extends RelativeLayout {
    method SearchBox (line 89) | public SearchBox(Context context) {
    method SearchBox (line 98) | public SearchBox(Context context, AttributeSet attrs) {
    method SearchBox (line 108) | public SearchBox(Context context, AttributeSet attrs, int defStyle) {
    method isSearchOpened (line 190) | public boolean isSearchOpened() {
    method isIntentAvailable (line 194) | private static boolean isIntentAvailable(Context context, Intent inten...
    method revealFromMenuItem (line 205) | public void revealFromMenuItem(int id, Activity activity) {
    method hideCircularly (line 224) | public void hideCircularly(Activity activity){
    method toggleSearch (line 271) | public void toggleSearch() {
    method hideResults (line 286) | public void hideResults(){
    method startVoiceRecognition (line 294) | public void startVoiceRecognition() {
    method enableVoiceRecognition (line 315) | public void enableVoiceRecognition(Activity context) {
    method enableVoiceRecognition (line 324) | public void enableVoiceRecognition(Fragment context) {
    method enableVoiceRecognition (line 333) | public void enableVoiceRecognition(android.support.v4.app.Fragment con...
    method isMicEnabled (line 338) | private boolean isMicEnabled() {
    method micStateChanged (line 342) | private void micStateChanged() {
    method micStateChanged (line 346) | private void micStateChanged(boolean isMic) {
    method showLoading (line 356) | public void showLoading(boolean show){
    method micClick (line 369) | public void micClick() {
    method populateEditText (line 382) | public void populateEditText(ArrayList<String> matches) {
    method updateResults (line 396) | public void updateResults() {
    method setInitialResults (line 420) | public void setInitialResults(ArrayList<SearchResult> results){
    method setMenuVisibility (line 429) | public void setMenuVisibility(int visibility){
    method setMenuListener (line 437) | public void setMenuListener(MenuListener menuListener) {
    method setSearchListener (line 445) | public void setSearchListener(SearchListener listener) {
    method setSearchWithoutSuggestions (line 453) | public void setSearchWithoutSuggestions(boolean state){
    method setMaxLength (line 461) | public void setMaxLength(int length) {
    method setLogoText (line 470) | public void setLogoText(String text) {
    method setDrawerLogo (line 479) | public void setDrawerLogo(Drawable icon) {
    method getSearchText (line 487) | public String getSearchText() {
    method setSearchString (line 495) | public void setSearchString(String text) {
    method addResult (line 503) | private void addResult(SearchResult result) {
    method clearResults (line 513) | public void clearResults() {
    method getNumberOfResults (line 525) | public int getNumberOfResults() {
    method setSearchables (line 533) | public void setSearchables(ArrayList<SearchResult> searchables){
    method addSearchable (line 541) | public void addSearchable(SearchResult searchable) {
    method removeSearchable (line 550) | public void removeSearchable(SearchResult searchable) {
    method clearSearchable (line 558) | public void clearSearchable() {
    method getSearchables (line 566) | public ArrayList<SearchResult> getSearchables() {
    method revealFrom (line 570) | private void revealFrom(float x, float y, Activity a, SearchBox s) {
    method search (line 612) | private void search(SearchResult result) {
    method openSearch (line 629) | private void openSearch(Boolean openKeyboard) {
    method setInitialResults (line 707) | private void setInitialResults(){
    method closeSearch (line 727) | private void closeSearch() {
    method setLogoTextInt (line 751) | private void setLogoTextInt(String text) {
    method search (line 759) | private void search(String text) {
    class SearchAdapter (line 767) | class SearchAdapter extends ArrayAdapter<SearchResult> {
      method SearchAdapter (line 768) | public SearchAdapter(Context context, ArrayList<SearchResult> option...
      method getView (line 774) | @Override
    type SearchListener (line 823) | public interface SearchListener {
      method onSearchOpened (line 827) | public void onSearchOpened();
      method onSearchCleared (line 832) | public void onSearchCleared();
      method onSearchClosed (line 837) | public void onSearchClosed();
      method onSearchTermChanged (line 842) | public void onSearchTermChanged();
      method onSearch (line 848) | public void onSearch(String result);
    type MenuListener (line 851) | public interface MenuListener {
      method onMenuClick (line 855) | public void onMenuClick();
    type VoiceRecognitionListener (line 858) | public interface VoiceRecognitionListener {
      method onClick (line 862) | public void onClick();

FILE: libraries/PersistentSearch/src/main/java/com/quinny898/library/persistentsearch/SearchResult.java
  class SearchResult (line 6) | public class SearchResult {
    method SearchResult (line 17) | public SearchResult(String title, Drawable icon) {
    method SearchResult (line 22) | public SearchResult(String title, @DrawableRes int drawableResId) {
    method toString (line 30) | @Override

FILE: libraries/PersistentSearch/src/main/java/io/codetail/animation/RevealAnimator.java
  type RevealAnimator (line 17) | public interface RevealAnimator{
    method setClipOutlines (line 19) | public void setClipOutlines(boolean clip);
    method setCenter (line 21) | public void setCenter(float cx, float cy);
    method setTarget (line 23) | public void setTarget(View target);
    method setRevealRadius (line 25) | public void setRevealRadius(float value);
    method getRevealRadius (line 27) | public float getRevealRadius();
    method invalidate (line 29) | public void invalidate(Rect bounds);
    class RevealFinishedGingerbread (line 31) | static class RevealFinishedGingerbread extends SimpleAnimationListener {
      method RevealFinishedGingerbread (line 35) | RevealFinishedGingerbread(RevealAnimator target, Rect bounds) {
      method onAnimationEnd (line 40) | @Override
    class RevealFinishedIceCreamSandwich (line 57) | static class RevealFinishedIceCreamSandwich extends SimpleAnimationLis...
      method RevealFinishedIceCreamSandwich (line 63) | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
      method onAnimationStart (line 71) | @Override
      method onAnimationEnd (line 78) | @Override
    class RevealFinishedJellyBeanMr1 (line 97) | static class RevealFinishedJellyBeanMr1 extends SimpleAnimationListener {
      method RevealFinishedJellyBeanMr1 (line 103) | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
      method onAnimationStart (line 111) | @Override
      method onAnimationEnd (line 118) | @Override

FILE: libraries/PersistentSearch/src/main/java/io/codetail/animation/ReverseInterpolator.java
  class ReverseInterpolator (line 5) | public class ReverseInterpolator implements Interpolator {
    method getInterpolation (line 7) | public float getInterpolation(float t) {

FILE: libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimator.java
  class SupportAnimator (line 5) | public abstract class SupportAnimator {
    method isNativeAnimator (line 11) | public abstract boolean isNativeAnimator();
    method get (line 18) | public abstract Object get();
    method start (line 34) | public abstract void start();
    method setDuration (line 41) | public abstract void setDuration(int duration);
    method setInterpolator (line 51) | public abstract void setInterpolator(Interpolator value);
    method addListener (line 60) | public abstract void addListener(AnimatorListener listener);
    method isRunning (line 69) | public abstract boolean isRunning();
    type AnimatorListener (line 77) | public static interface AnimatorListener {
      method onAnimationStart (line 81) | void onAnimationStart();
      method onAnimationEnd (line 87) | void onAnimationEnd();
      method onAnimationCancel (line 93) | void onAnimationCancel();
      method onAnimationRepeat (line 98) | void onAnimationRepeat();

FILE: libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimatorLollipop.java
  class SupportAnimatorLollipop (line 10) | @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    method SupportAnimatorLollipop (line 15) | SupportAnimatorLollipop(Animator animator) {
    method isNativeAnimator (line 19) | @Override
    method get (line 24) | @Override
    method start (line 30) | @Override
    method setDuration (line 38) | @Override
    method setInterpolator (line 46) | @Override
    method addListener (line 54) | @Override
    method isRunning (line 89) | @Override

FILE: libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimatorPreL.java
  class SupportAnimatorPreL (line 9) | final class SupportAnimatorPreL extends SupportAnimator {
    method SupportAnimatorPreL (line 13) | SupportAnimatorPreL(Animator animator) {
    method isNativeAnimator (line 17) | @Override
    method get (line 22) | @Override
    method start (line 27) | @Override
    method setDuration (line 35) | @Override
    method setInterpolator (line 43) | @Override
    method addListener (line 51) | @Override
    method isRunning (line 86) | @Override

FILE: libraries/PersistentSearch/src/main/java/io/codetail/animation/ViewAnimationUtils.java
  class ViewAnimationUtils (line 17) | public class ViewAnimationUtils {
    method createCircularReveal (line 41) | @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    method getRevealFinishListener (line 69) | static Animator.AnimatorListener getRevealFinishListener(RevealAnimato...
    method liftingFromBottom (line 89) | public static void liftingFromBottom(View view, float baseRotation, fl...
    method liftingFromBottom (line 112) | public static void liftingFromBottom(View view, float baseRotation, in...
    method liftingFromBottom (line 134) | public static void liftingFromBottom(View view, float baseRotation, in...
    class SimpleAnimationListener (line 148) | public static class SimpleAnimationListener implements Animator.Animat...
      method onAnimationStart (line 150) | @Override
      method onAnimationEnd (line 155) | @Override
      method onAnimationCancel (line 160) | @Override
      method onAnimationRepeat (line 165) | @Override

FILE: libraries/PersistentSearch/src/main/java/io/codetail/widget/RevealFrameLayout.java
  class RevealFrameLayout (line 12) | public class RevealFrameLayout extends FrameLayout implements RevealAnim...
    method RevealFrameLayout (line 24) | public RevealFrameLayout(Context context) {
    method RevealFrameLayout (line 28) | public RevealFrameLayout(Context context, AttributeSet attrs) {
    method RevealFrameLayout (line 32) | public RevealFrameLayout(Context context, AttributeSet attrs, int defS...
    method setTarget (line 42) | @Override
    method setCenter (line 52) | @Override
    method setClipOutlines (line 63) | @Override
    method setRevealRadius (line 73) | @Override
    method getRevealRadius (line 84) | @Override
    method drawChild (line 90) | @Override

FILE: libraries/PersistentSearch/src/main/java/io/codetail/widget/RevealLinearLayout.java
  class RevealLinearLayout (line 12) | public class RevealLinearLayout extends LinearLayout implements RevealAn...
    method RevealLinearLayout (line 24) | public RevealLinearLayout(Context context) {
    method RevealLinearLayout (line 28) | public RevealLinearLayout(Context context, AttributeSet attrs) {
    method RevealLinearLayout (line 32) | public RevealLinearLayout(Context context, AttributeSet attrs, int def...
    method setTarget (line 40) | @Override
    method setCenter (line 48) | @Override
    method setClipOutlines (line 57) | @Override
    method setRevealRadius (line 65) | @Override
    method getRevealRadius (line 74) | @Override
    method drawChild (line 80) | @Override
Condensed preview — 119 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (393K chars).
[
  {
    "path": ".gitignore",
    "chars": 57,
    "preview": ".gradle\n/local.properties\n/.idea\n.DS_Store\n/build\n\n*.iml\n"
  },
  {
    "path": "LICENSE",
    "chars": 35146,
    "preview": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free "
  },
  {
    "path": "README.md",
    "chars": 742,
    "preview": "# NHBooks for Android\n![NHBooksLogo](/art/nhbooks.png)\n\na Material Design NHentai client for Android.\n一枚 Material Design"
  },
  {
    "path": "app/.gitignore",
    "chars": 7,
    "preview": "/build\n"
  },
  {
    "path": "app/build.gradle",
    "chars": 1013,
    "preview": "apply plugin: 'com.android.application'\n\nandroid {\n\tcompileSdkVersion 22\n\tbuildToolsVersion \"22.0.1\"\n\n\tdefaultConfig {\n\t"
  },
  {
    "path": "app/proguard-rules.pro",
    "chars": 642,
    "preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in E:"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "chars": 2423,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package="
  },
  {
    "path": "app/src/main/assets/licenses.html",
    "chars": 5935,
    "preview": "<html>\n<head>\n\t<style>\n\t\tbody {\n\t\tmargin: 1em;\n\t\t}\n\t\tpre {\n\t\tbackground: #DDD;\n\t\tpadding: 1em;\n\t\twhite-space: pre-wrap;\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/api/BookApi.java",
    "chars": 6405,
    "preview": "package moe.feng.nhentai.api;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.util.Log;\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/api/PageApi.java",
    "chars": 3412,
    "preview": "package moe.feng.nhentai.api;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.util.Log;\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/api/common/NHentaiUrl.java",
    "chars": 2941,
    "preview": "package moe.feng.nhentai.api.common;\n\npublic class NHentaiUrl {\n\n\tpublic static final String NHENTAI_HOME = \"http://nhen"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/cache/common/Constants.java",
    "chars": 229,
    "preview": "package moe.feng.nhentai.cache.common;\n\npublic class Constants {\n\n\tpublic static final String CACHE_COVER = \"cover\", CAC"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/cache/file/FileCacheManager.java",
    "chars": 4437,
    "preview": "package moe.feng.nhentai.cache.file;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.gra"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/cache/file/OfflineDocumentManager.java",
    "chars": 1420,
    "preview": "package moe.feng.nhentai.cache.file;\n\nimport android.content.Context;\n\nimport java.io.BufferedReader;\nimport java.io.IOE"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/dao/CommonPreferences.java",
    "chars": 2880,
    "preview": "package moe.feng.nhentai.dao;\n\nimport android.content.Context;\n\nimport java.util.ArrayList;\n\nimport sumimakito.android.q"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/dao/SearchHistoryManager.java",
    "chars": 2635,
    "preview": "package moe.feng.nhentai.dao;\n\nimport android.content.Context;\n\nimport com.quinny898.library.persistentsearch.SearchResu"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/model/BaseMessage.java",
    "chars": 437,
    "preview": "package moe.feng.nhentai.model;\n\npublic class BaseMessage {\n\n\tprivate int code = -1;\n\tprivate Object data;\n\n\tpublic Base"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/model/Book.java",
    "chars": 971,
    "preview": "package moe.feng.nhentai.model;\n\nimport com.google.gson.Gson;\n\nimport java.util.ArrayList;\n\npublic class Book {\n\n\t/** 必须"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/BookDetailsActivity.java",
    "chars": 15087,
    "preview": "package moe.feng.nhentai.ui;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.os.Bundle;\nimpo"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/CategoryActivity.java",
    "chars": 5002,
    "preview": "package moe.feng.nhentai.ui;\n\nimport android.content.Intent;\nimport android.os.Build;\nimport android.os.Bundle;\nimport a"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/GalleryActivity.java",
    "chars": 2648,
    "preview": "package moe.feng.nhentai.ui;\n\nimport android.app.Activity;\nimport android.content.Intent;\nimport android.graphics.Color;"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/MainActivity.java",
    "chars": 5668,
    "preview": "package moe.feng.nhentai.ui;\n\nimport android.content.res.Configuration;\nimport android.os.Build;\nimport android.os.Bundl"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/SearchResultActivity.java",
    "chars": 4977,
    "preview": "package moe.feng.nhentai.ui;\n\nimport android.content.Intent;\nimport android.os.Build;\nimport android.os.Bundle;\nimport a"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/SettingsActivity.java",
    "chars": 1567,
    "preview": "package moe.feng.nhentai.ui;\n\nimport android.app.Activity;\nimport android.app.Fragment;\nimport android.content.Intent;\ni"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/BookListRecyclerAdapter.java",
    "chars": 4815,
    "preview": "package moe.feng.nhentai.ui.adapter;\n\nimport android.graphics.Bitmap;\nimport android.support.v7.widget.ListPopupWindow;\n"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/BookPreviewGridAdapter.java",
    "chars": 2587,
    "preview": "package moe.feng.nhentai.ui.adapter;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.tex"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/GalleryPagerAdapter.java",
    "chars": 781,
    "preview": "package moe.feng.nhentai.ui.adapter;\n\nimport android.app.Fragment;\nimport android.app.FragmentManager;\nimport android.su"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/adapter/HomePagerAdapter.java",
    "chars": 1298,
    "preview": "package moe.feng.nhentai.ui.adapter;\n\nimport android.app.Fragment;\nimport android.app.FragmentManager;\nimport android.co"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/common/AbsActivity.java",
    "chars": 2299,
    "preview": "package moe.feng.nhentai.ui.common;\n\nimport android.graphics.Color;\nimport android.os.Build;\nimport android.os.Bundle;\ni"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/common/AbsRecyclerViewAdapter.java",
    "chars": 2767,
    "preview": "package moe.feng.nhentai.ui.common;\n\nimport android.content.Context;\nimport android.support.v7.widget.RecyclerView;\nimpo"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/BookPageFragment.java",
    "chars": 2963,
    "preview": "package moe.feng.nhentai.ui.fragment;\n\nimport android.app.Fragment;\nimport android.graphics.Bitmap;\nimport android.graph"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/main/DownloadManagerFragment.java",
    "chars": 2522,
    "preview": "package moe.feng.nhentai.ui.fragment.main;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.suppor"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/main/FavoriteFragment.java",
    "chars": 2508,
    "preview": "package moe.feng.nhentai.ui.fragment.main;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.suppor"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/main/HomeFragment.java",
    "chars": 4536,
    "preview": "package moe.feng.nhentai.ui.fragment.main;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.suppor"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsLicense.java",
    "chars": 594,
    "preview": "package moe.feng.nhentai.ui.fragment.settings;\n\nimport android.app.Fragment;\nimport android.os.Bundle;\nimport android.vi"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/ui/fragment/settings/SettingsMain.java",
    "chars": 2210,
    "preview": "package moe.feng.nhentai.ui.fragment.settings;\n\nimport android.content.Intent;\nimport android.net.Uri;\nimport android.os"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/AsyncTask.java",
    "chars": 2164,
    "preview": "package moe.feng.nhentai.util;\n\n\nimport android.os.Handler;\nimport android.os.Message;\nimport android.util.Log;\n\nimport "
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/ColorGenerator.java",
    "chars": 1290,
    "preview": "package moe.feng.nhentai.util;\n\nimport java.util.Arrays;\nimport java.util.List;\nimport java.util.Random;\n\n/**\n * @author"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/FullScreenHelper.java",
    "chars": 4126,
    "preview": "package moe.feng.nhentai.util;\n\nimport android.annotation.SuppressLint;\nimport android.app.Activity;\nimport android.os.B"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/HttpTools.java",
    "chars": 898,
    "preview": "package moe.feng.nhentai.util;\n\nimport java.io.IOException;\nimport java.net.HttpURLConnection;\nimport java.net.URL;\nimpo"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/Settings.java",
    "chars": 1180,
    "preview": "package moe.feng.nhentai.util;\n\nimport android.content.Context;\n\nimport moe.feng.nhentai.dao.CommonPreferences;\n\npublic "
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/TextDrawable.java",
    "chars": 6817,
    "preview": "package moe.feng.nhentai.util;\n\nimport android.graphics.*;\nimport android.graphics.drawable.ShapeDrawable;\nimport androi"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/util/Utility.java",
    "chars": 1425,
    "preview": "package moe.feng.nhentai.util;\n\nimport android.content.Context;\nimport android.os.Build;\n\nimport java.lang.reflect.Metho"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/AutoWrapLayout.java",
    "chars": 7338,
    "preview": "package moe.feng.nhentai.view;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport android.annotation.SuppressLi"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/ExpandableHeightGridView.java",
    "chars": 1112,
    "preview": "package moe.feng.nhentai.view;\n\nimport android.content.Context;\nimport android.util.AttributeSet;\nimport android.view.Vi"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/WheelProgressView.java",
    "chars": 17742,
    "preview": "package moe.feng.nhentai.view;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport android.gr"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/pref/Preference.java",
    "chars": 1290,
    "preview": "package moe.feng.nhentai.view.pref;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/pref/SwitchPreference.java",
    "chars": 6271,
    "preview": "package moe.feng.nhentai.view.pref;\n\nimport android.content.Context;\nimport android.content.res.TypedArray;\nimport andro"
  },
  {
    "path": "app/src/main/java/moe/feng/nhentai/view/pref/TwoStatePreference.java",
    "chars": 6664,
    "preview": "package moe.feng.nhentai.view.pref;\n\nimport android.content.Context;\nimport android.content.SharedPreferences;\nimport an"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/DataProcessor.java",
    "chars": 2523,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QKVConfig.java",
    "chars": 729,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QKVFSReader.java",
    "chars": 1761,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QKVLogger.java",
    "chars": 596,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/QuickKV.java",
    "chars": 2960,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/database/KeyValueDatabase.java",
    "chars": 7169,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/database/QKVDatabase.java",
    "chars": 445,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/java/sumimakito/android/quickkv/security/AES256.java",
    "chars": 2613,
    "preview": "/**      \n * QucikKV\n * Copyright (c) 2014-2015 Sumi Makito\n * Licensed under Apache License 2.0.\n * @author sumimakito<"
  },
  {
    "path": "app/src/main/res/color/drawer_item_color.xml",
    "chars": 264,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n\t<item and"
  },
  {
    "path": "app/src/main/res/drawable/shadow_gradient.xml",
    "chars": 298,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:"
  },
  {
    "path": "app/src/main/res/drawable/shadow_gradient_reserve.xml",
    "chars": 292,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:"
  },
  {
    "path": "app/src/main/res/drawable/shadow_normal.xml",
    "chars": 298,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:"
  },
  {
    "path": "app/src/main/res/drawable/shadow_normal_reserve.xml",
    "chars": 298,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<shape xmlns:android=\"http://schemas.android.com/apk/res/android\"\n       android:"
  },
  {
    "path": "app/src/main/res/layout/activity_book_details.xml",
    "chars": 5245,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.design.widget.CoordinatorLayout xmlns:android=\"http://schemas.an"
  },
  {
    "path": "app/src/main/res/layout/activity_gallery.xml",
    "chars": 999,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout\n\txmlns:android=\"http://schemas.android.com/apk/res/android\"\n\tandroid"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "chars": 2369,
    "preview": "<android.support.v4.widget.DrawerLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n                     "
  },
  {
    "path": "app/src/main/res/layout/activity_search_result.xml",
    "chars": 1186,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        "
  },
  {
    "path": "app/src/main/res/layout/activity_settings.xml",
    "chars": 898,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        "
  },
  {
    "path": "app/src/main/res/layout/custom_preference.xml",
    "chars": 2403,
    "preview": "<android.support.v7.widget.LinearLayoutCompat\n    xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    xmlns:t"
  },
  {
    "path": "app/src/main/res/layout/custom_preference_widget_switch.xml",
    "chars": 353,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v7.widget.SwitchCompat\n    android:id=\"@android:id/checkbox\"\n   "
  },
  {
    "path": "app/src/main/res/layout/fragment_book_page.xml",
    "chars": 419,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        "
  },
  {
    "path": "app/src/main/res/layout/fragment_download.xml",
    "chars": 381,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n         "
  },
  {
    "path": "app/src/main/res/layout/fragment_favorite.xml",
    "chars": 381,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n         "
  },
  {
    "path": "app/src/main/res/layout/fragment_home.xml",
    "chars": 602,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n         "
  },
  {
    "path": "app/src/main/res/layout/list_item_book_card.xml",
    "chars": 1811,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<android.support.v7.widget.CardView xmlns:android=\"http://schemas.android.com/apk"
  },
  {
    "path": "app/src/main/res/layout/list_item_book_picture_thumb.xml",
    "chars": 918,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        "
  },
  {
    "path": "app/src/main/res/layout/list_item_menu_row.xml",
    "chars": 597,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        "
  },
  {
    "path": "app/src/main/res/layout/navigation_header.xml",
    "chars": 322,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n        "
  },
  {
    "path": "app/src/main/res/menu/menu_main.xml",
    "chars": 598,
    "preview": "<menu xmlns:android=\"http://schemas.android.com/apk/res/android\"\n      xmlns:app=\"http://schemas.android.com/apk/res-aut"
  },
  {
    "path": "app/src/main/res/menu/navigation_menu.xml",
    "chars": 648,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n\t<group androi"
  },
  {
    "path": "app/src/main/res/values/attrs.xml",
    "chars": 2117,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<attr name=\"dialogPreferenceStyle\" format=\"reference\"/>\n\t<attr name"
  },
  {
    "path": "app/src/main/res/values/color.xml",
    "chars": 637,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<color name=\"deep_purple_300\">#9575CD</color>\n\t<color name=\"deep_pu"
  },
  {
    "path": "app/src/main/res/values/dimen.xml",
    "chars": 387,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<dimen name=\"fab_transition_z\">5dp</dimen>\n\n\t<dimen name=\"navigatio"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "chars": 2180,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">NHBooks</string>\n    <string name=\"actio"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "chars": 2020,
    "preview": "<resources>\n\n\t<style name=\"Base.Theme.NHBooks.Light\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n\t\t<item name=\"windowA"
  },
  {
    "path": "app/src/main/res/values-v21/styles.xml",
    "chars": 685,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n\t<style name=\"Base.Theme.NHBooks.Light\" parent=\"Theme.AppCompat.Ligh"
  },
  {
    "path": "app/src/main/res/values-zh-rCN/strings.xml",
    "chars": 2008,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">NH 本子</string>\n    <string name=\"action_"
  },
  {
    "path": "app/src/main/res/values-zh-rTW/strings.xml",
    "chars": 2008,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n\n    <string name=\"app_name\">NH 本子</string>\n    <string name=\"action_"
  },
  {
    "path": "app/src/main/res/xml/settings_main.xml",
    "chars": 1008,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<PreferenceScreen xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n\t<"
  },
  {
    "path": "build.gradle",
    "chars": 388,
    "preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n\trepo"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "chars": 230,
    "preview": "#Wed May 27 13:24:38 CST 2015\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
  },
  {
    "path": "gradle.properties",
    "chars": 855,
    "preview": "# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will o"
  },
  {
    "path": "gradlew",
    "chars": 5080,
    "preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start "
  },
  {
    "path": "gradlew.bat",
    "chars": 2314,
    "preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
  },
  {
    "path": "libraries/PersistentSearch/.gitignore",
    "chars": 7,
    "preview": "/build\n"
  },
  {
    "path": "libraries/PersistentSearch/build.gradle",
    "chars": 638,
    "preview": "apply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion 22\n    buildToolsVersion \"22.0.1\"\n\n    defaultConfi"
  },
  {
    "path": "libraries/PersistentSearch/gradle.properties",
    "chars": 68,
    "preview": "POM_NAME=Persistent Search\nPOM_ARTIFACT_ID=library\nPOM_PACKAGING=aar"
  },
  {
    "path": "libraries/PersistentSearch/proguard-rules.pro",
    "chars": 728,
    "preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:"
  },
  {
    "path": "libraries/PersistentSearch/src/main/AndroidManifest.xml",
    "chars": 202,
    "preview": "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.quinny898.library.persistentsearch"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenu.java",
    "chars": 3191,
    "preview": "/*\n * Copyright (C) 2014 Balys Valentukevicius\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * "
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java",
    "chars": 31952,
    "preview": "/*\n * Copyright (C) 2014 Balys Valentukevicius\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * "
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/balysv/materialmenu/MaterialMenuView.java",
    "chars": 8400,
    "preview": "/*\n * Copyright (C) 2014 Balys Valentukevicius\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * "
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java",
    "chars": 22133,
    "preview": "package com.quinny898.library.persistentsearch;\n\nimport android.animation.LayoutTransition;\nimport android.app.Activity;"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/com/quinny898/library/persistentsearch/SearchResult.java",
    "chars": 760,
    "preview": "package com.quinny898.library.persistentsearch;\n\nimport android.graphics.drawable.Drawable;\nimport android.support.annot"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/RevealAnimator.java",
    "chars": 4012,
    "preview": "package io.codetail.animation;\n\nimport android.annotation.TargetApi;\nimport android.graphics.Rect;\nimport android.os.Bui"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/ReverseInterpolator.java",
    "chars": 344,
    "preview": "package io.codetail.animation;\n\nimport android.view.animation.Interpolator;\n\npublic class ReverseInterpolator implements"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimator.java",
    "chars": 3598,
    "preview": "package io.codetail.animation;\n\nimport android.view.animation.Interpolator;\n\npublic abstract class SupportAnimator {\n\n  "
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimatorLollipop.java",
    "chars": 2229,
    "preview": "package io.codetail.animation;\n\nimport android.animation.Animator;\nimport android.annotation.TargetApi;\nimport android.o"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/SupportAnimatorPreL.java",
    "chars": 2153,
    "preview": "package io.codetail.animation;\n\nimport android.view.animation.Interpolator;\n\nimport com.nineoldandroids.animation.Animat"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/animation/ViewAnimationUtils.java",
    "chars": 5910,
    "preview": "package io.codetail.animation;\n\nimport android.annotation.TargetApi;\nimport android.graphics.Rect;\nimport android.os.Bui"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/widget/RevealFrameLayout.java",
    "chars": 2228,
    "preview": "package io.codetail.widget;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Pat"
  },
  {
    "path": "libraries/PersistentSearch/src/main/java/io/codetail/widget/RevealLinearLayout.java",
    "chars": 2031,
    "preview": "package io.codetail.widget;\n\nimport android.content.Context;\nimport android.graphics.Canvas;\nimport android.graphics.Pat"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/anim/anim_down.xml",
    "chars": 171,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<translate xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/layout/search_option.xml",
    "chars": 2002,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<FrameLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    andro"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/layout/searchbox.xml",
    "chars": 4417,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<io.codetail.widget.RevealFrameLayout\n    xmlns:android=\"http://schemas.android.c"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/values/strings.xml",
    "chars": 75,
    "preview": "<resources>\n\n    <string name=\"speak_now\">Speak now</string>\n\n</resources>\n"
  },
  {
    "path": "libraries/PersistentSearch/src/main/res/values/styles.xml",
    "chars": 461,
    "preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n    <declare-styleable name=\"MaterialMenuView\">\n        <attr name=\"m"
  },
  {
    "path": "settings.gradle",
    "chars": 46,
    "preview": "include ':app', ':libraries:PersistentSearch'\n"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the NoireFHC/NHentai-android GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 119 files (346.6 KB), approximately 89.6k tokens, and a symbol index with 755 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!