-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New arch] Delete public share #2544
Conversation
2b471b0
to
b7e58b8
Compare
9421e7f
to
6f24ea1
Compare
…hanges regarding public share deletion
…or local and remote datasources
3324c21
to
6e01457
Compare
) | ||
) | ||
) | ||
ocShareDao.insert(listOf(newPublicShare())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't you created a method for a just one item instead of a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
private val file = mock(OCFile::class.java) | ||
private val publicShare = mock(OCShare::class.java) | ||
private val expirationDate = 1556575200000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put a comment with the date, but do you think is really important?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if it will some years later or some years ago.... I don't know...
The problem is if the date is a coming date, it will fail tests just because we are in that date or it's past...
I would do it that date dynamically in order to avoid that issue. For example:
System. currentTimeMillis() + 2000000
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this test we are setting a date in a view and checking if it appears, so I think is not affected by a coming or past date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok...
@@ -75,4 +76,11 @@ class OCRemoteSharesDataSource( | |||
updateRemoteShareOperation.retrieveShareDetails = true | |||
return updateRemoteShareOperation.execute(client) | |||
} | |||
|
|||
override fun deleteShare( | |||
remoteId: Long, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you use remoteId anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've seen it below
private fun refreshSharesFromStorageManager() { | ||
val shareFileFragment = shareFileFragment | ||
if (shareFileFragment?.isAdded == true) { // only if added to the view hierarchy!! | ||
shareFileFragment.refreshUsersOrGroupsListFromDB() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be better to have a livedata listening data from db. You will save to do this approach ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for private shares and has not been touched yet, it will be our next challenge in the architecture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
} | ||
|
||
if (!enableMultiplePublicSharing()) { | ||
if (publicLinks?.size == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you use isNullOrEmpty() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the else block wouldn't have condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* Adapter to show a list of public links | ||
*/ | ||
class SharePublicLinkListAdapter( | ||
private val mContext: Context, resource: Int, private val mPublicLinks: ArrayList<OCShare>?, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you put each param in a new line? Something like this:
class SharePublicLinkListAdapter(
private val mContext: Context,
resource: Int,
private val mPublicLinks: ArrayList<OCShare>?,
private val mListener: SharePublicLinkAdapterListener
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
) : ArrayAdapter<OCShare>(mContext, resource) { | ||
|
||
override fun getCount(): Int { | ||
return mPublicLinks!!.size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it can be null!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
override fun getCount(): Int = mPublicLinks?.size ?: 0
better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, done
val share = mPublicLinks[position] | ||
|
||
// If there's no name, set the token as name | ||
view.publicLinkName.text = if (share.name?.isEmpty()!!) share.token else share.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if name can be null, you can't set isEmpty as not null. That doesn't make any sense.
I would use isNullOrEmpty function instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, it does not make any sense and Android Studio keeps doing it when converting java files to kotlin 😄 , I will use if (share.name?.isEmpty() == true)
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and why don't you use if (share.name.isNullOrEmpty())
better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now
Code approved, ready to test @jesmrec |
Approved |
Implements #2517
Needs owncloud/android-library#250