Skip to content

Fav_API ์—ฐ๊ฒฐ(1)_activities, ProductModels ๐Ÿžย #13

Description

@honghyoeun
  1. activities _ ProductImageView.java

์ด๋ฏธ์ง€์™€ Url, File ๊ฒฝ๋กœ๋ฅผ ์ €์žฅํ•˜๊ณ , ํ•ด๋‹น ๊ฐ’๋“ค์„ ๊ฐ€์ ธ์˜ค๊ฑฐ๋‚˜ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฐ„๋‹จํ•œ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ ํด๋ž˜์Šค, ์ด๋ฏธ์ง€์™€ ๊ด€๋ จ๋œ ๋ฐ์ดํ„ฐ๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๋Š”๋ฐ ์‚ฌ์šฉ

package com.example.stylerent.activities;

import android.net.Uri;

import java.io.File;

public class ProductImageView {
    Uri uri;
    File imagePath;

    public ProductImageView(Uri uri, File imagePath) {
        this.uri = uri;
        this.imagePath = imagePath;
    }

    public Uri getUri() { /*์ €์žฅ๋œ Uri ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ*/
        return uri;
    }

    public File getImagePath() { /*์ €์žฅ๋œ File ๊ฒฝ๋กœ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ*/
        return imagePath;
    }

    public void setUri(Uri uri) { /*Uri ๊ฐ์ฒด๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ, ์ฃผ์–ด์ง„ Uri๋ฅผ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ €์žฅ*/
        this.uri = uri;
    }

    public void setImagePath(File imagePath) { /*File ๊ฒฝ๋กœ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ, ์ฃผ์–ด์ง„ File ๊ฒฝ๋กœ๋ฅผ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ €์žฅ*/
        this.imagePath = imagePath;
    }
}
  • Uri uri : ๋ฆฌ์†Œ์Šค๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐ ์‚ฌ์šฉ๋˜๋Š” ์‹๋ณ„์ž, ์ด๋ฏธ์ง€ Uri๋ฅผ ์ €์žฅํ•˜๋Š”๋ฐ ์‚ฌ์šฉ
  • File imagePath : ํŒŒ์ผ์ด๋‚˜ ๋””๋ ‰ํ† ๋ฆฌ ๊ฒฝ๋กœ๋Š” ๋‚˜ํƒ€๋‚ด๋Š” ๋ฐ ์‚ฌ์šฉ, ์ด๋ฏธ์ง€ ํŒŒ์ผ์˜ ๊ฒฝ๋กœ๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ
  • public ProductImageView(Uri uri, File imagePath): ProductImageView ****: ํด๋ž˜์Šค์˜ ์ƒ์„ฑ์ž, ์ƒ์„ฑ์ž Uri์™€ File ๊ฒฝ๋กœ๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›์•„ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ €์žฅ

  1. ProductModels_CustomFavModel.java

์‚ฌ์šฉ์ž์˜ ์ฆ๊ฒจ์ฐพ๊ธฐ์— ์žˆ๋Š” ์ƒํ’ˆ ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๋Š”๋ฐ ์‚ฌ์šฉ, ์‚ฌ์šฉ์ž๊ฐ€ ์ฆ๊ฒจ์ฐพ๊ธฐํ•œ ์ƒํ’ˆ๋“ค์˜ ์ •๋ณด๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ  ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

package com.example.stylerent.auth;

public class CustomFavModel {
    private String productImage;
    private Integer productId;
    private String productName;
    private String productPrice;
}
  • private String prodcutImage : ์ƒํ’ˆ ์ด๋ฏธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฌธ์ž์—ด ๋ณ€์ˆ˜, ์ด ๋ณ€์ˆ˜๋Š” ์ƒํ’ˆ์˜ ์ด๋ฏธ์ง€ URL์ด๋‚˜ ์ด๋ฏธ์ง€ ํŒŒ์ผ ๊ฒฝ๋กœ ์ €์žฅ
  • private Integer productId : ์ƒํ’ˆ ID๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ •์ˆ˜ํ˜• ๋ณ€์ˆ˜, ๊ฐ ์ƒํ’ˆ์— ๊ณ ์œ ํ•œ ID ๊ฐ’ ์ €์žฅ
  • private String productName : ์ƒํ’ˆ ์ด๋ฆ„์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฌธ์ž์—ด ๋ณ€์ˆ˜, ์ƒํ’ˆ์˜ ์ด๋ฆ„ ์ €์žฅ
  • private String productPrice : ์ƒํ’ˆ ๊ฐ€๊ฒฉ์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฌธ์ž์—ด ๋ณ€์ˆ˜, ์ƒํ’ˆ ๊ฐ€๊ฒฉ ์ •๋ณด ์ €์žฅ

  1. ProductModels_FavAdapterModel.java

์ฆ๊ฒจ์ฐพ๊ธฐ ๋ชฉ๋ก์— ํ‘œ์‹œ๋˜๋Š” ์ƒํ’ˆ์˜ ์ •๋ณด๋ฅผ ๊ฐ„๋‹จํ•˜๊ฒŒ ์ €์žฅ, ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ชฉ๋ก์„ ํ‘œ์‹œํ•˜๋Š” ์–ด๋Œ‘ํ„ฐ์—์„œ ๊ฐ ์•„์ดํ…œ์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ  ํ™œ์šฉ

