🌄 first commit
138
.gitignore
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/kotlin,intellij,gradle
|
||||
# Edit at https://www.gitignore.io/?templates=kotlin,intellij,gradle
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
### Kotlin ###
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
### Gradle Patch ###
|
||||
**/build/
|
||||
|
||||
# End of https://www.gitignore.io/api/kotlin,intellij,gradle
|
||||
SecretConstants.kt
|
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
||||
TopCorn
|
37
.idea/assetWizardSettings.xml
generated
Normal file
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WizardSettings">
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="imageWizard">
|
||||
<value>
|
||||
<PersistentState />
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="vectorWizard">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="vectorAssetStep">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="assetSourceType" value="FILE" />
|
||||
<entry key="outputName" value="ic_logo_line" />
|
||||
<entry key="sourceFile" value="$USER_HOME$/Downloads/cinema (1).svg" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
125
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,125 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Project" version="173">
|
||||
<JetCodeStyleSettings>
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</JetCodeStyleSettings>
|
||||
<MarkdownNavigatorCodeStyleSettings>
|
||||
<option name="RIGHT_MARGIN" value="72" />
|
||||
</MarkdownNavigatorCodeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
<arrangement>
|
||||
<rules>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:android</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>xmlns:.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:id</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*:name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>name</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>style</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>^$</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>ANDROID_ATTRIBUTE_ORDER</order>
|
||||
</rule>
|
||||
</section>
|
||||
<section>
|
||||
<rule>
|
||||
<match>
|
||||
<AND>
|
||||
<NAME>.*</NAME>
|
||||
<XML_ATTRIBUTE />
|
||||
<XML_NAMESPACE>.*</XML_NAMESPACE>
|
||||
</AND>
|
||||
</match>
|
||||
<order>BY_NAME</order>
|
||||
</rule>
|
||||
</section>
|
||||
</rules>
|
||||
</arrangement>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
9
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel>
|
||||
<module name="TopCorn.app" target="1.8" />
|
||||
<module name="topcorn.TopCorn.app" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
25
.idea/jarRepositories.xml
generated
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
14
.idea/misc.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeSettings">
|
||||
<configurations>
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
11
.idea/modules.xml
generated
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/TopCorn.iml" filepath="$PROJECT_DIR$/.idea/modules/TopCorn.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/TopCorn.app.iml" filepath="$PROJECT_DIR$/.idea/modules/app/TopCorn.app.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/topcorn.TopCorn.iml" filepath="$PROJECT_DIR$/.idea/modules/topcorn.TopCorn.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/app/topcorn.TopCorn.app.iml" filepath="$PROJECT_DIR$/.idea/modules/app/topcorn.TopCorn.app.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
20
.idea/modules/Movieum.iml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="TopCorn" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/../../build" />
|
||||
<option name="BUILDABLE" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../..">
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
219
.idea/modules/app/Movieum.app.iml
generated
Normal file
219
.idea/modules/app/topcorn.TopCorn.app.iml
generated
Normal file
20
.idea/modules/topcorn.TopCorn.iml
generated
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="TopCorn" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="java-gradle" name="Java-Gradle">
|
||||
<configuration>
|
||||
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/../../build" />
|
||||
<option name="BUILDABLE" value="false" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../..">
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
12
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
201
LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# TopCorn 🍿
|
||||
|
||||
A minimalistic movie listing app to list IMDB's top 250 movies of all time,
|
||||
built to *demonstrate latest hot trending Android development tools*.
|
||||
|
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
100
app/build.gradle
Normal file
@ -0,0 +1,100 @@
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'kotlin-android'
|
||||
id 'kotlin-kapt'
|
||||
id 'kotlin-android-extensions'
|
||||
}
|
||||
|
||||
|
||||
android {
|
||||
compileSdkVersion compile_sdk_version
|
||||
defaultConfig {
|
||||
applicationId "com.theapache64.topcorn"
|
||||
minSdkVersion min_sdk_version
|
||||
targetSdkVersion target_sdk_version
|
||||
versionCode 10001
|
||||
versionName "1.0.0-alpha01"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
multiDexEnabled true
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
//Core
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation "androidx.appcompat:appcompat:$appcompat_version"
|
||||
implementation "androidx.core:core-ktx:$ktx_version"
|
||||
implementation "androidx.constraintlayout:constraintlayout:$constraint_version"
|
||||
implementation "com.google.android.material:material:$material_version"
|
||||
|
||||
// Coroutines
|
||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"
|
||||
|
||||
// Lifecycle extension
|
||||
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
|
||||
|
||||
// Dagger 2
|
||||
def dagger_version = '2.27'
|
||||
implementation "com.google.dagger:dagger:$dagger_version"
|
||||
implementation "com.google.dagger:dagger-android-support:$dagger_version"
|
||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||
kapt "com.google.dagger:dagger-android-processor:$dagger_version"
|
||||
|
||||
|
||||
// Retrofit
|
||||
implementation "com.squareup.retrofit2:retrofit:$retrofit_version"
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.0'
|
||||
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofit_version"
|
||||
|
||||
// Moshi
|
||||
implementation 'com.squareup.moshi:moshi:1.9.2'
|
||||
|
||||
|
||||
// MaterialColors
|
||||
implementation 'com.theah64.materialcolors:materialcolors:1.0.0'
|
||||
|
||||
// TwinKill
|
||||
def twinkill_version = '1.0.0-alpha06'
|
||||
implementation "com.theapache64.twinkill:core:$twinkill_version"
|
||||
implementation "com.theapache64.twinkill:logger:$twinkill_version"
|
||||
implementation "com.theapache64.twinkill:network:$twinkill_version"
|
||||
implementation "com.theapache64.twinkill:google_sans:$twinkill_version"
|
||||
|
||||
// Room
|
||||
def room_version = "2.2.5"
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
implementation "androidx.room:room-ktx:$room_version"
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
|
||||
// Test
|
||||
testImplementation "junit:junit:$junit_version"
|
||||
testImplementation "org.mockito:mockito-core:$mockito_version"
|
||||
testImplementation "org.mockito:mockito-inline:$mockito_version"
|
||||
testImplementation('com.winterbe:expekt:0.5.0') {
|
||||
exclude group: "org.jetbrains.kotlin"
|
||||
}
|
||||
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
|
||||
}
|
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# 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 *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,22 @@
|
||||
package com.theapache64.topcorn
|
||||
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.theapache64.topcorn", appContext.packageName)
|
||||
}
|
||||
}
|
44
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.theapache64.topcorn">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:name=".App"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="GoogleAppIndexingWarning"
|
||||
tools:targetApi="m">
|
||||
|
||||
|
||||
<!--Splash-->
|
||||
<activity
|
||||
android:name=".ui.activities.splash.SplashActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Main -->
|
||||
<activity
|
||||
android:name=".ui.activities.feed.FeedActivity"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
|
||||
<!--Movie-->
|
||||
<activity
|
||||
android:name=".ui.activities.movie.MovieActivity"
|
||||
android:theme="@style/AppTheme.NoActionBar" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
54
app/src/main/java/com/theapache64/topcorn/App.kt
Normal file
@ -0,0 +1,54 @@
|
||||
package com.theapache64.topcorn
|
||||
|
||||
|
||||
import android.app.Application
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.theapache64.topcorn.di.components.DaggerAppComponent
|
||||
import com.theapache64.topcorn.utils.retrofit.FlowResourceCallAdapterFactory
|
||||
import com.theapache64.twinkill.TwinKill
|
||||
import com.theapache64.twinkill.di.modules.ContextModule
|
||||
import com.theapache64.twinkill.googlesans.GoogleSans
|
||||
import com.theapache64.twinkill.network.di.modules.BaseNetworkModule
|
||||
import com.theapache64.twinkill.network.utils.retrofit.interceptors.CurlInterceptor
|
||||
import dagger.android.AndroidInjector
|
||||
import dagger.android.DispatchingAndroidInjector
|
||||
import dagger.android.HasAndroidInjector
|
||||
import javax.inject.Inject
|
||||
|
||||
class App : Application(), HasAndroidInjector {
|
||||
|
||||
companion object {
|
||||
private const val BASE_URL = "https://raw.githubusercontent.com/theapache64/top250/master/"
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var androidInjector: DispatchingAndroidInjector<Any>
|
||||
|
||||
override fun androidInjector(): AndroidInjector<Any> = androidInjector
|
||||
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO)
|
||||
|
||||
// Dagger
|
||||
DaggerAppComponent.builder()
|
||||
.contextModule(ContextModule(this))
|
||||
.baseNetworkModule(BaseNetworkModule(BASE_URL))
|
||||
.build()
|
||||
.inject(this)
|
||||
|
||||
// TwinKill
|
||||
TwinKill.init(
|
||||
TwinKill
|
||||
.builder()
|
||||
.addCallAdapter(FlowResourceCallAdapterFactory()) // to return Flow<Resource<T>> from retrofit
|
||||
.addOkHttpInterceptor(CurlInterceptor())
|
||||
.setDefaultFont(GoogleSans.Regular)
|
||||
.build()
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.theapache64.topcorn.data.local
|
||||
|
||||
import androidx.room.Database
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import com.theapache64.topcorn.data.local.daos.MoviesDao
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
|
||||
@Database(entities = [Movie::class], version = 1)
|
||||
@TypeConverters(Converters::class)
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
abstract fun movieDao(): MoviesDao
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.theapache64.topcorn.data.local
|
||||
|
||||
import androidx.room.TypeConverter
|
||||
|
||||
class Converters {
|
||||
@TypeConverter
|
||||
fun fromStringList(list: List<String>): String {
|
||||
return list.joinToString(",")
|
||||
}
|
||||
|
||||
@TypeConverter
|
||||
fun fromStringToList(string: String): List<String> {
|
||||
return string.split(",")
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.theapache64.topcorn.data.local.daos
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Dao
|
||||
interface MoviesDao {
|
||||
@Query("SELECT * FROM movies")
|
||||
fun getAllMovies(): Flow<List<Movie>>
|
||||
|
||||
@Query("DELETE FROM movies")
|
||||
fun deleteAll()
|
||||
|
||||
@Insert
|
||||
fun addAll(data: List<Movie>)
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.theapache64.topcorn.data.remote
|
||||
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import retrofit2.http.GET
|
||||
|
||||
/**
|
||||
* This is a single route API to get IMDB top 250 movies
|
||||
*/
|
||||
interface ApiInterface {
|
||||
|
||||
@GET("top250_min.json")
|
||||
fun getTop250Movies(): Flow<Resource<List<Movie>>>
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.theapache64.topcorn.data.remote
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import com.squareup.moshi.Json
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
@Entity(
|
||||
tableName = "movies",
|
||||
indices = [
|
||||
Index("imdbUrl", unique = true)
|
||||
]
|
||||
)
|
||||
data class Movie(
|
||||
@Json(name = "actors")
|
||||
val actors: List<String>,
|
||||
@Json(name = "desc")
|
||||
val desc: String, // Yôjinbô is a movie starring Toshirô Mifune, Eijirô Tôno, and Tatsuya Nakadai. A crafty ronin comes to a town divided by two criminal gangs and decides to play them against each other to free the town.
|
||||
@Json(name = "directors")
|
||||
val directors: List<String>,
|
||||
@Json(name = "genre")
|
||||
val genre: List<String>,
|
||||
@Json(name = "image_url")
|
||||
val imageUrl: String, // https://m.media-amazon.com/images/M/MV5BZThiZjAzZjgtNDU3MC00YThhLThjYWUtZGRkYjc2ZWZlOTVjXkEyXkFqcGdeQXVyNTA4NzY1MzY@._V1_.jpg
|
||||
@Json(name = "thumb_url")
|
||||
val thumbUrl: String,
|
||||
@Json(name = "imdb_url")
|
||||
val imdbUrl: String, // /title/tt0055630/
|
||||
@Json(name = "name")
|
||||
val name: String, // Yôjinbô
|
||||
@Json(name = "rating")
|
||||
val rating: Float // 8.2
|
||||
) : Serializable {
|
||||
@PrimaryKey(autoGenerate = true)
|
||||
@ColumnInfo(name = "id")
|
||||
var id: Long = 0
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.theapache64.topcorn.data.repositories
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import com.theapache64.topcorn.data.local.daos.MoviesDao
|
||||
import com.theapache64.topcorn.data.remote.ApiInterface
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import com.theapache64.topcorn.utils.NetworkBoundResource
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.ExperimentalTime
|
||||
import kotlin.time.hours
|
||||
|
||||
class MoviesRepo @Inject constructor(
|
||||
private val sharedPref: SharedPreferences,
|
||||
private val apiInterface: ApiInterface,
|
||||
private val moviesDao: MoviesDao
|
||||
) {
|
||||
companion object {
|
||||
@ExperimentalTime
|
||||
private val MOVIE_EXPIRY_IN_MILLIS = 1.hours.inMilliseconds.toLong()
|
||||
private const val KEY_LAST_SYNCED = "last_synced"
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@ExperimentalTime
|
||||
fun getTop250Movies(): Flow<Resource<List<Movie>>> {
|
||||
|
||||
return object : NetworkBoundResource<List<Movie>, List<Movie>>() {
|
||||
|
||||
override fun fetchFromLocal(): Flow<List<Movie>> {
|
||||
return moviesDao.getAllMovies()
|
||||
}
|
||||
|
||||
override fun fetchFromRemote(): Flow<Resource<List<Movie>>> {
|
||||
return apiInterface.getTop250Movies()
|
||||
}
|
||||
|
||||
override fun saveRemoteData(data: List<Movie>) {
|
||||
moviesDao.deleteAll()
|
||||
moviesDao.addAll(data)
|
||||
sharedPref.edit {
|
||||
putLong(KEY_LAST_SYNCED, System.currentTimeMillis())
|
||||
}
|
||||
}
|
||||
|
||||
override fun shouldFetchFromRemote(data: List<Movie>): Boolean {
|
||||
val lastSynced = sharedPref.getLong(KEY_LAST_SYNCED, -1)
|
||||
return lastSynced == -1L ||
|
||||
data.isNullOrEmpty() ||
|
||||
isExpired(lastSynced)
|
||||
}
|
||||
|
||||
}.asFlow()
|
||||
.flowOn(Dispatchers.IO)
|
||||
}
|
||||
|
||||
@ExperimentalTime
|
||||
private fun isExpired(lastSynced: Long): Boolean {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
return (currentTime - lastSynced) >= MOVIE_EXPIRY_IN_MILLIS
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.theapache64.topcorn.di.components
|
||||
|
||||
import com.theapache64.topcorn.App
|
||||
import com.theapache64.topcorn.di.modules.AppModule
|
||||
import dagger.Component
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
||||
@Singleton
|
||||
@Component(
|
||||
modules = [
|
||||
AppModule::class
|
||||
]
|
||||
)
|
||||
interface AppComponent {
|
||||
// inject the above given modules into this App class
|
||||
fun inject(app: App)
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.theapache64.topcorn.di.modules
|
||||
|
||||
|
||||
import com.theapache64.topcorn.ui.activities.feed.FeedActivity
|
||||
import com.theapache64.topcorn.ui.activities.movie.MovieActivity
|
||||
import com.theapache64.topcorn.ui.activities.splash.SplashActivity
|
||||
import dagger.Module
|
||||
import dagger.android.ContributesAndroidInjector
|
||||
|
||||
/**
|
||||
* To hold activities to support AndroidInjection call from dagger.
|
||||
*/
|
||||
@Module
|
||||
abstract class ActivitiesBuilderModule {
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract fun getSplashActivity(): SplashActivity
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract fun getMainActivity(): FeedActivity
|
||||
|
||||
@ContributesAndroidInjector
|
||||
abstract fun getMovieActivity(): MovieActivity
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.theapache64.topcorn.di.modules
|
||||
|
||||
import android.app.Application
|
||||
import com.theapache64.twinkill.di.modules.PreferenceModule
|
||||
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.android.support.AndroidSupportInjectionModule
|
||||
|
||||
@Module(
|
||||
includes = [
|
||||
AndroidSupportInjectionModule::class,
|
||||
NetworkModule::class,
|
||||
DatabaseModule::class,
|
||||
ViewModelModule::class,
|
||||
PreferenceModule::class,
|
||||
ActivitiesBuilderModule::class
|
||||
]
|
||||
)
|
||||
class AppModule(private val application: Application) {
|
||||
|
||||
@Provides
|
||||
fun provideApplication(): Application {
|
||||
return this.application
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.theapache64.topcorn.di.modules
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Room
|
||||
import com.theapache64.topcorn.data.local.AppDatabase
|
||||
import com.theapache64.twinkill.di.modules.ContextModule
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
|
||||
@Module(includes = [ContextModule::class])
|
||||
class DatabaseModule {
|
||||
|
||||
@Provides
|
||||
fun provideAppDatabase(context: Context): AppDatabase {
|
||||
return Room.databaseBuilder(context, AppDatabase::class.java, "com.theapache64.topcorn_db")
|
||||
.build()
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun provideMovieDao(appDatabase: AppDatabase) = appDatabase.movieDao()
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.theapache64.topcorn.di.modules
|
||||
|
||||
import com.theapache64.topcorn.data.remote.ApiInterface
|
||||
import com.theapache64.twinkill.network.di.modules.BaseNetworkModule
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import retrofit2.Retrofit
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* To hold all network related objects.
|
||||
*/
|
||||
@Module(includes = [BaseNetworkModule::class])
|
||||
class NetworkModule {
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
fun provideApiInterface(retrofit: Retrofit): ApiInterface {
|
||||
return retrofit.create(ApiInterface::class.java)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.theapache64.topcorn.di.modules
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.theapache64.topcorn.ui.activities.feed.FeedViewModel
|
||||
import com.theapache64.topcorn.ui.activities.movie.MovieViewModel
|
||||
import com.theapache64.topcorn.ui.activities.splash.SplashViewModel
|
||||
import com.theapache64.twinkill.di.modules.BaseViewModelModule
|
||||
import com.theapache64.twinkill.utils.viewmodel.ViewModelKey
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.multibindings.IntoMap
|
||||
|
||||
|
||||
@Module(includes = [BaseViewModelModule::class])
|
||||
abstract class ViewModelModule {
|
||||
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ViewModelKey(SplashViewModel::class)
|
||||
abstract fun bindSplashViewModel(viewModel: SplashViewModel): ViewModel
|
||||
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ViewModelKey(FeedViewModel::class)
|
||||
abstract fun bindMainViewModel(viewModel: FeedViewModel): ViewModel
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@ViewModelKey(MovieViewModel::class)
|
||||
abstract fun bindMovieViewModel(viewModel: MovieViewModel): ViewModel
|
||||
|
||||
}
|
10
app/src/main/java/com/theapache64/topcorn/models/FeedItem.kt
Normal file
@ -0,0 +1,10 @@
|
||||
package com.theapache64.topcorn.models
|
||||
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
|
||||
|
||||
class FeedItem(
|
||||
val id: Long,
|
||||
val genre: String,
|
||||
val movies: List<Movie>
|
||||
)
|
@ -0,0 +1,131 @@
|
||||
package com.theapache64.topcorn.ui.activities.feed
|
||||
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.core.app.ActivityOptionsCompat
|
||||
import androidx.core.util.Pair
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.theapache64.topcorn.R
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import com.theapache64.topcorn.databinding.ActivityFeedBinding
|
||||
import com.theapache64.topcorn.ui.activities.movie.MovieActivity
|
||||
import com.theapache64.topcorn.ui.adapters.FeedAdapter
|
||||
import com.theapache64.topcorn.ui.adapters.MoviesAdapter
|
||||
import com.theapache64.twinkill.logger.info
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import com.theapache64.twinkill.ui.activities.base.BaseAppCompatActivity
|
||||
import com.theapache64.twinkill.utils.extensions.bindContentView
|
||||
import dagger.android.AndroidInjection
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
class FeedActivity : BaseAppCompatActivity(), FeedHandler {
|
||||
|
||||
companion object {
|
||||
|
||||
fun getStartIntent(context: Context): Intent {
|
||||
return Intent(context, FeedActivity::class.java).apply {
|
||||
// add data here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
lateinit var factory: ViewModelProvider.Factory
|
||||
private lateinit var viewModel: FeedViewModel
|
||||
|
||||
@ExperimentalTime
|
||||
@ExperimentalCoroutinesApi
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val binding = bindContentView<ActivityFeedBinding>(R.layout.activity_feed)
|
||||
|
||||
this.viewModel = ViewModelProvider(this, factory).get(FeedViewModel::class.java)
|
||||
this.viewModel.movies.observe(this, Observer {
|
||||
|
||||
when (it.status) {
|
||||
|
||||
Resource.Status.LOADING -> {
|
||||
binding.lvFeed.showLoading("Fetching movies..")
|
||||
binding.rvFeed.visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
Resource.Status.SUCCESS -> {
|
||||
binding.lvFeed.hideLoading()
|
||||
binding.rvFeed.visibility = View.VISIBLE
|
||||
|
||||
val adapter = FeedAdapter(this, it.data!!, { movies ->
|
||||
MoviesAdapter(this, movies) { position, poster, title ->
|
||||
info("Movie clicked $position")
|
||||
val movie = movies[position]
|
||||
goToMovieActivity(movie, poster, title)
|
||||
}.apply {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
}) { position ->
|
||||
info("Feed item clicked $position")
|
||||
}.apply {
|
||||
setHasStableIds(true)
|
||||
}
|
||||
|
||||
binding.rvFeed.adapter = adapter
|
||||
}
|
||||
|
||||
Resource.Status.ERROR -> {
|
||||
binding.lvFeed.showError(it.message!!)
|
||||
binding.rvFeed.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
viewModel.darkMode.observe(this, Observer { isDarkMode ->
|
||||
|
||||
val darkModeFlag = if (isDarkMode) {
|
||||
AppCompatDelegate.MODE_NIGHT_YES
|
||||
} else {
|
||||
AppCompatDelegate.MODE_NIGHT_NO
|
||||
}
|
||||
|
||||
AppCompatDelegate.setDefaultNightMode(darkModeFlag)
|
||||
})
|
||||
|
||||
binding.viewModel = viewModel
|
||||
binding.handler = this
|
||||
}
|
||||
|
||||
private fun goToMovieActivity(
|
||||
movie: Movie,
|
||||
mcvPoster: View,
|
||||
tvTitle: View
|
||||
) {
|
||||
val transition = ActivityOptionsCompat.makeSceneTransitionAnimation(
|
||||
this,
|
||||
Pair(tvTitle, "title"),
|
||||
Pair(mcvPoster, "poster")
|
||||
)
|
||||
startActivity(MovieActivity.getStartIntent(this, movie), transition.toBundle())
|
||||
}
|
||||
|
||||
override fun onToggleDarkModeClicked() {
|
||||
viewModel.toggleDarkMode()
|
||||
}
|
||||
|
||||
override fun onHeartClicked() {
|
||||
// goto github page ;)
|
||||
val intent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("https://github.com/theapache64/topcorn")
|
||||
)
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.theapache64.topcorn.ui.activities.feed
|
||||
|
||||
interface FeedHandler {
|
||||
fun onToggleDarkModeClicked()
|
||||
fun onHeartClicked()
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.theapache64.topcorn.ui.activities.feed
|
||||
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import com.theapache64.topcorn.data.repositories.MoviesRepo
|
||||
import com.theapache64.topcorn.models.FeedItem
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import com.theapache64.twinkill.utils.livedata.SingleLiveEvent
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.map
|
||||
import javax.inject.Inject
|
||||
import kotlin.time.ExperimentalTime
|
||||
|
||||
class FeedViewModel @Inject constructor(
|
||||
moviesRepo: MoviesRepo
|
||||
) : ViewModel() {
|
||||
|
||||
@ExperimentalTime
|
||||
@ExperimentalCoroutinesApi
|
||||
val movies: LiveData<Resource<List<FeedItem>>> = moviesRepo
|
||||
.getTop250Movies()
|
||||
.map {
|
||||
when (it.status) {
|
||||
Resource.Status.LOADING -> {
|
||||
Resource.loading()
|
||||
}
|
||||
Resource.Status.SUCCESS -> {
|
||||
val movies = it.data!!
|
||||
val feedItems = convertToFeed(movies)
|
||||
Resource.success(feedItems)
|
||||
}
|
||||
|
||||
Resource.Status.ERROR -> {
|
||||
Resource.error(it.message!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
.asLiveData(viewModelScope.coroutineContext + Dispatchers.Default)
|
||||
|
||||
private fun convertToFeed(movies: List<Movie>): List<FeedItem> {
|
||||
|
||||
val genreSet = mutableSetOf<String>()
|
||||
for (movie in movies) {
|
||||
for (genre in movie.genre) {
|
||||
genreSet.add(genre)
|
||||
}
|
||||
}
|
||||
val feedItems = mutableListOf<FeedItem>()
|
||||
for ((index, genre) in genreSet.withIndex()) {
|
||||
val genreMovies = movies
|
||||
.filter { it.genre.contains(genre) }
|
||||
feedItems.add(FeedItem(index.toLong(), genre, genreMovies.shuffled()))
|
||||
}
|
||||
return feedItems
|
||||
}
|
||||
|
||||
private val _darkMode = SingleLiveEvent<Boolean>()
|
||||
val darkMode: LiveData<Boolean> = _darkMode
|
||||
|
||||
fun toggleDarkMode() {
|
||||
val newDarkMode = !(darkMode.value ?: false)
|
||||
_darkMode.value = newDarkMode
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package com.theapache64.topcorn.ui.activities.movie
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.theapache64.topcorn.R
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import com.theapache64.topcorn.databinding.ActivityMovieBinding
|
||||
import com.theapache64.twinkill.ui.activities.base.BaseAppCompatActivity
|
||||
import com.theapache64.twinkill.utils.extensions.bindContentView
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class MovieActivity : BaseAppCompatActivity(), MovieHandler {
|
||||
|
||||
companion object {
|
||||
private const val KEY_MOVIE = "movie"
|
||||
fun getStartIntent(context: Context, movie: Movie): Intent {
|
||||
return Intent(context, MovieActivity::class.java).apply {
|
||||
// data goes here
|
||||
putExtra(KEY_MOVIE, movie)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Inject
|
||||
lateinit var factory: ViewModelProvider.Factory
|
||||
|
||||
private lateinit var binding: ActivityMovieBinding
|
||||
private lateinit var viewModel: MovieViewModel
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
binding = bindContentView(R.layout.activity_movie)
|
||||
|
||||
viewModel = ViewModelProvider(this, factory).get(MovieViewModel::class.java)
|
||||
val movie = intent.getSerializableExtra(KEY_MOVIE) as Movie
|
||||
viewModel.init(movie)
|
||||
|
||||
binding.handler = this
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
override fun onBackButtonClicked() {
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onGoToImdbClicked() {
|
||||
val intent = Intent(
|
||||
Intent.ACTION_VIEW,
|
||||
Uri.parse("https://imdb.com${viewModel.movie!!.imdbUrl}")
|
||||
)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
package com.theapache64.topcorn.ui.activities.movie
|
||||
|
||||
interface MovieHandler {
|
||||
fun onBackButtonClicked()
|
||||
fun onGoToImdbClicked()
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.theapache64.topcorn.ui.activities.movie
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import javax.inject.Inject
|
||||
|
||||
class MovieViewModel @Inject constructor() : ViewModel() {
|
||||
fun init(movie: Movie) {
|
||||
this.movie = movie
|
||||
}
|
||||
|
||||
var movie: Movie? = null
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.theapache64.topcorn.ui.activities.splash
|
||||
|
||||
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.theapache64.topcorn.R
|
||||
import com.theapache64.topcorn.databinding.ActivitySplashBinding
|
||||
import com.theapache64.topcorn.ui.activities.feed.FeedActivity
|
||||
import com.theapache64.twinkill.ui.activities.base.BaseAppCompatActivity
|
||||
import com.theapache64.twinkill.utils.extensions.bindContentView
|
||||
import dagger.android.AndroidInjection
|
||||
import javax.inject.Inject
|
||||
|
||||
class SplashActivity : BaseAppCompatActivity() {
|
||||
|
||||
@Inject
|
||||
lateinit var factory: ViewModelProvider.Factory
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
AndroidInjection.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val binding = bindContentView<ActivitySplashBinding>(R.layout.activity_splash)
|
||||
val viewModel = ViewModelProvider(this, factory).get(SplashViewModel::class.java)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// Watching activity launch command
|
||||
viewModel.getLaunchActivityEvent().observe(this, Observer { activityName ->
|
||||
|
||||
when (activityName) {
|
||||
|
||||
FeedActivity::class.simpleName -> {
|
||||
startActivity(FeedActivity.getStartIntent(this))
|
||||
}
|
||||
|
||||
else -> throw IllegalArgumentException("Undefined activity id $activityName")
|
||||
}
|
||||
|
||||
finish()
|
||||
|
||||
})
|
||||
|
||||
// Starting splash timer
|
||||
Handler().postDelayed({
|
||||
viewModel.goToNextScreen()
|
||||
}, SPLASH_DURATION)
|
||||
|
||||
}
|
||||
|
||||
|
||||
companion object {
|
||||
private const val SPLASH_DURATION = 1000L
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.theapache64.topcorn.ui.activities.splash
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.theapache64.topcorn.BuildConfig
|
||||
import com.theapache64.topcorn.ui.activities.feed.FeedActivity
|
||||
import com.theapache64.twinkill.utils.livedata.SingleLiveEvent
|
||||
import javax.inject.Inject
|
||||
|
||||
class SplashViewModel @Inject constructor(
|
||||
|
||||
) : ViewModel() {
|
||||
|
||||
val versionName = "v${BuildConfig.VERSION_NAME}"
|
||||
|
||||
private val launchActivityEvent = SingleLiveEvent<String>()
|
||||
|
||||
fun getLaunchActivityEvent(): LiveData<String> {
|
||||
return launchActivityEvent
|
||||
}
|
||||
|
||||
fun goToNextScreen() {
|
||||
|
||||
val activityName = FeedActivity::class.simpleName
|
||||
|
||||
// passing id with the finish notification
|
||||
launchActivityEvent.value = activityName
|
||||
}
|
||||
|
||||
companion object {
|
||||
val TAG = SplashViewModel::class.java.simpleName
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.theapache64.topcorn.ui.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import com.theapache64.topcorn.databinding.ItemFeedBinding
|
||||
import com.theapache64.topcorn.models.FeedItem
|
||||
|
||||
class FeedAdapter(
|
||||
context: Context,
|
||||
private val feedItems: List<FeedItem>,
|
||||
private val getMoviesAdapter: (List<Movie>) -> MoviesAdapter,
|
||||
private val callback: (position: Int) -> Unit
|
||||
) : RecyclerView.Adapter<FeedAdapter.ViewHolder>() {
|
||||
|
||||
private val inflater = LayoutInflater.from(context)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val binding = ItemFeedBinding.inflate(inflater, parent, false)
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = feedItems.size
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return feedItems[position].id
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val feed = feedItems[position]
|
||||
holder.binding.feed = feed
|
||||
val adapter = getMoviesAdapter(feed.movies)
|
||||
holder.binding.rvMovies.adapter = adapter
|
||||
}
|
||||
|
||||
inner class ViewHolder(val binding: ItemFeedBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
binding.root.setOnClickListener {
|
||||
callback(layoutPosition)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.theapache64.topcorn.ui.adapters
|
||||
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.theapache64.topcorn.data.remote.Movie
|
||||
import com.theapache64.topcorn.databinding.ItemMovieBinding
|
||||
|
||||
class MoviesAdapter(
|
||||
private val context: Context,
|
||||
private val movies: List<Movie>,
|
||||
private val callback: (position: Int, mcvPoster: MaterialCardView, tvTitle: TextView) -> Unit
|
||||
) : RecyclerView.Adapter<MoviesAdapter.ViewHolder>() {
|
||||
|
||||
private val inflater = LayoutInflater.from(context)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||
val binding = ItemMovieBinding.inflate(inflater, parent, false)
|
||||
return ViewHolder(binding)
|
||||
}
|
||||
|
||||
override fun getItemId(position: Int): Long {
|
||||
return movies[position].id
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = movies.size
|
||||
|
||||
|
||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||
val movie = movies[position]
|
||||
holder.binding.movie = movie
|
||||
}
|
||||
|
||||
inner class ViewHolder(val binding: ItemMovieBinding) : RecyclerView.ViewHolder(binding.root) {
|
||||
init {
|
||||
binding.root.setOnClickListener {
|
||||
callback(layoutPosition, binding.mcvPoster, binding.tvTitle)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.theapache64.topcorn.utils
|
||||
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.BindingAdapter
|
||||
|
||||
@BindingAdapter("textList")
|
||||
fun setTextList(textView: TextView, list: List<String>) {
|
||||
textView.text = list.joinToString(",")
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.theapache64.topcorn.utils
|
||||
|
||||
import androidx.annotation.MainThread
|
||||
import androidx.annotation.WorkerThread
|
||||
import com.theapache64.twinkill.logger.debug
|
||||
import com.theapache64.twinkill.logger.info
|
||||
import com.theapache64.twinkill.logger.mistake
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
/**
|
||||
* A super cool utility class to provide controlled data cache-ing
|
||||
*/
|
||||
abstract class NetworkBoundResource<DB, REMOTE> {
|
||||
|
||||
@MainThread
|
||||
abstract fun fetchFromLocal(): Flow<DB>
|
||||
|
||||
@MainThread
|
||||
abstract fun fetchFromRemote(): Flow<Resource<REMOTE>>
|
||||
|
||||
@WorkerThread
|
||||
abstract fun saveRemoteData(data: REMOTE)
|
||||
|
||||
@MainThread
|
||||
abstract fun shouldFetchFromRemote(data: DB): Boolean
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
fun asFlow() = flow<Resource<DB>> {
|
||||
|
||||
debug("----------------------")
|
||||
debug("Starting...")
|
||||
|
||||
// sending loading status
|
||||
debug("Sending loading...")
|
||||
emit(Resource.loading())
|
||||
|
||||
val localData = fetchFromLocal().first()
|
||||
|
||||
// checking if local data is staled
|
||||
if (shouldFetchFromRemote(localData)) {
|
||||
|
||||
debug("Fetching from remote")
|
||||
// need remote data
|
||||
fetchFromRemote()
|
||||
.collect { response ->
|
||||
when (response.status) {
|
||||
|
||||
Resource.Status.LOADING -> {
|
||||
debug("Remote is loading")
|
||||
emit(Resource.loading())
|
||||
}
|
||||
|
||||
Resource.Status.SUCCESS -> {
|
||||
info("Remote got data")
|
||||
val data = response.data!!
|
||||
saveRemoteData(data)
|
||||
|
||||
// start watching it
|
||||
emitLocalDbData()
|
||||
}
|
||||
|
||||
|
||||
Resource.Status.ERROR -> {
|
||||
mistake("Remote met with an error")
|
||||
emit(Resource.error(response.message!!))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
info("Fetching from local")
|
||||
// valid cache, no need to fetch from remote.
|
||||
emitLocalDbData()
|
||||
}
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
private suspend fun FlowCollector<Resource<DB>>.emitLocalDbData() {
|
||||
info("Sending local data to UI")
|
||||
emitAll(fetchFromLocal().map { dbData ->
|
||||
info("Sending local...")
|
||||
Resource.success(dbData)
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.theapache64.topcorn.utils.retrofit
|
||||
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import retrofit2.Call
|
||||
import retrofit2.CallAdapter
|
||||
import retrofit2.awaitResponse
|
||||
import java.lang.reflect.Type
|
||||
|
||||
/**
|
||||
* To convert retrofit response to Flow<Resource<T>>.
|
||||
* Inspired from FlowCallAdapterFactory
|
||||
*/
|
||||
class FlowResourceCallAdapter<R>(
|
||||
private val responseType: Type,
|
||||
private val isNeedDeepCheck: Boolean,
|
||||
private val isSelfExceptionHandling: Boolean
|
||||
) : CallAdapter<R, Flow<Resource<R>>> {
|
||||
|
||||
override fun responseType() = responseType
|
||||
|
||||
override fun adapt(call: Call<R>): Flow<Resource<R>> = flow {
|
||||
|
||||
// Firing loading resource
|
||||
emit(Resource.loading())
|
||||
|
||||
try {
|
||||
val resp = call.awaitResponse()
|
||||
|
||||
if (resp.isSuccessful) {
|
||||
emit(Resource.create(resp, isNeedDeepCheck))
|
||||
} else {
|
||||
emit(Resource.create<R>(Throwable(resp.message())))
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
if (isSelfExceptionHandling) {
|
||||
emit(Resource.create<R>(e))
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.theapache64.topcorn.utils.retrofit
|
||||
|
||||
|
||||
import com.theapache64.twinkill.network.utils.Resource
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import retrofit2.CallAdapter
|
||||
import retrofit2.CallAdapter.Factory
|
||||
import retrofit2.Retrofit
|
||||
import java.lang.reflect.ParameterizedType
|
||||
import java.lang.reflect.Type
|
||||
|
||||
class FlowResourceCallAdapterFactory(
|
||||
private val isNeedDeepCheck: Boolean = false,
|
||||
private val isSelfExceptionHandling: Boolean = true
|
||||
) : Factory() {
|
||||
override fun get(
|
||||
returnType: Type,
|
||||
annotations: Array<Annotation>,
|
||||
retrofit: Retrofit
|
||||
): CallAdapter<*, *>? {
|
||||
if (getRawType(returnType) != Flow::class.java) {
|
||||
return null
|
||||
}
|
||||
val observableType = getParameterUpperBound(0, returnType as ParameterizedType)
|
||||
val rawObservableType = getRawType(observableType)
|
||||
require(rawObservableType == Resource::class.java) { "type must be a resource" }
|
||||
require(observableType is ParameterizedType) { "resource must be parameterized" }
|
||||
val bodyType = getParameterUpperBound(0, observableType)
|
||||
return FlowResourceCallAdapter<Any>(bodyType, isNeedDeepCheck, isSelfExceptionHandling)
|
||||
}
|
||||
}
|
33
app/src/main/res/drawable-night/ic_switch_dark_mode.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="470"
|
||||
android:viewportHeight="470">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m235,104.605c-72.016,0 -130.395,58.379 -130.395,130.395s58.379,130.395 130.395,130.395 130.395,-58.379 130.395,-130.395c-0.082,-71.98 -58.414,-130.313 -130.395,-130.395zM235,345.395c-60.969,0 -110.395,-49.426 -110.395,-110.395s49.426,-110.395 110.395,-110.395 110.395,49.426 110.395,110.395c-0.07,60.941 -49.453,110.324 -110.395,110.395zM235,345.395" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m245,61v-51c0,-5.523 -4.477,-10 -10,-10s-10,4.477 -10,10v51c0,5.523 4.477,10 10,10s10,-4.477 10,-10zM245,61" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m235,399c-5.523,0 -10,4.477 -10,10v51c0,5.523 4.477,10 10,10s10,-4.477 10,-10v-51c0,-5.523 -4.477,-10 -10,-10zM235,399" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m460,225h-51c-5.523,0 -10,4.477 -10,10s4.477,10 10,10h51c5.523,0 10,-4.477 10,-10s-4.477,-10 -10,-10zM460,225" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m71,235c0,-5.523 -4.477,-10 -10,-10h-51c-5.523,0 -10,4.477 -10,10s4.477,10 10,10h51c5.523,0 10,-4.477 10,-10zM71,235" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m365.258,118.883 l35.473,-35.473c3.879,-3.91 3.863,-10.219 -0.031,-14.109 -3.891,-3.895 -10.199,-3.91 -14.109,-0.031l-35.473,35.473c-2.543,2.52 -3.547,6.211 -2.625,9.676 0.926,3.461 3.629,6.164 7.09,7.09 3.465,0.922 7.156,-0.082 9.676,-2.625zM365.258,118.883" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m104.742,351.117 l-35.473,35.473c-2.547,2.523 -3.547,6.215 -2.625,9.676s3.629,6.168 7.09,7.09 7.152,-0.078 9.676,-2.625l35.473,-35.473c2.543,-2.52 3.547,-6.211 2.625,-9.676 -0.926,-3.461 -3.629,-6.164 -7.09,-7.09 -3.465,-0.922 -7.156,0.082 -9.676,2.625zM104.742,351.117" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m365.258,351.117c-2.52,-2.543 -6.211,-3.547 -9.676,-2.625 -3.461,0.926 -6.164,3.629 -7.09,7.09 -0.922,3.465 0.082,7.156 2.625,9.676l35.473,35.473c3.91,3.879 10.219,3.863 14.109,-0.031 3.895,-3.891 3.91,-10.199 0.031,-14.109zM365.258,351.117" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m104.742,118.883c2.52,2.543 6.211,3.547 9.676,2.625 3.461,-0.926 6.164,-3.629 7.09,-7.09 0.922,-3.465 -0.082,-7.156 -2.625,-9.676l-35.473,-35.473c-3.91,-3.879 -10.219,-3.863 -14.109,0.031 -3.895,3.891 -3.91,10.199 -0.031,14.109zM104.742,118.883" />
|
||||
</vector>
|
30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_back_arrow.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="64"
|
||||
android:viewportHeight="64">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m54,30h-39.899l15.278,-14.552c0.8,-0.762 0.831,-2.028 0.069,-2.828 -0.761,-0.799 -2.027,-0.831 -2.828,-0.069l-17.448,16.62c-0.755,0.756 -1.172,1.76 -1.172,2.829 0,1.068 0.417,2.073 1.207,2.862l17.414,16.586c0.387,0.369 0.883,0.552 1.379,0.552 0.528,0 1.056,-0.208 1.449,-0.621 0.762,-0.8 0.731,-2.065 -0.069,-2.827l-15.342,-14.552h39.962c1.104,0 2,-0.896 2,-2s-0.896,-2 -2,-2z" />
|
||||
</vector>
|
9
app/src/main/res/drawable/ic_heart.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="448"
|
||||
android:viewportHeight="448">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="m224,427.902c29.383,-16.215 224,-129.496 224,-282.902 0,-66.055 -54.199,-124 -116,-124 -41.867,0.074 -80.461,22.66 -101.031,59.129 -1.539,2.352 -4.16,3.766 -6.969,3.766s-5.43,-1.414 -6.969,-3.766c-20.57,-36.469 -59.164,-59.055 -101.031,-59.129 -61.801,0 -116,57.945 -116,124 0,153.406 194.617,266.688 224,282.902zM224,427.902" />
|
||||
</vector>
|
170
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,170 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M9,0L9,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,0L19,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,0L29,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,0L39,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,0L49,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,0L59,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,0L69,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,0L79,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M89,0L89,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M99,0L99,108"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,9L108,9"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,19L108,19"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,29L108,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,39L108,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,49L108,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,59L108,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,69L108,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,79L108,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,89L108,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M0,99L108,99"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,29L89,29"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,39L89,39"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,49L89,49"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,59L89,59"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,69L89,69"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M19,79L89,79"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M29,19L29,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M39,19L39,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M49,19L49,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M59,19L59,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M69,19L69,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
<path
|
||||
android:fillColor="#00000000"
|
||||
android:pathData="M79,19L79,89"
|
||||
android:strokeWidth="0.8"
|
||||
android:strokeColor="#33FFFFFF" />
|
||||
</vector>
|
129
app/src/main/res/drawable/ic_logo.xml
Normal file
@ -0,0 +1,129 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="100dp"
|
||||
android:height="100dp"
|
||||
android:viewportWidth="512"
|
||||
android:viewportHeight="512">
|
||||
<path
|
||||
android:fillColor="#ffcd01"
|
||||
android:pathData="m401.818,128.076a24,24 0,0 0,-33.874 -33.911,32 32,0 0,0 -48.379,-25.623 23.994,23.994 0,0 0,-40.777 -21.259,32 32,0 0,0 -62.435,3.97 31.991,31.991 0,0 0,-53.021 6.528,24 24,0 0,0 -41,24.554 24,24 0,0 0,-32.723 30.305,32 32,0 0,0 6.391,63.36h304a24,24 0,0 0,1.818 -47.924z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m401.818,128.076a24,24 0,0 0,-33.874 -33.911,31.965 31.965,0 0,0 -13.325,-24.191 581.066,581.066 0,0 1,-289.628 81.951,32.012 32.012,0 0,0 31.009,24.075h304a24,24 0,0 0,1.818 -47.924z" />
|
||||
<path
|
||||
android:fillColor="#e6e6e6"
|
||||
android:pathData="m128,440h240l40,-240h-320z" />
|
||||
<path
|
||||
android:fillColor="#d3d3d3"
|
||||
android:pathData="m343.064,200c-31.251,94.671 -120.422,163 -225.564,163 -0.782,0 -1.558,-0.022 -2.338,-0.03l12.838,77.03h240l40,-240z" />
|
||||
<path
|
||||
android:fillColor="#ff2b63"
|
||||
android:pathData="m216,200 l8,240h48l8,-240z" />
|
||||
<path
|
||||
android:fillColor="#e5235f"
|
||||
android:pathData="m220.65,339.489 l3.35,100.511h48l4.606,-138.18a237.938,237.938 0,0 1,-55.956 37.669z" />
|
||||
<path
|
||||
android:fillColor="#e5235f"
|
||||
android:pathData="m344,200 l-24,240h48l40,-240z" />
|
||||
<path
|
||||
android:fillColor="#48bdff"
|
||||
android:pathData="m280,464v-64a24,24 0,0 1,-24 -24h-208a24,24 0,0 1,-24 24v64a24,24 0,0 1,24 24h208a24,24 0,0 1,24 -24z" />
|
||||
<path
|
||||
android:fillColor="#3ba4f2"
|
||||
android:pathData="m256,376h-40.706a159.164,159.164 0,0 1,-191.294 80.294v7.706a24,24 0,0 1,24 24h208a24,24 0,0 1,24 -24v-64a24,24 0,0 1,-24 -24z" />
|
||||
<path
|
||||
android:fillColor="#ff2b63"
|
||||
android:pathData="m88,200 l40,240h48l-24,-240z" />
|
||||
<path
|
||||
android:fillColor="#e5235f"
|
||||
android:pathData="m117.5,363c-0.782,0 -1.558,-0.022 -2.338,-0.03l12.838,77.03h48l-8.235,-82.348a238.371,238.371 0,0 1,-50.265 5.348z" />
|
||||
<path
|
||||
android:fillColor="#b3b3b3"
|
||||
android:pathData="M88,168L408,168A16,16 0,0 1,424 184L424,184A16,16 0,0 1,408 200L88,200A16,16 0,0 1,72 184L72,184A16,16 0,0 1,88 168z" />
|
||||
<path
|
||||
android:fillColor="#ff891f"
|
||||
android:pathData="M368,136m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff891f"
|
||||
android:pathData="M320,120m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff9f03"
|
||||
android:pathData="M272,88m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff891f"
|
||||
android:pathData="M264,136m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff9f03"
|
||||
android:pathData="M224,96m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff9f03"
|
||||
android:pathData="M192,80m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff9f03"
|
||||
android:pathData="M160,104m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff9f03"
|
||||
android:pathData="M192,128m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#ff9f03"
|
||||
android:pathData="M120,136m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#e6e6e6"
|
||||
android:pathData="m88,376h128v112h-128z" />
|
||||
<path
|
||||
android:fillColor="#fdc47d"
|
||||
android:pathData="M56,432m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
<path
|
||||
android:fillColor="#703f16"
|
||||
android:pathData="m464,488h-112l-24,-216h160z" />
|
||||
<path
|
||||
android:fillColor="#ffcd01"
|
||||
android:pathData="m472,64a23.948,23.948 0,0 0,-8.928 -18.672,16 16,0 1,0 -30.144,0 24,24 0,0 0,24.3 40.829,16 16,0 1,0 14.772,-22.157z" />
|
||||
<path
|
||||
android:fillColor="#3bdabe"
|
||||
android:pathData="m485.657,146.343a8,8 0,0 0,-11.314 0l-32,32a8,8 0,0 0,-2.343 5.657v88a8,8 0,0 0,16 0v-84.687l29.657,-29.656a8,8 0,0 0,0 -11.314z" />
|
||||
<path
|
||||
android:fillColor="#ffcd01"
|
||||
android:pathData="m456,408c5.668,0 11.307,-0.125 16.926,-0.331l2.316,-20.846a452.791,452.791 0,0 1,-139.491 -45.065l5.749,51.732a456.78,456.78 0,0 0,114.5 14.51z" />
|
||||
<path
|
||||
android:fillColor="#ffcd01"
|
||||
android:pathData="m72,56c0,-0.708 -0.037,-1.407 -0.1,-2.1a15.993,15.993 0,1 0,-21.8 -21.8c-0.692,-0.06 -1.391,-0.1 -2.1,-0.1a24,24 0,1 0,24 24z" />
|
||||
<path
|
||||
android:fillColor="#ffcd01"
|
||||
android:pathData="m72,312c-0.455,0 -0.9,0.031 -1.348,0.068a23.938,23.938 0,0 0,-2.731 -5.422,15.993 15.993,0 1,0 -27.921,-10.646c0,0.455 0.031,0.9 0.068,1.348a24,24 0,1 0,21.3 42.586,15.993 15.993,0 1,0 10.632,-27.934z" />
|
||||
<path
|
||||
android:fillColor="#d3d3d3"
|
||||
android:pathData="m88,463.291v24.709h128v-112h-0.706a159.069,159.069 0,0 1,-127.294 87.291z" />
|
||||
<path
|
||||
android:fillColor="#fdc47d"
|
||||
android:pathData="m176,400h-48a8,8 0,0 0,0 16h16v40a8,8 0,0 0,16 0v-40h16a8,8 0,0 0,0 -16z" />
|
||||
<path
|
||||
android:fillColor="#603813"
|
||||
android:pathData="m329.778,288h156.444l1.778,-16h-160z" />
|
||||
<path
|
||||
android:fillColor="#b3b3b3"
|
||||
android:pathData="M336,248L480,248A16,16 0,0 1,496 264L496,264A16,16 0,0 1,480 280L336,280A16,16 0,0 1,320 264L320,264A16,16 0,0 1,336 248z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m80,40a15.99,15.99 0,0 0,-9.425 -14.575,15.954 15.954,0 0,1 -6.675,20.475c0.06,0.692 0.1,1.391 0.1,2.1a24,24 0,0 1,-36.494 20.494,24 24,0 0,0 44.494,-12.494c0,-0.708 -0.037,-1.407 -0.1,-2.1a15.985,15.985 0,0 0,8.1 -13.9z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m456,32a15.942,15.942 0,0 1,-0.928 5.328,23.948 23.948,0 0,1 8.928,18.672 15.914,15.914 0,0 1,7.156 1.7,24.02 24.02,0 0,0 -8.084,-12.376 15.935,15.935 0,0 0,-8.5 -19.9,15.9 15.9,0 0,1 1.428,6.576z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m478.575,65.425a15.985,15.985 0,0 1,-21.149 21.155,15.993 15.993,0 1,0 21.149,-21.155z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m449.232,78.157a24.027,24.027 0,0 1,-21.726 -1.663,23.992 23.992,0 0,0 29.34,9.813 16.053,16.053 0,0 1,-7.614 -8.15z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m64,288a15.92,15.92 0,0 1,-4.079 10.646,23.938 23.938,0 0,1 2.731,5.422c0.445,-0.037 0.893,-0.068 1.348,-0.068a15.935,15.935 0,0 1,5.259 0.9,15.933 15.933,0 0,0 -6.684,-23.478 15.9,15.9 0,0 1,1.425 6.578z" />
|
||||
<path
|
||||
android:fillColor="#ffba01"
|
||||
android:pathData="m78.575,313.425a15.981,15.981 0,0 1,-25.207 18.509,24.011 24.011,0 0,1 -25.862,0.56 24.006,24.006 0,0 0,33.862 7.44,15.988 15.988,0 1,0 17.207,-26.509z" />
|
||||
<path
|
||||
android:fillColor="#fcae60"
|
||||
android:pathData="m152,464a8,8 0,0 0,8 -8v-17.915a158.75,158.75 0,0 1,-16 9.188v8.727a8,8 0,0 0,8 8z" />
|
||||
<path
|
||||
android:fillColor="#fdc47d"
|
||||
android:pathData="M248,432m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
|
||||
</vector>
|
27
app/src/main/res/drawable/ic_switch_dark_mode.xml
Normal file
@ -0,0 +1,27 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="16dp"
|
||||
android:height="16dp"
|
||||
android:viewportWidth="512"
|
||||
android:viewportHeight="512">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M503.686,326.871c-7.932,-6.33 -19.109,-6.452 -27.18,-0.29c-35.597,27.194 -78.143,41.567 -123.041,41.567c-12.218,0 -24.465,-1.1 -36.401,-3.268c-4.761,-0.868 -9.317,2.291 -10.181,7.051c-0.865,4.758 2.292,9.317 7.051,10.181c12.966,2.356 26.266,3.55 39.53,3.55c48.774,0 94.997,-15.617 133.671,-45.162c1.67,-1.276 3.982,-1.25 5.624,0.059c1.641,1.31 2.176,3.559 1.303,5.469c-19.069,41.693 -49.47,77.047 -87.915,102.238c-39.456,25.851 -85.352,39.517 -132.724,39.517c-133.718,0 -242.506,-108.788 -242.506,-242.506c0,-47.375 13.665,-93.27 39.517,-132.723c25.191,-38.447 60.544,-68.847 102.242,-87.917c1.908,-0.874 4.152,-0.337 5.462,1.305c1.309,1.641 1.336,3.953 0.061,5.621c-29.546,38.68 -45.163,84.903 -45.163,133.673c0,47.23 14.783,92.296 42.752,130.328c27.397,37.254 64.95,64.578 108.6,79.017c4.595,1.516 9.545,-0.974 11.065,-5.564c1.518,-4.592 -0.973,-9.547 -5.564,-11.065c-83.343,-27.567 -139.338,-105.013 -139.338,-192.715c0,-44.895 14.374,-87.442 41.567,-123.042c6.163,-8.068 6.042,-19.244 -0.292,-27.179c-6.337,-7.94 -17.215,-10.527 -26.439,-6.304c-44.699,20.442 -82.6,53.032 -109.603,94.242c-27.727,42.313 -42.382,91.528 -42.382,142.323c0,143.376 116.646,260.021 260.021,260.021c50.792,0 100.007,-14.655 142.324,-42.382c41.209,-27.003 73.8,-64.903 94.245,-109.603C514.213,344.081 511.622,333.208 503.686,326.871z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M251.454,164.085c20.691,0 37.526,16.834 37.526,37.525c0,4.836 3.921,8.757 8.757,8.757s8.757,-3.921 8.757,-8.757c0,-20.691 16.834,-37.525 37.525,-37.525c4.836,0 8.757,-3.921 8.757,-8.757c0,-4.836 -3.921,-8.757 -8.757,-8.757c-20.691,0 -37.525,-16.835 -37.525,-37.526c0,-4.836 -3.921,-8.757 -8.757,-8.757s-8.757,3.921 -8.757,8.757c0,20.691 -16.835,37.526 -37.526,37.526c-4.836,0 -8.757,3.921 -8.757,8.757C242.697,160.164 246.618,164.085 251.454,164.085zM297.737,138.804c4.267,6.614 9.909,12.256 16.523,16.524c-6.614,4.267 -12.255,9.909 -16.523,16.523c-4.267,-6.614 -9.91,-12.255 -16.524,-16.523C287.827,151.061 293.47,145.418 297.737,138.804z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M375.404,276.696c15.022,0 27.244,-12.221 27.244,-27.242c0,-15.022 -12.222,-27.244 -27.244,-27.244s-27.243,12.222 -27.243,27.244C348.163,264.475 360.383,276.696 375.404,276.696zM375.404,239.726c5.364,0 9.729,4.364 9.729,9.729c0,5.363 -4.364,9.727 -9.729,9.727s-9.728,-4.363 -9.728,-9.727C365.677,244.09 370.04,239.726 375.404,239.726z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M40.451,436.768c-15.022,0 -27.243,12.221 -27.243,27.243c0,15.022 12.221,27.244 27.243,27.244c15.022,0 27.243,-12.222 27.243,-27.244C67.694,448.989 55.473,436.768 40.451,436.768zM40.451,473.739c-5.364,0 -9.728,-4.364 -9.728,-9.729c0,-5.365 4.364,-9.727 9.728,-9.727s9.728,4.363 9.728,9.728C50.179,469.375 45.816,473.739 40.451,473.739z" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M297.736,260.44m-10.979,0a10.979,10.979 0,1 1,21.958 0a10.979,10.979 0,1 1,-21.958 0" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M10.979,392.27m-10.979,0a10.979,10.979 0,1 1,21.958 0a10.979,10.979 0,1 1,-21.958 0" />
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M368.144,90.735m-10.979,0a10.979,10.979 0,1 1,21.958 0a10.979,10.979 0,1 1,-21.958 0" />
|
||||
</vector>
|
89
app/src/main/res/layout/activity_feed.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.theapache64.topcorn.ui.activities.feed.FeedViewModel" />
|
||||
|
||||
<variable
|
||||
name="handler"
|
||||
type="com.theapache64.topcorn.ui.activities.feed.FeedHandler" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.activities.feed.FeedActivity">
|
||||
|
||||
<!--Movium title-->
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
fontPath="fonts/GoogleSans-Bold.ttf"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="18dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
android:textSize="28sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<!--Heart-->
|
||||
<ImageButton
|
||||
android:id="@+id/ib_github"
|
||||
android:layout_width="@dimen/toolbar_icon_wh"
|
||||
android:layout_height="@dimen/toolbar_icon_wh"
|
||||
android:layout_margin="18dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:onClick="@{()-> handler.onHeartClicked()}"
|
||||
android:src="@drawable/ic_heart"
|
||||
android:tint="@color/red_800"
|
||||
app:layout_constraintBottom_toBottomOf="@id/ib_dark_mode"
|
||||
app:layout_constraintEnd_toStartOf="@id/ib_dark_mode"
|
||||
app:layout_constraintTop_toTopOf="@id/ib_dark_mode"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<!--Dark Mode-->
|
||||
<ImageButton
|
||||
android:id="@+id/ib_dark_mode"
|
||||
android:layout_width="@dimen/toolbar_icon_wh"
|
||||
android:layout_height="@dimen/toolbar_icon_wh"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:layout_marginRight="18dp"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:onClick="@{()->handler.onToggleDarkModeClicked()}"
|
||||
android:src="@drawable/ic_switch_dark_mode"
|
||||
android:tint="@color/toolbarIconColor"
|
||||
app:layout_constraintBottom_toBottomOf="@id/tv_title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_title"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<!--Feed-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_feed"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title"
|
||||
tools:listitem="@layout/item_feed" />
|
||||
|
||||
<com.theapache64.twinkill.ui.widgets.LoadingView
|
||||
android:id="@+id/lv_feed"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
202
app/src/main/res/layout/activity_movie.xml
Normal file
@ -0,0 +1,202 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="handler"
|
||||
type="com.theapache64.topcorn.ui.activities.movie.MovieHandler" />
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.theapache64.topcorn.ui.activities.movie.MovieViewModel" />
|
||||
</data>
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:context=".ui.activities.movie.MovieActivity">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!--Back button-->
|
||||
<ImageButton
|
||||
android:id="@+id/ib_go_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:onClick="@{()->handler.onBackButtonClicked()}"
|
||||
android:padding="18dp"
|
||||
android:src="@drawable/ic_back_arrow"
|
||||
android:tint="@color/toolbarIconColor"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<!--Image-->
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/mcv_poster"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="190dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:transitionName="poster"
|
||||
app:layout_constraintStart_toStartOf="@id/ib_go_back"
|
||||
app:layout_constraintTop_toBottomOf="@id/ib_go_back">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="centerCrop"
|
||||
app:imageUrl="@{viewModel.movie.thumbUrl}"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
<!--Rating label-->
|
||||
<TextView
|
||||
android:id="@+id/tv_label_rating"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/label_rating"
|
||||
app:layout_constraintStart_toEndOf="@id/mcv_poster"
|
||||
app:layout_constraintTop_toTopOf="@id/mcv_poster" />
|
||||
|
||||
<!--Rating value-->
|
||||
<TextView
|
||||
android:id="@+id/tv_rating"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@{viewModel.movie.rating+``}"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_label_rating"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_label_rating"
|
||||
tools:text="8.5" />
|
||||
|
||||
<!--Director label-->
|
||||
<TextView
|
||||
android:id="@+id/tv_label_director"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/movie_details_top_margin"
|
||||
android:text="@string/label_director"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_label_rating"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_rating" />
|
||||
|
||||
<!--director value-->
|
||||
<TextView
|
||||
android:id="@+id/tv_director"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
app:layout_constraintEnd_toEndOf="@id/tv_rating"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_label_director"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_label_director"
|
||||
app:textList="@{viewModel.movie.directors}"
|
||||
tools:text="Guy Ritchie" />
|
||||
|
||||
<!--actor label-->
|
||||
<TextView
|
||||
android:id="@+id/tv_label_actor"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/movie_details_top_margin"
|
||||
android:text="@string/label_starring"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_label_rating"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_director" />
|
||||
|
||||
<!--actor value-->
|
||||
<TextView
|
||||
android:id="@+id/tv_actor"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
app:layout_constraintEnd_toEndOf="@id/tv_director"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_label_actor"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_label_actor"
|
||||
app:textList="@{viewModel.movie.actors}"
|
||||
tools:text="Tom Cruise, Robert Doney Jr.dsfdfggf" />
|
||||
|
||||
|
||||
<!--genre label-->
|
||||
<TextView
|
||||
android:id="@+id/tv_label_genre"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/movie_details_top_margin"
|
||||
android:text="@string/label_genre"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_label_rating"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_actor" />
|
||||
|
||||
<!--genre value-->
|
||||
<TextView
|
||||
android:id="@+id/tv_genre"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
app:layout_constraintEnd_toEndOf="@id/tv_actor"
|
||||
app:layout_constraintStart_toEndOf="@id/tv_label_genre"
|
||||
app:layout_constraintTop_toTopOf="@id/tv_label_genre"
|
||||
app:textList="@{viewModel.movie.genre}"
|
||||
tools:text="Action, Adventure" />
|
||||
|
||||
<!--Title-->
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
fontPath="fonts/GoogleSans-Bold.ttf"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@{viewModel.movie.name}"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
android:textSize="24sp"
|
||||
android:transitionName="title"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="@id/mcv_poster"
|
||||
app:layout_constraintTop_toBottomOf="@id/mcv_poster"
|
||||
tools:targetApi="lollipop"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<!--Description-->
|
||||
<TextView
|
||||
android:id="@+id/tv_description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@{viewModel.movie.desc}"
|
||||
android:textColor="@color/secondaryTextColor"
|
||||
app:layout_constraintEnd_toEndOf="@id/tv_title"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
|
||||
<!--Goto imdb-->
|
||||
<Button
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:onClick="@{()->handler.onGoToImdbClicked()}"
|
||||
android:text="@string/action_open_imdb"
|
||||
android:textColor="@color/primaryTextColor"
|
||||
app:layout_constraintEnd_toEndOf="@id/tv_description"
|
||||
app:layout_constraintStart_toStartOf="@id/tv_description"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_description" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
</layout>
|
49
app/src/main/res/layout/activity_splash.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.theapache64.topcorn.ui.activities.splash.SplashViewModel" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:src="@drawable/ic_logo"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_version_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="80dp"
|
||||
android:text="@{viewModel.versionName}"
|
||||
android:textColor="@color/grey_500"
|
||||
app:layout_constraintBottom_toTopOf="@id/clpb_splash"
|
||||
app:layout_constraintEnd_toEndOf="@id/clpb_splash"
|
||||
app:layout_constraintStart_toStartOf="@id/clpb_splash"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<androidx.core.widget.ContentLoadingProgressBar
|
||||
android:id="@+id/clpb_splash"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:indeterminate="true"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
44
app/src/main/res/layout/item_feed.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="feed"
|
||||
type="com.theapache64.topcorn.models.FeedItem" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!--Genre-->
|
||||
<TextView
|
||||
android:id="@+id/tv_genre"
|
||||
fontPath="fonts/GoogleSans-Medium.ttf"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="18dp"
|
||||
android:text="@{feed.genre}"
|
||||
android:textColor="@color/grey_700"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<!--Movies-->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_movies"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:orientation="horizontal"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_genre"
|
||||
tools:listitem="@layout/item_movie" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
53
app/src/main/res/layout/item_movie.xml
Normal file
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="movie"
|
||||
type="com.theapache64.topcorn.data.remote.Movie" />
|
||||
</data>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="4dp">
|
||||
|
||||
<!--Poster-->
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/mcv_poster"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="175dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_poster"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="fitXY"
|
||||
app:imageUrl="@{movie.thumbUrl}"
|
||||
tools:src="@tools:sample/backgrounds/scenic" />
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<!--Title-->
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:lines="3"
|
||||
android:text="@{movie.name}"
|
||||
android:textColor="@color/secondaryTextColor"
|
||||
android:transitionName="title"
|
||||
app:layout_constraintEnd_toEndOf="@id/mcv_poster"
|
||||
app:layout_constraintStart_toStartOf="@id/mcv_poster"
|
||||
app:layout_constraintTop_toBottomOf="@id/mcv_poster"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</layout>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
5
app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<background android:drawable="@drawable/ic_launcher_background" />
|
||||
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||
</adaptive-icon>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 3.5 KiB |
BIN
app/src/main/res/mipmap-hdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 7.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Normal file
After Width: | Height: | Size: 16 KiB |
6
app/src/main/res/values-night/colors.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="primaryTextColor">@color/grey_300</color>
|
||||
<color name="secondaryTextColor">@color/grey_400</color>
|
||||
<color name="toolbarIconColor">@color/grey_300</color>
|
||||
</resources>
|
11
app/src/main/res/values-night/styles.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/grey_700</item>
|
||||
<item name="android:navigationBarColor" tools:targetApi="lollipop">@color/grey_900
|
||||
</item>
|
||||
</style>
|
||||
</resources>
|
11
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">@android:color/black</color>
|
||||
<color name="colorPrimaryDark">@android:color/black</color>
|
||||
<color name="colorAccent">@android:color/black</color>
|
||||
|
||||
<color name="primaryTextColor">@color/grey_900</color>
|
||||
<color name="secondaryTextColor">@color/grey_800</color>
|
||||
<color name="toolbarIconColor">@color/grey_900</color>
|
||||
|
||||
</resources>
|
6
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="fab_margin">32dp</dimen>
|
||||
<dimen name="toolbar_icon_wh">32dp</dimen>
|
||||
<dimen name="movie_details_top_margin">6dp</dimen>
|
||||
</resources>
|
11
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
<string name="app_name">TopCorn</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="label_rating">"Rating: "</string>
|
||||
<string name="label_director">"Director: "</string>
|
||||
<string name="label_starring">"Starring: "</string>
|
||||
<string name="label_genre">"Genre: "</string>
|
||||
<string name="action_open_imdb">OPEN IMDB</string>
|
||||
|
||||
|
||||
</resources>
|
26
app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
<item name="android:windowContentTransitions" tools:targetApi="lollipop">true</item>
|
||||
<item name="android:windowAllowEnterTransitionOverlap" tools:targetApi="lollipop">true
|
||||
</item>
|
||||
<item name="android:windowAllowReturnTransitionOverlap" tools:targetApi="lollipop">true
|
||||
</item>
|
||||
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">false</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
16
app/src/test/java/com/theapache64/movieum/ExampleUnitTest.kt
Normal file
@ -0,0 +1,16 @@
|
||||
package com.theapache64.topcorn
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
47
build.gradle
Normal file
@ -0,0 +1,47 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
ext {
|
||||
// Core
|
||||
kotlin_version = '1.3.72'
|
||||
compile_sdk_version = 29
|
||||
min_sdk_version = 16
|
||||
target_sdk_version = 29
|
||||
appcompat_version = '1.1.0'
|
||||
ktx_version = '1.2.0'
|
||||
constraint_version = '1.1.3'
|
||||
material_version = '1.1.0'
|
||||
lifecycle_version = '2.2.0'
|
||||
|
||||
// External
|
||||
retrofit_version = '2.8.1'
|
||||
mockito_version = '3.1.0'
|
||||
|
||||
// Test
|
||||
junit_version = '4.13'
|
||||
espresso_version = '3.2.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.1.0-alpha06'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module app.build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
BIN
extras/dark.png
Normal file
After Width: | Height: | Size: 648 KiB |
BIN
extras/light.png
Normal file
After Width: | Height: | Size: 668 KiB |
23
gradle.properties
Normal file
@ -0,0 +1,23 @@
|
||||
# Project-wide Gradle settings.
|
||||
# IDE (e.g. Android Studio) users:
|
||||
# Gradle settings configured through the IDE *will override*
|
||||
# any settings specified in this file.
|
||||
# For more details on how to configure your build environment visit
|
||||
# http://www.gradle.org/docs/current/userguide/build_environment.html
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
# This option should only be used with decoupled projects. More details, visit
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app"s APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
android.enableJetifier=true
|
||||
# Kotlin code style for this project: "official" or "obsolete":
|
||||
kotlin.code.style=official# Fix room warning
|
||||
# https://stackoverflow.com/questions/57670510/how-to-get-rid-of-incremental-annotation-processing-requested-warning
|
||||
kapt.incremental.apt=true
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
#Thu Apr 16 17:26:49 IST 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
|
172
gradlew
vendored
Executable file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
case $i in
|
||||
(0) set -- ;;
|
||||
(1) set -- "$args0" ;;
|
||||
(2) set -- "$args0" "$args1" ;;
|
||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
84
gradlew.bat
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
12
jaba_project.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "Topcorn",
|
||||
"dir": "/home/theapache64/Documents/projects/topcorn",
|
||||
"packageName": "com.theapache64.topcorn",
|
||||
"architecture": 1,
|
||||
"isNeedGoogleFontsModule": true,
|
||||
"isNeedNetworkModule": true,
|
||||
"baseUrl": "http://omdbapi.com/",
|
||||
"isNeedRoomSupport": true,
|
||||
"isNeedSplashScreen": true,
|
||||
"isNeedLogInScreen": false
|
||||
}
|
10
local.properties
Normal file
@ -0,0 +1,10 @@
|
||||
## This file is automatically generated by Android Studio.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file should *NOT* be checked into Version Control Systems,
|
||||
# as it contains information specific to your local configuration.
|
||||
#
|
||||
# Location of the SDK. This is only used by Gradle.
|
||||
# For customization when using a Version Control System, please read the
|
||||
# header note.
|
||||
sdk.dir=/home/theapache64/Android/Sdk
|
2
settings.gradle
Normal file
@ -0,0 +1,2 @@
|
||||
include ':app'
|
||||
rootProject.name = "TopCorn"
|