Skip to content

Commit

Permalink
Rename photo to content
Browse files Browse the repository at this point in the history
  • Loading branch information
SungjunApp committed Oct 7, 2020
1 parent 42cd6ab commit c9f56ad
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 35 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# pixlee-android-sdk
This SDK makes it easy for Pixlee customers to find and download Pixlee images and albums. There's a native wrapper to the Pixlee album API for Android, and there's also a demo app showing how easy it is to drop in and customize a UI. This repo includes both the Pixlee Android SDK and an example project to show you how it's used.


### Notice: please be aware of these terms in the document.
- the word 'content' is used in the documentation. this means a photo or video.
- PXLPhoto contains a content, which can be a photo or video.

# Table of Content
- [Get Started](#Get-Started)
- [Run the Demo App](#Run-the-Demo-App)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void loadPixleeAlbum() {
public void onComplete(ArrayList<PXLPhoto> result) {
photos.addAll(result);
if(result.size()>0){
binding.pxlPhotoView.setPhoto(result.get(0), PXLPhotoView.ImageScaleType.FIT_CENTER);
binding.pxlPhotoView.setContent(result.get(0), PXLPhotoView.ImageScaleType.FIT_CENTER);
}

binding.tvStatus.setText(R.string.album_loading_complete);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class KtxAnalyticsFragment : BaseFragment() {
when (it) {
is BaseViewModel.Command.Data -> {
it.list.firstOrNull()?.also {
pxlPhotoView.setPhoto(it.pxlPhoto, PXLPhotoView.ImageScaleType.FIT_CENTER)
pxlPhotoView.setContent(it.pxlPhoto, PXLPhotoView.ImageScaleType.FIT_CENTER)
}
tvStatus.setText(R.string.album_loading_complete)
tvStatus.text = if(it.isFirstPage) "First Load" else "Loaded More..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class PXLPhotoViewFragment : BaseFragment(), LifecycleObserver {

fun initPXLPhotoView(pxlPhotoView: PXLPhotoView, configuration: PXLPhotoView.Configuration, data:PhotoWithImageScaleType, imageScaleType: PXLPhotoView.ImageScaleType){
pxlPhotoView.setConfiguration(configuration = configuration)
pxlPhotoView.setPhoto(data.pxlPhoto, imageScaleType)
pxlPhotoView.setContent(data.pxlPhoto, imageScaleType)
pxlPhotoView.setLooping(data.isLoopingVideo)
pxlPhotoView.setVolume(if(data.soundMuted) 0f else 1f)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import android.content.Intent
import android.graphics.Color
import android.net.Uri
import android.os.Bundle
import android.util.Log
import android.util.TypedValue
import android.view.View
import android.widget.Toast
import androidx.annotation.DrawableRes
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.pixlee.pixleeandroidsdk.R
Expand Down Expand Up @@ -59,7 +57,7 @@ class ViewerActivity : AppCompatActivity() {

fun init(item: PhotoWithVideoInfo){
pxlPhotoProductView.useLifecycleObserver(lifecycle)
pxlPhotoProductView.setPhoto(photoInfo = item,
pxlPhotoProductView.setContent(photoInfo = item,
configuration = ProductViewHolder.Configuration().apply {
circleIcon = ProductViewHolder.CircleIcon().apply {
icon = R.drawable.outline_shopping_bag_black_24
Expand Down
31 changes: 16 additions & 15 deletions doc/kotlin/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
- [Album and Product Features](#Album-and-Product-Features)
- [Initialization](#Initialization)
- [Prepare parameters](#Prepare-parameters)
- Option 1: [to get Album photos](#to-get-Album-photos)
- Option 2: [to get Product photos](#to-get-Product-photos)
- Option 1: [to get Album contents](#to-get-Album-contents)
- Option 2: [to get Product contents](#to-get-Product-contents)
- [Advanced parameter options](#Advanced-parameter-options)
- [Get Photos](#Get-Photos)
- [Get contents](#Get-contents)
- [Get a PXLPhoto with an album photo id](API.md#get-pxlphoto-with-an-albumphotoid)
- [How to get image urls](#How-to-get-image-urls)
- Analytics
- [Album Analytics](#Album-Analytics)
Expand All @@ -20,7 +21,7 @@
- [Conversion](#Conversion)

## Album and Product Features
To prepare to load the photos, you'll need the codes below
To prepare to load the contents, you'll need the codes below
### Initialization
```kotlin
#!kotlin
Expand All @@ -44,7 +45,7 @@ val ktxAnalyticsDataSource = client.ktxAnalyticsDataSource
val pxlKtxAlbum = PXLKtxAlbum(ktxBasicDataSource, ktxAnalyticsDataSource)
```
### Prepare parameters
- #### Option 1: to get Album photos
- #### Option 1: to get Album contents
```kotlin
#!kotlin

Expand All @@ -54,7 +55,7 @@ pxlKtxAlbum.params = PXLKtxBaseAlbum.Params(
searchId = searchId
)
```
- #### Option 2: to get Product photos
- #### Option 2: to get Product contents
```kotlin
#!kotlin

Expand Down Expand Up @@ -83,7 +84,7 @@ pxlKtxAlbum.params = PXLKtxBaseAlbum.Params(
}
)
```
### Get Photos
### Get contents (a list of PXLPhoto)
Get the first page
```kotlin
#!Kotlin.coroutines
Expand All @@ -98,15 +99,15 @@ Get the next pages
val result = pxlKtxAlbum.getNextPage()
```

### Get a Photo with an albumPhotoId of PXLPhoto
### Get PXLPhoto with an albumPhotoId
```kotlin
#!Kotlin.coroutines

val albumPhotoId:String = <one of your album photo ids>
val result:PXLPhoto = pxlKtxAlbum.getPhotoWithId(albumPhotoId)
```

## How to get image urls
### How to get image urls
Some imageURL fields can be empty or null depending on its data's status. In order to get appropriate images, you can use this method.
```kotlin
#!kotlin
Expand All @@ -127,7 +128,7 @@ You can see the example codes for analytics in the demo app.
Be aware of the difference between **Opened Widget** and **Widget Visible**. (Need a sample code. Check the demo app in the project)

There is an order of firing these two APIs.
1. **Opened Widget**: You should fire this when firing the api is done and loading the photo data into your own view for the widget is complete.
1. **Opened Widget**: You should fire this when firing the api is done and loading a list of PXLPhoto into your own view for the widget is complete.
2. **Widget Visible**: **Opened Widget** should be fired first. Then, you can fire this when your own view for the widget started to be visible on the screen.

- #### Opened Widget
Expand Down Expand Up @@ -161,16 +162,16 @@ See the onComplete function in GalleryFragment.java for an example.

pxlKtxAlbum.loadMore();
```
- if you want to manually fire pxlKtxAlbum.loadMore(), first you must successfully call this pxlKtxAlbum.getNextPage(callLoadMoreAnalytics = true) to get photos which does not fire loadMore(), then you manually fire pxlKtxAlbum.loadMore() in your app.
- if you want to manually fire pxlKtxAlbum.loadMore(), first you must successfully call this pxlKtxAlbum.getNextPage(callLoadMoreAnalytics = true) to get contents which does not fire loadMore(), then you manually fire pxlKtxAlbum.loadMore() in your app.

### Opened Lightbox
- To fire an opened ligtbox event, simply call the `openedLightbox` method of PXLKtxAlbum, and an "Opened Lightbox" event will be fired containing all of the necessary analytics information.

```kotlin
#!Kotlin.coroutines

pxlKtxAlbum.openedLightbox(photo.albumPhotoId)
pxlKtxAlbum.openedLightbox(photo)
pxlKtxAlbum.openedLightbox(pxlPhoto.albumPhotoId)
pxlKtxAlbum.openedLightbox(pxlPhoto)
```

### Action Clicked
Expand All @@ -179,8 +180,8 @@ See the onComplete function in GalleryFragment.java for an example.
```kotlin
#!Kotlin.coroutines

pxlKtxAlbum.actionClicked(photo.albumPhotoId, "https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html");
pxlKtxAlbum.actionClicked(photo, "https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html");
pxlKtxAlbum.actionClicked(pxlPhoto.albumPhotoId, "https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html");
pxlKtxAlbum.actionClicked(pxlPhoto, "https://ca.puma.com/en/ca/pd/clyde-court-core-basketball-shoes/191712.html");

```
## Ecommerce Analytics
Expand Down
3 changes: 2 additions & 1 deletion doc/kotlin/INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
# Table of Content
- [Initialize SDK](#Initialize-SDK)
- [Register Pixlee credentials](#Register-Pixlee-credentials)
- [API: Getting Album/PDP photos](API.md)
- [API: Getting Album/PDP contents](API.md)
- [API: Getting a PXLPhoto with an album photo id](API.md#get-pxlphoto-with-an-albumphotoid)
- [API: Analytics for album/product](API.md#album-analytics)
- [API: Analytics for Ecommerce](API.md#ecommerce-analytics)
- [UI Components](UI.md)
Expand Down
10 changes: 5 additions & 5 deletions doc/kotlin/UI.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ override fun onCreate(savedInstanceState: Bundle?) {
...
...
val item: PhotoWithVideoInfo? = i.getParcelableExtra("photoWithVideoInfo")
// if the photo is null, close this image view
// if item is null, close this image view
if (item == null) {
finish()
return
}
pxlPhotoProductView.setPhoto(photoInfo = item,
pxlPhotoProductView.loadContent(photoInfo = item,
configuration = ProductViewHolder.Configuration().apply {
circleIcon = ProductViewHolder.CircleIcon().apply {
icon = R.drawable.<your drawable>
Expand Down Expand Up @@ -290,11 +290,11 @@ override fun onCreate(savedInstanceState: Bundle?) {
fun startList(cellSize: Int) {
// write codes to get photos first. Read API doc.
// you should convert List<PXLPhoto> into List<PhotoWithImageScaleType>
val photos: List<PXLPhoto> = ....
val pxlPhotos: List<PXLPhoto> = ....
// turn the list into List<PhotoWithImageScaleType> to set ImageScaleType[CENTER_CROP, FIT_CENTER], and the cells' height size
val list = ArrayList<PhotoWithImageScaleType>()
photos.forEach { pxlPhoto ->
pxlPhotos.forEach { pxlPhoto ->
list.add(PhotoWithImageScaleType(pxlPhoto = pxlPhoto,
imageScaleType = PXLPhotoView.ImageScaleType.CENTER_CROP,
heightInPixel = cellSize,
Expand Down Expand Up @@ -417,7 +417,7 @@ class YourActivity: AppCompatActivity, LifecycleObserver {

}
pxlPhotoView.setConfiguration(configuration)
pxlPhotoView.setPhoto(it, PXLPhotoView.ImageScaleType.CENTER_CROP)
pxlPhotoView.loadContent(it, PXLPhotoView.ImageScaleType.CENTER_CROP)
}

@OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class PXLPhotoViewHolder(override val containerView: View) :
fun bind(data: PhotoWithImageScaleType, configuration: PXLPhotoView.Configuration? = null, showingDebugView: Boolean = false) {
pxlPhotoView.layoutParams.height = data.heightInPixel
pxlPhotoView.setConfiguration(configuration = configuration ?: PXLPhotoView.Configuration())
pxlPhotoView.setPhoto(data.pxlPhoto, data.imageScaleType)
pxlPhotoView.setContent(data.pxlPhoto, data.imageScaleType)
pxlPhotoView.setLooping(data.isLoopingVideo)
pxlPhotoView.setVolume(if(data.soundMuted) 0f else 1f)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ class PXLPhotoProductView : FrameLayout, LifecycleObserver {
* if not null, show bookmark toggle
* @param onBookmarkClicked {productId: String, isBookmarkChecked: Boolean -> ... }
*/
fun setPhoto(photoInfo: PhotoWithVideoInfo,
configuration: ProductViewHolder.Configuration = ProductViewHolder.Configuration(),
bookmarkMap: HashMap<String, Boolean>? = null,
onBookmarkClicked: ((productId: String, isBookmarkChecked: Boolean) -> Unit)? = null,
onProductClicked: ((pxlProduct: PXLProduct) -> Unit)? = null) {
fun setContent(photoInfo: PhotoWithVideoInfo,
configuration: ProductViewHolder.Configuration = ProductViewHolder.Configuration(),
bookmarkMap: HashMap<String, Boolean>? = null,
onBookmarkClicked: ((productId: String, isBookmarkChecked: Boolean) -> Unit)? = null,
onProductClicked: ((pxlProduct: PXLProduct) -> Unit)? = null) {
this.photoInfo = photoInfo
this.bookmarkMap = bookmarkMap
this.onBookmarkClicked = onBookmarkClicked
Expand All @@ -61,7 +61,7 @@ class PXLPhotoProductView : FrameLayout, LifecycleObserver {
loadProducts(configuration)

pxlPhotoView.setConfiguration(configuration = PXLPhotoView.Configuration())
pxlPhotoView.setPhoto(photoInfo.pxlPhoto, photoInfo.imageScaleType)
pxlPhotoView.setContent(photoInfo.pxlPhoto, photoInfo.imageScaleType)
pxlPhotoView.setLooping(photoInfo.isLoopingVideo)
pxlPhotoView.setVolume(if(photoInfo.soundMuted) 0f else 1f)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ class PXLPhotoView : RelativeLayout {
* @param pxlPhoto
* @param imageScaleType
*/
fun setPhoto(pxlPhoto: PXLPhoto, imageScaleType: ImageScaleType = defaultScaleType) {
fun setContent(pxlPhoto: PXLPhoto, imageScaleType: ImageScaleType = defaultScaleType) {
this.pxlPhoto = pxlPhoto
currentConfiguration.imageScaleType = imageScaleType
startBlurBG()
Expand Down

0 comments on commit c9f56ad

Please sign in to comment.