Wprowadź końcową szatę graficzną aplikacji - kolory, tekst przycisków i pasków itd.; wprowadź różne drobne poprawki w funkcjonowaniu aplikacji
This commit is contained in:
parent
7bf66b1f8f
commit
e6cd0230b5
@ -8,23 +8,32 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:name=".MyApplication"
|
||||
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=".Popup"></activity>
|
||||
<activity android:name=".Favourites"
|
||||
android:label="Obserwowane"/>
|
||||
<activity android:name=".Popup"
|
||||
android:label="Szczegóły"/>
|
||||
<activity android:name=".Results"
|
||||
android:theme="@style/NoBar"/>
|
||||
android:label="Rekomendacje"/>
|
||||
<activity android:name=".ProductsAdapter" />
|
||||
<activity android:name=".Product" />
|
||||
<activity android:name=".DecodeFail" />
|
||||
<activity android:name=".Decode" />
|
||||
<activity android:name=".DecodeFail"
|
||||
android:label="Skanowanie"/>
|
||||
<activity android:name=".Decode"
|
||||
android:label="Skanowanie"/>
|
||||
<activity android:name=".TakePhoto" />
|
||||
<activity android:name=".Help" />
|
||||
<activity android:name=".About" />
|
||||
<activity android:name=".MainActivity">
|
||||
<activity android:name=".Help"
|
||||
android:label="Pomoc"/>
|
||||
<activity android:name=".About"
|
||||
android:label="O aplikacji"/>
|
||||
<activity android:name=".MainActivity"
|
||||
android:label="Lookify">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@ -133,10 +133,16 @@ public class Decode extends AppCompatActivity {
|
||||
finish();
|
||||
}
|
||||
if(reminder == 0) {
|
||||
|
||||
Toast.makeText(this, contents,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
|
||||
Intent intent_Results = new Intent(this, Results.class);
|
||||
intent_Results.putExtra("decodedcode", contents);
|
||||
startActivity(intent_Results);
|
||||
finish();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.example.lookifyv2;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@ -18,7 +19,9 @@ public class DecodeFail extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_decode_fail);
|
||||
|
||||
button_tryagain = findViewById(R.id.try_again_button);
|
||||
button_tryagain.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
button_backtomain = findViewById(R.id.backto_main_button);
|
||||
button_backtomain.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
button_tryagain.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
123
Lookify/app/src/main/java/com/example/lookifyv2/Favourites.java
Normal file
123
Lookify/app/src/main/java/com/example/lookifyv2/Favourites.java
Normal file
@ -0,0 +1,123 @@
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class Favourites extends AppCompatActivity {
|
||||
|
||||
private List<Product> products;
|
||||
private List<Product> favourites;
|
||||
private RecyclerView recyclerView;
|
||||
private GridLayoutManager gridLayout;
|
||||
private FavouritesAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_favourites);
|
||||
|
||||
recyclerView = findViewById(R.id.favouriterecyclerview);
|
||||
products = new ArrayList<>();
|
||||
favourites = new ArrayList<>();
|
||||
getProductsFromDB();
|
||||
|
||||
gridLayout = new GridLayoutManager(this, 2);
|
||||
recyclerView.setLayoutManager(gridLayout);
|
||||
|
||||
adapter = new FavouritesAdapter(this, favourites);
|
||||
recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
private void getProductsFromDB() {
|
||||
|
||||
@SuppressLint("StaticFieldLeak") AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... Void) {
|
||||
|
||||
OkHttpClient client = new OkHttpClient();
|
||||
Request request = new Request.Builder().url("http://192.168.8.101/products.php?id=0").build();
|
||||
try {
|
||||
Response response = client.newCall(request).execute();
|
||||
|
||||
JSONArray array = new JSONArray(response.body().string());
|
||||
|
||||
for (int i = 0; i < array.length(); i++) {
|
||||
|
||||
JSONObject object = array.getJSONObject(i);
|
||||
|
||||
Product product = new Product(object.getInt("id"), object.getString("product_code"),
|
||||
object.getString("product_name"), object.getString("product_image"),
|
||||
object.getString("product_price"), object.getString("product_retailer"),
|
||||
object.getString("product_colour"), object.getString("product_style"),
|
||||
object.getString("product_collection"),
|
||||
object.getString("product_type"), object.getString("product_sex"));
|
||||
|
||||
Favourites.this.products.add(product);
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
getFavourites();//funkcja
|
||||
}
|
||||
};
|
||||
asyncTask.execute();
|
||||
}
|
||||
|
||||
private void getFavourites() {
|
||||
SharedPreferences pref = MyApplication.getInstance().getSharedPreferences("Favourites", 0);
|
||||
Map<String, ?> codes = pref.getAll();
|
||||
ArrayList<String> codeslist = Lists.newArrayList(codes.keySet());
|
||||
if (codeslist.size() == 0) {
|
||||
TextView noproductsmessage = findViewById(R.id.nofavouritesmessage);
|
||||
noproductsmessage.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
for (int i = 0; i < products.size(); i++) {
|
||||
if (codeslist.size() != 0) {
|
||||
for (int j = 0; j < codeslist.size(); j++) {
|
||||
if (products.get(i).getproductCode().equals(codeslist.get(j))) {
|
||||
favourites.add(products.get(i));
|
||||
codeslist.remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.PopupMenu;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FavouritesAdapter extends RecyclerView.Adapter<FavouritesAdapter.ViewHolder>{
|
||||
|
||||
private Context context;
|
||||
private List<Product> products;
|
||||
|
||||
public FavouritesAdapter(Context context, List<Product> products) {
|
||||
this.context = context;
|
||||
this.products = products;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
|
||||
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.card,parent,false);
|
||||
|
||||
return new ViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(final ViewHolder holder, int position) {
|
||||
|
||||
Glide.with(context).load(products.get(position).getImageLink()).into(holder.imageView);
|
||||
holder.productName.setText(products.get(position).getproductName());
|
||||
holder.productPrice.setText(products.get(position).getproductPrice());
|
||||
holder.productRetailer.setText(products.get(position).getproductRetailer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return products.size();
|
||||
}
|
||||
|
||||
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
|
||||
|
||||
private ImageView imageView;
|
||||
private TextView productName;
|
||||
private TextView productPrice;
|
||||
private TextView productRetailer;
|
||||
|
||||
private ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
imageView = itemView.findViewById(R.id.productimage);
|
||||
imageView.setOnClickListener(this);
|
||||
productName = itemView.findViewById(R.id.productname);
|
||||
productPrice = itemView.findViewById(R.id.productprice);
|
||||
productRetailer = itemView.findViewById(R.id.productretailer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int position = getAdapterPosition();
|
||||
showPopupMenu(v,position);
|
||||
}
|
||||
}
|
||||
|
||||
private void showPopupMenu(View view, int position) {
|
||||
PopupMenu popup = new PopupMenu(context, view);
|
||||
MenuInflater inflater = popup.getMenuInflater();
|
||||
inflater.inflate(R.menu.menu_favourites, popup.getMenu());
|
||||
popup.setOnMenuItemClickListener(new MenuClickListener(position));
|
||||
popup.show();
|
||||
}
|
||||
|
||||
class MenuClickListener implements PopupMenu.OnMenuItemClickListener {
|
||||
Integer pos;
|
||||
private MenuClickListener(int pos) {
|
||||
this.pos=pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_remove:
|
||||
SharedPreferences pref = MyApplication.getInstance().getSharedPreferences("Favourites", 0);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
editor.remove(products.get(pos).getproductCode());
|
||||
editor.apply();
|
||||
|
||||
Intent intent_Favourites = new Intent(context, Favourites.class);
|
||||
intent_Favourites.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
context.startActivity(intent_Favourites);
|
||||
|
||||
Toast.makeText(context, "Produkt \"" + products.get(pos).getproductName() + "\" został usunięty z Obserwowanych.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
case R.id.action_favourite_details:
|
||||
Intent intent_Popup = new Intent(context, Popup.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
|
||||
bundle.putSerializable("productimage", products.get(pos).getImageLink());
|
||||
bundle.putSerializable("productcode", products.get(pos).getproductCode());
|
||||
bundle.putSerializable("productname", products.get(pos).getproductName());
|
||||
bundle.putSerializable("productprice", products.get(pos).getproductPrice());
|
||||
bundle.putSerializable("productretailer", products.get(pos).getproductRetailer());
|
||||
bundle.putSerializable("productcolour", products.get(pos).getproductColour());
|
||||
bundle.putSerializable("productstyle", products.get(pos).getproductStyle());
|
||||
bundle.putSerializable("productcollection", products.get(pos).getproductCollection());
|
||||
|
||||
intent_Popup.putExtras(bundle);
|
||||
|
||||
context.startActivity(intent_Popup);
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.example.lookifyv2;
|
||||
import android.Manifest;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
@ -14,8 +15,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Button button_scan;
|
||||
Button button_help;
|
||||
Button button_about;
|
||||
|
||||
Button button_results;
|
||||
Button button_favourites;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@ -23,10 +23,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
button_scan = findViewById(R.id.scan_start_button);
|
||||
button_scan.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
button_help = findViewById(R.id.help_start_button);
|
||||
button_help.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
button_about = findViewById(R.id.about_start_button);
|
||||
|
||||
button_results = findViewById(R.id.results_start_button);
|
||||
button_about.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
button_favourites = findViewById(R.id.favourites_start_button);
|
||||
button_favourites.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
button_scan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -46,11 +49,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
openAbout();
|
||||
}
|
||||
});
|
||||
|
||||
button_results.setOnClickListener(new View.OnClickListener() {
|
||||
button_favourites.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
openResults();
|
||||
openFavourites();
|
||||
}
|
||||
});
|
||||
|
||||
@ -87,10 +89,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
startActivity(intent_Scan);
|
||||
}
|
||||
|
||||
public void openResults(){
|
||||
Intent intent_Results = new Intent(this, Results.class);
|
||||
startActivity(intent_Results);
|
||||
public void openFavourites(){
|
||||
Intent intent_Favourites = new Intent(this, Favourites.class);
|
||||
startActivity(intent_Favourites);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
//https://stackoverflow.com/a/12405879/12566206
|
||||
public class MyApplication extends Application {
|
||||
private static MyApplication instance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public static MyApplication getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.example.lookifyv2;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.View;
|
||||
@ -40,6 +42,7 @@ public class Popup extends AppCompatActivity {
|
||||
productCollection.setText(Html.fromHtml("<b>" + "Kolekcja:" + "</b> " + bundle.getSerializable("productcollection")));
|
||||
|
||||
button_back = findViewById(R.id.back_button);
|
||||
button_back.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
button_back.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ package com.example.lookifyv2;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.content.Context;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@ -18,8 +19,11 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ViewHolder>{
|
||||
|
||||
@ -94,8 +98,25 @@ public class ProductsAdapter extends RecyclerView.Adapter<ProductsAdapter.ViewHo
|
||||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_favourite:
|
||||
Toast.makeText(context, "Produkt \"" + products.get(pos).getproductName() + "\" został dodany do obserwowanych",
|
||||
SharedPreferences pref = MyApplication.getInstance().getSharedPreferences("Favourites", 0);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
Map<String, ?> codes = pref.getAll();
|
||||
ArrayList<String> codeslist = Lists.newArrayList(codes.keySet());
|
||||
int checker = 0;
|
||||
for(int i = 0; i < codeslist.size(); i++){
|
||||
if(products.get(pos).getproductCode().equals(codeslist.get(i))){
|
||||
checker = -1;
|
||||
Toast.makeText(context, "Ten produkt jest już obserwowany!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(checker == 0){
|
||||
editor.putBoolean(products.get(pos).getproductCode(), true);
|
||||
editor.apply(); //commit?
|
||||
Toast.makeText(context, "Produkt \"" + products.get(pos).getproductName() + "\" został dodany do Obserwowanych.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
case R.id.action_details:
|
||||
Intent intent_Popup = new Intent(context, Popup.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
@ -5,6 +5,8 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
@ -108,7 +110,7 @@ public class Results extends AppCompatActivity {
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
adapter.notifyDataSetChanged();
|
||||
|
||||
/*
|
||||
|
||||
Bundle extras = getIntent().getExtras();
|
||||
decodedCode = extras.getString("decodedcode");
|
||||
|
||||
@ -124,8 +126,8 @@ public class Results extends AppCompatActivity {
|
||||
startActivity(intent_DecodeFail);
|
||||
finish();
|
||||
}
|
||||
*/
|
||||
int foundPosition = 2; //TESTESTSRETSTETSTETT
|
||||
|
||||
//int foundPosition = 2; //TESTESTSRETSTETSTETT
|
||||
|
||||
ImageView imageView = findViewById(R.id.foundproductimage);
|
||||
TextView foundProductPrice = findViewById(R.id.foundproductprice);
|
||||
@ -138,7 +140,9 @@ public class Results extends AppCompatActivity {
|
||||
getFoundProductRetailer.setText(products.get(foundPosition).getproductRetailer());
|
||||
|
||||
button_favourite = findViewById(R.id.favourite_button);
|
||||
button_favourite.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
button_details = findViewById(R.id.details_button);
|
||||
button_details.getBackground().setColorFilter(0xFF67BAFF, PorterDuff.Mode.MULTIPLY);
|
||||
|
||||
final int finalFoundPosition = foundPosition;
|
||||
button_favourite.setOnClickListener(new View.OnClickListener() {
|
||||
@ -180,11 +184,28 @@ public class Results extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void addFavourite(Context context, int position){
|
||||
Toast.makeText(context, "Produkt \"" + products.get(position).getproductName() + "\" został dodany do obserwowanych",
|
||||
SharedPreferences pref = MyApplication.getInstance().getSharedPreferences("Favourites", 0);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
Map<String, ?> codes = pref.getAll();
|
||||
ArrayList<String> codeslist = Lists.newArrayList(codes.keySet());
|
||||
int checker = 0;
|
||||
for(int i = 0; i < codeslist.size(); i++){
|
||||
if(products.get(position).getproductCode().equals(codeslist.get(i))){
|
||||
checker = -1;
|
||||
Toast.makeText(context, "Ten produkt jest już obserwowany!",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(checker == 0){
|
||||
editor.putBoolean(products.get(position).getproductCode(), true);
|
||||
editor.apply(); //commit?
|
||||
Toast.makeText(context, "Produkt \"" + products.get(position).getproductName() + "\" został dodany do Obserwowanych.",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
public void getRecommendedProducts(int foundpos){
|
||||
private void getRecommendedProducts(int foundpos){
|
||||
HashMap<Integer, Integer> ranking = new HashMap<>();
|
||||
for(int i = 0; i < products.size(); i++) {
|
||||
if (products.get(foundpos).getId() != products.get(i).getId()
|
||||
@ -221,8 +242,6 @@ public class Results extends AppCompatActivity {
|
||||
List<Map.Entry<Integer, Integer>> rankinglist = Lists.newArrayList(ranking.entrySet());
|
||||
Collections.sort(rankinglist, byMapValues.reverse());
|
||||
|
||||
|
||||
|
||||
for(int i = 0; i < 6; i++) {
|
||||
productstop6.add(products.get(rankinglist.get(i).getKey()));
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -15,6 +15,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -28,7 +28,8 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/backto_main_button"
|
||||
@ -41,6 +42,7 @@
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/try_again_button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
31
Lookify/app/src/main/res/layout/activity_favourites.xml
Normal file
31
Lookify/app/src/main/res/layout/activity_favourites.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="#67BAFF"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:card_view="http://schemas.android.com/tools"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/nofavouritesmessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:layout_marginTop="712dp"
|
||||
android:text="Nie obserwujesz żadnych produktów..."
|
||||
android:visibility="gone" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/favouriterecyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
card_view:cardUseCompatPadding="true"
|
||||
card_view:cardElevation="4dp"
|
||||
card_view:cardCornerRadius="4dp"
|
||||
android:scrollbars="vertical"
|
||||
android:layout_marginTop="6dp"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp" />
|
||||
|
||||
</RelativeLayout>
|
@ -15,6 +15,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -8,18 +8,33 @@
|
||||
|
||||
<Button
|
||||
android:id="@+id/scan_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="314dp"
|
||||
android:layout_height="104dp"
|
||||
android:text="Skanowanie"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/favourites_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Obserwowane"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/scan_start_button"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/help_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Pomoc"
|
||||
@ -27,12 +42,13 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/scan_start_button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/favourites_start_button"
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/about_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="130dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="O aplikacji"
|
||||
@ -41,19 +57,7 @@
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/help_start_button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/results_start_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="Results test"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/about_start_button"
|
||||
app:layout_constraintVertical_bias="0.0" />
|
||||
app:layout_constraintVertical_bias="0.0"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -115,7 +115,8 @@
|
||||
app:layout_constraintHorizontal_bias="1.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="1.0" />
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.785">
|
||||
android:layout_weight="0.75">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/header"
|
||||
@ -23,7 +23,8 @@
|
||||
android:text="Rekomendacje dla produktu:"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/foundproductimage"
|
||||
@ -50,7 +51,8 @@
|
||||
android:layout_marginTop="8dp"
|
||||
app:autoSizeTextType="uniform"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/header" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/header"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/foundproductretailer"
|
||||
@ -60,7 +62,8 @@
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/foundproductname" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/foundproductname"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/foundproductprice"
|
||||
@ -70,7 +73,8 @@
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/foundproductretailer" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/foundproductretailer"
|
||||
android:textColor="#000000"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/favourite_button"
|
||||
@ -81,7 +85,8 @@
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="Obserwuj"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/details_button"
|
||||
@ -92,15 +97,16 @@
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="Szczegóły"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:textColor="#FFFFFF"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="0.215"
|
||||
android:background="#3889FF">
|
||||
android:layout_weight="0.25"
|
||||
android:background="#67BAFF">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noproductsmessage"
|
||||
|
@ -36,7 +36,7 @@
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/cardview_dark_background"
|
||||
android:textColor="#000000"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
@ -47,7 +47,7 @@
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/cardview_dark_background" />
|
||||
android:textColor="#000000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/productprice"
|
||||
@ -57,7 +57,7 @@
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:textColor="@color/cardview_dark_background"
|
||||
android:textColor="#000000"
|
||||
android:textStyle="bold" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
<menu 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">
|
||||
<item
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_favourite"
|
||||
android:title="Obserwuj" />
|
||||
<item
|
||||
|
9
Lookify/app/src/main/res/menu/menu_favourites.xml
Normal file
9
Lookify/app/src/main/res/menu/menu_favourites.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item
|
||||
android:id="@+id/action_remove"
|
||||
android:title="Usuń z Obserwowanych" />
|
||||
<item
|
||||
android:id="@+id/action_favourite_details"
|
||||
android:title="Szczegóły" />
|
||||
</menu>
|
@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<color name="colorPrimary">#008577</color>
|
||||
<color name="colorPrimaryDark">#00574B</color>
|
||||
<color name="colorPrimary">#67BAFF</color>
|
||||
<color name="colorPrimaryDark">#0052A5</color>
|
||||
<color name="colorAccent">#D81B60</color>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user