Skip to content

Commit

Permalink
Modularize video and image viewer (#31)
Browse files Browse the repository at this point in the history
* Move image&video viewer to the sdk

* Refactor classes

* Move integrate image viewer and video viewer into a single activity to make it simpler to be used by our clients

* Update README

* Update README

* Update README
  • Loading branch information
SungjunApp authored Aug 24, 2020
1 parent 60979f8 commit 058ff51
Show file tree
Hide file tree
Showing 30 changed files with 259 additions and 469 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ This SDK makes it easy for Pixlee customers to find and download Pixlee images a
- [Ecommerce Analytics](#Ecommerce-Analytics)
- [Add To Cart](#Add-To-Cart)
- [Conversion](#Conversion)
- [UI components](#UI-components)
- [Image & Video Viewer with PXLPhoto](#Image-and-Video-Viewer-with-PXLPhoto)
- Migration
- [from 1.0.6 or older](doc/migration/1.0.6.md)

Expand Down Expand Up @@ -307,5 +309,14 @@ The parameters for this method are:
analytics.conversion(cartContents, "123", 4);
```
## UI components
#### Image and Video Viewer with PXLPhoto
- after receiving PXLPhoto list via PXLBaseAlbum.loadNextPageOfPhotos(...), you can launch watch the content using PXLPhotoViewerActivity. Depending on its content_type, PXLPhotoViewerActivity will play a video or display a photo.
- you can use the activity using the code here
```
PXLPhotoViewerActivity.launch(getContext(), pxlPhoto, "photo name");
PXLPhotoViewerActivity.launch(getContext(), pxlPhoto);
```
# License
pixlee-android-sdk is available under the MIT license.
13 changes: 4 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ repositories {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.2.0-alpha02'
implementation "androidx.appcompat:appcompat:$androidxAppcompat"
implementation "androidx.constraintlayout:constraintlayout:$androidxConstraint"
implementation "com.google.android.material:material:$androidxCardView"
implementation 'androidx.cardview:cardview:1.0.0'
implementation project(':pixleesdk')
testImplementation 'junit:junit:4.12'
Expand Down Expand Up @@ -77,10 +77,5 @@ dependencies {
/**
* Lottie for animation
*/
implementation 'com.airbnb.android:lottie:3.4.0'

/**
* Glide Transformation
*/
implementation 'jp.wasabeef:glide-transformations:4.1.0'
implementation "com.airbnb.android:lottie:$lottie"
}
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
</intent-filter>
</activity>

<activity android:name=".ui.viewer.ImageViewerActivity"/>
<activity android:name=".ui.viewer.VideoViewerActivity"/>

</application>

</manifest>
16 changes: 0 additions & 16 deletions app/src/main/java/com/pixlee/pixleeandroidsdk/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,20 +162,4 @@ public void setSystemBarColor(@ColorRes int colorRes) {
window.setStatusBarColor(ContextCompat.getColor(this, colorRes));
}
}

public void expandContentAreaOverStatusBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}

public int getStatusBarHeight() {
int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0) {
return getResources().getDimensionPixelSize(resourceId);
} else {
return 0;
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import com.pixlee.pixleeandroidsdk.R;
import com.pixlee.pixleeandroidsdk.databinding.FragmentGalleryBinding;
import com.pixlee.pixleeandroidsdk.ui.BaseFragment;
import com.pixlee.pixleeandroidsdk.ui.util.AssetUtil;
import com.pixlee.pixleeandroidsdk.ui.viewer.ImageViewerActivity;
import com.pixlee.pixleeandroidsdk.ui.viewer.VideoViewerActivity;
import com.pixlee.pixleesdk.PXLAlbum;
import com.pixlee.pixleesdk.PXLAlbumFilterOptions;
import com.pixlee.pixleesdk.PXLAlbumSortOptions;
Expand All @@ -32,6 +29,7 @@
import com.pixlee.pixleesdk.PXLContentType;
import com.pixlee.pixleesdk.PXLPdpAlbum;
import com.pixlee.pixleesdk.PXLPhoto;
import com.pixlee.pixleesdk.ui.activity.PXLPhotoViewerActivity;

import java.util.ArrayList;

Expand Down Expand Up @@ -311,13 +309,9 @@ else if (text.equals(getString(R.string.radio_true)))
void setLoading(boolean visible) {
if (visible) {
binding.lottieView.setVisibility(View.VISIBLE);
String json = AssetUtil.getLottieLoadingJson(getContext());
binding.lottieView.setAnimationFromJson(json, json);
binding.lottieView.playAnimation();
} else {
binding.lottieView.setVisibility(View.GONE);
}

}

class Mode {
Expand Down Expand Up @@ -384,11 +378,8 @@ public void onLoadMore(int page, int totalItemsCount, RecyclerView view) {
void moveToViewer(View view, PXLPhoto photo) {
// You can choose images by using this example below.
// PXLPhotoSize Options: [ORIGINAL, BIG, MEDIUM, THUMBNAIL]
if (photo.isVideo()) {
VideoViewerActivity.launch(getContext(), photo);
} else {
ImageViewerActivity.launch(getContext(), photo);
}
// optional: PXLPhotoViewerActivity.launch(getContext(), photo, "photo name");
PXLPhotoViewerActivity.launch(getContext(), photo);
}

/***
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void onBindViewHolder(GridViewHolder viewHolder, int i) {
viewHolder.message.setVisibility(photo.photoTitle == null || photo.photoTitle.isEmpty() ? View.GONE : View.VISIBLE);

viewHolder.video.setVisibility(photo.isVideo() ? View.VISIBLE : View.GONE);
Glide.with(context)
Glide.with(viewHolder.netImg)
.load(photo.getUrlForSize(PXLPhotoSize.MEDIUM))
.centerCrop()
.into(viewHolder.netImg);
Expand Down

This file was deleted.

This file was deleted.

56 changes: 0 additions & 56 deletions app/src/main/res/layout/activity_image_viewer.xml

This file was deleted.

Loading

0 comments on commit 058ff51

Please sign in to comment.