Skip to content
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
6 changes: 6 additions & 0 deletions .idea/misc.xml

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

17 changes: 8 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Thrifty">
<activity
android:name=".FavouriteActivity"
android:exported="false" />
<activity
android:name=".Accessories"
android:exported="false" />
<activity
android:name=".Profile"
android:exported="true" />

<activity
android:name=".ProductView"
android:exported="false" />

<activity
android:name=".Belts"
android:exported="false" />
Expand All @@ -39,26 +40,24 @@
android:name=".MenClothes"
android:exported="false" />
<activity

android:name=".SearchActivity"
android:exported="false" />
<activity
android:name=".Admin"
android:exported="true" />
<activity
android:name=".Categories"
android:exported="false" />
<!-- <activity-->
<!-- android:name=".Splash"-->
<!-- android:exported="false" />-->
android:exported="false" /> <!-- <activity -->
<!-- android:name=".Splash" -->
<!-- android:exported="false" /> -->
<activity
android:name=".ConfirmationPage"
android:exported="false" />
<activity
android:name=".MainActivity"
android:name=".Signin"
android:exported="false" />
<activity
android:name=".Signin"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.amplifyframework.datastore.generated.model;


import java.util.List;
import java.util.UUID;
import java.util.Objects;

Expand All @@ -11,7 +10,6 @@
import com.amplifyframework.core.model.Model;
import com.amplifyframework.core.model.ModelOperation;
import com.amplifyframework.core.model.annotations.AuthRule;
import com.amplifyframework.core.model.annotations.Index;
import com.amplifyframework.core.model.annotations.ModelConfig;
import com.amplifyframework.core.model.annotations.ModelField;
import com.amplifyframework.core.model.query.predicate.QueryField;
Expand Down
137 changes: 137 additions & 0 deletions app/src/main/java/com/example/thrifty/FavouriteActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
package com.example.thrifty;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.preference.PreferenceManager;
import android.view.View;
import android.util.Log;
import android.widget.Toolbar;

import com.amplifyframework.AmplifyException;
import com.amplifyframework.api.aws.AWSApiPlugin;
import com.amplifyframework.api.graphql.model.ModelQuery;
import com.amplifyframework.auth.cognito.AWSCognitoAuthPlugin;
import com.amplifyframework.core.Amplify;
import com.amplifyframework.datastore.AWSDataStorePlugin;
import com.amplifyframework.datastore.generated.model.Favourites;
import com.amplifyframework.datastore.generated.model.Product;
import com.amplifyframework.storage.s3.AWSS3StoragePlugin;
import com.example.thrifty.adapters.FavAdapter;
import com.example.thrifty.fragments.MainMenuFragment;
import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationView;

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


public class FavouriteActivity extends AppCompatActivity {

private List<Favourites> favProduct = new ArrayList<>();
private List<Product> myProduct= new ArrayList<>();

RecyclerView favRecView;
FavAdapter favAdapter;


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

MainMenuFragment mainMenuFragment = new MainMenuFragment();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
// toolbar.setNavigationIcon(R.drawable.ic_baseline_arrow_back_ios_new_24);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});

try {
Amplify.addPlugin(new AWSS3StoragePlugin());
Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.addPlugin(new AWSDataStorePlugin());
Amplify.addPlugin(new AWSApiPlugin());
Amplify.configure(getApplicationContext());
Log.i("MyAmplifyApp", "Initialized Amplify");
} catch (AmplifyException error) {
Log.e("MyAmplifyApp", "Could not initialize Amplify", error);
}

bottomNav();
initRecyclerViews();
}

public void bottomNav(){
BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
bottomNavigationView.setSelectedItemId(R.id.homeNav);
BottomNavigationItemView homeNav = findViewById(R.id.homeNav);
BottomNavigationItemView search = findViewById(R.id.search);
// BottomNavigationItemView cart = findViewById(R.id.cart);
BottomNavigationItemView wishlist = findViewById(R.id.wishlist);
BottomNavigationItemView profile = findViewById(R.id.profile);

search.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), SearchActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});

homeNav.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});

profile.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});

wishlist.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), FavouriteActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
}

private void initRecyclerViews() {
favRecView = findViewById(R.id.FavRecView);
favRecView.setAdapter(favAdapter);
favRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL, false));

favRecView.setAdapter(new FavAdapter(favProduct));
Handler handler = new Handler(Looper.myLooper(), new Handler.Callback() {
@SuppressLint("NotifyDataSetChanged")
@Override
public boolean handleMessage(@NonNull Message message) {
Objects.requireNonNull(favRecView.getAdapter()).notifyDataSetChanged();
return false;
}
});

Amplify.API.query(
ModelQuery.list(Product.class),
response -> {
for (Product todo : response.getData()) {
myProduct.add(todo);
}
handler.sendEmptyMessage(1);
}, error -> Log.e("MyAmplifyApp", "Query failure", error)
);
}
}
37 changes: 20 additions & 17 deletions app/src/main/java/com/example/thrifty/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
import java.util.List;


public class MainActivity extends AppCompatActivity {
public class MainActivity extends AppCompatActivity {

private List<Product> NewProduct = new ArrayList<>();
private List<Product> PopularProduct = new ArrayList<>();
Expand Down Expand Up @@ -69,7 +69,6 @@ public void onClick(View v) {
});

try {
// Amplify.addPlugin(new AWSPinpointAnalyticsPlugin(getApplication()));
Amplify.addPlugin(new AWSS3StoragePlugin());
Amplify.addPlugin(new AWSCognitoAuthPlugin());
Amplify.addPlugin(new AWSDataStorePlugin());
Expand All @@ -85,61 +84,65 @@ public void onClick(View v) {
initRecyclerViews();



findViewById(R.id.admin).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(MainActivity.this, Admin.class);
startActivity(intent);
}
});

}

public void bottomNav(){
public void bottomNav() {
BottomNavigationView bottomNavigationView = findViewById(R.id.bottomNavigationView);
bottomNavigationView.setSelectedItemId(R.id.homeNav);
BottomNavigationItemView homeNav = findViewById(R.id.homeNav);
BottomNavigationItemView search = findViewById(R.id.search);
// BottomNavigationItemView cart = findViewById(R.id.cart);
// BottomNavigationItemView wishlist = findViewById(R.id.wishlist);
BottomNavigationItemView wishlist = findViewById(R.id.wishlist);
BottomNavigationItemView profile = findViewById(R.id.profile);

search.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), SearchActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});

homeNav.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});

profile.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), Profile.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});

wishlist.setOnClickListener(view -> {
Intent intent = new Intent(getApplicationContext(), FavouriteActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
});
}

private void initRecyclerViews(){
private void initRecyclerViews() {

newItemRecView = findViewById(R.id.newItemsRecView);
suggestedRecView = findViewById(R.id.suggestedRecView);
popularRecView = findViewById(R.id.popularRecView);

// newItemRecView.setAdapter(newItemsAdapter);
newItemRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false));
newItemRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL, false));

suggestedRecView.setAdapter(suggestedItemsAdapter);
suggestedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL,false));
suggestedRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL, false));

popularRecView.setAdapter(popularItemsAdapter);
popularRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(),RecyclerView.HORIZONTAL,false));
popularRecView.setLayoutManager(new LinearLayoutManager(getApplicationContext(), RecyclerView.HORIZONTAL, false));

newItemRecView.setAdapter(new NewItemsAdapter(NewProduct , MainActivity.this));
newItemRecView.setAdapter(new NewItemsAdapter(NewProduct));
Handler handler = new Handler(Looper.myLooper(), new Handler.Callback() {
@SuppressLint("NotifyDataSetChanged")
@Override
Expand All @@ -150,7 +153,7 @@ public boolean handleMessage(@NonNull Message message) {
});


popularRecView.setAdapter(new NewItemsAdapter(PopularProduct , MainActivity.this));
popularRecView.setAdapter(new NewItemsAdapter(PopularProduct));
Handler popularhandler = new Handler(Looper.myLooper(), new Handler.Callback() {
@SuppressLint("NotifyDataSetChanged")
@Override
Expand All @@ -160,7 +163,7 @@ public boolean handleMessage(@NonNull Message message) {
}
});

suggestedRecView.setAdapter(new NewItemsAdapter(SuggestProduct , MainActivity.this));
suggestedRecView.setAdapter(new NewItemsAdapter(SuggestProduct));
Handler suggesthandler = new Handler(Looper.myLooper(), new Handler.Callback() {
@SuppressLint("NotifyDataSetChanged")
@Override
Expand Down Expand Up @@ -212,7 +215,7 @@ protected void onResume() {
stopButton.setVisibility(View.GONE);
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
String email1 = sharedPreferences.getString("email", "Your email");
if (email1.equals("jamalwari2@gmail.com")){
if (email1.equals("jamalwari2@gmail.com")) {
stopButton.setVisibility(View.VISIBLE);
}
}
Expand Down
Loading