Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Core/AndroidBinding/src/gueei/binding/Binder.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public static BindingMap getBindingMapForView(View view){
public static InflateResult inflateView(Context context, int layoutId, ViewGroup parent, boolean attachToRoot){
return _kernel.inflateView(context, layoutId, parent, attachToRoot);
}

public static InflateResult inflateViewFromExistingView(Context context, View view, int layoutId){
return _kernel.inflateViewFromExistingView(context, view, layoutId);
}

public static View bindView(Context context, InflateResult inflatedView, Object model){
return _kernel.bindView(context, inflatedView, model);
Expand Down
12 changes: 11 additions & 1 deletion Core/AndroidBinding/src/gueei/binding/IKernel.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ public interface IKernel {
* @return Inflate Result.
*/
public InflateResult inflateView(Context context, int layoutId, ViewGroup parent, boolean attachToRoot);
/**

/**
* Inflate, and parse the binding information with Android binding
* @param context
* @param view inflate from this view instance
* @param layoutId The xml layout definition (it's not INFLATED FROM this definition)
* @return Inflate Result.
*/
public InflateResult inflateViewFromExistingView(Context context, View view, int layoutId);

/**
* Returns the binded root view of the inflated view
* @param context
* @param inflatedView The inflated result from inflateView
Expand Down
46 changes: 36 additions & 10 deletions Core/AndroidBinding/src/gueei/binding/kernel/KernelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import gueei.binding.AttributeBinder;
import gueei.binding.AttributeCollection;
import gueei.binding.*;
import gueei.binding.Binder.InflateResult;
import gueei.binding.BindingLog;
import gueei.binding.BindingMap;
import gueei.binding.IBindableView;
import gueei.binding.IKernel;
import gueei.binding.ISyntaxResolver;
import gueei.binding.ViewAttribute;
import gueei.binding.ViewFactory;
import gueei.binding.ViewTag;
import gueei.binding.bindingProviders.AbsSpinnerViewProvider;
import gueei.binding.bindingProviders.AdapterViewProvider;
import gueei.binding.bindingProviders.CompoundButtonProvider;
Expand All @@ -33,6 +24,8 @@
import gueei.binding.listeners.MulticastListenerCollection;
import gueei.binding.listeners.ViewMulticastListener;

import java.util.ArrayList;

public abstract class KernelBase implements IKernel {

public KernelBase() {
Expand Down Expand Up @@ -112,6 +105,39 @@ public InflateResult inflateView(Context context, int layoutId, ViewGroup parent
return result;
}

@Override
public InflateResult inflateViewFromExistingView(Context context, View view, int layoutId) {
LayoutInflater inflater = LayoutInflater.from(context).cloneInContext(context);
ViewFactory factory = new ViewFactory(inflater);
inflater.setFactory(factory);
InflateResult result = new InflateResult();
inflater.inflate(layoutId, null, false);
result.rootView = view;
result.processedViews = getReattachedViews(factory.getProcessedViews(), result.rootView);

return result;
}

private ArrayList<View> getReattachedViews(ArrayList<View> cloneViews, View rootView) {
ArrayList<View> originalControls = new ArrayList<View>();

for (View cloneView : cloneViews) {

int cloneId = cloneView.getId();
if (cloneId == -1)
android.util.Log.e("ANDROID-BINDING","ALL BINDABLE CONTROLS IN ANDROID-BINDING MUST HAVE AN ID!");

View view = rootView.findViewById(cloneId);
if (view != null) {
BindingMap bm = Binder.getBindingMapForView(cloneView);
Binder.putBindingMapToView(view, bm);
originalControls.add(view);
}
}

return originalControls;
}

@Override
public View bindView(Context context, InflateResult inflatedView, Object model) {
for(View v: inflatedView.processedViews){
Expand Down