-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FS-4097 single selection support (#180)
* Add Kotlin support in tests * FS-4097 add flag for enabling single/multi selection * Update dependencies + gradle version * Remove local.properties from source control
- Loading branch information
Showing
16 changed files
with
216 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
.idea | ||
*.iml | ||
/build | ||
local.properties |
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
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
20 changes: 20 additions & 0 deletions
20
filestack/src/main/java/com/filestack/android/internal/SelectionFactory.java
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.filestack.android.internal; | ||
|
||
import android.net.Uri; | ||
|
||
import com.filestack.CloudItem; | ||
import com.filestack.Sources; | ||
import com.filestack.android.Selection; | ||
|
||
class SelectionFactory { | ||
|
||
public static Selection from(String sourceId, CloudItem cloudItem) { | ||
return new Selection(sourceId, cloudItem.getPath(), cloudItem.getMimetype(), | ||
cloudItem.getName()); | ||
} | ||
|
||
public static Selection from(Uri uri, int size, String mimeType, String name) { | ||
return new Selection(Sources.DEVICE, uri, size, mimeType, name); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
filestack/src/main/java/com/filestack/android/internal/Selector.java
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.filestack.android.internal; | ||
|
||
import com.filestack.android.Selection; | ||
|
||
public interface Selector { | ||
boolean toggle(Selection selection); | ||
boolean isSelected(Selection selection); | ||
|
||
class Single implements Selector { | ||
|
||
private final SelectionSaver selectionSaver; | ||
|
||
public Single(SelectionSaver selectionSaver) { | ||
this.selectionSaver = selectionSaver; | ||
} | ||
|
||
@Override | ||
public boolean toggle(Selection selection) { | ||
if (selectionSaver.isEmpty()) { | ||
return selectionSaver.toggleItem(selection); | ||
} else if (selectionSaver.getItems().get(0).equals(selection)) { | ||
return selectionSaver.toggleItem(selection); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isSelected(Selection selection) { | ||
return selectionSaver.isSelected(selection); | ||
} | ||
} | ||
|
||
class Multi implements Selector { | ||
|
||
private SelectionSaver selectionSaver; | ||
|
||
public Multi(SelectionSaver selectionSaver) { | ||
this.selectionSaver = selectionSaver; | ||
} | ||
|
||
@Override | ||
public boolean toggle(Selection selection) { | ||
return selectionSaver.toggleItem(selection); | ||
} | ||
|
||
@Override | ||
public boolean isSelected(Selection selection) { | ||
return selectionSaver.isSelected(selection); | ||
} | ||
} | ||
} |
Oops, something went wrong.