This repository was archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Programatically generate configurator view
This removes the dependency on resources making it possible to put the entire project into a jar file for easier integration.
- Loading branch information
1 parent
88be135
commit 0a5b504
Showing
8 changed files
with
233 additions
and
160 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
# A special build that includes rebound-android but not the resources so that a jar file can be | ||
# created for distribution to users who do not use the gradle aar and don't need the utils like | ||
# SpringConfiguratorView. | ||
# A special build that depends on rebound-android:src and packages into a jar file for distribution. | ||
java_binary( | ||
name = 'rebound', | ||
deps = ['//rebound-android:src-no-res'], | ||
deps = ['//rebound-android:src'], | ||
visibility = ['PUBLIC'], | ||
) |
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
49 changes: 49 additions & 0 deletions
49
rebound-android/src/main/java/com/facebook/rebound/ui/Util.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,49 @@ | ||
package com.facebook.rebound.ui; | ||
|
||
import android.content.res.Resources; | ||
import android.util.TypedValue; | ||
import android.view.ViewGroup; | ||
import android.widget.FrameLayout; | ||
import android.widget.RelativeLayout; | ||
|
||
/** | ||
* Utilities for generating view hierarchies without using resources. | ||
*/ | ||
public abstract class Util { | ||
|
||
public static final int dpToPx(float dp, Resources res) { | ||
return (int) TypedValue.applyDimension( | ||
TypedValue.COMPLEX_UNIT_DIP, | ||
dp, | ||
res.getDisplayMetrics()); | ||
} | ||
|
||
public static final FrameLayout.LayoutParams createLayoutParams(int width, int height) { | ||
return new FrameLayout.LayoutParams(width, height); | ||
} | ||
|
||
public static final FrameLayout.LayoutParams createMatchParams() { | ||
return createLayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT); | ||
} | ||
|
||
public static final FrameLayout.LayoutParams createWrapParams() { | ||
return createLayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.WRAP_CONTENT); | ||
} | ||
|
||
public static final FrameLayout.LayoutParams createWrapMatchParams() { | ||
return createLayoutParams( | ||
ViewGroup.LayoutParams.WRAP_CONTENT, | ||
ViewGroup.LayoutParams.MATCH_PARENT); | ||
} | ||
|
||
public static final FrameLayout.LayoutParams createMatchWrapParams() { | ||
return createLayoutParams( | ||
ViewGroup.LayoutParams.MATCH_PARENT, | ||
ViewGroup.LayoutParams.WRAP_CONTENT); | ||
} | ||
|
||
} |
Oops, something went wrong.