-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional fields for uploading content (#39)
* Add additional fields for uploading content * Update document * Update document * Remove example * Remove example * Remove real data * Fix a bug * Replace it with fake data * Replace it with fake data * Replace it with fake data Co-authored-by: sungjun <[email protected]>
- Loading branch information
1 parent
ae1fbeb
commit 0924cdd
Showing
22 changed files
with
553 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,11 +44,15 @@ import com.pixlee.pixleesdk.util.px | |
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.* | ||
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.drawerLayout | ||
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.fabFilter | ||
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.fabUpload | ||
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.lottieView | ||
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.tvDebugText | ||
import kotlinx.android.synthetic.main.fragment_ktx_gallery_grid.v_body | ||
import kotlinx.android.synthetic.main.module_search.* | ||
import kotlinx.coroutines.launch | ||
import org.json.JSONArray | ||
import org.json.JSONException | ||
import org.json.JSONObject | ||
|
||
/** | ||
* This shows how you can load photos of Pixlee using PXLAlbum.java | ||
|
@@ -109,6 +113,14 @@ class KtxGalleryGridFragment : BaseFragment(), LifecycleObserver { | |
} | ||
|
||
fun addViewModelListeners() { | ||
viewModel.toastMessage.observe(viewLifecycleOwner, EventObserver{ | ||
showToast(it) | ||
}) | ||
|
||
viewModel.uploadStatus.observe(viewLifecycleOwner, Observer{ | ||
fabUpload.isEnabled = !it | ||
}) | ||
|
||
viewModel.loading.observe(viewLifecycleOwner, Observer { | ||
lottieView.visibility = if (it) View.VISIBLE else View.GONE | ||
}) | ||
|
@@ -225,6 +237,7 @@ class KtxGalleryGridFragment : BaseFragment(), LifecycleObserver { | |
|
||
fun initFilterClickListeners() { | ||
// set filter buttons | ||
fabUpload.setOnClickListener { setupExternalStoragePermission() } | ||
fabFilter.setOnClickListener { drawerLayout.openDrawer(GravityCompat.END) } | ||
btnCloseFilter.setOnClickListener { drawerLayout.closeDrawer(GravityCompat.END) } | ||
btnApply.setOnClickListener { | ||
|
@@ -233,6 +246,30 @@ class KtxGalleryGridFragment : BaseFragment(), LifecycleObserver { | |
} | ||
} | ||
|
||
override fun uploadFile(filePath: String) { | ||
val json = JSONObject() | ||
try { | ||
json.put("name", "Sample Name") | ||
json.put("age", 24) | ||
val arr = JSONArray() | ||
arr.put(10) | ||
arr.put(20) | ||
arr.put(35) | ||
json.put("points", arr) | ||
} catch (e: JSONException) { | ||
e.printStackTrace() | ||
} | ||
viewModel.uploadPhoto( | ||
filePath, | ||
"uploaded from SDK-" + System.currentTimeMillis() + " using a file", | ||
"[email protected]", | ||
"replace this with your user name", | ||
true, | ||
null, | ||
null, | ||
json) | ||
} | ||
|
||
/*** | ||
* Initializes the PXLClient and creates the PXLAlbum | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,11 @@ import com.pixlee.pixleeandroidsdk.ui.BaseFragment | |
import com.pixlee.pixleeandroidsdk.ui.BaseViewModel | ||
import com.pixlee.pixleeandroidsdk.ui.widgets.PXLPhotoViewFragment | ||
import com.pixlee.pixleeandroidsdk.ui.widgets.ViewerActivity | ||
import com.pixlee.pixleesdk.client.PXLBaseAlbum.RequestHandlers | ||
import com.pixlee.pixleesdk.client.PXLClient | ||
import com.pixlee.pixleesdk.client.PXLKtxAlbum | ||
import com.pixlee.pixleesdk.client.PXLKtxBaseAlbum | ||
import com.pixlee.pixleesdk.data.MediaResult | ||
import com.pixlee.pixleesdk.data.PXLAlbumFilterOptions | ||
import com.pixlee.pixleesdk.data.PXLAlbumSortOptions | ||
import com.pixlee.pixleesdk.enums.* | ||
|
@@ -38,6 +40,9 @@ import com.pixlee.pixleesdk.util.px | |
import kotlinx.android.synthetic.main.fragment_ktx_gallery_list.* | ||
import kotlinx.android.synthetic.main.module_search.* | ||
import kotlinx.coroutines.launch | ||
import org.json.JSONArray | ||
import org.json.JSONException | ||
import org.json.JSONObject | ||
|
||
|
||
/** | ||
|
@@ -107,6 +112,13 @@ class KtxGalleryListFragment : BaseFragment(), LifecycleObserver { | |
} | ||
|
||
fun addViewModelListeners() { | ||
viewModel.toastMessage.observe(viewLifecycleOwner, EventObserver { | ||
showToast(it) | ||
}) | ||
|
||
viewModel.uploadStatus.observe(viewLifecycleOwner, Observer { | ||
fabUpload.isEnabled = !it | ||
}) | ||
|
||
viewModel.loading.observe(viewLifecycleOwner, Observer { | ||
lottieView.visibility = if (it) View.VISIBLE else View.GONE | ||
|
@@ -206,6 +218,7 @@ class KtxGalleryListFragment : BaseFragment(), LifecycleObserver { | |
|
||
fun initFilterClickListeners() { | ||
// set filter buttons | ||
fabUpload.setOnClickListener { setupExternalStoragePermission() } | ||
fabFilter.setOnClickListener { drawerLayout.openDrawer(GravityCompat.END) } | ||
btnCloseFilter.setOnClickListener { drawerLayout.closeDrawer(GravityCompat.END) } | ||
btnApply.setOnClickListener { | ||
|
@@ -214,6 +227,26 @@ class KtxGalleryListFragment : BaseFragment(), LifecycleObserver { | |
} | ||
} | ||
|
||
override fun uploadFile(filePath: String) { | ||
viewModel.uploadPhoto( | ||
localMediaPath = filePath, | ||
title = "uploaded from SDK-" + System.currentTimeMillis() + " using a file", | ||
email = "[email protected]", | ||
username = "replace this with your user name", | ||
approved = true, | ||
productSKUs = listOf("productA", "productB"), // Optional | ||
categoryNames = listOf("Clothing", "Shoes"), // Optional | ||
connectedUser = JSONObject().apply { // Optional | ||
put("name", "sample name") | ||
put("age", 24) | ||
put("points", JSONArray().apply { | ||
put(10) | ||
put(20) | ||
put(35) | ||
}) | ||
}) | ||
} | ||
|
||
/*** | ||
* Initializes the PXLClient and creates the PXLAlbum | ||
*/ | ||
|
Oops, something went wrong.