Skip to content
Snippets Groups Projects
Commit dede80ea authored by Alexandre Lision's avatar Alexandre Lision
Browse files

Remove history detail parallax for now (better library version on the way)

parent b266969f
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,12 @@ tags ...@@ -10,9 +10,12 @@ tags
TAGS.LST TAGS.LST
ID ID
src/org/sflphone/views/paralloidviews/
src/org/sflphone/views/paralloid
AndroidUnusedResources1.6.2.jar AndroidUnusedResources1.6.2.jar
/jni/pjproject-android/build jni/pjproject-android/build
jni/pjproject-android/pjsip/build/.pjsua2-lib-arm-unknown-linux-androideabi.depend jni/pjproject-android/pjsip/build/.pjsua2-lib-arm-unknown-linux-androideabi.depend
jni/pjproject-android/pjsip/build/.pjsua2-test-arm-unknown-linux-androideabi.depend jni/pjproject-android/pjsip/build/.pjsua2-test-arm-unknown-linux-androideabi.depend
.classpath .classpath
......
<org.sflphone.views.parallaxscrollview.ParallaxScrollView xmlns:tools="http://schemas.android.com/tools" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/frame"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<!-- Background --> <!-- Background -->
<RelativeLayout <RelativeLayout
android:id="@+id/iv" android:id="@+id/iv"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/header_history_detail" > android:layout_height="@dimen/header_history_detail"
android:layout_alignParentTop="true">
<ImageView <ImageView
android:id="@+id/contact_photo" android:id="@+id/contact_photo"
...@@ -38,60 +37,33 @@ ...@@ -38,60 +37,33 @@
android:singleLine="true" android:singleLine="true"
android:textSize="18sp"/> android:textSize="18sp"/>
</LinearLayout> </LinearLayout>
</RelativeLayout>
<!-- Foreground -->
<org.sflphone.views.parallaxscrollview.AnotherView
android:id="@+id/anotherView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout <LinearLayout
android:id="@+id/llMainHolder" android:id="@+id/contact_name_holder"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="50dp"
android:layout_marginTop="@dimen/header_history_detail" android:layout_alignParentBottom="true"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/call_main_action"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:background="@drawable/item_generic_selector" >
<TextView
android:id="@+id/history_entry_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_alignParentRight="true"
android:layout_marginLeft="10dp" android:background="#AAFFFFFF"
android:singleLine="true" android:orientation="vertical"
android:textSize="18sp" /> android:padding="5dp">
</LinearLayout>
</RelativeLayout> </RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/divider" />
<LinearLayout <!-- Foreground -->
android:id="@+id/llMain"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView <ListView
android:id="@+id/lvMain" android:id="@+id/lvMain"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/white"
android:dividerHeight="2dp" android:dividerHeight="2dp"
android:layout_below="@+id/iv"
android:fillViewport="true"
android:drawSelectorOnTop="true"> android:drawSelectorOnTop="true">
</ListView> </ListView>
</LinearLayout>
</LinearLayout>
</org.sflphone.views.parallaxscrollview.AnotherView>
</org.sflphone.views.parallaxscrollview.ParallaxScrollView>
\ No newline at end of file </RelativeLayout>
\ No newline at end of file
...@@ -104,12 +104,8 @@ as that of the covered work. ...@@ -104,12 +104,8 @@ as that of the covered work.
<string name="me">Moi</string> <string name="me">Moi</string>
<string name="action_call_attended_transfer">Transfert</string> <string name="action_call_attended_transfer">Transfert</string>
<string name="action_call_unattended_transfer">Transfert Direct</string> <string name="action_call_unattended_transfer">Transfert Direct</string>
<string name="action_call_general_transfer">Transfert</string>
<string name="action_call_conference">Conférence</string> <string name="action_call_conference">Conférence</string>
<string name="action_call_hold">Attente</string> <string name="action_call_hold">Attente</string>
<string name="action_call_unhold">Reprendre</string>
<string name="action_call_record">Enregistrer</string>
<string name="action_call_stop_record">Arrêter l\'enregistrement</string>
<string name="action_settings">Paramètres</string> <string name="action_settings">Paramètres</string>
<string name="copyright">Copyright \u00A9 2004&#8211;2014 Savoir-Faire Linux Inc.</string> <string name="copyright">Copyright \u00A9 2004&#8211;2014 Savoir-Faire Linux Inc.</string>
<string name="web_site">Site web</string> <string name="web_site">Site web</string>
......
...@@ -36,6 +36,8 @@ import java.util.ArrayList; ...@@ -36,6 +36,8 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.NavigableMap; import java.util.NavigableMap;
import android.util.Log;
import android.widget.*;
import org.sflphone.R; import org.sflphone.R;
import org.sflphone.adapters.ContactPictureTask; import org.sflphone.adapters.ContactPictureTask;
import org.sflphone.history.HistoryCall; import org.sflphone.history.HistoryCall;
...@@ -43,7 +45,6 @@ import org.sflphone.model.Account; ...@@ -43,7 +45,6 @@ import org.sflphone.model.Account;
import org.sflphone.history.HistoryEntry; import org.sflphone.history.HistoryEntry;
import org.sflphone.model.SipCall; import org.sflphone.model.SipCall;
import org.sflphone.service.ISipService; import org.sflphone.service.ISipService;
import org.sflphone.views.parallaxscrollview.AnotherView;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
...@@ -55,14 +56,10 @@ import android.view.View; ...@@ -55,14 +56,10 @@ import android.view.View;
import android.view.View.MeasureSpec; import android.view.View.MeasureSpec;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.BaseAdapter; import org.sflphone.views.paralloid.ParallaxController;
import android.widget.Button; import org.sflphone.views.paralloid.Parallaxor;
import android.widget.ImageView; import org.sflphone.views.paralloidviews.ParallaxListView;
import android.widget.LinearLayout; import org.sflphone.views.paralloidviews.ParallaxScrollView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
public class DetailsHistoryEntryFragment extends Fragment { public class DetailsHistoryEntryFragment extends Fragment {
...@@ -73,8 +70,7 @@ public class DetailsHistoryEntryFragment extends Fragment { ...@@ -73,8 +70,7 @@ public class DetailsHistoryEntryFragment extends Fragment {
ContactPictureTask tasker; ContactPictureTask tasker;
private ListView lvMain; private ListView lvMain;
private LinearLayout llMain, llMainHolder; private LinearLayout llMain;
private AnotherView anotherView;
private RelativeLayout iv; private RelativeLayout iv;
private Callbacks mCallbacks = sDummyCallbacks; private Callbacks mCallbacks = sDummyCallbacks;
...@@ -130,19 +126,17 @@ public class DetailsHistoryEntryFragment extends Fragment { ...@@ -130,19 +126,17 @@ public class DetailsHistoryEntryFragment extends Fragment {
View inflatedView = inflater.inflate(R.layout.frag_history_detail, parent, false); View inflatedView = inflater.inflate(R.layout.frag_history_detail, parent, false);
llMain = (LinearLayout) inflatedView.findViewById(R.id.llMain); llMain = (LinearLayout) inflatedView.findViewById(R.id.llMain);
llMainHolder = (LinearLayout) inflatedView.findViewById(R.id.llMainHolder); /*llMainHolder = (LinearLayout) inflatedView.findViewById(R.id.llMainHolder);*/
lvMain = (ListView) inflatedView.findViewById(R.id.lvMain); lvMain = (ListView) inflatedView.findViewById(R.id.lvMain);
lvMain.setAdapter(mAdapter); lvMain.setAdapter(mAdapter);
iv = (RelativeLayout) inflatedView.findViewById(R.id.iv); iv = (RelativeLayout) inflatedView.findViewById(R.id.iv);
((TextView) iv.findViewById(R.id.history_call_name)).setText(toDisplay.getContact().getmDisplayName()); ((TextView) iv.findViewById(R.id.history_call_name)).setText(toDisplay.getContact().getmDisplayName());
tasker = new ContactPictureTask(getActivity(), (ImageView) iv.findViewById(R.id.contact_photo), toDisplay.getContact()); tasker = new ContactPictureTask(getActivity(), (ImageView) inflatedView.findViewById(R.id.contact_photo), toDisplay.getContact());
tasker.run(); tasker.run();
anotherView = (AnotherView) inflatedView.findViewById(R.id.anotherView); // ((TextView) iv.findViewById(R.id.history_entry_number)).setText(getString(R.string.detail_hist_call_number, toDisplay.getNumber()));
iv.findViewById(R.id.history_call_name).setOnClickListener(new OnClickListener() {
((TextView) anotherView.findViewById(R.id.history_entry_number)).setText(getString(R.string.detail_hist_call_number, toDisplay.getNumber()));
anotherView.findViewById(R.id.call_main_action).setOnClickListener(new OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
...@@ -150,9 +144,7 @@ public class DetailsHistoryEntryFragment extends Fragment { ...@@ -150,9 +144,7 @@ public class DetailsHistoryEntryFragment extends Fragment {
SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance(); SipCall.SipCallBuilder callBuilder = SipCall.SipCallBuilder.getInstance();
HashMap<String, String> details = (HashMap<String, String>) mCallbacks.getService().getAccountDetails(toDisplay.getAccountID()); HashMap<String, String> details = (HashMap<String, String>) mCallbacks.getService().getAccountDetails(toDisplay.getAccountID());
ArrayList<HashMap<String, String>> creds; ArrayList<HashMap<String, String>> creds = (ArrayList<HashMap<String, String>>) mCallbacks.getService().getCredentials(toDisplay.getAccountID());
creds = (ArrayList<HashMap<String, String>>) mCallbacks.getService().getCredentials(toDisplay.getAccountID());
callBuilder.startCallCreation().setAccount(new Account(toDisplay.getAccountID(), details, creds)) callBuilder.startCallCreation().setAccount(new Account(toDisplay.getAccountID(), details, creds))
.setCallType(SipCall.direction.CALL_TYPE_OUTGOING); .setCallType(SipCall.direction.CALL_TYPE_OUTGOING);
...@@ -170,22 +162,20 @@ public class DetailsHistoryEntryFragment extends Fragment { ...@@ -170,22 +162,20 @@ public class DetailsHistoryEntryFragment extends Fragment {
} }
}); });
lvMain.post(new Runnable() { /*lvMain.post(new Runnable() {
@Override @Override
public void run() { public void run() {
// Adjusts llMain's height to match ListView's height
setListViewHeight(lvMain, llMain); setListViewHeight(lvMain, llMain);
}
});*/
/* ParallaxScrollView parSV = (ParallaxScrollView) inflatedView.findViewById(R.id.scroll_view);*/
// LayoutParams to set the top margin of LinearLayout holding if (lvMain instanceof Parallaxor) {
// the content. ((Parallaxor) lvMain).parallaxViewBy(inflatedView.findViewById(R.id.iv), 0.5f);
// topMargin = iv.getHeight() - tvTitle.getHeight()
LinearLayout.LayoutParams p = (LinearLayout.LayoutParams) llMainHolder.getLayoutParams();
// p.topMargin = iv.getHeight() - tvTitle.getHeight();
llMainHolder.setLayoutParams(p);
} }
});
return inflatedView; return inflatedView;
} }
...@@ -218,11 +208,11 @@ public class DetailsHistoryEntryFragment extends Fragment { ...@@ -218,11 +208,11 @@ public class DetailsHistoryEntryFragment extends Fragment {
// totalHeight -= iv.getMeasuredHeight(); // totalHeight -= iv.getMeasuredHeight();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) llMain.getLayoutParams(); FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) llMain.getLayoutParams();
params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
llMain.setLayoutParams(params); llMain.setLayoutParams(params);
anotherView.requestLayout();
} }
private class DetailHistoryAdapter extends BaseAdapter implements ListAdapter { private class DetailHistoryAdapter extends BaseAdapter implements ListAdapter {
...@@ -310,9 +300,11 @@ public class DetailsHistoryEntryFragment extends Fragment { ...@@ -310,9 +300,11 @@ public class DetailsHistoryEntryFragment extends Fragment {
return convertView; return convertView;
} }
/********************* /**
* ******************
* ViewHolder Pattern * ViewHolder Pattern
*********************/ * *******************
*/
public class HistoryCallView { public class HistoryCallView {
protected TextView historyCallState; protected TextView historyCallState;
protected TextView formatted_date; protected TextView formatted_date;
......
package org.sflphone.views.parallaxscrollview;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.LinearLayout;
public class AnotherView extends LinearLayout{
private ScrollCallbacks mCallbacks;
public AnotherView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt)
{
super.onScrollChanged(l, t, oldl, oldt);
if (mCallbacks != null)
{
mCallbacks.onScrollChanged(l, t, oldl, oldt);
}
}
@Override
public int computeVerticalScrollRange()
{
return super.computeVerticalScrollRange();
}
public void setCallbacks(ScrollCallbacks listener)
{
mCallbacks = listener;
}
@Override
public void draw(Canvas canvas)
{
super.draw(canvas);
}
static interface ScrollCallbacks
{
public void onScrollChanged(int l, int t, int oldl, int oldt);
}
}
package org.sflphone.views.parallaxscrollview;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ScrollView;
public class ObservableScrollView extends ScrollView
{
private ScrollCallbacks mCallbacks;
public ObservableScrollView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt)
{
super.onScrollChanged(l, t, oldl, oldt);
if (mCallbacks != null)
{
mCallbacks.onScrollChanged(l, t, oldl, oldt);
}
}
@Override
public int computeVerticalScrollRange()
{
return super.computeVerticalScrollRange();
}
public void setCallbacks(ScrollCallbacks listener)
{
mCallbacks = listener;
}
@Override
public void draw(Canvas canvas)
{
super.draw(canvas);
}
static interface ScrollCallbacks
{
public void onScrollChanged(int l, int t, int oldl, int oldt);
}
}
\ No newline at end of file
package org.sflphone.views.parallaxscrollview;
import org.sflphone.R;
import org.sflphone.views.parallaxscrollview.ObservableScrollView.ScrollCallbacks;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ScrollView;
/**
* A custom ScrollView that can accept a scroll listener.
*/
public class ParallaxScrollView extends ViewGroup
{
private static final int DEFAULT_CHILD_GRAVITY = Gravity.CENTER_HORIZONTAL;
private static final String TAG = "ParallaxScrollView";
private static float PARALLAX_OFFSET_DEFAULT = 0.2f;
/**
* By how much should the background move to the foreground
*/
private float mParallaxOffset = PARALLAX_OFFSET_DEFAULT;
private View mBackground;
private ObservableScrollView mScrollView;
private final ScrollCallbacks mScrollCallbacks = new ScrollCallbacks()
{
@Override
public void onScrollChanged(int l, int t, int oldl, int oldt)
{
requestLayout();
}
};
// Layout stuff
private int mBackgroundRight;
private int mBackgroundBottom;
/**
* Height of the Foreground ScrollView Content
*/
private int mScrollContentHeight = 0;
/**
* Height of the ScrollView, should be the same as this view
*/
private int mScrollViewHeight = 0;
/**
* The multipler by how much to move the background to the foreground
*/
private float mScrollDiff = 0f;
public ParallaxScrollView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs,
R.styleable.ParallaxScrollView, 0, 0);
try
{
setParallaxOffset(a.getFloat(R.styleable.ParallaxScrollView_parallexOffset,
PARALLAX_OFFSET_DEFAULT));
}
catch (Exception e)
{
}
finally
{
a.recycle();
}
}
public ParallaxScrollView(Context context, AttributeSet attrs)
{
this(context, attrs, 0);
}
public ParallaxScrollView(Context context)
{
this(context, null);
}
@Override
public void addView(View child)
{
if (getChildCount() > 1)
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
super.addView(child);
}
@Override
public void addView(View child, int index)
{
if (getChildCount() > 1)
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
super.addView(child, index);
}
@Override
public void addView(View child, int index, android.view.ViewGroup.LayoutParams params)
{
if (getChildCount() > 1)
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
super.addView(child, index, params);
}
@Override
public void addView(View child, int width, int height)
{
if (getChildCount() > 1)
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
super.addView(child, width, height);
}
@Override
public void addView(View child, android.view.ViewGroup.LayoutParams params)
{
if (getChildCount() > 1)
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
super.addView(child, params);
}
/**
* Set the offset
*
* @param offset
* a number greater than 0.0
*/
public void setParallaxOffset(float offset)
{
// Make sure we only get to .05 of a floating number
offset = (float) Math.rint(offset * 100) / 100;
if (offset > 0.0)
mParallaxOffset = offset;
else
mParallaxOffset = PARALLAX_OFFSET_DEFAULT;
requestLayout();
}
/**
* Get the current offset
*
* @return
*/
public float getParallaxOffset()
{
return mParallaxOffset;
}
/**
* Sort the views out after they have been inflated from a layout
*/
@Override
protected void onFinishInflate()
{
super.onFinishInflate();
if (getChildCount() > 2)
{
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
}
organiseViews();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mScrollView != null)
{
measureChild(mScrollView, MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.AT_MOST),
MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec),
MeasureSpec.AT_MOST));
mScrollContentHeight = mScrollView.getChildAt(0).getMeasuredHeight();
mScrollViewHeight = mScrollView.getMeasuredHeight();
}
if (mBackground != null)
{
int minHeight = 0;
minHeight = (int) (mScrollViewHeight + mParallaxOffset
* (mScrollContentHeight - mScrollViewHeight));
minHeight = Math.max(minHeight, MeasureSpec.getSize(heightMeasureSpec));
measureChild(mBackground, MeasureSpec.makeMeasureSpec(
MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(minHeight, MeasureSpec.EXACTLY));
mBackgroundRight = getLeft() + mBackground.getMeasuredWidth();
mBackgroundBottom = getTop() + mBackground.getMeasuredHeight();
mScrollDiff = (float) (mBackground.getMeasuredHeight() - mScrollViewHeight)
/ (float) (mScrollContentHeight - mScrollViewHeight);
}
}
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
final int parentLeft = getPaddingLeft();
final int parentRight = right - left - getPaddingRight();
final int parentTop = getPaddingTop();
final int parentBottom = bottom - top - getPaddingBottom();
if (mScrollView != null && mScrollView.getVisibility() != GONE)
{
final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mScrollView
.getLayoutParams();
final int width = mScrollView.getMeasuredWidth();
final int height = mScrollView.getMeasuredHeight();
int childLeft;
int childTop;
int gravity = lp.gravity;
if (gravity == -1)
{
gravity = DEFAULT_CHILD_GRAVITY;
}
final int horizontalGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;
switch (horizontalGravity)
{
case Gravity.LEFT:
childLeft = parentLeft + lp.leftMargin;
break;
case Gravity.CENTER_HORIZONTAL:
childLeft = parentLeft + (parentRight - parentLeft - width) / 2 + lp.leftMargin
- lp.rightMargin;
break;
case Gravity.RIGHT:
childLeft = parentRight - width - lp.rightMargin;
break;
default:
childLeft = parentLeft + lp.leftMargin;
}
switch (verticalGravity)
{
case Gravity.TOP:
childTop = parentTop + lp.topMargin;
break;
case Gravity.CENTER_VERTICAL:
childTop = parentTop + (parentBottom - parentTop - height) / 2 + lp.topMargin
- lp.bottomMargin;
break;
case Gravity.BOTTOM:
childTop = parentBottom - height - lp.bottomMargin;
break;
default:
childTop = parentTop + lp.topMargin;
}
mScrollView.layout(childLeft, childTop, childLeft + width, childTop + height);
}
if (mBackground != null)
{
final int scrollYCenterOffset = mScrollView.getScrollY();
final int offset = (int) (scrollYCenterOffset * mScrollDiff);
// Log.d(TAG, "Layout Scroll Y: " + scrollYCenterOffset +
// " ScrollDiff: " + mScrollDiff
// + " Background Offset:" + offset);
mBackground.layout(getLeft(), offset, mBackgroundRight, offset + mBackgroundBottom);
}
}
/**
* {@inheritDoc}
*/
@Override
public LayoutParams generateLayoutParams(AttributeSet attrs)
{
return new FrameLayout.LayoutParams(getContext(), attrs);
}
@Override
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
{
return new FrameLayout.LayoutParams(p);
}
@Override
protected LayoutParams generateDefaultLayoutParams()
{
return new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
Gravity.CENTER_HORIZONTAL);
}
/**
* {@inheritDoc}
*/
@Override
protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
{
return p instanceof FrameLayout.LayoutParams;
}
/**
* Take the direct children and sort them
*/
private void organiseViews()
{
if (getChildCount() <= 0) return;
if (getChildCount() == 1)
{
// Get the only child
final View forground = getChildAt(0);
organiseBackgroundView(null);
organiseForgroundView(forground);
}
else if (getChildCount() == 2)
{
final View background = getChildAt(0);
final View foreground = getChildAt(1);
organiseBackgroundView(background);
organiseForgroundView(foreground);
}
else
{
throw new IllegalStateException("ParallaxScrollView can host only two direct children");
}
}
private void organiseBackgroundView(final View background)
{
mBackground = background;
}
private void organiseForgroundView(final View forground)
{
final int insertPos = getChildCount() - 1;
// See if its a observable scroll view?
if (forground instanceof ObservableScrollView)
{
// Attach the callback to it.
mScrollView = (ObservableScrollView) forground;
}
else if (forground instanceof ViewGroup && !(forground instanceof ScrollView))
{
// See if it is a view group but not a scroll view and wrap it
// with an observable ScrollView
mScrollView = new ObservableScrollView(getContext(), null);
removeView(forground);
mScrollView.addView(forground);
addView(mScrollView, insertPos);
}
else if (forground instanceof ScrollView)
{
final View child;
if (((ScrollView) forground).getChildCount() > 0)
child = ((ScrollView) forground).getChildAt(0);
else
child = null;
mScrollView = new ObservableScrollView(getContext(), null);
removeView(forground);
if (child != null) mScrollView.addView(child);
addView(mScrollView, insertPos);
}
else if (forground instanceof View)
{
mScrollView = new ObservableScrollView(getContext(), null);
removeView(forground);
mScrollView.addView(forground);
addView(mScrollView, insertPos);
}
if (mScrollView != null)
{
mScrollView.setLayoutParams(forground.getLayoutParams());
mScrollView.setCallbacks(mScrollCallbacks);
mScrollView.setFillViewport(true);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment