Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

landing page layout done! #7

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.1'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.vendit">

<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">
<activity android:name=".MainActivity">
<activity android:name="com.example.shopeIt.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
56 changes: 56 additions & 0 deletions app/src/main/java/com/example/shopeIt/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.example.shopeIt;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;

import com.example.vendit.R;
import com.example.shopeIt.adapters.ItemRecyclerAdapter;
import com.example.shopeIt.adapters.OnRecipeListener;
import com.example.shopeIt.util.VerticalSpacingItemDecorator;

public class MainActivity extends AppCompatActivity {
private RecyclerView mRecyclerView;
private ItemRecyclerAdapter mAdapter;

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

mRecyclerView = findViewById(R.id.recipe_list_recyclerView);

}

private void initSearchView(){
final androidx.appcompat.widget.SearchView searchView = findViewById(R.id.search_view);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//...
return false;
}

@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});


}
private void initRecyclerView(){
mAdapter = new ItemRecyclerAdapter((OnRecipeListener) this);

VerticalSpacingItemDecorator itemDecorator = new VerticalSpacingItemDecorator(30);
mRecyclerView.addItemDecoration(itemDecorator);

mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.shopeIt.adapters;

import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.shopeIt.models.Item;

import java.util.List;

public class ItemRecyclerAdapter extends RecyclerView.Adapter<ItemRecyclerAdapter.ViewHolder> {
private List<Item> mItems;
private OnRecipeListener mOnRecipeListener;

public ItemRecyclerAdapter(OnRecipeListener onRecipeListener) {
mOnRecipeListener = onRecipeListener;
}
@NonNull
@Override
public ItemRecyclerAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return null;
}

@Override
public void onBindViewHolder(@NonNull ItemRecyclerAdapter.ViewHolder holder, int position) {

}

@Override
public int getItemCount() {
return 0;
}

public class ViewHolder extends RecyclerView.ViewHolder {
public ViewHolder(@NonNull View itemView) {
super(itemView);
}
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example.shopeIt.adapters;

import android.view.View;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class LoadingViewHolder extends RecyclerView.ViewHolder {
public LoadingViewHolder(@NonNull View itemView) {
super(itemView);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.example.shopeIt.adapters;

public interface OnRecipeListener {
void onRecipeClick(int position);

void onCategoryClick(String category);
}
122 changes: 122 additions & 0 deletions app/src/main/java/com/example/shopeIt/models/Item.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package com.example.shopeIt.models;

import android.os.Parcel;
import android.os.Parcelable;

public class Item implements Parcelable {
private String title;
private String publisher;
private String description;
private String item_id;
private String image_url;
private String brand;


public Item(String title, String publisher, String description, String item_id, String image_url, String brand) {
this.title = title;
this.publisher = publisher;
this.description = description;
this.item_id = item_id;
this.image_url = image_url;
this.brand = brand;
}

public Item() {
}

protected Item(Parcel in) {
title = in.readString();
publisher = in.readString();
description = in.readString();
item_id = in.readString();
image_url = in.readString();
brand = in.readString();
}

public static final Creator<Item> CREATOR = new Creator<Item>() {
@Override
public Item createFromParcel(Parcel in) {
return new Item(in);
}

@Override
public Item[] newArray(int size) {
return new Item[size];
}
};

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getPublisher() {
return publisher;
}

public void setPublisher(String publisher) {
this.publisher = publisher;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getItem_id() {
return item_id;
}

public void setItem_id(String item_id) {
this.item_id = item_id;
}

public String getImage_url() {
return image_url;
}

public void setImage_url(String image_url) {
this.image_url = image_url;
}

public String getBrand() {
return brand;
}

public void setBrand(String brand) {
this.brand = brand;
}

@Override
public String toString() {
return "Item{" +
"title='" + title + '\'' +
", publisher='" + publisher + '\'' +
", description='" + description + '\'' +
", item_id='" + item_id + '\'' +
", image_url='" + image_url + '\'' +
", brand='" + brand + '\'' +
'}';
}

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(title);
dest.writeString(publisher);
dest.writeString(description);
dest.writeString(item_id);
dest.writeString(image_url);
dest.writeString(brand);
}
}
24 changes: 24 additions & 0 deletions app/src/main/java/com/example/shopeIt/util/Constants.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.shopeIt.util;

public class Constants {
public static final String BASE_URL = "https://recipesapi.herokuapp.com/";
public static final String API_KEY = "";

public static final int NETWORK_TIMEOUT = 3000;

public static final String[] DEFAULT_SEARCH_CATEGORIES =
{"Barbeque", "Breakfast", "Chicken", "Beef", "Brunch", "Dinner", "Wine", "Italian"};

public static final String[] DEFAULT_SEARCH_CATEGORY_IMAGES =
{
"barbeque",
"breakfast",
"chicken",
"beef",
"brunch",
"dinner",
"wine",
"italian"
};
}

Loading