Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

[library] added DesignSpecActivity #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions library/src/main/java/org/lucasr/dspec/DesignSpecActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.lucasr.dspec;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

/**
* Created with IntelliJ IDEA.
* User: Sergey Chuvashev
* Date: 08.09.14
* Time: 23:30
*/
public class DesignSpecActivity extends Activity {

private DesignSpecFrameLayout mDesignSpecFrameLayout;

@Override
public void onContentChanged() {
super.onContentChanged();

ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content);

DesignSpecFrameLayout designSpecFrameLayout = new DesignSpecFrameLayout(this);

mDesignSpecFrameLayout = designSpecFrameLayout;

int childCount = rootView.getChildCount();

View child;
for (int i = childCount - 1; i >= 0; i--) {
child = rootView.getChildAt(i);
rootView.removeView(child);
designSpecFrameLayout.addView(child);
}

rootView.addView(designSpecFrameLayout,
new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
}

public DesignSpec getDesignSpec() {
return mDesignSpecFrameLayout.getDesignSpec();
}

}