diff --git a/FOOD-19/IMG_20191119_150348.jpg b/FOOD-19/IMG_20191119_150348.jpg new file mode 100644 index 0000000..c8105d9 Binary files /dev/null and b/FOOD-19/IMG_20191119_150348.jpg differ diff --git a/FOOD-19/IMG_20191125_152334.jpg b/FOOD-19/IMG_20191125_152334.jpg new file mode 100644 index 0000000..956a9f5 Binary files /dev/null and b/FOOD-19/IMG_20191125_152334.jpg differ diff --git a/FOOD-19/Notatka ze spotkania z klientem.docx b/FOOD-19/Notatka ze spotkania z klientem.docx new file mode 100644 index 0000000..a632878 Binary files /dev/null and b/FOOD-19/Notatka ze spotkania z klientem.docx differ diff --git a/FOOD-19/Prosty algorytm w 10 krokach.docx b/FOOD-19/Prosty algorytm w 10 krokach.docx new file mode 100644 index 0000000..163c9c2 Binary files /dev/null and b/FOOD-19/Prosty algorytm w 10 krokach.docx differ diff --git a/IMG_20191119_150348.jpg b/IMG_20191119_150348.jpg new file mode 100644 index 0000000..c8105d9 Binary files /dev/null and b/IMG_20191119_150348.jpg differ diff --git a/IMG_20191125_152334.jpg b/IMG_20191125_152334.jpg new file mode 100644 index 0000000..956a9f5 Binary files /dev/null and b/IMG_20191125_152334.jpg differ diff --git a/Notatka ze spotkania z klientem.docx b/Notatka ze spotkania z klientem.docx new file mode 100644 index 0000000..a632878 Binary files /dev/null and b/Notatka ze spotkania z klientem.docx differ diff --git a/Prosty algorytm w 10 krokach.docx b/Prosty algorytm w 10 krokach.docx new file mode 100644 index 0000000..163c9c2 Binary files /dev/null and b/Prosty algorytm w 10 krokach.docx differ diff --git a/aplication/.idea/codeStyles/codeStyleConfig.xml b/aplication/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/aplication/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/aplication/.idea/gradle.xml b/aplication/.idea/gradle.xml new file mode 100644 index 0000000..169fd0d --- /dev/null +++ b/aplication/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/aplication/.idea/kotlinCodeInsightSettings.xml b/aplication/.idea/kotlinCodeInsightSettings.xml new file mode 100644 index 0000000..71e404d --- /dev/null +++ b/aplication/.idea/kotlinCodeInsightSettings.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/aplication/.idea/vcs.xml b/aplication/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/aplication/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/aplication/app/src/main/java/com/example/foodinder/CardItem.java b/aplication/app/src/main/java/com/example/foodinder/CardItem.java new file mode 100644 index 0000000..3b5c2db --- /dev/null +++ b/aplication/app/src/main/java/com/example/foodinder/CardItem.java @@ -0,0 +1,4 @@ +package com.example.foodinder; + +public class CardItem { +} diff --git a/aplication/app/src/main/java/com/example/foodinder/CardsAdapter.java b/aplication/app/src/main/java/com/example/foodinder/CardsAdapter.java new file mode 100644 index 0000000..e4d617c --- /dev/null +++ b/aplication/app/src/main/java/com/example/foodinder/CardsAdapter.java @@ -0,0 +1,116 @@ +package com.example.foodinder + +import android.app.Activity +import android.content.res.Resources +import android.graphics.Bitmap +import android.graphics.BitmapFactory +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.BaseAdapter +import android.widget.ImageView +import android.widget.TextView + +class CardsAdapter(private val activity: Activity, private val data: List) : + BaseAdapter() { + override fun getCount(): Int { + return data.size + } + + override fun getItem(position: Int): CardItem { + return data[position] + } + + override fun getItemId(position: Int): Long { + return position.toLong() + } + + override fun getView( + position: Int, + convertView: View, + parent: ViewGroup + ): View { + var convertView = convertView + val holder: ViewHolder + val inflater = + activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE) as LayoutInflater + // If holder not exist then locate all view from UI file. + if (convertView == null) { // inflate UI from XML file + convertView = inflater.inflate(R.layout.item_card, parent, false) + // get all UI view + holder = ViewHolder(convertView) + // set tag for holder + convertView.tag = holder + } else { // if holder created, get tag from view + holder = convertView.tag as ViewHolder + } + //setting data to views + holder.name.text = getItem(position).name + holder.location.text = getItem(position).location + holder.avatar.setImageBitmap( + decodeSampledBitmapFromResource( + activity.resources, + getItem(position).drawableId, + AVATAR_WIDTH, + AVATAR_HEIGHT + ) + ) + return convertView + } + + private inner class ViewHolder(view: View) { + val avatar: ImageView + val name: TextView + val location: TextView + + init { + avatar = view.findViewById(R.id.avatar) as ImageView + name = view.findViewById(R.id.name) as TextView + location = view.findViewById(R.id.location) as TextView + } + } + + companion object { + private const val AVATAR_WIDTH = 150 + private const val AVATAR_HEIGHT = 300 + fun decodeSampledBitmapFromResource( + res: Resources?, + resId: Int, + reqWidth: Int, + reqHeight: Int + ): Bitmap { // First decode with inJustDecodeBounds=true to check dimensions + val options = BitmapFactory.Options() + options.inJustDecodeBounds = true + BitmapFactory.decodeResource(res, resId, options) + // Calculate inSampleSize + options.inSampleSize = + calculateInSampleSize(options, reqWidth, reqHeight) + // Decode bitmap with inSampleSize set + options.inJustDecodeBounds = false + return BitmapFactory.decodeResource(res, resId, options) + } + + fun calculateInSampleSize( + options: BitmapFactory.Options, + reqWidth: Int, + reqHeight: Int + ): Int { // Raw height and width of image + val height = options.outHeight + val width = options.outWidth + var inSampleSize = 1 + if (height > reqHeight || width > reqWidth) { + val halfHeight = height / 2 + val halfWidth = width / 2 + // Calculate the largest inSampleSize value that is a power of 2 and keeps both +// height and width larger than the requested height and width. + while (halfHeight / inSampleSize >= reqHeight + && halfWidth / inSampleSize >= reqWidth + ) { + inSampleSize *= 2 + } + } + return inSampleSize + } + } + +} \ No newline at end of file diff --git a/aplication/app/src/main/java/com/example/foodinder/swipper.java b/aplication/app/src/main/java/com/example/foodinder/swipper.java new file mode 100644 index 0000000..5c399de --- /dev/null +++ b/aplication/app/src/main/java/com/example/foodinder/swipper.java @@ -0,0 +1,99 @@ +package info.devexchanges.cardsstack; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Toast; + +import java.util.ArrayList; + +import link.fls.swipestack.SwipeStack; + +public class swipper extends AppCompatActivity { + + private SwipeStack cardStack; + private CardsAdapter cardsAdapter; + private ArrayList cardItems; + private View btnCancel; + private View btnLove; + private int currentPosition; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + cardStack = (SwipeStack) findViewById(R.id.container); + btnCancel = findViewById(R.id.cancel); + btnLove = findViewById(R.id.love); + + setCardStackAdapter(); + currentPosition = 0; + + //Handling swipe event of Cards stack + cardStack.setListener(new SwipeStack.SwipeStackListener() { + @Override + public void onViewSwipedToLeft(int position) { + currentPosition = position + 1; + } + + @Override + public void onViewSwipedToRight(int position) { + currentPosition = position + 1; + } + + @Override + public void onStackEmpty() { + + } + }); + + btnCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + cardStack.swipeTopViewToRight(); + } + }); + + btnLove.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + Toast.makeText(swipper.this, "You liked " + cardItems.get(currentPosition).getName(), + Toast.LENGTH_SHORT).show(); + cardStack.swipeTopViewToLeft(); + } + }); + } + + private void setCardStackAdapter() { + cardItems = new ArrayList<>(); + + cardItems.add(new CardItem(R.drawable.a, "Huyen My", "Hanoi")); + cardItems.add(new CardItem(R.drawable.f, "Do Ha", "Nghe An")); + cardItems.add(new CardItem(R.drawable.g, "Dong Nhi", "Hue")); + cardItems.add(new CardItem(R.drawable.e, "Le Quyen", "Sai Gon")); + cardItems.add(new CardItem(R.drawable.c, "Phuong Linh", "Thanh Hoa")); + cardItems.add(new CardItem(R.drawable.d, "Phuong Vy", "Hanoi")); + cardItems.add(new CardItem(R.drawable.b, "Ha Ho", "Da Nang")); + + cardsAdapter = new CardsAdapter(this, cardItems); + cardStack.setAdapter(cardsAdapter); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.reset) { + cardStack.resetStack(); + currentPosition = 0; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/aplication/app/src/main/res/drawable-v24/a.jpg b/aplication/app/src/main/res/drawable-v24/a.jpg new file mode 100644 index 0000000..2d9a2b9 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/a.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/b.jpg b/aplication/app/src/main/res/drawable-v24/b.jpg new file mode 100644 index 0000000..9f26ffd Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/b.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/c.jpg b/aplication/app/src/main/res/drawable-v24/c.jpg new file mode 100644 index 0000000..496f8fc Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/c.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/d.jpg b/aplication/app/src/main/res/drawable-v24/d.jpg new file mode 100644 index 0000000..fa1ee2b Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/d.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/e.jpg b/aplication/app/src/main/res/drawable-v24/e.jpg new file mode 100644 index 0000000..36ee769 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/e.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/f.jpg b/aplication/app/src/main/res/drawable-v24/f.jpg new file mode 100644 index 0000000..dfb8d67 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/f.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/g.jpg b/aplication/app/src/main/res/drawable-v24/g.jpg new file mode 100644 index 0000000..dfb8d67 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/g.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/h.jpg b/aplication/app/src/main/res/drawable-v24/h.jpg new file mode 100644 index 0000000..a805ae0 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/h.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/i.jpg b/aplication/app/src/main/res/drawable-v24/i.jpg new file mode 100644 index 0000000..b8013cc Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/i.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/j.jpg b/aplication/app/src/main/res/drawable-v24/j.jpg new file mode 100644 index 0000000..3145250 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/j.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/k.jpg b/aplication/app/src/main/res/drawable-v24/k.jpg new file mode 100644 index 0000000..c95369d Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/k.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/l.jpg b/aplication/app/src/main/res/drawable-v24/l.jpg new file mode 100644 index 0000000..de2fd42 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/l.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/m.jpg b/aplication/app/src/main/res/drawable-v24/m.jpg new file mode 100644 index 0000000..88010dc Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/m.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/n.jpg b/aplication/app/src/main/res/drawable-v24/n.jpg new file mode 100644 index 0000000..6033e74 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/n.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/o.jpg b/aplication/app/src/main/res/drawable-v24/o.jpg new file mode 100644 index 0000000..78cd3b0 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/o.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/p.jpg b/aplication/app/src/main/res/drawable-v24/p.jpg new file mode 100644 index 0000000..de20486 Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/p.jpg differ diff --git a/aplication/app/src/main/res/drawable-v24/r.jpg b/aplication/app/src/main/res/drawable-v24/r.jpg new file mode 100644 index 0000000..682a58c Binary files /dev/null and b/aplication/app/src/main/res/drawable-v24/r.jpg differ diff --git a/aplication/app/src/main/res/layout/activity_swipper.xml b/aplication/app/src/main/res/layout/activity_swipper.xml new file mode 100644 index 0000000..7e53d22 --- /dev/null +++ b/aplication/app/src/main/res/layout/activity_swipper.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/aplication/app/src/main/res/layout/item_card.xml b/aplication/app/src/main/res/layout/item_card.xml new file mode 100644 index 0000000..3509b84 --- /dev/null +++ b/aplication/app/src/main/res/layout/item_card.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/aplication/app/src/main/res/menu/menu_main.xml b/aplication/app/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..fe187c0 --- /dev/null +++ b/aplication/app/src/main/res/menu/menu_main.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/aplication/app/src/main/res/values/dimens.xml b/aplication/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..47c8224 --- /dev/null +++ b/aplication/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/foodinder_app/.gitignore b/foodinder_app/.gitignore new file mode 100644 index 0000000..603b140 --- /dev/null +++ b/foodinder_app/.gitignore @@ -0,0 +1,14 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx diff --git a/foodinder_app/.idea/codeStyles/Project.xml b/foodinder_app/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/foodinder_app/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/foodinder_app/.idea/gradle.xml b/foodinder_app/.idea/gradle.xml new file mode 100644 index 0000000..169fd0d --- /dev/null +++ b/foodinder_app/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/foodinder_app/.idea/misc.xml b/foodinder_app/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/foodinder_app/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/foodinder_app/.idea/runConfigurations.xml b/foodinder_app/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/foodinder_app/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/foodinder_app/.idea/vcs.xml b/foodinder_app/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/foodinder_app/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/foodinder_app/app/.gitignore b/foodinder_app/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/foodinder_app/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/foodinder_app/app/build.gradle b/foodinder_app/app/build.gradle new file mode 100644 index 0000000..16f10d6 --- /dev/null +++ b/foodinder_app/app/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android-extensions' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 28 + buildToolsVersion "28.0.3" + defaultConfig { + applicationId "com.example.foodinder_app" + minSdkVersion 16 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'link.fls:swipestack:0.3.0' + implementation 'com.android.support:appcompat-v7:25.0.0' + implementation 'com.android.support:cardview-v7:25.0.0' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.android.support.constraint:constraint-layout:1.1.3' +} +allprojects { + repositories { + jcenter() + maven { + url "https://maven.google.com" + } + } +} +repositories { + mavenCentral() +} diff --git a/foodinder_app/app/libs/android-card-stack-0.1.5.aar b/foodinder_app/app/libs/android-card-stack-0.1.5.aar new file mode 100644 index 0000000..8fdee4f Binary files /dev/null and b/foodinder_app/app/libs/android-card-stack-0.1.5.aar differ diff --git a/foodinder_app/app/proguard-rules.pro b/foodinder_app/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/foodinder_app/app/proguard-rules.pro @@ -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 diff --git a/foodinder_app/app/src/main/AndroidManifest.xml b/foodinder_app/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..1b2e72e --- /dev/null +++ b/foodinder_app/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/foodinder_app/app/src/main/java/com/example/foodinder_app/CardItem.java b/foodinder_app/app/src/main/java/com/example/foodinder_app/CardItem.java new file mode 100644 index 0000000..d77a156 --- /dev/null +++ b/foodinder_app/app/src/main/java/com/example/foodinder_app/CardItem.java @@ -0,0 +1,34 @@ +package com.example.foodinder_app; + +public class CardItem { + + private int drawableId; + private String name; + private String location; + + public CardItem(int drawableId, String name, String location) { + this.drawableId = drawableId; + this.name = name; + this.location = location; + } + + public int getDrawableId() { + return drawableId; + } + + public void setDrawableId(int drawableId) { + this.drawableId = drawableId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLocation() { + return location; + } +} diff --git a/foodinder_app/app/src/main/java/com/example/foodinder_app/CardsAdapter.java b/foodinder_app/app/src/main/java/com/example/foodinder_app/CardsAdapter.java new file mode 100644 index 0000000..59a1ec2 --- /dev/null +++ b/foodinder_app/app/src/main/java/com/example/foodinder_app/CardsAdapter.java @@ -0,0 +1,117 @@ +package com.example.foodinder_app; + +import android.app.Activity; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.ImageView; +import android.widget.TextView; + +import java.util.List; + +public class CardsAdapter extends BaseAdapter { + + private Activity activity; + private final static int AVATAR_WIDTH = 150; + private final static int AVATAR_HEIGHT = 300; + private List data; + + public CardsAdapter(Activity activity, List data) { + this.data = data; + this.activity = activity; + } + + @Override + public int getCount() { + return data.size(); + } + + @Override + public CardItem getItem(int position) { + return data.get(position); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + ViewHolder holder; + LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); + // If holder not exist then locate all view from UI file. + if (convertView == null) { + // inflate UI from XML file + convertView = inflater.inflate(R.layout.item_card, parent, false); + // get all UI view + holder = new ViewHolder(convertView); + // set tag for holder + convertView.setTag(holder); + } else { + // if holder created, get tag from view + holder = (ViewHolder) convertView.getTag(); + } + + //setting data to views + holder.name.setText(getItem(position).getName()); + holder.location.setText(getItem(position).getLocation()); + holder.avatar.setImageBitmap(decodeSampledBitmapFromResource(activity.getResources(), + getItem(position).getDrawableId(), AVATAR_WIDTH, AVATAR_HEIGHT)); + + return convertView; + } + + private class ViewHolder{ + private ImageView avatar; + private TextView name; + private TextView location; + + public ViewHolder(View view) { + avatar = (ImageView)view.findViewById(R.id.avatar); + name = (TextView)view.findViewById(R.id.name); + location = (TextView)view.findViewById(R.id.location); + } + } + + public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) { + + // First decode with inJustDecodeBounds=true to check dimensions + final BitmapFactory.Options options = new BitmapFactory.Options(); + options.inJustDecodeBounds = true; + BitmapFactory.decodeResource(res, resId, options); + + // Calculate inSampleSize + options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); + + // Decode bitmap with inSampleSize set + options.inJustDecodeBounds = false; + return BitmapFactory.decodeResource(res, resId, options); + } + + public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { + // Raw height and width of image + final int height = options.outHeight; + final int width = options.outWidth; + int inSampleSize = 1; + + if (height > reqHeight || width > reqWidth) { + + final int halfHeight = height / 2; + final int halfWidth = width / 2; + + // Calculate the largest inSampleSize value that is a power of 2 and keeps both + // height and width larger than the requested height and width. + while ((halfHeight / inSampleSize) >= reqHeight + && (halfWidth / inSampleSize) >= reqWidth) { + inSampleSize *= 2; + } + } + + return inSampleSize; + } +} diff --git a/foodinder_app/app/src/main/java/com/example/foodinder_app/Main2Activity.java b/foodinder_app/app/src/main/java/com/example/foodinder_app/Main2Activity.java new file mode 100644 index 0000000..dacce41 --- /dev/null +++ b/foodinder_app/app/src/main/java/com/example/foodinder_app/Main2Activity.java @@ -0,0 +1,28 @@ +package com.example.foodinder_app; + +import android.content.Intent; +import android.support.v7.app.AppCompatActivity; +import android.os.Bundle; +import android.view.View; + +public class Main2Activity extends AppCompatActivity { + + private View button; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main2); + + button = findViewById(R.id.button); + + button.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) + { + Intent intent = new Intent(Main2Activity.this, swipper.class); + startActivity(intent); + } + }); + } +} diff --git a/foodinder_app/app/src/main/java/com/example/foodinder_app/swipper.java b/foodinder_app/app/src/main/java/com/example/foodinder_app/swipper.java new file mode 100644 index 0000000..361ff30 --- /dev/null +++ b/foodinder_app/app/src/main/java/com/example/foodinder_app/swipper.java @@ -0,0 +1,115 @@ +package com.example.foodinder_app; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.Toast; + +import java.util.ArrayList; + +import link.fls.swipestack.SwipeStack; + +public class swipper extends AppCompatActivity { + + private SwipeStack cardStack; + private CardsAdapter cardsAdapter; + private ArrayList cardItems; + private View btnCancel; + private View btnLove; + private int currentPosition; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + cardStack = (SwipeStack) findViewById(R.id.container); + btnCancel = findViewById(R.id.cancel); + btnLove = findViewById(R.id.love); + + setCardStackAdapter(); + currentPosition = 0; + + //Handling swipe event of Cards stack + cardStack.setListener(new SwipeStack.SwipeStackListener() { + @Override + public void onViewSwipedToLeft(int position) { + + Toast.makeText(swipper.this, "You liked " + cardItems.get(currentPosition).getName(), + Toast.LENGTH_SHORT).show(); + currentPosition = position + 1; + + } + + @Override + public void onViewSwipedToRight(int position) { + + Toast.makeText(swipper.this, "You DON'T liked " + cardItems.get(currentPosition).getName(), + Toast.LENGTH_SHORT).show(); + currentPosition = position + 1; + } + + @Override + public void onStackEmpty() { + + } + }); + + btnCancel.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + cardStack.swipeTopViewToRight(); + } + }); + + btnLove.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + cardStack.swipeTopViewToLeft(); + } + }); + } + + private void setCardStackAdapter() { + cardItems = new ArrayList<>(); + + cardItems.add(new CardItem(R.drawable.a, "JedzenieA", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.b, "JedzenieB", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.c, "JedzenieC", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.d, "JedzenieD", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.e, "JedzenieE", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.f, "JedzenieF", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.g, "JedzenieG", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.h, "JedzenieH", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.i, "JedzenieI", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.j, "JedzenieJ", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.k, "JedzenieK", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.l, "JedzenieL", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.m, "JedzenieM", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.n, "JedzenieN", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.o, "JedzenieO", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.p, "JedzenieP", "Jedzenie")); + cardItems.add(new CardItem(R.drawable.r, "JedzenieR", "Jedzenie")); + + + cardsAdapter = new CardsAdapter(this, cardItems); + cardStack.setAdapter(cardsAdapter); + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + if (item.getItemId() == R.id.reset) { + cardStack.resetStack(); + currentPosition = 0; + } + return super.onOptionsItemSelected(item); + } +} diff --git a/foodinder_app/app/src/main/res/drawable/a.jpg b/foodinder_app/app/src/main/res/drawable/a.jpg new file mode 100644 index 0000000..2d9a2b9 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/a.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/b.jpg b/foodinder_app/app/src/main/res/drawable/b.jpg new file mode 100644 index 0000000..9f26ffd Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/b.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/c.jpg b/foodinder_app/app/src/main/res/drawable/c.jpg new file mode 100644 index 0000000..496f8fc Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/c.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/d.jpg b/foodinder_app/app/src/main/res/drawable/d.jpg new file mode 100644 index 0000000..fa1ee2b Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/d.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/e.jpg b/foodinder_app/app/src/main/res/drawable/e.jpg new file mode 100644 index 0000000..36ee769 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/e.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/f.jpg b/foodinder_app/app/src/main/res/drawable/f.jpg new file mode 100644 index 0000000..dfb8d67 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/f.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/g.jpg b/foodinder_app/app/src/main/res/drawable/g.jpg new file mode 100644 index 0000000..dfb8d67 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/g.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/h.jpg b/foodinder_app/app/src/main/res/drawable/h.jpg new file mode 100644 index 0000000..a805ae0 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/h.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/i.jpg b/foodinder_app/app/src/main/res/drawable/i.jpg new file mode 100644 index 0000000..b8013cc Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/i.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/j.jpg b/foodinder_app/app/src/main/res/drawable/j.jpg new file mode 100644 index 0000000..3145250 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/j.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/k.jpg b/foodinder_app/app/src/main/res/drawable/k.jpg new file mode 100644 index 0000000..c95369d Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/k.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/l.jpg b/foodinder_app/app/src/main/res/drawable/l.jpg new file mode 100644 index 0000000..de2fd42 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/l.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/m.jpg b/foodinder_app/app/src/main/res/drawable/m.jpg new file mode 100644 index 0000000..88010dc Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/m.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/n.jpg b/foodinder_app/app/src/main/res/drawable/n.jpg new file mode 100644 index 0000000..6033e74 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/n.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/o.jpg b/foodinder_app/app/src/main/res/drawable/o.jpg new file mode 100644 index 0000000..78cd3b0 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/o.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/p.jpg b/foodinder_app/app/src/main/res/drawable/p.jpg new file mode 100644 index 0000000..de20486 Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/p.jpg differ diff --git a/foodinder_app/app/src/main/res/drawable/r.jpg b/foodinder_app/app/src/main/res/drawable/r.jpg new file mode 100644 index 0000000..682a58c Binary files /dev/null and b/foodinder_app/app/src/main/res/drawable/r.jpg differ diff --git a/foodinder_app/app/src/main/res/layout/activity_main.xml b/foodinder_app/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..73061d5 --- /dev/null +++ b/foodinder_app/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + diff --git a/foodinder_app/app/src/main/res/layout/activity_main2.xml b/foodinder_app/app/src/main/res/layout/activity_main2.xml new file mode 100644 index 0000000..b4e1297 --- /dev/null +++ b/foodinder_app/app/src/main/res/layout/activity_main2.xml @@ -0,0 +1,19 @@ + + + +