package com.example.stylerent.auth;

import android.graphics.Bitmap;

public class FavAdapterModel {
    private Integer productId;
    private String productName;
    private String productPrice;
    private Bitmap imageBitmap; /*์ƒํ’ˆ ์ด๋ฏธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” Bitmap ๊ฐ์ฒด*/

    public FavAdapterModel(Integer productId, String productName, String productPrice, Bitmap imageBitmap) {
        this.productId = productId;
        this.productName = productName;
        this.productPrice = productPrice;
        this.imageBitmap = imageBitmap;
    }

    public Integer getProductId() { /*์ €์žฅ๋œ ์ƒํ’ˆ ID๋ฅผ ๋ฐ˜ํ™˜*/
        return productId;
    }

    public void setProductId(Integer productId) { /*์ƒํ’ˆ ID ์„ค์ •, ์ฃผ์–ด์ง„ ID๋ฅผ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ €์žฅ*/
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(String productPrice) {
        this.productPrice = productPrice;
    }

    public Bitmap getImageBitmap() { /*์ €์žฅ๋œ ์ด๋ฏธ์ง€ ๋น„ํŠธ๋งต์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ*/
        return imageBitmap;
    }

    public void setImageBitmap(Bitmap imageBitmap) { /*์ด๋ฏธ์ง€ ๋น„ํŠธ๋งต์„ ์„ค์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ, ์ฃผ์–ด์ง„ ๋น„ํŠธ๋งต์„ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ €์žฅ */
        this.imageBitmap = imageBitmap;
    }
}

  1. ProductModels_FavModel.java

์ฆ๊ฒจ์ฐพ๊ธฐ์— ์žˆ๋Š” ์ƒํ’ˆ ์ •๋ณด ์ €์žฅ, ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ชฉ๋ก์„ ํ‘œ์‹œํ•˜๊ฑฐ๋‚˜ ์ƒ์„ธ ์ •๋ณด๋ฅผ ํ‘œ์‹œํ•˜๋Š” ๋“ฑ์˜ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•  ๋•Œ ์‚ฌ์šฉ

package com.example.stylerent.auth;

import android.graphics.Bitmap;

public class FavModel {
    private String productImage;
    private Integer productId;
    private String productName;
    private String productPrice;
    private Bitmap imageBitmap;

    public FavModel(String productImage, Integer productId, String productName, String productPrice, Bitmap imageBitmap) {
        this.productImage = productImage;
        this.productId = productId;
        this.productName = productName;
        this.productPrice = productPrice;
        this.imageBitmap = imageBitmap;
    }

    public Bitmap getImageBitmap() {
        return imageBitmap;
    }

    public void setImageBitmap(Bitmap imageBitmap) {
        this.imageBitmap = imageBitmap;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getProductImage() {
        return productImage;
    }

    public void setProductImage(String productImage) {
        this.productImage = productImage;
    }

    public Integer getProductId() {
        return productId;
    }

    public void setProductId(Integer productId) {
        this.productId = productId;
    }

    public String getProductPrice() {
        return productPrice;
    }

    public void setProductPrice(String productPrice) {
        this.productPrice = productPrice;
    }
}

  1. ProductModels_lmagePathRequest.java

์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ์„œ๋ฒ„์— ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•œ ์š”์ฒญ ๊ฐ์ฒด๋ฅผ ์ •์˜ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ, ์˜ˆ๋ฅผ ๋“ค์–ด ์ด๋ฏธ์ง€๋ฅผ ์—…๋กœ๋“œํ•˜๊ฑฐ๋‚˜ ์ด๋ฏธ์ง€๋ฅผ ์š”์ฒญํ•˜๊ธฐ ์œ„ํ•œ API์—์„œ ์‚ฌ์šฉ

์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ์บก์Аํ™”ํ•˜๊ณ  ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ๋‹ค.

package com.example.stylerent.auth;

public class ImagePathRequest {
    private String imagePath;

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public ImagePathRequest(String imagePath) {
        this.imagePath = imagePath;
    }
}
  • private String imagePath : ์ด๋ฏธ์ง€ ํŒŒ์ผ์˜ ๊ฒฝ๋กœ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฌธ์ž์—ด, ์ด๋ฏธ์ง€ ํŒŒ์ผ์˜ ๋กœ์ปฌ ๊ฒฝ๋กœ๋‚˜ ์›๊ฒฉ ๊ฒฝ๋กœ ์ €์žฅ
  • private String getImagePatr() : ์ €์žฅ๋œ ์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฉ”์„œ๋“œ
  • public void setImagePath(String imagePath) : ์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ, ์ฃผ์–ด์ง„ ๊ฒฝ๋กœ๋ฅผ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ €์žฅ
  • public ImagePathRequest(String imagePath) : ImagePathRequest ํด๋ž˜์Šค ์ƒ์„ฑ์ž, ์ƒ์„ฑ์ž๋Š” ์ด๋ฏธ์ง€ ๊ฒฝ๋กœ๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๋ฐ›์•„ ๋ฉค๋ฒ„ ๋ณ€์ˆ˜์— ์ง€์ •

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions