Skip to content

Commit d885866

Browse files
committed
clean up layout params, add PFragment.init()
1 parent 615ec0e commit d885866

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

core/src/processing/android/PFragment.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
package processing.android;
2424

25-
//import android.app.Fragment;
2625
import android.support.v4.app.Fragment;
26+
import android.support.v4.app.FragmentManager;
27+
import android.support.v4.app.FragmentTransaction;
2728
import android.util.DisplayMetrics;
2829
import android.content.pm.ActivityInfo;
2930
import android.content.res.Configuration;
@@ -46,6 +47,12 @@ public class PFragment extends Fragment implements AppComponent {
4647
public PFragment() {
4748
}
4849

50+
public void init(int layout, FragmentManager fragmentManager) {
51+
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
52+
fragmentTransaction.add(layout, this);
53+
fragmentTransaction.commit();
54+
}
55+
4956
public void initDimensions() {
5057
WindowManager wm = getActivity().getWindowManager();
5158
Display display = wm.getDefaultDisplay();

core/src/processing/core/PApplet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@ final public int sketchWindowColor() {
806806
}
807807

808808

809-
810809
public void orientation(int which) {
811810
surface.setOrientation(which);
812811
}

core/src/processing/core/PSurfaceNone.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,15 @@ public void initView(LayoutInflater inflater, ViewGroup container,
197197
Bundle savedInstanceState) {
198198
// https://www.bignerdranch.com/blog/understanding-androids-layoutinflater-inflate/
199199
ViewGroup rootView = (ViewGroup)inflater.inflate(sketch.parentLayout, container, false);
200-
RelativeLayout.LayoutParams gp =
201-
new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
202-
LayoutParams.WRAP_CONTENT);
203-
gp.addRule(RelativeLayout.CENTER_IN_PARENT);
204200

205201
View view = getSurfaceView();
206-
LinearLayout.LayoutParams vp;
207-
vp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
202+
LinearLayout.LayoutParams lp;
203+
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
208204
LayoutParams.MATCH_PARENT);
209-
vp.weight = 1.0f;
210-
vp.setMargins(0, 0, 0, 0);
211-
view.setLayoutParams(vp);
205+
lp.weight = 1.0f;
206+
lp.setMargins(0, 0, 0, 0);
212207
view.setPadding(0,0,0,0);
213-
rootView.addView(view, gp);
208+
rootView.addView(view, lp);
214209

215210
rootView.setBackgroundColor(sketch.sketchWindowColor());
216211
setRootView(rootView);

0 commit comments

Comments
 (0)