-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated all remaining files in util module
- Loading branch information
1 parent
a42067e
commit d543625
Showing
18 changed files
with
538 additions
and
566 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
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
30 changes: 15 additions & 15 deletions
30
app/src/main/java/fr/free/nrw/commons/utils/MediaDataExtractorUtil.kt
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 |
---|---|---|
@@ -1,29 +1,29 @@ | ||
package fr.free.nrw.commons.utils; | ||
package fr.free.nrw.commons.utils | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.apache.commons.lang3.StringUtils | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.ArrayList | ||
|
||
object MediaDataExtractorUtil { | ||
|
||
public class MediaDataExtractorUtil { | ||
/** | ||
* Extracts a list of categories from | separated category string | ||
* | ||
* @param source | ||
* @return | ||
*/ | ||
public static List<String> extractCategoriesFromList(String source) { | ||
if (StringUtils.isBlank(source)) { | ||
return new ArrayList<>(); | ||
@JvmStatic | ||
fun extractCategoriesFromList(source: String): List<String> { | ||
if (source.isBlank()) { | ||
return emptyList() | ||
} | ||
String[] cats = source.split("\\|"); | ||
List<String> categories = new ArrayList<>(); | ||
for (String category : cats) { | ||
if (!StringUtils.isBlank(category.trim())) { | ||
categories.add(category); | ||
val cats = source.split("|") | ||
val categories = mutableListOf<String>() | ||
for (category in cats) { | ||
if (category.trim().isNotBlank()) { | ||
categories.add(category) | ||
} | ||
} | ||
return categories; | ||
return categories | ||
} | ||
|
||
} |
76 changes: 40 additions & 36 deletions
76
app/src/main/java/fr/free/nrw/commons/utils/NearbyFABUtils.kt
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 |
---|---|---|
@@ -1,51 +1,55 @@ | ||
package fr.free.nrw.commons.utils; | ||
package fr.free.nrw.commons.utils | ||
|
||
import android.view.Gravity; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.view.Gravity | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.coordinatorlayout.widget.CoordinatorLayout | ||
import com.google.android.material.floatingactionbutton.FloatingActionButton | ||
|
||
import androidx.coordinatorlayout.widget.CoordinatorLayout; | ||
object NearbyFABUtils { | ||
|
||
import com.google.android.material.floatingactionbutton.FloatingActionButton; | ||
|
||
public class NearbyFABUtils { | ||
/* | ||
* Add anchors back before making them visible again. | ||
* */ | ||
public static void addAnchorToBigFABs(FloatingActionButton floatingActionButton, int anchorID) { | ||
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams | ||
(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); | ||
params.setAnchorId(anchorID); | ||
params.anchorGravity = Gravity.TOP|Gravity.RIGHT|Gravity.END; | ||
floatingActionButton.setLayoutParams(params); | ||
*/ | ||
@JvmStatic | ||
fun addAnchorToBigFABs(floatingActionButton: FloatingActionButton, anchorID: Int) { | ||
val params = CoordinatorLayout.LayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.WRAP_CONTENT | ||
) | ||
params.anchorId = anchorID | ||
params.anchorGravity = Gravity.TOP or Gravity.RIGHT or Gravity.END | ||
floatingActionButton.layoutParams = params | ||
} | ||
|
||
/* | ||
* Add anchors back before making them visible again. Big and small fabs have different anchor | ||
* gravities, therefore the are two methods. | ||
* */ | ||
public static void addAnchorToSmallFABs(FloatingActionButton floatingActionButton, int anchorID) { | ||
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams | ||
(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT); | ||
params.setAnchorId(anchorID); | ||
params.anchorGravity = Gravity.CENTER_HORIZONTAL; | ||
floatingActionButton.setLayoutParams(params); | ||
* gravities, therefore there are two methods. | ||
*/ | ||
@JvmStatic | ||
fun addAnchorToSmallFABs(floatingActionButton: FloatingActionButton, anchorID: Int) { | ||
val params = CoordinatorLayout.LayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.WRAP_CONTENT | ||
) | ||
params.anchorId = anchorID | ||
params.anchorGravity = Gravity.CENTER_HORIZONTAL | ||
floatingActionButton.layoutParams = params | ||
} | ||
|
||
/* | ||
* We are not able to hide FABs without removing anchors, this method removes anchors | ||
* */ | ||
public static void removeAnchorFromFAB(FloatingActionButton floatingActionButton) { | ||
//get rid of anchors | ||
//Somehow this was the only way https://stackoverflow.com/questions/32732932 | ||
// /floatingactionbutton-visible-for-sometime-even-if-visibility-is-set-to-gone | ||
CoordinatorLayout.LayoutParams param = (CoordinatorLayout.LayoutParams) floatingActionButton | ||
.getLayoutParams(); | ||
param.setAnchorId(View.NO_ID); | ||
* We are not able to hide FABs without removing anchors, this method removes anchors. | ||
*/ | ||
@JvmStatic | ||
fun removeAnchorFromFAB(floatingActionButton: FloatingActionButton) { | ||
// get rid of anchors | ||
// Somehow this was the only way https://stackoverflow.com/questions/32732932 | ||
// floatingactionbutton-visible-for-sometime-even-if-visibility-is-set-to-gone | ||
val params = floatingActionButton.layoutParams as CoordinatorLayout.LayoutParams | ||
params.anchorId = View.NO_ID | ||
// If we don't set them to zero, then they become visible for a moment on upper left side | ||
param.width = 0; | ||
param.height = 0; | ||
floatingActionButton.setLayoutParams(param); | ||
params.width = 0 | ||
params.height = 0 | ||
floatingActionButton.layoutParams = params | ||
} | ||
|
||
} |
Oops, something went wrong.