-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit ( App UI without network endpoints wire-up plus no arc…
…hitecture)
- Loading branch information
1 parent
d1434a4
commit 9c9bb5f
Showing
59 changed files
with
1,613 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
apply plugin: 'kotlin-android' | ||
|
||
apply plugin: 'kotlin-android-extensions' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "foodapp.com.foodapp" | ||
minSdkVersion 21 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
androidExtensions { | ||
experimental = true | ||
} | ||
|
||
dependencies { | ||
|
||
def anko_version = '0.10.5' | ||
|
||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
implementation 'androidx.appcompat:appcompat:1.0.0-beta01' | ||
implementation 'com.google.android.material:material:1.0.0-beta01' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.2' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3' | ||
|
||
implementation "org.jetbrains.anko:anko:$anko_version" | ||
implementation 'com.squareup.picasso:picasso:2.71828' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |
24 changes: 24 additions & 0 deletions
24
app/src/androidTest/java/foodapp/com/foodapp/ExampleInstrumentedTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package foodapp.com.foodapp | ||
|
||
import androidx.test.InstrumentationRegistry | ||
import androidx.test.runner.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* 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.getTargetContext() | ||
assertEquals("foodapp.com.foodapp", appContext.packageName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?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="foodapp.com.foodapp"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
tools:ignore="GoogleAppIndexingWarning"> | ||
|
||
<activity | ||
android:name=".dashboard.ui.MainActivity" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<activity | ||
android:name=".foods.ui.FoodListActivity" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme.Transparent" /> | ||
|
||
<activity | ||
android:name=".details.FoodDetailsActivity" | ||
android:theme="@style/Theme.AppCompat.Light.NoActionBar" /> | ||
|
||
<activity android:name=".details.DishImageActivity" /> | ||
</application> | ||
|
||
</manifest> |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/foodapp/com/foodapp/dashboard/adapter/HeroImageViewsAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package foodapp.com.foodapp.dashboard.adapter | ||
|
||
import androidx.fragment.app.Fragment | ||
import androidx.fragment.app.FragmentManager | ||
import androidx.fragment.app.FragmentStatePagerAdapter | ||
import foodapp.com.foodapp.dashboard.ui.HeroImageFragment | ||
|
||
class HeroImageViewsAdapter(private var imagesRes: ArrayList<Int>? = null, private var imagesUrls: ArrayList<String>? = null, manager: FragmentManager) : FragmentStatePagerAdapter(manager) { | ||
|
||
override fun getCount(): Int { | ||
imagesRes?.let { | ||
return it.size | ||
} | ||
imagesUrls?.let { | ||
return it.size | ||
} | ||
return -1 | ||
} | ||
|
||
override fun getItem(position: Int): Fragment? { | ||
imagesRes?.let { | ||
return HeroImageFragment.newInstance(imageRes = it[position]) | ||
} | ||
imagesUrls?.let { | ||
return HeroImageFragment.newInstance(imageUrl = it[position]) | ||
} | ||
return null | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
app/src/main/java/foodapp/com/foodapp/dashboard/ui/HeroImageFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package foodapp.com.foodapp.dashboard.ui | ||
|
||
import android.os.Bundle | ||
import android.text.TextUtils | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ImageView | ||
import androidx.annotation.DrawableRes | ||
import androidx.fragment.app.Fragment | ||
import com.squareup.picasso.Picasso | ||
import foodapp.com.foodapp.R | ||
|
||
class HeroImageFragment : Fragment() { | ||
|
||
companion object { | ||
const val ARG_IMAGE_RES = "image_res" | ||
const val ARG_IMAGE_URL = "image_url" | ||
|
||
fun newInstance(@DrawableRes imageRes: Int = -1, imageUrl: String = ""): HeroImageFragment { | ||
val fragment = HeroImageFragment() | ||
val bundle = Bundle() | ||
if (imageRes != -1) { | ||
bundle.putInt(ARG_IMAGE_RES, imageRes) | ||
} | ||
if (!TextUtils.isEmpty(imageUrl)) { | ||
bundle.putString(ARG_IMAGE_URL, imageUrl) | ||
} | ||
fragment.arguments = bundle | ||
return fragment | ||
} | ||
} | ||
|
||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | ||
return inflater.inflate(R.layout.fragment_hero_image, container, false) | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
val imageView = view.findViewById<ImageView>(R.id.heroImageView) | ||
|
||
if (arguments!!.containsKey(ARG_IMAGE_RES)) { | ||
val imageRes = arguments!!.getInt(ARG_IMAGE_RES) | ||
Picasso.get().load(imageRes).fit().centerInside().into(imageView) | ||
return | ||
} | ||
|
||
if (arguments!!.containsKey(ARG_IMAGE_URL)) { | ||
val imageUrl = arguments!!.getString(ARG_IMAGE_URL) | ||
Picasso.get().load(imageUrl).fit().centerInside().into(imageView) | ||
return | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
app/src/main/java/foodapp/com/foodapp/dashboard/ui/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package foodapp.com.foodapp.dashboard.ui | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
import androidx.core.app.ActivityOptionsCompat | ||
import foodapp.com.foodapp.R | ||
import foodapp.com.foodapp.dashboard.adapter.HeroImageViewsAdapter | ||
import foodapp.com.foodapp.foods.ui.FoodListActivity | ||
import foodapp.com.foodapp.views.DepthPageTransformer | ||
import kotlinx.android.synthetic.main.activity_main.* | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
val fragmentManager = supportFragmentManager | ||
|
||
heroImagesViewPager.setPageTransformer(true, DepthPageTransformer()) | ||
heroImagesViewPager.adapter = HeroImageViewsAdapter( | ||
imagesRes = arrayListOf(R.drawable.frame1, R.drawable.frame2, R.drawable.frame3), | ||
manager = fragmentManager | ||
) | ||
|
||
tabLayout.setupWithViewPager(heroImagesViewPager, true) | ||
|
||
startButton.setOnClickListener { | ||
|
||
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(this, it, "transition") | ||
val revealX = (it.x + it.width / 2).toInt() | ||
val revealY = (it.y + it.height / 2).toInt() | ||
|
||
startActivity(FoodListActivity.newInstance(this@MainActivity, revealX, revealY), options.toBundle()) | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
app/src/main/java/foodapp/com/foodapp/details/DishImageActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package foodapp.com.foodapp.details | ||
|
||
import android.os.Bundle | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
class DishImageActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
} | ||
} |
Oops, something went wrong.