repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
|---|---|---|---|---|---|---|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableCursor.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Property;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* Expose a cursor that is observable, duh.
*/
public class ObservableCursor
extends ObservableObject
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableCursor.java
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Property;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* Expose a cursor that is observable, duh.
*/
public class ObservableCursor
extends ObservableObject
|
implements IObservableCursor
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableCursor.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Property;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
|
@Override
public void setLayoutId(int layoutId) {
this.templateId = layoutId;
if (internalCursorAdapter != null)
internalCursorAdapter.setLayoutId(layoutId);
}
@Override
public int indexOf(Object obj) {
if (internalCursorAdapter !=null)
return internalCursorAdapter.getCursor().getPosition();
return -1;
}
@Override
public void onLoaderReset(Loader<Cursor> cursorLoader)
{
if (internalCursorAdapter != null)
internalCursorAdapter.swapCursor(null);
}
// @Override
// public IPropertyStore getPropertyStore()
// {
// if (internalCursorAdapter == null || !(internalCursorAdapter.getCursor() instanceof internalCursorWrapper))
// return null;
// return (internalCursorWrapper)internalCursorAdapter.getCursor();
// }
@Override
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableCursor.java
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Property;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
@Override
public void setLayoutId(int layoutId) {
this.templateId = layoutId;
if (internalCursorAdapter != null)
internalCursorAdapter.setLayoutId(layoutId);
}
@Override
public int indexOf(Object obj) {
if (internalCursorAdapter !=null)
return internalCursorAdapter.getCursor().getPosition();
return -1;
}
@Override
public void onLoaderReset(Loader<Cursor> cursorLoader)
{
if (internalCursorAdapter != null)
internalCursorAdapter.swapCursor(null);
}
// @Override
// public IPropertyStore getPropertyStore()
// {
// if (internalCursorAdapter == null || !(internalCursorAdapter.getCursor() instanceof internalCursorWrapper))
// return null;
// return (internalCursorWrapper)internalCursorAdapter.getCursor();
// }
@Override
|
protected IPropertyStore getPropertyStore()
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableCursor.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Property;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
|
Cursor internalCursor = (Cursor)obj;
if (index == -1)
{
//if (cursorExtension == null)
// return null;
//return cursorExtension.getCursorExtendedProperty(internalCursor, getName());
}
Class<Object> c = cursorPropAccessor.this.getType();
if (c.equals(float.class))
return internalCursor.getFloat(index);
else if (c.equals(double.class))
return internalCursor.getDouble(index);
else if (c.equals(int.class))
return internalCursor.getInt(index);
else if (c.equals(long.class))
return internalCursor.getLong(index);
else if (c.equals(short.class))
return internalCursor.getShort(index);
else if (c.equals(String.class))
return internalCursor.getString(index);
else if (c.equals(Void.class))
return null;
else
return internalCursor.getBlob(index);
}
};
class internalCursorWrapper extends CursorWrapper
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableCursor.java
import android.content.Loader;
import android.database.Cursor;
import android.database.CursorWrapper;
import android.database.DataSetObserver;
import android.os.Bundle;
import android.util.Property;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
Cursor internalCursor = (Cursor)obj;
if (index == -1)
{
//if (cursorExtension == null)
// return null;
//return cursorExtension.getCursorExtendedProperty(internalCursor, getName());
}
Class<Object> c = cursorPropAccessor.this.getType();
if (c.equals(float.class))
return internalCursor.getFloat(index);
else if (c.equals(double.class))
return internalCursor.getDouble(index);
else if (c.equals(int.class))
return internalCursor.getInt(index);
else if (c.equals(long.class))
return internalCursor.getLong(index);
else if (c.equals(short.class))
return internalCursor.getShort(index);
else if (c.equals(String.class))
return internalCursor.getString(index);
else if (c.equals(Void.class))
return null;
else
return internalCursor.getBlob(index);
}
};
class internalCursorWrapper extends CursorWrapper
|
implements IPOJO, IPropertyStore
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
|
import android.text.format.Time;
import java.util.List;
import traction.mvc.observables.Command;
|
type = t;
}
private String type;
@Override
public String toString()
{
return type;
}
public String getType()
{
return type;
}
}
List<Gender> getGenders();
Gender getUserGender();
void setUserGender(Gender gender);
String getFirstName();
void setFirstName(String firstName);
String getLastName();
void setLastName(String lastName);
Time getDateOfBirth();
void setDateOfBirth(Time dateOfBirth);
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
import android.text.format.Time;
import java.util.List;
import traction.mvc.observables.Command;
type = t;
}
private String type;
@Override
public String toString()
{
return type;
}
public String getType()
{
return type;
}
}
List<Gender> getGenders();
Gender getUserGender();
void setUserGender(Gender gender);
String getFirstName();
void setFirstName(String firstName);
String getLastName();
void setLastName(String lastName);
Time getDateOfBirth();
void setDateOfBirth(Time dateOfBirth);
|
Command getSave();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/models/IBridgeOfDeathModel.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
|
import traction.mvc.interfaces.IObservableCursor;
|
package ni3po42.android.tractiondemo.models;
public interface IBridgeOfDeathModel
{
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IBridgeOfDeathModel.java
import traction.mvc.interfaces.IObservableCursor;
package ni3po42.android.tractiondemo.models;
public interface IBridgeOfDeathModel
{
|
IObservableCursor getAnswers();
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/implementations/ui/viewbinding/ListViewBinding.java
|
// Path: traction/src/main/java/traction/mvc/implementations/ui/UIProperty.java
// public class UIProperty<T>
// implements IUIElement<T>
// {
// protected String path;
// protected T tempValue;
//
// private IUIElement.IUIUpdateListener<T> updateListener;
//
// private boolean _isUpdating;
//
// protected String pathAttribute = null;
// protected final IViewBinding parentViewBinding;
//
// @SuppressWarnings("unused")
// private UIProperty(){parentViewBinding = null;}
//
// public UIProperty(IProxyViewBinding viewBinding, String pathAttribute)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.pathAttribute = pathAttribute;
// this.parentViewBinding.registerUIElement(this);
// }
//
// public UIProperty(IProxyViewBinding viewBinding)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.parentViewBinding.registerUIElement(this);
// }
//
// /**
// * @return : true when element is currently sending an update back to the model or view-model
// */
// public boolean isUpdating()
// {
// return _isUpdating;
// }
//
// /**
// * Initiates the BindingInventory to send data to the model/view-model
// */
// public void sendUpdate(T value)
// {
// if (path == null)
// return;
//
// disableReceiveUpdates();
// getBindingInventory().sendUpdate(path, value);
// enableReceiveUpdates();
// }
//
// public T dereferenceValue()
// {
// return (T) getBindingInventory().dereferenceValue(path);
// }
//
// public T getTempValue()
// {
// return tempValue;
// }
//
// public void setTempValue(T value)
// {
// this.tempValue = value;
// }
//
// @Override
// public void setUIUpdateListener(IUIElement.IUIUpdateListener<T> listener)
// {
// this.updateListener = listener;
// }
//
// @Override
// public void receiveUpdate(final Object value)
// {
// if (updateListener == null)
// return;
//
// synchronized(this)
// {
// //is true is 'disableReceiveUpdates' has been called before 'enablRecieveUpdates'
// //This is also the case if UIProperty has called the 'sendUpdate' method
// if (isUpdating())
// return;
//
// //if no handler, then just run on current thread
// if (getUIHandler() == null)
// {
// updateListener.onUpdate((T)value);
// }
// else
// {
// //call the update listener on the UI thread. Needs to be on the UI thread because it is most
// //certainly updating something on the UI
// getUIHandler().tryPostImmediatelyToUIThread(new Runnable()
// {
// @Override
// public void run()
// {
// updateListener.onUpdate((T) value);
// }
// });
// }
// }
// }
//
// @Override
// public void initialize() throws Exception
// {
// JSONObject tagProperties =parentViewBinding.getTagProperties();
// if (tagProperties != null)
// {
// String tempPath = tagProperties.has(pathAttribute) ? tagProperties.getString(pathAttribute) : null;
//
// if (pathAttribute != null) {
// if (parentViewBinding.getPathPrefix() == null)
// path = tempPath;
// else if (tempPath != null)
// path = parentViewBinding.getPathPrefix() + "." + tempPath;
// else
// path = null;
// }
// }
// getBindingInventory().track(this, path);
// }
//
// protected void disableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = true;
// }
// }
//
// protected void enableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = false;
// }
// }
//
// @Override
// public BindingInventory getBindingInventory()
// {
// return parentViewBinding.getBindingInventory();
// }
//
// public Class<?> getDereferencedPathType()
// {
// return parentViewBinding.getBindingInventory().dereferencePropertyType(this.path);
// }
//
// @Override
// public boolean isDefined()
// {
// return path != null;
// }
//
// @Override
// public void track(BindingInventory differentBindingInventory)
// {
// if (this.path == null)
// return;
// differentBindingInventory.track(this, this.path);
// }
//
// protected UIHandler getUIHandler()
// {
// return parentViewBinding.getUIHandler();
// }
// }
|
import traction.mvc.implementations.ui.UIProperty;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations.ui.viewbinding;
/**
* Binding for a list view; it just extends the AdapterViewBinding to add a special attribute: 'Selected'.
* The 'Selected' attribute is an 'item' relative member path, letting the listview know which property to look for when determining
* if it is marked selected or not. It didn't need an actual ui element because the path is not dynamic.
* @author Tim Stratton
*
*
* Exposes the following properties:
* SelectedItem - Path to the child item that is selected
* SelectedItemIndex - Path to child item's index that was selected
*/
public class ListViewBinding
extends AdapterViewBinding
implements OnItemClickListener
{
|
// Path: traction/src/main/java/traction/mvc/implementations/ui/UIProperty.java
// public class UIProperty<T>
// implements IUIElement<T>
// {
// protected String path;
// protected T tempValue;
//
// private IUIElement.IUIUpdateListener<T> updateListener;
//
// private boolean _isUpdating;
//
// protected String pathAttribute = null;
// protected final IViewBinding parentViewBinding;
//
// @SuppressWarnings("unused")
// private UIProperty(){parentViewBinding = null;}
//
// public UIProperty(IProxyViewBinding viewBinding, String pathAttribute)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.pathAttribute = pathAttribute;
// this.parentViewBinding.registerUIElement(this);
// }
//
// public UIProperty(IProxyViewBinding viewBinding)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.parentViewBinding.registerUIElement(this);
// }
//
// /**
// * @return : true when element is currently sending an update back to the model or view-model
// */
// public boolean isUpdating()
// {
// return _isUpdating;
// }
//
// /**
// * Initiates the BindingInventory to send data to the model/view-model
// */
// public void sendUpdate(T value)
// {
// if (path == null)
// return;
//
// disableReceiveUpdates();
// getBindingInventory().sendUpdate(path, value);
// enableReceiveUpdates();
// }
//
// public T dereferenceValue()
// {
// return (T) getBindingInventory().dereferenceValue(path);
// }
//
// public T getTempValue()
// {
// return tempValue;
// }
//
// public void setTempValue(T value)
// {
// this.tempValue = value;
// }
//
// @Override
// public void setUIUpdateListener(IUIElement.IUIUpdateListener<T> listener)
// {
// this.updateListener = listener;
// }
//
// @Override
// public void receiveUpdate(final Object value)
// {
// if (updateListener == null)
// return;
//
// synchronized(this)
// {
// //is true is 'disableReceiveUpdates' has been called before 'enablRecieveUpdates'
// //This is also the case if UIProperty has called the 'sendUpdate' method
// if (isUpdating())
// return;
//
// //if no handler, then just run on current thread
// if (getUIHandler() == null)
// {
// updateListener.onUpdate((T)value);
// }
// else
// {
// //call the update listener on the UI thread. Needs to be on the UI thread because it is most
// //certainly updating something on the UI
// getUIHandler().tryPostImmediatelyToUIThread(new Runnable()
// {
// @Override
// public void run()
// {
// updateListener.onUpdate((T) value);
// }
// });
// }
// }
// }
//
// @Override
// public void initialize() throws Exception
// {
// JSONObject tagProperties =parentViewBinding.getTagProperties();
// if (tagProperties != null)
// {
// String tempPath = tagProperties.has(pathAttribute) ? tagProperties.getString(pathAttribute) : null;
//
// if (pathAttribute != null) {
// if (parentViewBinding.getPathPrefix() == null)
// path = tempPath;
// else if (tempPath != null)
// path = parentViewBinding.getPathPrefix() + "." + tempPath;
// else
// path = null;
// }
// }
// getBindingInventory().track(this, path);
// }
//
// protected void disableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = true;
// }
// }
//
// protected void enableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = false;
// }
// }
//
// @Override
// public BindingInventory getBindingInventory()
// {
// return parentViewBinding.getBindingInventory();
// }
//
// public Class<?> getDereferencedPathType()
// {
// return parentViewBinding.getBindingInventory().dereferencePropertyType(this.path);
// }
//
// @Override
// public boolean isDefined()
// {
// return path != null;
// }
//
// @Override
// public void track(BindingInventory differentBindingInventory)
// {
// if (this.path == null)
// return;
// differentBindingInventory.track(this, this.path);
// }
//
// protected UIHandler getUIHandler()
// {
// return parentViewBinding.getUIHandler();
// }
// }
// Path: traction/src/main/java/traction/mvc/implementations/ui/viewbinding/ListViewBinding.java
import traction.mvc.implementations.ui.UIProperty;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations.ui.viewbinding;
/**
* Binding for a list view; it just extends the AdapterViewBinding to add a special attribute: 'Selected'.
* The 'Selected' attribute is an 'item' relative member path, letting the listview know which property to look for when determining
* if it is marked selected or not. It didn't need an actual ui element because the path is not dynamic.
* @author Tim Stratton
*
*
* Exposes the following properties:
* SelectedItem - Path to the child item that is selected
* SelectedItemIndex - Path to child item's index that was selected
*/
public class ListViewBinding
extends AdapterViewBinding
implements OnItemClickListener
{
|
public final UIProperty<Integer> SelectedItemIndex = new UIProperty<Integer>(this, "SelectedItemIndex");
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/IProxyObservableObject.java
// public interface IProxyObservableObject
// {
// /**
// * Allow access to the composed IObservableObject
// * @return
// */
// ObservableObject getProxyObservableObject();
//
// }
|
import traction.mvc.observables.Command;
import traction.mvc.observables.IProxyObservableObject;
|
package ni3po42.android.tractiondemo.models;
public interface IUIWireModel
extends IProxyObservableObject
{
int getImage();
void setImage(int image);
boolean isMainFlagOn();
void setMainFlagOn(boolean mainFlag);
int getUpperBound();
void setUpperBound(int upperBound);
int getCurrentInteger();
void setCurrentInteger(int currentInteger);
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/IProxyObservableObject.java
// public interface IProxyObservableObject
// {
// /**
// * Allow access to the composed IObservableObject
// * @return
// */
// ObservableObject getProxyObservableObject();
//
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
import traction.mvc.observables.Command;
import traction.mvc.observables.IProxyObservableObject;
package ni3po42.android.tractiondemo.models;
public interface IUIWireModel
extends IProxyObservableObject
{
int getImage();
void setImage(int image);
boolean isMainFlagOn();
void setMainFlagOn(boolean mainFlag);
int getUpperBound();
void setUpperBound(int upperBound);
int getCurrentInteger();
void setCurrentInteger(int currentInteger);
|
Command getMyEvent();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ActualDialogController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/DialogController.java
// public abstract class DialogController
// extends DialogFragment
// {
// private Dialog tempDialog;
//
// /**
// * Helper
// */
// protected final ControllerHelper View = new ControllerHelper(this)
// {
// @Override
// protected void invalidateMenu()
// {
// if (getDialog() != null)
// getDialog().invalidateOptionsMenu();
// }
//
// @Override
// public void setMenuLayout(int id)
// {
// setHasOptionsMenu(id > 0);
// super.setMenuLayout(id);
// }
// };
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState)
// {
// tempDialog = new Dialog(getActivity(), getTheme())
// {
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
// };
//
// View.invalidateMenu();
// return tempDialog;
// }
//
// @Override
// public Dialog getDialog()
// {
// Dialog d = super.getDialog();
// if (d != null)
// tempDialog = null;
//
// return (d == null) ? tempDialog : d;
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, true);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
// public interface DialogModel
// {
// String getSomeText();
// void setSomeText(String t);
//
// Command getClose();
// Command getOpen();
// }
|
import android.os.Bundle;
import traction.mvc.controllers.DialogController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.DialogModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class ActualDialogController extends DialogController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.dialog);
View.setMenuLayout(R.menu.dialog_menu);
};
@Override
public void onStart()
{
super.onStart();
|
// Path: traction/src/main/java/traction/mvc/controllers/DialogController.java
// public abstract class DialogController
// extends DialogFragment
// {
// private Dialog tempDialog;
//
// /**
// * Helper
// */
// protected final ControllerHelper View = new ControllerHelper(this)
// {
// @Override
// protected void invalidateMenu()
// {
// if (getDialog() != null)
// getDialog().invalidateOptionsMenu();
// }
//
// @Override
// public void setMenuLayout(int id)
// {
// setHasOptionsMenu(id > 0);
// super.setMenuLayout(id);
// }
// };
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState)
// {
// tempDialog = new Dialog(getActivity(), getTheme())
// {
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
// };
//
// View.invalidateMenu();
// return tempDialog;
// }
//
// @Override
// public Dialog getDialog()
// {
// Dialog d = super.getDialog();
// if (d != null)
// tempDialog = null;
//
// return (d == null) ? tempDialog : d;
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, true);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
// public interface DialogModel
// {
// String getSomeText();
// void setSomeText(String t);
//
// Command getClose();
// Command getOpen();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ActualDialogController.java
import android.os.Bundle;
import traction.mvc.controllers.DialogController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.DialogModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class ActualDialogController extends DialogController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.dialog);
View.setMenuLayout(R.menu.dialog_menu);
};
@Override
public void onStart()
{
super.onStart();
|
DialogModel model = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ActualDialogController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/DialogController.java
// public abstract class DialogController
// extends DialogFragment
// {
// private Dialog tempDialog;
//
// /**
// * Helper
// */
// protected final ControllerHelper View = new ControllerHelper(this)
// {
// @Override
// protected void invalidateMenu()
// {
// if (getDialog() != null)
// getDialog().invalidateOptionsMenu();
// }
//
// @Override
// public void setMenuLayout(int id)
// {
// setHasOptionsMenu(id > 0);
// super.setMenuLayout(id);
// }
// };
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState)
// {
// tempDialog = new Dialog(getActivity(), getTheme())
// {
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
// };
//
// View.invalidateMenu();
// return tempDialog;
// }
//
// @Override
// public Dialog getDialog()
// {
// Dialog d = super.getDialog();
// if (d != null)
// tempDialog = null;
//
// return (d == null) ? tempDialog : d;
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, true);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
// public interface DialogModel
// {
// String getSomeText();
// void setSomeText(String t);
//
// Command getClose();
// Command getOpen();
// }
|
import android.os.Bundle;
import traction.mvc.controllers.DialogController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.DialogModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class ActualDialogController extends DialogController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.dialog);
View.setMenuLayout(R.menu.dialog_menu);
};
@Override
public void onStart()
{
super.onStart();
DialogModel model = View.getScope();
|
// Path: traction/src/main/java/traction/mvc/controllers/DialogController.java
// public abstract class DialogController
// extends DialogFragment
// {
// private Dialog tempDialog;
//
// /**
// * Helper
// */
// protected final ControllerHelper View = new ControllerHelper(this)
// {
// @Override
// protected void invalidateMenu()
// {
// if (getDialog() != null)
// getDialog().invalidateOptionsMenu();
// }
//
// @Override
// public void setMenuLayout(int id)
// {
// setHasOptionsMenu(id > 0);
// super.setMenuLayout(id);
// }
// };
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState)
// {
// tempDialog = new Dialog(getActivity(), getTheme())
// {
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
// };
//
// View.invalidateMenu();
// return tempDialog;
// }
//
// @Override
// public Dialog getDialog()
// {
// Dialog d = super.getDialog();
// if (d != null)
// tempDialog = null;
//
// return (d == null) ? tempDialog : d;
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, true);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
// public interface DialogModel
// {
// String getSomeText();
// void setSomeText(String t);
//
// Command getClose();
// Command getOpen();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ActualDialogController.java
import android.os.Bundle;
import traction.mvc.controllers.DialogController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.DialogModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class ActualDialogController extends DialogController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.dialog);
View.setMenuLayout(R.menu.dialog_menu);
};
@Override
public void onStart()
{
super.onStart();
DialogModel model = View.getScope();
|
model.getClose().setExecuteListener(new IOnExecuteListener() {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ActualDialogController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/DialogController.java
// public abstract class DialogController
// extends DialogFragment
// {
// private Dialog tempDialog;
//
// /**
// * Helper
// */
// protected final ControllerHelper View = new ControllerHelper(this)
// {
// @Override
// protected void invalidateMenu()
// {
// if (getDialog() != null)
// getDialog().invalidateOptionsMenu();
// }
//
// @Override
// public void setMenuLayout(int id)
// {
// setHasOptionsMenu(id > 0);
// super.setMenuLayout(id);
// }
// };
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState)
// {
// tempDialog = new Dialog(getActivity(), getTheme())
// {
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
// };
//
// View.invalidateMenu();
// return tempDialog;
// }
//
// @Override
// public Dialog getDialog()
// {
// Dialog d = super.getDialog();
// if (d != null)
// tempDialog = null;
//
// return (d == null) ? tempDialog : d;
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, true);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
// public interface DialogModel
// {
// String getSomeText();
// void setSomeText(String t);
//
// Command getClose();
// Command getOpen();
// }
|
import android.os.Bundle;
import traction.mvc.controllers.DialogController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.DialogModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class ActualDialogController extends DialogController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.dialog);
View.setMenuLayout(R.menu.dialog_menu);
};
@Override
public void onStart()
{
super.onStart();
DialogModel model = View.getScope();
model.getClose().setExecuteListener(new IOnExecuteListener() {
@Override
|
// Path: traction/src/main/java/traction/mvc/controllers/DialogController.java
// public abstract class DialogController
// extends DialogFragment
// {
// private Dialog tempDialog;
//
// /**
// * Helper
// */
// protected final ControllerHelper View = new ControllerHelper(this)
// {
// @Override
// protected void invalidateMenu()
// {
// if (getDialog() != null)
// getDialog().invalidateOptionsMenu();
// }
//
// @Override
// public void setMenuLayout(int id)
// {
// setHasOptionsMenu(id > 0);
// super.setMenuLayout(id);
// }
// };
//
// @Override
// public Dialog onCreateDialog(Bundle savedInstanceState)
// {
// tempDialog = new Dialog(getActivity(), getTheme())
// {
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
// };
//
// View.invalidateMenu();
// return tempDialog;
// }
//
// @Override
// public Dialog getDialog()
// {
// Dialog d = super.getDialog();
// if (d != null)
// tempDialog = null;
//
// return (d == null) ? tempDialog : d;
// }
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, true);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
// public interface DialogModel
// {
// String getSomeText();
// void setSomeText(String t);
//
// Command getClose();
// Command getOpen();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ActualDialogController.java
import android.os.Bundle;
import traction.mvc.controllers.DialogController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.DialogModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class ActualDialogController extends DialogController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.dialog);
View.setMenuLayout(R.menu.dialog_menu);
};
@Override
public void onStart()
{
super.onStart();
DialogModel model = View.getScope();
model.getClose().setExecuteListener(new IOnExecuteListener() {
@Override
|
public void onExecuted(CommandArgument argument) {
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ScopeBuilder.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
|
import android.util.Property;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
|
package traction.mvc.observables;
public class ScopeBuilder
{
public static Object CreateScope(Class<?> scopeInterface)
{
return Proxy
.newProxyInstance(
scopeInterface.getClassLoader(),
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ScopeBuilder.java
import android.util.Property;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
package traction.mvc.observables;
public class ScopeBuilder
{
public static Object CreateScope(Class<?> scopeInterface)
{
return Proxy
.newProxyInstance(
scopeInterface.getClassLoader(),
|
new Class[]{scopeInterface, IProxyObservableObject.class, IPOJO.class},
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ScopeBuilder.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
|
import android.util.Property;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
|
{
if (!name.equals("getProxyObservableObject"))
throw new IllegalStateException("only 'getProxyObservableObject' may be called on 'IProxyObservableObject'.");
return map.getProxyObservableObject();
}
else if (IPOJO.class == method.getDeclaringClass())
{
if (!name.equals("getProperty"))
throw new IllegalStateException("only 'getProperty' may be called on 'IPOJO'.");
return map.getProperty((String)args[1]);
}
if (method.getReturnType().equals(Void.TYPE))//set
{
map.put(name.substring(3), args[0]);
return null;
}
else//get
{
name = name.substring(method.getName().startsWith("is") ? 2 : 3);
Property<?,?> prop = Property.of(proxy.getClass(), method.getReturnType(), name);
if (prop.isReadOnly() && map.get(name) == null)
{
if (Collection.class.isAssignableFrom(method.getReturnType()) ||
Iterable.class.isAssignableFrom(method.getReturnType()))
{
ObservableList<Object> list = new ObservableList<Object>(new LinkedList<Object>());
map.put(name, list);
}
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ScopeBuilder.java
import android.util.Property;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
{
if (!name.equals("getProxyObservableObject"))
throw new IllegalStateException("only 'getProxyObservableObject' may be called on 'IProxyObservableObject'.");
return map.getProxyObservableObject();
}
else if (IPOJO.class == method.getDeclaringClass())
{
if (!name.equals("getProperty"))
throw new IllegalStateException("only 'getProperty' may be called on 'IPOJO'.");
return map.getProperty((String)args[1]);
}
if (method.getReturnType().equals(Void.TYPE))//set
{
map.put(name.substring(3), args[0]);
return null;
}
else//get
{
name = name.substring(method.getName().startsWith("is") ? 2 : 3);
Property<?,?> prop = Property.of(proxy.getClass(), method.getReturnType(), name);
if (prop.isReadOnly() && map.get(name) == null)
{
if (Collection.class.isAssignableFrom(method.getReturnType()) ||
Iterable.class.isAssignableFrom(method.getReturnType()))
{
ObservableList<Object> list = new ObservableList<Object>(new LinkedList<Object>());
map.put(name, list);
}
|
else if (IObservableCursor.class.isAssignableFrom(method.getReturnType()))
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ScopeBuilder.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
|
import android.util.Property;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
|
}
else if (IPOJO.class == method.getDeclaringClass())
{
if (!name.equals("getProperty"))
throw new IllegalStateException("only 'getProperty' may be called on 'IPOJO'.");
return map.getProperty((String)args[1]);
}
if (method.getReturnType().equals(Void.TYPE))//set
{
map.put(name.substring(3), args[0]);
return null;
}
else//get
{
name = name.substring(method.getName().startsWith("is") ? 2 : 3);
Property<?,?> prop = Property.of(proxy.getClass(), method.getReturnType(), name);
if (prop.isReadOnly() && map.get(name) == null)
{
if (Collection.class.isAssignableFrom(method.getReturnType()) ||
Iterable.class.isAssignableFrom(method.getReturnType()))
{
ObservableList<Object> list = new ObservableList<Object>(new LinkedList<Object>());
map.put(name, list);
}
else if (IObservableCursor.class.isAssignableFrom(method.getReturnType()))
{
map.put(name, new ObservableCursor());
}
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCursor.java
// public interface IObservableCursor
// extends LoaderManager.LoaderCallbacks<Cursor>,IProxyObservableObject, ITemplateAdapter
// {
// void setLoader(Loader<Cursor> loader);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ScopeBuilder.java
import android.util.Property;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collection;
import java.util.Hashtable;
import java.util.LinkedList;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IObservableCursor;
import traction.mvc.interfaces.IPOJO;
}
else if (IPOJO.class == method.getDeclaringClass())
{
if (!name.equals("getProperty"))
throw new IllegalStateException("only 'getProperty' may be called on 'IPOJO'.");
return map.getProperty((String)args[1]);
}
if (method.getReturnType().equals(Void.TYPE))//set
{
map.put(name.substring(3), args[0]);
return null;
}
else//get
{
name = name.substring(method.getName().startsWith("is") ? 2 : 3);
Property<?,?> prop = Property.of(proxy.getClass(), method.getReturnType(), name);
if (prop.isReadOnly() && map.get(name) == null)
{
if (Collection.class.isAssignableFrom(method.getReturnType()) ||
Iterable.class.isAssignableFrom(method.getReturnType()))
{
ObservableList<Object> list = new ObservableList<Object>(new LinkedList<Object>());
map.put(name, list);
}
else if (IObservableCursor.class.isAssignableFrom(method.getReturnType()))
{
map.put(name, new ObservableCursor());
}
|
else if (IObservableCommand.class.isAssignableFrom(method.getReturnType()))
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/activities/MainActivity.java
|
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MainController.java
// public class MainController extends FragmentController
// {
// public final static String NoMultiViewModelSupport = "multiViewModelSupport";
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// if (savedInstanceState != null)
// return;
// View.setContentView(R.layout.mainview);
// }
//
// @Override
// public void onStart() {
// super.onStart();
//
// final IDemoSelectionModel model = View.getScope();
//
// model.getChoices().clear();
// model.getChoices().add(new DemoFragmentChoice(SimpleFormController.class, "Simple Form", "Explore the ease of filling out a user information form"));
// model.getChoices().add(new DemoFragmentChoice(UIWiringController.class, "UI Wiring", "Demonstrates how elements can react to other elements changing without referencing other UI elements!"));
// model.getChoices().add(new DemoFragmentChoice(DemoADialogController.class, "Dialog Controller", "Shows a view model hooking to a dialog."));
// model.getChoices().add(new DemoFragmentChoice(MultiSelectController.class, "Multi-selection", "Gives an example on how multi-selection could work in Traction MVC."));
// model.getChoices().add(new DemoFragmentChoice(EntryController.class, "Swipe List", "A custom view is built that binds data and provides a catchy (ok, at least not boring) UX. Swipe items to the left to activate/de-active."));
// model.getChoices().add(new DemoFragmentChoice(CalculatorController.class, "Calculator", "A simple calculator. Lots of buttons; simple view model."));
// model.getChoices().add(new DemoFragmentChoice(BridgeOfDeathController.class, "The Bridge of Death", "STOP! Who would cross the Bridge of Death must answer me these questions three; Ere the other side he see. Cursors and Generic Bindings!"));
// model.getChoices().add(new DemoFragmentChoice(RelativeContextFragmentController.class, "Relative Context", "Shows how relative context works."));
// model.getChoices().add(new DemoFragmentChoice(ScopeExampleController.class, "Scopes", "Example of using generated scopes."));
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"Choice".equals(propertyName) || newValue == null) return;
//
// model.setCurrentFragment(((DemoFragmentChoice)newValue).getFragment());
// }
// });
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"CurrentFragment".equals(propertyName) || newValue == null)
// return;
//
// Fragment newF = (Fragment)newValue;
//
// FragmentTransaction trans = getFragmentManager().beginTransaction()
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
// .replace(R.id.main_view_id, newF);
// if (hasNoMultiViewModelSupport())
// trans.addToBackStack(null);
// trans.commit();
// }
// });
//
// }
//
// private boolean hasNoMultiViewModelSupport()
// {
// return getArguments() == null ? false : getArguments().getBoolean(NoMultiViewModelSupport, false);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IHomeModel.java
// public interface IHomeModel
// {
// Fragment getCurrentFragment();
// void setCurrentFragment(Fragment modelView);
//
// }
//
// Path: traction/src/main/java/traction/mvc/controllers/ActivityController.java
// @SuppressLint("Registered")
// public abstract class ActivityController
// extends Activity
// {
// /**
// * Helper object: houses almost all the logic the activity will need
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public Object getSystemService(String name)
// {
// return View.tweakServiceCall(name, super.getSystemService(name));
// }
//
// @Override
// public MenuInflater getMenuInflater()
// {
// return View.getMenuInflater();
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
//
// }
|
import android.app.FragmentTransaction;
import android.os.Bundle;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.controllers.MainController;
import ni3po42.android.tractiondemo.models.IHomeModel;
import traction.mvc.controllers.ActivityController;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.activities;
public class MainActivity extends ActivityController
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.main);
}
@Override
protected void onStart()
{
super.onStart();
|
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MainController.java
// public class MainController extends FragmentController
// {
// public final static String NoMultiViewModelSupport = "multiViewModelSupport";
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// if (savedInstanceState != null)
// return;
// View.setContentView(R.layout.mainview);
// }
//
// @Override
// public void onStart() {
// super.onStart();
//
// final IDemoSelectionModel model = View.getScope();
//
// model.getChoices().clear();
// model.getChoices().add(new DemoFragmentChoice(SimpleFormController.class, "Simple Form", "Explore the ease of filling out a user information form"));
// model.getChoices().add(new DemoFragmentChoice(UIWiringController.class, "UI Wiring", "Demonstrates how elements can react to other elements changing without referencing other UI elements!"));
// model.getChoices().add(new DemoFragmentChoice(DemoADialogController.class, "Dialog Controller", "Shows a view model hooking to a dialog."));
// model.getChoices().add(new DemoFragmentChoice(MultiSelectController.class, "Multi-selection", "Gives an example on how multi-selection could work in Traction MVC."));
// model.getChoices().add(new DemoFragmentChoice(EntryController.class, "Swipe List", "A custom view is built that binds data and provides a catchy (ok, at least not boring) UX. Swipe items to the left to activate/de-active."));
// model.getChoices().add(new DemoFragmentChoice(CalculatorController.class, "Calculator", "A simple calculator. Lots of buttons; simple view model."));
// model.getChoices().add(new DemoFragmentChoice(BridgeOfDeathController.class, "The Bridge of Death", "STOP! Who would cross the Bridge of Death must answer me these questions three; Ere the other side he see. Cursors and Generic Bindings!"));
// model.getChoices().add(new DemoFragmentChoice(RelativeContextFragmentController.class, "Relative Context", "Shows how relative context works."));
// model.getChoices().add(new DemoFragmentChoice(ScopeExampleController.class, "Scopes", "Example of using generated scopes."));
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"Choice".equals(propertyName) || newValue == null) return;
//
// model.setCurrentFragment(((DemoFragmentChoice)newValue).getFragment());
// }
// });
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"CurrentFragment".equals(propertyName) || newValue == null)
// return;
//
// Fragment newF = (Fragment)newValue;
//
// FragmentTransaction trans = getFragmentManager().beginTransaction()
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
// .replace(R.id.main_view_id, newF);
// if (hasNoMultiViewModelSupport())
// trans.addToBackStack(null);
// trans.commit();
// }
// });
//
// }
//
// private boolean hasNoMultiViewModelSupport()
// {
// return getArguments() == null ? false : getArguments().getBoolean(NoMultiViewModelSupport, false);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IHomeModel.java
// public interface IHomeModel
// {
// Fragment getCurrentFragment();
// void setCurrentFragment(Fragment modelView);
//
// }
//
// Path: traction/src/main/java/traction/mvc/controllers/ActivityController.java
// @SuppressLint("Registered")
// public abstract class ActivityController
// extends Activity
// {
// /**
// * Helper object: houses almost all the logic the activity will need
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public Object getSystemService(String name)
// {
// return View.tweakServiceCall(name, super.getSystemService(name));
// }
//
// @Override
// public MenuInflater getMenuInflater()
// {
// return View.getMenuInflater();
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
//
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/activities/MainActivity.java
import android.app.FragmentTransaction;
import android.os.Bundle;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.controllers.MainController;
import ni3po42.android.tractiondemo.models.IHomeModel;
import traction.mvc.controllers.ActivityController;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.activities;
public class MainActivity extends ActivityController
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.main);
}
@Override
protected void onStart()
{
super.onStart();
|
IHomeModel model = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/activities/MainActivity.java
|
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MainController.java
// public class MainController extends FragmentController
// {
// public final static String NoMultiViewModelSupport = "multiViewModelSupport";
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// if (savedInstanceState != null)
// return;
// View.setContentView(R.layout.mainview);
// }
//
// @Override
// public void onStart() {
// super.onStart();
//
// final IDemoSelectionModel model = View.getScope();
//
// model.getChoices().clear();
// model.getChoices().add(new DemoFragmentChoice(SimpleFormController.class, "Simple Form", "Explore the ease of filling out a user information form"));
// model.getChoices().add(new DemoFragmentChoice(UIWiringController.class, "UI Wiring", "Demonstrates how elements can react to other elements changing without referencing other UI elements!"));
// model.getChoices().add(new DemoFragmentChoice(DemoADialogController.class, "Dialog Controller", "Shows a view model hooking to a dialog."));
// model.getChoices().add(new DemoFragmentChoice(MultiSelectController.class, "Multi-selection", "Gives an example on how multi-selection could work in Traction MVC."));
// model.getChoices().add(new DemoFragmentChoice(EntryController.class, "Swipe List", "A custom view is built that binds data and provides a catchy (ok, at least not boring) UX. Swipe items to the left to activate/de-active."));
// model.getChoices().add(new DemoFragmentChoice(CalculatorController.class, "Calculator", "A simple calculator. Lots of buttons; simple view model."));
// model.getChoices().add(new DemoFragmentChoice(BridgeOfDeathController.class, "The Bridge of Death", "STOP! Who would cross the Bridge of Death must answer me these questions three; Ere the other side he see. Cursors and Generic Bindings!"));
// model.getChoices().add(new DemoFragmentChoice(RelativeContextFragmentController.class, "Relative Context", "Shows how relative context works."));
// model.getChoices().add(new DemoFragmentChoice(ScopeExampleController.class, "Scopes", "Example of using generated scopes."));
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"Choice".equals(propertyName) || newValue == null) return;
//
// model.setCurrentFragment(((DemoFragmentChoice)newValue).getFragment());
// }
// });
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"CurrentFragment".equals(propertyName) || newValue == null)
// return;
//
// Fragment newF = (Fragment)newValue;
//
// FragmentTransaction trans = getFragmentManager().beginTransaction()
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
// .replace(R.id.main_view_id, newF);
// if (hasNoMultiViewModelSupport())
// trans.addToBackStack(null);
// trans.commit();
// }
// });
//
// }
//
// private boolean hasNoMultiViewModelSupport()
// {
// return getArguments() == null ? false : getArguments().getBoolean(NoMultiViewModelSupport, false);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IHomeModel.java
// public interface IHomeModel
// {
// Fragment getCurrentFragment();
// void setCurrentFragment(Fragment modelView);
//
// }
//
// Path: traction/src/main/java/traction/mvc/controllers/ActivityController.java
// @SuppressLint("Registered")
// public abstract class ActivityController
// extends Activity
// {
// /**
// * Helper object: houses almost all the logic the activity will need
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public Object getSystemService(String name)
// {
// return View.tweakServiceCall(name, super.getSystemService(name));
// }
//
// @Override
// public MenuInflater getMenuInflater()
// {
// return View.getMenuInflater();
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
//
// }
|
import android.app.FragmentTransaction;
import android.os.Bundle;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.controllers.MainController;
import ni3po42.android.tractiondemo.models.IHomeModel;
import traction.mvc.controllers.ActivityController;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.activities;
public class MainActivity extends ActivityController
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.main);
}
@Override
protected void onStart()
{
super.onStart();
IHomeModel model = View.getScope();
boolean multiViewModelSupport = model.getCurrentFragment() != null;
if (multiViewModelSupport)
return;
|
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MainController.java
// public class MainController extends FragmentController
// {
// public final static String NoMultiViewModelSupport = "multiViewModelSupport";
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// if (savedInstanceState != null)
// return;
// View.setContentView(R.layout.mainview);
// }
//
// @Override
// public void onStart() {
// super.onStart();
//
// final IDemoSelectionModel model = View.getScope();
//
// model.getChoices().clear();
// model.getChoices().add(new DemoFragmentChoice(SimpleFormController.class, "Simple Form", "Explore the ease of filling out a user information form"));
// model.getChoices().add(new DemoFragmentChoice(UIWiringController.class, "UI Wiring", "Demonstrates how elements can react to other elements changing without referencing other UI elements!"));
// model.getChoices().add(new DemoFragmentChoice(DemoADialogController.class, "Dialog Controller", "Shows a view model hooking to a dialog."));
// model.getChoices().add(new DemoFragmentChoice(MultiSelectController.class, "Multi-selection", "Gives an example on how multi-selection could work in Traction MVC."));
// model.getChoices().add(new DemoFragmentChoice(EntryController.class, "Swipe List", "A custom view is built that binds data and provides a catchy (ok, at least not boring) UX. Swipe items to the left to activate/de-active."));
// model.getChoices().add(new DemoFragmentChoice(CalculatorController.class, "Calculator", "A simple calculator. Lots of buttons; simple view model."));
// model.getChoices().add(new DemoFragmentChoice(BridgeOfDeathController.class, "The Bridge of Death", "STOP! Who would cross the Bridge of Death must answer me these questions three; Ere the other side he see. Cursors and Generic Bindings!"));
// model.getChoices().add(new DemoFragmentChoice(RelativeContextFragmentController.class, "Relative Context", "Shows how relative context works."));
// model.getChoices().add(new DemoFragmentChoice(ScopeExampleController.class, "Scopes", "Example of using generated scopes."));
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"Choice".equals(propertyName) || newValue == null) return;
//
// model.setCurrentFragment(((DemoFragmentChoice)newValue).getFragment());
// }
// });
//
// model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
// @Override
// protected void onChange(String propertyName, Object oldValue, Object newValue) {
// if (!"CurrentFragment".equals(propertyName) || newValue == null)
// return;
//
// Fragment newF = (Fragment)newValue;
//
// FragmentTransaction trans = getFragmentManager().beginTransaction()
// .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
// .replace(R.id.main_view_id, newF);
// if (hasNoMultiViewModelSupport())
// trans.addToBackStack(null);
// trans.commit();
// }
// });
//
// }
//
// private boolean hasNoMultiViewModelSupport()
// {
// return getArguments() == null ? false : getArguments().getBoolean(NoMultiViewModelSupport, false);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IHomeModel.java
// public interface IHomeModel
// {
// Fragment getCurrentFragment();
// void setCurrentFragment(Fragment modelView);
//
// }
//
// Path: traction/src/main/java/traction/mvc/controllers/ActivityController.java
// @SuppressLint("Registered")
// public abstract class ActivityController
// extends Activity
// {
// /**
// * Helper object: houses almost all the logic the activity will need
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public Object getSystemService(String name)
// {
// return View.tweakServiceCall(name, super.getSystemService(name));
// }
//
// @Override
// public MenuInflater getMenuInflater()
// {
// return View.getMenuInflater();
// }
//
// @Override
// public boolean onCreateOptionsMenu(Menu menu)
// {
// return View.onCreateOptionsMenu(menu);
// }
//
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/activities/MainActivity.java
import android.app.FragmentTransaction;
import android.os.Bundle;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.controllers.MainController;
import ni3po42.android.tractiondemo.models.IHomeModel;
import traction.mvc.controllers.ActivityController;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.activities;
public class MainActivity extends ActivityController
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.main);
}
@Override
protected void onStart()
{
super.onStart();
IHomeModel model = View.getScope();
boolean multiViewModelSupport = model.getCurrentFragment() != null;
if (multiViewModelSupport)
return;
|
MainController mvm = new MainController();
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/implementations/ui/viewbinding/NumberPickerBinding.java
|
// Path: traction/src/main/java/traction/mvc/implementations/ui/UIProperty.java
// public class UIProperty<T>
// implements IUIElement<T>
// {
// protected String path;
// protected T tempValue;
//
// private IUIElement.IUIUpdateListener<T> updateListener;
//
// private boolean _isUpdating;
//
// protected String pathAttribute = null;
// protected final IViewBinding parentViewBinding;
//
// @SuppressWarnings("unused")
// private UIProperty(){parentViewBinding = null;}
//
// public UIProperty(IProxyViewBinding viewBinding, String pathAttribute)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.pathAttribute = pathAttribute;
// this.parentViewBinding.registerUIElement(this);
// }
//
// public UIProperty(IProxyViewBinding viewBinding)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.parentViewBinding.registerUIElement(this);
// }
//
// /**
// * @return : true when element is currently sending an update back to the model or view-model
// */
// public boolean isUpdating()
// {
// return _isUpdating;
// }
//
// /**
// * Initiates the BindingInventory to send data to the model/view-model
// */
// public void sendUpdate(T value)
// {
// if (path == null)
// return;
//
// disableReceiveUpdates();
// getBindingInventory().sendUpdate(path, value);
// enableReceiveUpdates();
// }
//
// public T dereferenceValue()
// {
// return (T) getBindingInventory().dereferenceValue(path);
// }
//
// public T getTempValue()
// {
// return tempValue;
// }
//
// public void setTempValue(T value)
// {
// this.tempValue = value;
// }
//
// @Override
// public void setUIUpdateListener(IUIElement.IUIUpdateListener<T> listener)
// {
// this.updateListener = listener;
// }
//
// @Override
// public void receiveUpdate(final Object value)
// {
// if (updateListener == null)
// return;
//
// synchronized(this)
// {
// //is true is 'disableReceiveUpdates' has been called before 'enablRecieveUpdates'
// //This is also the case if UIProperty has called the 'sendUpdate' method
// if (isUpdating())
// return;
//
// //if no handler, then just run on current thread
// if (getUIHandler() == null)
// {
// updateListener.onUpdate((T)value);
// }
// else
// {
// //call the update listener on the UI thread. Needs to be on the UI thread because it is most
// //certainly updating something on the UI
// getUIHandler().tryPostImmediatelyToUIThread(new Runnable()
// {
// @Override
// public void run()
// {
// updateListener.onUpdate((T) value);
// }
// });
// }
// }
// }
//
// @Override
// public void initialize() throws Exception
// {
// JSONObject tagProperties =parentViewBinding.getTagProperties();
// if (tagProperties != null)
// {
// String tempPath = tagProperties.has(pathAttribute) ? tagProperties.getString(pathAttribute) : null;
//
// if (pathAttribute != null) {
// if (parentViewBinding.getPathPrefix() == null)
// path = tempPath;
// else if (tempPath != null)
// path = parentViewBinding.getPathPrefix() + "." + tempPath;
// else
// path = null;
// }
// }
// getBindingInventory().track(this, path);
// }
//
// protected void disableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = true;
// }
// }
//
// protected void enableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = false;
// }
// }
//
// @Override
// public BindingInventory getBindingInventory()
// {
// return parentViewBinding.getBindingInventory();
// }
//
// public Class<?> getDereferencedPathType()
// {
// return parentViewBinding.getBindingInventory().dereferencePropertyType(this.path);
// }
//
// @Override
// public boolean isDefined()
// {
// return path != null;
// }
//
// @Override
// public void track(BindingInventory differentBindingInventory)
// {
// if (this.path == null)
// return;
// differentBindingInventory.track(this, this.path);
// }
//
// protected UIHandler getUIHandler()
// {
// return parentViewBinding.getUIHandler();
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
|
import traction.mvc.implementations.ui.UIProperty;
import traction.mvc.interfaces.IUIElement.IUIUpdateListener;
import android.widget.NumberPicker;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations.ui.viewbinding;
/**
* Defines ui elements for binding to a number picker.
* @author Tim Stratton
*
* Exposes the following properties:
* Value - current value of the picker
* MinValue - lowest value of the picker
* MaxValue - highest value of the picker
*
*/
public class NumberPickerBinding
extends GenericViewBinding<NumberPicker>
implements NumberPicker.Formatter, NumberPicker.OnScrollListener, NumberPicker.OnValueChangeListener
{
//expose the min, max and current value
|
// Path: traction/src/main/java/traction/mvc/implementations/ui/UIProperty.java
// public class UIProperty<T>
// implements IUIElement<T>
// {
// protected String path;
// protected T tempValue;
//
// private IUIElement.IUIUpdateListener<T> updateListener;
//
// private boolean _isUpdating;
//
// protected String pathAttribute = null;
// protected final IViewBinding parentViewBinding;
//
// @SuppressWarnings("unused")
// private UIProperty(){parentViewBinding = null;}
//
// public UIProperty(IProxyViewBinding viewBinding, String pathAttribute)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.pathAttribute = pathAttribute;
// this.parentViewBinding.registerUIElement(this);
// }
//
// public UIProperty(IProxyViewBinding viewBinding)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.parentViewBinding.registerUIElement(this);
// }
//
// /**
// * @return : true when element is currently sending an update back to the model or view-model
// */
// public boolean isUpdating()
// {
// return _isUpdating;
// }
//
// /**
// * Initiates the BindingInventory to send data to the model/view-model
// */
// public void sendUpdate(T value)
// {
// if (path == null)
// return;
//
// disableReceiveUpdates();
// getBindingInventory().sendUpdate(path, value);
// enableReceiveUpdates();
// }
//
// public T dereferenceValue()
// {
// return (T) getBindingInventory().dereferenceValue(path);
// }
//
// public T getTempValue()
// {
// return tempValue;
// }
//
// public void setTempValue(T value)
// {
// this.tempValue = value;
// }
//
// @Override
// public void setUIUpdateListener(IUIElement.IUIUpdateListener<T> listener)
// {
// this.updateListener = listener;
// }
//
// @Override
// public void receiveUpdate(final Object value)
// {
// if (updateListener == null)
// return;
//
// synchronized(this)
// {
// //is true is 'disableReceiveUpdates' has been called before 'enablRecieveUpdates'
// //This is also the case if UIProperty has called the 'sendUpdate' method
// if (isUpdating())
// return;
//
// //if no handler, then just run on current thread
// if (getUIHandler() == null)
// {
// updateListener.onUpdate((T)value);
// }
// else
// {
// //call the update listener on the UI thread. Needs to be on the UI thread because it is most
// //certainly updating something on the UI
// getUIHandler().tryPostImmediatelyToUIThread(new Runnable()
// {
// @Override
// public void run()
// {
// updateListener.onUpdate((T) value);
// }
// });
// }
// }
// }
//
// @Override
// public void initialize() throws Exception
// {
// JSONObject tagProperties =parentViewBinding.getTagProperties();
// if (tagProperties != null)
// {
// String tempPath = tagProperties.has(pathAttribute) ? tagProperties.getString(pathAttribute) : null;
//
// if (pathAttribute != null) {
// if (parentViewBinding.getPathPrefix() == null)
// path = tempPath;
// else if (tempPath != null)
// path = parentViewBinding.getPathPrefix() + "." + tempPath;
// else
// path = null;
// }
// }
// getBindingInventory().track(this, path);
// }
//
// protected void disableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = true;
// }
// }
//
// protected void enableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = false;
// }
// }
//
// @Override
// public BindingInventory getBindingInventory()
// {
// return parentViewBinding.getBindingInventory();
// }
//
// public Class<?> getDereferencedPathType()
// {
// return parentViewBinding.getBindingInventory().dereferencePropertyType(this.path);
// }
//
// @Override
// public boolean isDefined()
// {
// return path != null;
// }
//
// @Override
// public void track(BindingInventory differentBindingInventory)
// {
// if (this.path == null)
// return;
// differentBindingInventory.track(this, this.path);
// }
//
// protected UIHandler getUIHandler()
// {
// return parentViewBinding.getUIHandler();
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
// Path: traction/src/main/java/traction/mvc/implementations/ui/viewbinding/NumberPickerBinding.java
import traction.mvc.implementations.ui.UIProperty;
import traction.mvc.interfaces.IUIElement.IUIUpdateListener;
import android.widget.NumberPicker;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations.ui.viewbinding;
/**
* Defines ui elements for binding to a number picker.
* @author Tim Stratton
*
* Exposes the following properties:
* Value - current value of the picker
* MinValue - lowest value of the picker
* MaxValue - highest value of the picker
*
*/
public class NumberPickerBinding
extends GenericViewBinding<NumberPicker>
implements NumberPicker.Formatter, NumberPicker.OnScrollListener, NumberPicker.OnValueChangeListener
{
//expose the min, max and current value
|
public final UIProperty<Integer> MinValue = new UIProperty<Integer>(this,"MinValue");
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
|
import traction.mvc.implementations.CommandArgument;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.interfaces;
/**
* Defines an observable command
* @author Tim Stratton
*/
public interface IObservableCommand
extends IObservableObject
{
/**
* call to execute command
* @param arg
*/
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
import traction.mvc.implementations.CommandArgument;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.interfaces;
/**
* Defines an observable command
* @author Tim Stratton
*/
public interface IObservableCommand
extends IObservableObject
{
/**
* call to execute command
* @param arg
*/
|
void execute(CommandArgument arg);
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
|
import traction.mvc.observables.Command;
|
package ni3po42.android.tractiondemo.models;
public interface DialogModel
{
String getSomeText();
void setSomeText(String t);
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/DialogModel.java
import traction.mvc.observables.Command;
package ni3po42.android.tractiondemo.models;
public interface DialogModel
{
String getSomeText();
void setSomeText(String t);
|
Command getClose();
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/IObservable.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObjectListener.java
// public interface IObjectListener
// {
// public static class Utility
// {
// public static String generatePropagationId(String currentPropagationId, String currentSource)
// {
// if (currentSource == null || currentSource.equals(""))
// return currentPropagationId;
// else if (currentPropagationId == null || currentPropagationId.equals(""))
// return currentSource;
// else
// return currentSource + "." + currentPropagationId;
// }
// }
//
// /**
// * Fired when listener is signalled of something, anything really.
// */
// void onEvent(String propagationId);
// }
|
import traction.mvc.interfaces.IObjectListener;
|
package traction.mvc.observables;
//package visibility
interface IObservable
{
/**
* Registers a listener to the IObservable
* @param sourceName : name of source property to track changes and bubble up to inventory
*/
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObjectListener.java
// public interface IObjectListener
// {
// public static class Utility
// {
// public static String generatePropagationId(String currentPropagationId, String currentSource)
// {
// if (currentSource == null || currentSource.equals(""))
// return currentPropagationId;
// else if (currentPropagationId == null || currentPropagationId.equals(""))
// return currentSource;
// else
// return currentSource + "." + currentPropagationId;
// }
// }
//
// /**
// * Fired when listener is signalled of something, anything really.
// */
// void onEvent(String propagationId);
// }
// Path: traction/src/main/java/traction/mvc/observables/IObservable.java
import traction.mvc.interfaces.IObjectListener;
package traction.mvc.observables;
//package visibility
interface IObservable
{
/**
* Registers a listener to the IObservable
* @param sourceName : name of source property to track changes and bubble up to inventory
*/
|
void registerListener(String sourceName, IObjectListener listener);
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableMap.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.util.Property;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import traction.mvc.interfaces.IPropertyStore;
|
store.removeKey(current);
}
internalMap.putAll(map);
notifyListener();
}
@Override
public Object remove(Object key) {
Object obj = internalMap.remove(key);
store.removeKey(String.valueOf(key));
notifyListener(String.valueOf(key), obj, null);
if (obj instanceof IProxyObservableObject)
{
((IProxyObservableObject)obj).getProxyObservableObject().getObservable().unregisterListener(String.valueOf(key), getProxyObservableObject());
}
return obj;
}
@Override
public int size() {
return internalMap.size();
}
@Override
public Collection<Object> values() {
return internalMap.values();
}
@Override
|
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableMap.java
import android.util.Property;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import traction.mvc.interfaces.IPropertyStore;
store.removeKey(current);
}
internalMap.putAll(map);
notifyListener();
}
@Override
public Object remove(Object key) {
Object obj = internalMap.remove(key);
store.removeKey(String.valueOf(key));
notifyListener(String.valueOf(key), obj, null);
if (obj instanceof IProxyObservableObject)
{
((IProxyObservableObject)obj).getProxyObservableObject().getObservable().unregisterListener(String.valueOf(key), getProxyObservableObject());
}
return obj;
}
@Override
public int size() {
return internalMap.size();
}
@Override
public Collection<Object> values() {
return internalMap.values();
}
@Override
|
protected IPropertyStore getPropertyStore()
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableList.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableList.java
// public interface IObservableList<T>
// extends IProxyObservableObject, List<T>
// {
// /**
// * A read-only property 'Count'. Should return the number of elements in the list
// * @return size of list
// */
// public int getCount();
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import traction.mvc.interfaces.IObservableList;
import traction.mvc.interfaces.IPropertyStore;
import android.util.Property;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* A concrete class of IObservableList. This allows a list to be a container of this oberservable list
* @author Tim Stratton
*
* @param <T> : item type of list
*/
public class ObservableList<T>
extends ListAdapter
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableList.java
// public interface IObservableList<T>
// extends IProxyObservableObject, List<T>
// {
// /**
// * A read-only property 'Count'. Should return the number of elements in the list
// * @return size of list
// */
// public int getCount();
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableList.java
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import traction.mvc.interfaces.IObservableList;
import traction.mvc.interfaces.IPropertyStore;
import android.util.Property;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* A concrete class of IObservableList. This allows a list to be a container of this oberservable list
* @author Tim Stratton
*
* @param <T> : item type of list
*/
public class ObservableList<T>
extends ListAdapter
|
implements IObservableList<T>
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableList.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableList.java
// public interface IObservableList<T>
// extends IProxyObservableObject, List<T>
// {
// /**
// * A read-only property 'Count'. Should return the number of elements in the list
// * @return size of list
// */
// public int getCount();
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import traction.mvc.interfaces.IObservableList;
import traction.mvc.interfaces.IPropertyStore;
import android.util.Property;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* A concrete class of IObservableList. This allows a list to be a container of this oberservable list
* @author Tim Stratton
*
* @param <T> : item type of list
*/
public class ObservableList<T>
extends ListAdapter
implements IObservableList<T>
{
//internal list to store
protected List<T> internalImp;
private ObservableObject proxy = new ObservableObject() {
@Override
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableList.java
// public interface IObservableList<T>
// extends IProxyObservableObject, List<T>
// {
// /**
// * A read-only property 'Count'. Should return the number of elements in the list
// * @return size of list
// */
// public int getCount();
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableList.java
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import traction.mvc.interfaces.IObservableList;
import traction.mvc.interfaces.IPropertyStore;
import android.util.Property;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* A concrete class of IObservableList. This allows a list to be a container of this oberservable list
* @author Tim Stratton
*
* @param <T> : item type of list
*/
public class ObservableList<T>
extends ListAdapter
implements IObservableList<T>
{
//internal list to store
protected List<T> internalImp;
private ObservableObject proxy = new ObservableObject() {
@Override
|
protected IPropertyStore getPropertyStore() {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MultiSelectController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IMultiSelectionModel.java
// public interface IMultiSelectionModel
// extends IProxyObservableObject
// {
// List<SelectableItem> getItems();
//
// void setSelected(SelectableItem i);
// SelectableItem getSelected();
//
// int getSelectedCount();
// void setSelectedCount(int i);
//
// Command getCountSelected();
//
// String getMyString();
// void setMyString(String myString);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/SelectableItem.java
// public class SelectableItem extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(SelectableItem.class);
//
// private boolean selected;
//
// public boolean isSelected()
// {
// return selected;
// }
//
// public void setSelected(boolean b)
// {
// if (b != selected)
// {
// notifyListener("Selected", selected, selected = b);
// }
// }
//
// public int getImage()
// {
// return R.drawable.ic_launcher;
// }
//
// @Override
// public PropertyStore getPropertyStore()
// {
// return store;
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IMultiSelectionModel;
import ni3po42.android.tractiondemo.models.SelectableItem;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class MultiSelectController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.multiselection);
View.setMenuLayout(R.menu.multiselectoptions);
}
@Override
public void onStart()
{
super.onStart();
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IMultiSelectionModel.java
// public interface IMultiSelectionModel
// extends IProxyObservableObject
// {
// List<SelectableItem> getItems();
//
// void setSelected(SelectableItem i);
// SelectableItem getSelected();
//
// int getSelectedCount();
// void setSelectedCount(int i);
//
// Command getCountSelected();
//
// String getMyString();
// void setMyString(String myString);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/SelectableItem.java
// public class SelectableItem extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(SelectableItem.class);
//
// private boolean selected;
//
// public boolean isSelected()
// {
// return selected;
// }
//
// public void setSelected(boolean b)
// {
// if (b != selected)
// {
// notifyListener("Selected", selected, selected = b);
// }
// }
//
// public int getImage()
// {
// return R.drawable.ic_launcher;
// }
//
// @Override
// public PropertyStore getPropertyStore()
// {
// return store;
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MultiSelectController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IMultiSelectionModel;
import ni3po42.android.tractiondemo.models.SelectableItem;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class MultiSelectController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.multiselection);
View.setMenuLayout(R.menu.multiselectoptions);
}
@Override
public void onStart()
{
super.onStart();
|
final IMultiSelectionModel model = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MultiSelectController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IMultiSelectionModel.java
// public interface IMultiSelectionModel
// extends IProxyObservableObject
// {
// List<SelectableItem> getItems();
//
// void setSelected(SelectableItem i);
// SelectableItem getSelected();
//
// int getSelectedCount();
// void setSelectedCount(int i);
//
// Command getCountSelected();
//
// String getMyString();
// void setMyString(String myString);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/SelectableItem.java
// public class SelectableItem extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(SelectableItem.class);
//
// private boolean selected;
//
// public boolean isSelected()
// {
// return selected;
// }
//
// public void setSelected(boolean b)
// {
// if (b != selected)
// {
// notifyListener("Selected", selected, selected = b);
// }
// }
//
// public int getImage()
// {
// return R.drawable.ic_launcher;
// }
//
// @Override
// public PropertyStore getPropertyStore()
// {
// return store;
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IMultiSelectionModel;
import ni3po42.android.tractiondemo.models.SelectableItem;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class MultiSelectController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.multiselection);
View.setMenuLayout(R.menu.multiselectoptions);
}
@Override
public void onStart()
{
super.onStart();
final IMultiSelectionModel model = View.getScope();
model.getItems().clear();
for(int i=0;i<12;i++)
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IMultiSelectionModel.java
// public interface IMultiSelectionModel
// extends IProxyObservableObject
// {
// List<SelectableItem> getItems();
//
// void setSelected(SelectableItem i);
// SelectableItem getSelected();
//
// int getSelectedCount();
// void setSelectedCount(int i);
//
// Command getCountSelected();
//
// String getMyString();
// void setMyString(String myString);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/SelectableItem.java
// public class SelectableItem extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(SelectableItem.class);
//
// private boolean selected;
//
// public boolean isSelected()
// {
// return selected;
// }
//
// public void setSelected(boolean b)
// {
// if (b != selected)
// {
// notifyListener("Selected", selected, selected = b);
// }
// }
//
// public int getImage()
// {
// return R.drawable.ic_launcher;
// }
//
// @Override
// public PropertyStore getPropertyStore()
// {
// return store;
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MultiSelectController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IMultiSelectionModel;
import ni3po42.android.tractiondemo.models.SelectableItem;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class MultiSelectController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.multiselection);
View.setMenuLayout(R.menu.multiselectoptions);
}
@Override
public void onStart()
{
super.onStart();
final IMultiSelectionModel model = View.getScope();
model.getItems().clear();
for(int i=0;i<12;i++)
|
model.getItems().add(new SelectableItem());
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MultiSelectController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IMultiSelectionModel.java
// public interface IMultiSelectionModel
// extends IProxyObservableObject
// {
// List<SelectableItem> getItems();
//
// void setSelected(SelectableItem i);
// SelectableItem getSelected();
//
// int getSelectedCount();
// void setSelectedCount(int i);
//
// Command getCountSelected();
//
// String getMyString();
// void setMyString(String myString);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/SelectableItem.java
// public class SelectableItem extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(SelectableItem.class);
//
// private boolean selected;
//
// public boolean isSelected()
// {
// return selected;
// }
//
// public void setSelected(boolean b)
// {
// if (b != selected)
// {
// notifyListener("Selected", selected, selected = b);
// }
// }
//
// public int getImage()
// {
// return R.drawable.ic_launcher;
// }
//
// @Override
// public PropertyStore getPropertyStore()
// {
// return store;
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IMultiSelectionModel;
import ni3po42.android.tractiondemo.models.SelectableItem;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class MultiSelectController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.multiselection);
View.setMenuLayout(R.menu.multiselectoptions);
}
@Override
public void onStart()
{
super.onStart();
final IMultiSelectionModel model = View.getScope();
model.getItems().clear();
for(int i=0;i<12;i++)
model.getItems().add(new SelectableItem());
model.setSelectedCount(0);
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IMultiSelectionModel.java
// public interface IMultiSelectionModel
// extends IProxyObservableObject
// {
// List<SelectableItem> getItems();
//
// void setSelected(SelectableItem i);
// SelectableItem getSelected();
//
// int getSelectedCount();
// void setSelectedCount(int i);
//
// Command getCountSelected();
//
// String getMyString();
// void setMyString(String myString);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/SelectableItem.java
// public class SelectableItem extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(SelectableItem.class);
//
// private boolean selected;
//
// public boolean isSelected()
// {
// return selected;
// }
//
// public void setSelected(boolean b)
// {
// if (b != selected)
// {
// notifyListener("Selected", selected, selected = b);
// }
// }
//
// public int getImage()
// {
// return R.drawable.ic_launcher;
// }
//
// @Override
// public PropertyStore getPropertyStore()
// {
// return store;
// }
//
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/MultiSelectController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IMultiSelectionModel;
import ni3po42.android.tractiondemo.models.SelectableItem;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class MultiSelectController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.multiselection);
View.setMenuLayout(R.menu.multiselectoptions);
}
@Override
public void onStart()
{
super.onStart();
final IMultiSelectionModel model = View.getScope();
model.getItems().clear();
for(int i=0;i<12;i++)
model.getItems().add(new SelectableItem());
model.setSelectedCount(0);
|
model.getCountSelected().setExecuteListener(new IOnExecuteListener() {
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/Command.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* class representing a Command. It exposes a property that can be used to determine if
* the command can execute and gives a handle to override to perform functions when the command has been invoked
* @author Tim Stratton
*/
public class Command
extends ObservableObject
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/Command.java
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* class representing a Command. It exposes a property that can be used to determine if
* the command can execute and gives a handle to override to perform functions when the command has been invoked
* @author Tim Stratton
*/
public class Command
extends ObservableObject
|
implements IObservableCommand
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/Command.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* class representing a Command. It exposes a property that can be used to determine if
* the command can execute and gives a handle to override to perform functions when the command has been invoked
* @author Tim Stratton
*/
public class Command
extends ObservableObject
implements IObservableCommand
{
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/Command.java
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* class representing a Command. It exposes a property that can be used to determine if
* the command can execute and gives a handle to override to perform functions when the command has been invoked
* @author Tim Stratton
*/
public class Command
extends ObservableObject
implements IObservableCommand
{
|
private IOnExecuteListener executeListener;
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/Command.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* class representing a Command. It exposes a property that can be used to determine if
* the command can execute and gives a handle to override to perform functions when the command has been invoked
* @author Tim Stratton
*/
public class Command
extends ObservableObject
implements IObservableCommand
{
private IOnExecuteListener executeListener;
public Command()
{
setCanExecute(true);
}
public Command(boolean initCanExecute)
{
setCanExecute(initCanExecute);
}
public void setExecuteListener(IOnExecuteListener listener)
{
executeListener = listener;
}
private boolean canExecute;
@Override
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/Command.java
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* class representing a Command. It exposes a property that can be used to determine if
* the command can execute and gives a handle to override to perform functions when the command has been invoked
* @author Tim Stratton
*/
public class Command
extends ObservableObject
implements IObservableCommand
{
private IOnExecuteListener executeListener;
public Command()
{
setCanExecute(true);
}
public Command(boolean initCanExecute)
{
setCanExecute(initCanExecute);
}
public void setExecuteListener(IOnExecuteListener listener)
{
executeListener = listener;
}
private boolean canExecute;
@Override
|
protected IPropertyStore getPropertyStore()
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/Command.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
|
@SuppressWarnings("unchecked")
@Override
public Property<Object, Object> getProperty(String name)
{
Class<?> c = boolean.class;
//The only supported property on a command will be 'CanExecute', for now...
if (name.equals("CanExecute") && getSource() != null)
return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
return null;
}
@Override
public boolean getCanExecute()
{
return canExecute;
}
@Override
public void setCanExecute(boolean b)
{
if (canExecute == b)
return;
notifyListener("CanExecute", canExecute, canExecute = b);
}
/**
* Is fired when execute(TArg) is called and CanExecute() is true
* @param arg : argument passed to execute method. Could very well be null.
*/
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/Command.java
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IOnExecuteListener;
import traction.mvc.interfaces.IPropertyStore;
@SuppressWarnings("unchecked")
@Override
public Property<Object, Object> getProperty(String name)
{
Class<?> c = boolean.class;
//The only supported property on a command will be 'CanExecute', for now...
if (name.equals("CanExecute") && getSource() != null)
return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
return null;
}
@Override
public boolean getCanExecute()
{
return canExecute;
}
@Override
public void setCanExecute(boolean b)
{
if (canExecute == b)
return;
notifyListener("CanExecute", canExecute, canExecute = b);
}
/**
* Is fired when execute(TArg) is called and CanExecute() is true
* @param arg : argument passed to execute method. Could very well be null.
*/
|
protected void onExecuted(CommandArgument arg)
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/implementations/PathBinding.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import java.util.ArrayList;
import traction.mvc.interfaces.IUIElement;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations;
/**
* Object to hold list of ui elements for the binding inventory
* @author Tim Stratton
*
*/
public class PathBinding
{
|
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
import java.util.ArrayList;
import traction.mvc.interfaces.IUIElement;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations;
/**
* Object to hold list of ui elements for the binding inventory
* @author Tim Stratton
*
*/
public class PathBinding
{
|
private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
|
final IUIWireModel model = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
final IUIWireModel model = View.getScope();
model.setMyString("MainFlag is " + (model.isMainFlagOn() ? "on" : "off"));
model.setLargest(20);
model.setSmallest(0);
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
final IUIWireModel model = View.getScope();
model.setMyString("MainFlag is " + (model.isMainFlagOn() ? "on" : "off"));
model.setLargest(20);
model.setSmallest(0);
|
model.getMyEvent().setExecuteListener(new IOnExecuteListener() {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
final IUIWireModel model = View.getScope();
model.setMyString("MainFlag is " + (model.isMainFlagOn() ? "on" : "off"));
model.setLargest(20);
model.setSmallest(0);
model.getMyEvent().setExecuteListener(new IOnExecuteListener() {
@Override
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
final IUIWireModel model = View.getScope();
model.setMyString("MainFlag is " + (model.isMainFlagOn() ? "on" : "off"));
model.setLargest(20);
model.setSmallest(0);
model.getMyEvent().setExecuteListener(new IOnExecuteListener() {
@Override
|
public void onExecuted(CommandArgument argument) {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
|
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
final IUIWireModel model = View.getScope();
model.setMyString("MainFlag is " + (model.isMainFlagOn() ? "on" : "off"));
model.setLargest(20);
model.setSmallest(0);
model.getMyEvent().setExecuteListener(new IOnExecuteListener() {
@Override
public void onExecuted(CommandArgument argument) {
Toast toast = View.createBindableToast(R.layout.customtoast);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}
});
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUIWireModel.java
// public interface IUIWireModel
// extends IProxyObservableObject
// {
// int getImage();
// void setImage(int image);
//
// boolean isMainFlagOn();
// void setMainFlagOn(boolean mainFlag);
//
// int getUpperBound();
// void setUpperBound(int upperBound);
//
// int getCurrentInteger();
// void setCurrentInteger(int currentInteger);
//
// Command getMyEvent();
//
// String getMyString();
// void setMyString(String str);
//
// int getMyInt();
// void setMyInt(int myInt);
//
// int getSmallest();
// void setSmallest(int i);
//
// int getLargest();
// void setLargest(int i);
// }
//
// Path: traction/src/main/java/traction/mvc/observables/OnPropertyChangedEvent.java
// public abstract class OnPropertyChangedEvent
// implements IObjectListener
// {
// @Override
// public void onEvent(String propagationId) {
// //eh, nothing
// }
//
// protected abstract void onChange(String propertyName, Object oldValue, Object newValue);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/UIWiringController.java
import android.os.Bundle;
import android.widget.Toast;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUIWireModel;
import traction.mvc.observables.OnPropertyChangedEvent;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class UIWiringController extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.uiwiring);
}
@Override
public void onStart()
{
super.onStart();
final IUIWireModel model = View.getScope();
model.setMyString("MainFlag is " + (model.isMainFlagOn() ? "on" : "off"));
model.setLargest(20);
model.setSmallest(0);
model.getMyEvent().setExecuteListener(new IOnExecuteListener() {
@Override
public void onExecuted(CommandArgument argument) {
Toast toast = View.createBindableToast(R.layout.customtoast);
toast.setDuration(Toast.LENGTH_LONG);
toast.show();
}
});
|
model.getProxyObservableObject().addOnChange(new OnPropertyChangedEvent() {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
|
import traction.mvc.observables.Command;
|
package ni3po42.android.tractiondemo.models;
public interface ICalculatorModel
{
String getDisplay();
void setDisplay(String str);
|
// Path: traction/src/main/java/traction/mvc/observables/Command.java
// public class Command
// extends ObservableObject
// implements IObservableCommand
// {
// private IOnExecuteListener executeListener;
//
// public Command()
// {
// setCanExecute(true);
// }
//
// public Command(boolean initCanExecute)
// {
// setCanExecute(initCanExecute);
// }
//
// public void setExecuteListener(IOnExecuteListener listener)
// {
// executeListener = listener;
// }
//
// private boolean canExecute;
//
// @Override
// protected IPropertyStore getPropertyStore()
// {
// //getProperty was overridden, this is not used.
// return null;
// }
//
// @SuppressWarnings("unchecked")
// @Override
// public Property<Object, Object> getProperty(String name)
// {
// Class<?> c = boolean.class;
// //The only supported property on a command will be 'CanExecute', for now...
// if (name.equals("CanExecute") && getSource() != null)
// return (Property<Object, Object>) Property.of(getSource().getClass(), c, name);
// return null;
// }
//
// @Override
// public boolean getCanExecute()
// {
// return canExecute;
// }
//
// @Override
// public void setCanExecute(boolean b)
// {
// if (canExecute == b)
// return;
// notifyListener("CanExecute", canExecute, canExecute = b);
// }
//
// /**
// * Is fired when execute(TArg) is called and CanExecute() is true
// * @param arg : argument passed to execute method. Could very well be null.
// */
// protected void onExecuted(CommandArgument arg)
// {
// if (executeListener != null)
// executeListener.onExecuted(arg);
// }
//
// @Override
// public void execute(CommandArgument arg)
// {
// if (!getCanExecute())
// return;
//
// onExecuted(arg);
// }
//
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
import traction.mvc.observables.Command;
package ni3po42.android.tractiondemo.models;
public interface ICalculatorModel
{
String getDisplay();
void setDisplay(String str);
|
Command getNumberUpdate();
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
|
import traction.mvc.implementations.CommandArgument;
|
package traction.mvc.interfaces;
public interface IOnExecuteListener
{
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
import traction.mvc.implementations.CommandArgument;
package traction.mvc.interfaces;
public interface IOnExecuteListener
{
|
void onExecuted(CommandArgument arg);
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/implementations/ui/viewbinding/ProgressBarBinding.java
|
// Path: traction/src/main/java/traction/mvc/implementations/ui/UIProperty.java
// public class UIProperty<T>
// implements IUIElement<T>
// {
// protected String path;
// protected T tempValue;
//
// private IUIElement.IUIUpdateListener<T> updateListener;
//
// private boolean _isUpdating;
//
// protected String pathAttribute = null;
// protected final IViewBinding parentViewBinding;
//
// @SuppressWarnings("unused")
// private UIProperty(){parentViewBinding = null;}
//
// public UIProperty(IProxyViewBinding viewBinding, String pathAttribute)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.pathAttribute = pathAttribute;
// this.parentViewBinding.registerUIElement(this);
// }
//
// public UIProperty(IProxyViewBinding viewBinding)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.parentViewBinding.registerUIElement(this);
// }
//
// /**
// * @return : true when element is currently sending an update back to the model or view-model
// */
// public boolean isUpdating()
// {
// return _isUpdating;
// }
//
// /**
// * Initiates the BindingInventory to send data to the model/view-model
// */
// public void sendUpdate(T value)
// {
// if (path == null)
// return;
//
// disableReceiveUpdates();
// getBindingInventory().sendUpdate(path, value);
// enableReceiveUpdates();
// }
//
// public T dereferenceValue()
// {
// return (T) getBindingInventory().dereferenceValue(path);
// }
//
// public T getTempValue()
// {
// return tempValue;
// }
//
// public void setTempValue(T value)
// {
// this.tempValue = value;
// }
//
// @Override
// public void setUIUpdateListener(IUIElement.IUIUpdateListener<T> listener)
// {
// this.updateListener = listener;
// }
//
// @Override
// public void receiveUpdate(final Object value)
// {
// if (updateListener == null)
// return;
//
// synchronized(this)
// {
// //is true is 'disableReceiveUpdates' has been called before 'enablRecieveUpdates'
// //This is also the case if UIProperty has called the 'sendUpdate' method
// if (isUpdating())
// return;
//
// //if no handler, then just run on current thread
// if (getUIHandler() == null)
// {
// updateListener.onUpdate((T)value);
// }
// else
// {
// //call the update listener on the UI thread. Needs to be on the UI thread because it is most
// //certainly updating something on the UI
// getUIHandler().tryPostImmediatelyToUIThread(new Runnable()
// {
// @Override
// public void run()
// {
// updateListener.onUpdate((T) value);
// }
// });
// }
// }
// }
//
// @Override
// public void initialize() throws Exception
// {
// JSONObject tagProperties =parentViewBinding.getTagProperties();
// if (tagProperties != null)
// {
// String tempPath = tagProperties.has(pathAttribute) ? tagProperties.getString(pathAttribute) : null;
//
// if (pathAttribute != null) {
// if (parentViewBinding.getPathPrefix() == null)
// path = tempPath;
// else if (tempPath != null)
// path = parentViewBinding.getPathPrefix() + "." + tempPath;
// else
// path = null;
// }
// }
// getBindingInventory().track(this, path);
// }
//
// protected void disableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = true;
// }
// }
//
// protected void enableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = false;
// }
// }
//
// @Override
// public BindingInventory getBindingInventory()
// {
// return parentViewBinding.getBindingInventory();
// }
//
// public Class<?> getDereferencedPathType()
// {
// return parentViewBinding.getBindingInventory().dereferencePropertyType(this.path);
// }
//
// @Override
// public boolean isDefined()
// {
// return path != null;
// }
//
// @Override
// public void track(BindingInventory differentBindingInventory)
// {
// if (this.path == null)
// return;
// differentBindingInventory.track(this, this.path);
// }
//
// protected UIHandler getUIHandler()
// {
// return parentViewBinding.getUIHandler();
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
|
import traction.mvc.implementations.ui.UIProperty;
import traction.mvc.interfaces.IUIElement.IUIUpdateListener;
import android.widget.ProgressBar;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations.ui.viewbinding;
/**
* Defines the ui elements for a progress bar
* @author Tim Stratton
*
* Exposes the following properties:
* Value - current value of the progess bar
* MaxValue - the largets such values (defaults to 100)
* IsIndeterminate - sets progress bar as indeterminate or not
*
*/
public class ProgressBarBinding
extends GenericViewBinding<ProgressBar>
{
|
// Path: traction/src/main/java/traction/mvc/implementations/ui/UIProperty.java
// public class UIProperty<T>
// implements IUIElement<T>
// {
// protected String path;
// protected T tempValue;
//
// private IUIElement.IUIUpdateListener<T> updateListener;
//
// private boolean _isUpdating;
//
// protected String pathAttribute = null;
// protected final IViewBinding parentViewBinding;
//
// @SuppressWarnings("unused")
// private UIProperty(){parentViewBinding = null;}
//
// public UIProperty(IProxyViewBinding viewBinding, String pathAttribute)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.pathAttribute = pathAttribute;
// this.parentViewBinding.registerUIElement(this);
// }
//
// public UIProperty(IProxyViewBinding viewBinding)
// {
// this.parentViewBinding = viewBinding.getProxyViewBinding();
// this.parentViewBinding.registerUIElement(this);
// }
//
// /**
// * @return : true when element is currently sending an update back to the model or view-model
// */
// public boolean isUpdating()
// {
// return _isUpdating;
// }
//
// /**
// * Initiates the BindingInventory to send data to the model/view-model
// */
// public void sendUpdate(T value)
// {
// if (path == null)
// return;
//
// disableReceiveUpdates();
// getBindingInventory().sendUpdate(path, value);
// enableReceiveUpdates();
// }
//
// public T dereferenceValue()
// {
// return (T) getBindingInventory().dereferenceValue(path);
// }
//
// public T getTempValue()
// {
// return tempValue;
// }
//
// public void setTempValue(T value)
// {
// this.tempValue = value;
// }
//
// @Override
// public void setUIUpdateListener(IUIElement.IUIUpdateListener<T> listener)
// {
// this.updateListener = listener;
// }
//
// @Override
// public void receiveUpdate(final Object value)
// {
// if (updateListener == null)
// return;
//
// synchronized(this)
// {
// //is true is 'disableReceiveUpdates' has been called before 'enablRecieveUpdates'
// //This is also the case if UIProperty has called the 'sendUpdate' method
// if (isUpdating())
// return;
//
// //if no handler, then just run on current thread
// if (getUIHandler() == null)
// {
// updateListener.onUpdate((T)value);
// }
// else
// {
// //call the update listener on the UI thread. Needs to be on the UI thread because it is most
// //certainly updating something on the UI
// getUIHandler().tryPostImmediatelyToUIThread(new Runnable()
// {
// @Override
// public void run()
// {
// updateListener.onUpdate((T) value);
// }
// });
// }
// }
// }
//
// @Override
// public void initialize() throws Exception
// {
// JSONObject tagProperties =parentViewBinding.getTagProperties();
// if (tagProperties != null)
// {
// String tempPath = tagProperties.has(pathAttribute) ? tagProperties.getString(pathAttribute) : null;
//
// if (pathAttribute != null) {
// if (parentViewBinding.getPathPrefix() == null)
// path = tempPath;
// else if (tempPath != null)
// path = parentViewBinding.getPathPrefix() + "." + tempPath;
// else
// path = null;
// }
// }
// getBindingInventory().track(this, path);
// }
//
// protected void disableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = true;
// }
// }
//
// protected void enableReceiveUpdates()
// {
// synchronized(this)
// {
// _isUpdating = false;
// }
// }
//
// @Override
// public BindingInventory getBindingInventory()
// {
// return parentViewBinding.getBindingInventory();
// }
//
// public Class<?> getDereferencedPathType()
// {
// return parentViewBinding.getBindingInventory().dereferencePropertyType(this.path);
// }
//
// @Override
// public boolean isDefined()
// {
// return path != null;
// }
//
// @Override
// public void track(BindingInventory differentBindingInventory)
// {
// if (this.path == null)
// return;
// differentBindingInventory.track(this, this.path);
// }
//
// protected UIHandler getUIHandler()
// {
// return parentViewBinding.getUIHandler();
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
// Path: traction/src/main/java/traction/mvc/implementations/ui/viewbinding/ProgressBarBinding.java
import traction.mvc.implementations.ui.UIProperty;
import traction.mvc.interfaces.IUIElement.IUIUpdateListener;
import android.widget.ProgressBar;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.implementations.ui.viewbinding;
/**
* Defines the ui elements for a progress bar
* @author Tim Stratton
*
* Exposes the following properties:
* Value - current value of the progess bar
* MaxValue - the largets such values (defaults to 100)
* IsIndeterminate - sets progress bar as indeterminate or not
*
*/
public class ProgressBarBinding
extends GenericViewBinding<ProgressBar>
{
|
public final UIProperty<Integer> MaxValue = new UIProperty<Integer>(this, "MaxValue");
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/SimpleFormController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
// public interface IUserInfo
// {
// public static class Gender
// {
// private static Gender male = new Gender("Male");
// private static Gender female = new Gender("Female");
//
// public static Gender getMale()
// { return male;}
//
// public static Gender getFemale()
// { return female;}
//
// public static Gender getGender(String type)
// {
// if (type.toLowerCase().equals("male"))
// return getMale();
// else
// return getFemale();
// }
//
// private Gender(String t)
// {
// type = t;
// }
//
// private String type;
// @Override
// public String toString()
// {
// return type;
// }
//
// public String getType()
// {
// return type;
// }
// }
//
// List<Gender> getGenders();
//
// Gender getUserGender();
// void setUserGender(Gender gender);
//
// String getFirstName();
// void setFirstName(String firstName);
//
// String getLastName();
// void setLastName(String lastName);
//
// Time getDateOfBirth();
// void setDateOfBirth(Time dateOfBirth);
//
// Command getSave();
// Command getCancel();
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.format.Time;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUserInfo;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class SimpleFormController extends FragmentController
{
private static String prefName = "ni3po42.android.tractiondemo.userinfo";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.userinfo);
}
@Override
public void onStart()
{
super.onStart();
SharedPreferences preference = getActivity().getSharedPreferences(prefName, Context.MODE_PRIVATE);
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
// public interface IUserInfo
// {
// public static class Gender
// {
// private static Gender male = new Gender("Male");
// private static Gender female = new Gender("Female");
//
// public static Gender getMale()
// { return male;}
//
// public static Gender getFemale()
// { return female;}
//
// public static Gender getGender(String type)
// {
// if (type.toLowerCase().equals("male"))
// return getMale();
// else
// return getFemale();
// }
//
// private Gender(String t)
// {
// type = t;
// }
//
// private String type;
// @Override
// public String toString()
// {
// return type;
// }
//
// public String getType()
// {
// return type;
// }
// }
//
// List<Gender> getGenders();
//
// Gender getUserGender();
// void setUserGender(Gender gender);
//
// String getFirstName();
// void setFirstName(String firstName);
//
// String getLastName();
// void setLastName(String lastName);
//
// Time getDateOfBirth();
// void setDateOfBirth(Time dateOfBirth);
//
// Command getSave();
// Command getCancel();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/SimpleFormController.java
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.format.Time;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUserInfo;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class SimpleFormController extends FragmentController
{
private static String prefName = "ni3po42.android.tractiondemo.userinfo";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.userinfo);
}
@Override
public void onStart()
{
super.onStart();
SharedPreferences preference = getActivity().getSharedPreferences(prefName, Context.MODE_PRIVATE);
|
final IUserInfo userInfo = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/SimpleFormController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
// public interface IUserInfo
// {
// public static class Gender
// {
// private static Gender male = new Gender("Male");
// private static Gender female = new Gender("Female");
//
// public static Gender getMale()
// { return male;}
//
// public static Gender getFemale()
// { return female;}
//
// public static Gender getGender(String type)
// {
// if (type.toLowerCase().equals("male"))
// return getMale();
// else
// return getFemale();
// }
//
// private Gender(String t)
// {
// type = t;
// }
//
// private String type;
// @Override
// public String toString()
// {
// return type;
// }
//
// public String getType()
// {
// return type;
// }
// }
//
// List<Gender> getGenders();
//
// Gender getUserGender();
// void setUserGender(Gender gender);
//
// String getFirstName();
// void setFirstName(String firstName);
//
// String getLastName();
// void setLastName(String lastName);
//
// Time getDateOfBirth();
// void setDateOfBirth(Time dateOfBirth);
//
// Command getSave();
// Command getCancel();
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.format.Time;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUserInfo;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class SimpleFormController extends FragmentController
{
private static String prefName = "ni3po42.android.tractiondemo.userinfo";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.userinfo);
}
@Override
public void onStart()
{
super.onStart();
SharedPreferences preference = getActivity().getSharedPreferences(prefName, Context.MODE_PRIVATE);
final IUserInfo userInfo = View.getScope();
userInfo.getGenders().clear();
userInfo.getGenders().add(IUserInfo.Gender.getMale());
userInfo.getGenders().add(IUserInfo.Gender.getFemale());
retrieveUserInfo(userInfo, preference);
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
// public interface IUserInfo
// {
// public static class Gender
// {
// private static Gender male = new Gender("Male");
// private static Gender female = new Gender("Female");
//
// public static Gender getMale()
// { return male;}
//
// public static Gender getFemale()
// { return female;}
//
// public static Gender getGender(String type)
// {
// if (type.toLowerCase().equals("male"))
// return getMale();
// else
// return getFemale();
// }
//
// private Gender(String t)
// {
// type = t;
// }
//
// private String type;
// @Override
// public String toString()
// {
// return type;
// }
//
// public String getType()
// {
// return type;
// }
// }
//
// List<Gender> getGenders();
//
// Gender getUserGender();
// void setUserGender(Gender gender);
//
// String getFirstName();
// void setFirstName(String firstName);
//
// String getLastName();
// void setLastName(String lastName);
//
// Time getDateOfBirth();
// void setDateOfBirth(Time dateOfBirth);
//
// Command getSave();
// Command getCancel();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/SimpleFormController.java
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.format.Time;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUserInfo;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class SimpleFormController extends FragmentController
{
private static String prefName = "ni3po42.android.tractiondemo.userinfo";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.userinfo);
}
@Override
public void onStart()
{
super.onStart();
SharedPreferences preference = getActivity().getSharedPreferences(prefName, Context.MODE_PRIVATE);
final IUserInfo userInfo = View.getScope();
userInfo.getGenders().clear();
userInfo.getGenders().add(IUserInfo.Gender.getMale());
userInfo.getGenders().add(IUserInfo.Gender.getFemale());
retrieveUserInfo(userInfo, preference);
|
userInfo.getSave().setExecuteListener(new IOnExecuteListener() {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/SimpleFormController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
// public interface IUserInfo
// {
// public static class Gender
// {
// private static Gender male = new Gender("Male");
// private static Gender female = new Gender("Female");
//
// public static Gender getMale()
// { return male;}
//
// public static Gender getFemale()
// { return female;}
//
// public static Gender getGender(String type)
// {
// if (type.toLowerCase().equals("male"))
// return getMale();
// else
// return getFemale();
// }
//
// private Gender(String t)
// {
// type = t;
// }
//
// private String type;
// @Override
// public String toString()
// {
// return type;
// }
//
// public String getType()
// {
// return type;
// }
// }
//
// List<Gender> getGenders();
//
// Gender getUserGender();
// void setUserGender(Gender gender);
//
// String getFirstName();
// void setFirstName(String firstName);
//
// String getLastName();
// void setLastName(String lastName);
//
// Time getDateOfBirth();
// void setDateOfBirth(Time dateOfBirth);
//
// Command getSave();
// Command getCancel();
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.format.Time;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUserInfo;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class SimpleFormController extends FragmentController
{
private static String prefName = "ni3po42.android.tractiondemo.userinfo";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.userinfo);
}
@Override
public void onStart()
{
super.onStart();
SharedPreferences preference = getActivity().getSharedPreferences(prefName, Context.MODE_PRIVATE);
final IUserInfo userInfo = View.getScope();
userInfo.getGenders().clear();
userInfo.getGenders().add(IUserInfo.Gender.getMale());
userInfo.getGenders().add(IUserInfo.Gender.getFemale());
retrieveUserInfo(userInfo, preference);
userInfo.getSave().setExecuteListener(new IOnExecuteListener() {
@Override
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IUserInfo.java
// public interface IUserInfo
// {
// public static class Gender
// {
// private static Gender male = new Gender("Male");
// private static Gender female = new Gender("Female");
//
// public static Gender getMale()
// { return male;}
//
// public static Gender getFemale()
// { return female;}
//
// public static Gender getGender(String type)
// {
// if (type.toLowerCase().equals("male"))
// return getMale();
// else
// return getFemale();
// }
//
// private Gender(String t)
// {
// type = t;
// }
//
// private String type;
// @Override
// public String toString()
// {
// return type;
// }
//
// public String getType()
// {
// return type;
// }
// }
//
// List<Gender> getGenders();
//
// Gender getUserGender();
// void setUserGender(Gender gender);
//
// String getFirstName();
// void setFirstName(String firstName);
//
// String getLastName();
// void setLastName(String lastName);
//
// Time getDateOfBirth();
// void setDateOfBirth(Time dateOfBirth);
//
// Command getSave();
// Command getCancel();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/SimpleFormController.java
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.text.format.Time;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IUserInfo;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class SimpleFormController extends FragmentController
{
private static String prefName = "ni3po42.android.tractiondemo.userinfo";
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.userinfo);
}
@Override
public void onStart()
{
super.onStart();
SharedPreferences preference = getActivity().getSharedPreferences(prefName, Context.MODE_PRIVATE);
final IUserInfo userInfo = View.getScope();
userInfo.getGenders().clear();
userInfo.getGenders().add(IUserInfo.Gender.getMale());
userInfo.getGenders().add(IUserInfo.Gender.getFemale());
retrieveUserInfo(userInfo, preference);
userInfo.getSave().setExecuteListener(new IOnExecuteListener() {
@Override
|
public void onExecuted(CommandArgument argument) {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/EntryController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/EntryItem.java
// public class EntryItem
// extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(EntryItem.class);
//
// @Override
// protected PropertyStore getPropertyStore()
// {
// return store;
// }
//
// public EntryItem(int id, String content, boolean active)
// {
// this.id = id;
// this.content = content;
// this.active = active;
// }
//
// private String content;
// private int id;
// private boolean active;
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// notifyListener("Id", this.id, this.id = id);
// }
//
// public String getContent()
// {
// return content;
// }
//
// public void setContent(String content)
// {
// notifyListener("Content", this.content, this.content = content);
// }
//
// public boolean isActive()
// {
// return active;
// }
//
// public void setActive(boolean active)
// {
// notifyListener("Active", this.active, this.active = active);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IEntryModel.java
// public interface IEntryModel
// {
// List<EntryItem> getEntries();
// }
|
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.EntryItem;
import ni3po42.android.tractiondemo.models.IEntryModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class EntryController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.entry);
}
@Override
public void onStart()
{
super.onStart();
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/EntryItem.java
// public class EntryItem
// extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(EntryItem.class);
//
// @Override
// protected PropertyStore getPropertyStore()
// {
// return store;
// }
//
// public EntryItem(int id, String content, boolean active)
// {
// this.id = id;
// this.content = content;
// this.active = active;
// }
//
// private String content;
// private int id;
// private boolean active;
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// notifyListener("Id", this.id, this.id = id);
// }
//
// public String getContent()
// {
// return content;
// }
//
// public void setContent(String content)
// {
// notifyListener("Content", this.content, this.content = content);
// }
//
// public boolean isActive()
// {
// return active;
// }
//
// public void setActive(boolean active)
// {
// notifyListener("Active", this.active, this.active = active);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IEntryModel.java
// public interface IEntryModel
// {
// List<EntryItem> getEntries();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/EntryController.java
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.EntryItem;
import ni3po42.android.tractiondemo.models.IEntryModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class EntryController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.entry);
}
@Override
public void onStart()
{
super.onStart();
|
IEntryModel model = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/EntryController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/EntryItem.java
// public class EntryItem
// extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(EntryItem.class);
//
// @Override
// protected PropertyStore getPropertyStore()
// {
// return store;
// }
//
// public EntryItem(int id, String content, boolean active)
// {
// this.id = id;
// this.content = content;
// this.active = active;
// }
//
// private String content;
// private int id;
// private boolean active;
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// notifyListener("Id", this.id, this.id = id);
// }
//
// public String getContent()
// {
// return content;
// }
//
// public void setContent(String content)
// {
// notifyListener("Content", this.content, this.content = content);
// }
//
// public boolean isActive()
// {
// return active;
// }
//
// public void setActive(boolean active)
// {
// notifyListener("Active", this.active, this.active = active);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IEntryModel.java
// public interface IEntryModel
// {
// List<EntryItem> getEntries();
// }
|
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.EntryItem;
import ni3po42.android.tractiondemo.models.IEntryModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class EntryController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.entry);
}
@Override
public void onStart()
{
super.onStart();
IEntryModel model = View.getScope();
model.getEntries().clear();
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/EntryItem.java
// public class EntryItem
// extends ObservableObject
// {
// private static final PropertyStore store = new PropertyStore(EntryItem.class);
//
// @Override
// protected PropertyStore getPropertyStore()
// {
// return store;
// }
//
// public EntryItem(int id, String content, boolean active)
// {
// this.id = id;
// this.content = content;
// this.active = active;
// }
//
// private String content;
// private int id;
// private boolean active;
//
// public int getId()
// {
// return id;
// }
//
// public void setId(int id)
// {
// notifyListener("Id", this.id, this.id = id);
// }
//
// public String getContent()
// {
// return content;
// }
//
// public void setContent(String content)
// {
// notifyListener("Content", this.content, this.content = content);
// }
//
// public boolean isActive()
// {
// return active;
// }
//
// public void setActive(boolean active)
// {
// notifyListener("Active", this.active, this.active = active);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IEntryModel.java
// public interface IEntryModel
// {
// List<EntryItem> getEntries();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/EntryController.java
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.EntryItem;
import ni3po42.android.tractiondemo.models.IEntryModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class EntryController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.entry);
}
@Override
public void onStart()
{
super.onStart();
IEntryModel model = View.getScope();
model.getEntries().clear();
|
model.getEntries().add(new EntryItem(1,"Something", true));
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/BindingInventory.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* Tracks all ui element and the property paths to the model's data, also delegates to and from the view and the model/view-model.
* Pretty much the most important class in this library.
* @author Tim Stratton
*
*/
public class BindingInventory
extends ObservableObject
{
/**
* patterns for parsing property chains
*/
private final static Pattern pathPattern = Pattern.compile("(\\\\|[\\.]*)(.+)");
private final static Pattern split = Pattern.compile("\\.");
//used for determining a range of paths to get from the inventory. Useful for getting all properties down a
//specific branch
private final static String pathTerminator = "{";
//current context object, may be the view model or model
private IProxyObservableObject context;
private Object nonObservableContext;
//there may be many levels of inventories, this points to the parent inventory. will be null if it is the root
private BindingInventory parentInventory;
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/observables/BindingInventory.java
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package traction.mvc.observables;
/**
* Tracks all ui element and the property paths to the model's data, also delegates to and from the view and the model/view-model.
* Pretty much the most important class in this library.
* @author Tim Stratton
*
*/
public class BindingInventory
extends ObservableObject
{
/**
* patterns for parsing property chains
*/
private final static Pattern pathPattern = Pattern.compile("(\\\\|[\\.]*)(.+)");
private final static Pattern split = Pattern.compile("\\.");
//used for determining a range of paths to get from the inventory. Useful for getting all properties down a
//specific branch
private final static String pathTerminator = "{";
//current context object, may be the view model or model
private IProxyObservableObject context;
private Object nonObservableContext;
//there may be many levels of inventories, this points to the parent inventory. will be null if it is the root
private BindingInventory parentInventory;
|
private final TreeMap<String, PathBinding> map = new TreeMap<String, PathBinding>();
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/BindingInventory.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
|
private final TreeMap<String, PathBinding> map = new TreeMap<String, PathBinding>();
@Override
public void onEvent(String propagationId)
{
onContextSignaled(propagationId);
}
private String[] tempStringArray = new String[0];
public void onContextSignaled(String path)
{
Object value = null;
if (path != null && map.containsKey(path))
value = dereferenceValue(path);
if (path == null || !map.containsKey(path))
{
path = (path == null) ? "" : path + ".";
NavigableMap<String, PathBinding> subMap = map.subMap(path, false, path+pathTerminator, true);
Set<String> keys = subMap.keySet();
tempStringArray = keys.toArray(tempStringArray);
for(int i = 0;i< keys.size();i++)
{
String subPath = tempStringArray[i];
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/observables/BindingInventory.java
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
private final TreeMap<String, PathBinding> map = new TreeMap<String, PathBinding>();
@Override
public void onEvent(String propagationId)
{
onContextSignaled(propagationId);
}
private String[] tempStringArray = new String[0];
public void onContextSignaled(String path)
{
Object value = null;
if (path != null && map.containsKey(path))
value = dereferenceValue(path);
if (path == null || !map.containsKey(path))
{
path = (path == null) ? "" : path + ".";
NavigableMap<String, PathBinding> subMap = map.subMap(path, false, path+pathTerminator, true);
Set<String> keys = subMap.keySet();
tempStringArray = keys.toArray(tempStringArray);
for(int i = 0;i< keys.size();i++)
{
String subPath = tempStringArray[i];
|
ArrayList<IUIElement<?>> elements = subMap.get(subPath).getUIElements();
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/BindingInventory.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
|
}
public BindingInventory getParentInventory()
{
return parentInventory;
}
public void merge(BindingInventory inventoryToMerge)
{
Iterator<PathBinding> collection = inventoryToMerge.map.values().iterator();
while(collection.hasNext())
{
PathBinding current = collection.next();
ArrayList<IUIElement<?>> elements = current.getUIElements();
if (elements != null)
{
int size = elements.size();
for(int i=0;i<size;i++)
{
elements.get(i).track(this);
}
}
}
inventoryToMerge.map.clear();
inventoryToMerge.setContextObject(null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/observables/BindingInventory.java
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
}
public BindingInventory getParentInventory()
{
return parentInventory;
}
public void merge(BindingInventory inventoryToMerge)
{
Iterator<PathBinding> collection = inventoryToMerge.map.values().iterator();
while(collection.hasNext())
{
PathBinding current = collection.next();
ArrayList<IUIElement<?>> elements = current.getUIElements();
if (elements != null)
{
int size = elements.size();
for(int i=0;i<size;i++)
{
elements.get(i).track(this);
}
}
}
inventoryToMerge.map.clear();
inventoryToMerge.setContextObject(null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
|
public void fireCommand(String commandPath, CommandArgument commandArg)
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/BindingInventory.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
|
{
return parentInventory;
}
public void merge(BindingInventory inventoryToMerge)
{
Iterator<PathBinding> collection = inventoryToMerge.map.values().iterator();
while(collection.hasNext())
{
PathBinding current = collection.next();
ArrayList<IUIElement<?>> elements = current.getUIElements();
if (elements != null)
{
int size = elements.size();
for(int i=0;i<size;i++)
{
elements.get(i).track(this);
}
}
}
inventoryToMerge.map.clear();
inventoryToMerge.setContextObject(null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void fireCommand(String commandPath, CommandArgument commandArg)
{
Object command = dereferenceValue(commandPath);
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/observables/BindingInventory.java
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
{
return parentInventory;
}
public void merge(BindingInventory inventoryToMerge)
{
Iterator<PathBinding> collection = inventoryToMerge.map.values().iterator();
while(collection.hasNext())
{
PathBinding current = collection.next();
ArrayList<IUIElement<?>> elements = current.getUIElements();
if (elements != null)
{
int size = elements.size();
for(int i=0;i<size;i++)
{
elements.get(i).track(this);
}
}
}
inventoryToMerge.map.clear();
inventoryToMerge.setContextObject(null);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public void fireCommand(String commandPath, CommandArgument commandArg)
{
Object command = dereferenceValue(commandPath);
|
if (command instanceof IObservableCommand)
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/BindingInventory.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
|
if (!map.containsKey(path))
{
map.put(path, new PathBinding());
}
PathBinding p = map.get(path);
p.addUIElement(element);
}
@SuppressWarnings("unchecked")
public void sendUpdate(String path, Object value)
{
if (path == null || path.equals("."))
return;
Matcher matches = pathPattern.matcher(path);
if (!matches.find())
return;
BindingInventory currentInventory = getInventoryByMatchedPattern(matches);
Object currentContext = currentInventory.extractSource();
String[] chains = split.split(matches.group(2));
Property<Object,Object> prop = null;
for(int i=0;i<chains.length;i++)
{
if (currentContext == null)
return;
String member =chains[i];
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/observables/BindingInventory.java
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
if (!map.containsKey(path))
{
map.put(path, new PathBinding());
}
PathBinding p = map.get(path);
p.addUIElement(element);
}
@SuppressWarnings("unchecked")
public void sendUpdate(String path, Object value)
{
if (path == null || path.equals("."))
return;
Matcher matches = pathPattern.matcher(path);
if (!matches.find())
return;
BindingInventory currentInventory = getInventoryByMatchedPattern(matches);
Object currentContext = currentInventory.extractSource();
String[] chains = split.split(matches.group(2));
Property<Object,Object> prop = null;
for(int i=0;i<chains.length;i++)
{
if (currentContext == null)
return;
String member =chains[i];
|
if (currentContext instanceof IPOJO)
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/BindingInventory.java
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
|
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
|
for(int i=0;i<chains.length;i++)
{
if (currentContext == null)
return null;
String member = chains[i];
if (currentContext instanceof IPOJO)
prop = ((IPOJO)currentContext).getProperty(member);
else
prop = (Property<Object, Object>) PropertyStore.find(currentContext.getClass(), member);
if (i + 1 < chains.length)
{
currentContext = extractByProxy(prop.get(currentContext));
}
}
if (prop == null)
throw new InvalidParameterException("invalid path supplied: "+path);
return prop.getType();
}
public void clearAll()
{
map.clear();
}
//will not support property store!
@Override
|
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/PathBinding.java
// public class PathBinding
// {
// private final ArrayList<IUIElement<?>> uiElements = new ArrayList<IUIElement<?>>();
//
// /**
// * Adds a ui element to the Path biding
// * @param element
// */
// public void addUIElement(IUIElement<?> element)
// {
// uiElements.add(element);
// }
//
// /**
// * Gets all ui elements tracked to this path so far
// * @return
// */
// public ArrayList<IUIElement<?>> getUIElements()
// {
// return uiElements;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IObservableCommand.java
// public interface IObservableCommand
// extends IObservableObject
// {
// /**
// * call to execute command
// * @param arg
// */
// void execute(CommandArgument arg);
//
// void setExecuteListener(IOnExecuteListener listener);
//
// /**
// *
// * @return : true if command can execute
// */
// boolean getCanExecute();
//
// /**
// * set whether command can execute
// * @param b
// */
// void setCanExecute(boolean b);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IUIElement.java
// public interface IUIElement<T>
// {
// /**
// * sets a handler for when the ui recieves data from the model/view-model
// * @param listener
// */
// public void setUIUpdateListener(IUIUpdateListener<T> listener);
//
// /**
// * Sends data to the ui element. Expects the IUIUpdateListener to be called
// * @param value
// */
// public void receiveUpdate(final Object value);
//
// /**
// * Sends data from ui back to model/view-model
// * @param value
// */
// public void sendUpdate(T value);
//
// /**
// * Initializes data for ui element during inflation
// */
// public void initialize() throws Exception;
//
// /**
// * gets the binding inventory the ui element is associated to
// * @return
// */
// public BindingInventory getBindingInventory();
//
// /**
// * listener to handle updates to the ui element
// * @author Tim Stratton
// *
// * @param <S> : type of data sent to ui element
// */
// public interface IUIUpdateListener<S>
// {
// public void onUpdate(S value);
// }
//
// public boolean isDefined();
//
// public void track(BindingInventory differentBindingInventory);
// }
// Path: traction/src/main/java/traction/mvc/observables/BindingInventory.java
import traction.mvc.interfaces.IUIElement;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.util.Property;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.implementations.PathBinding;
import traction.mvc.interfaces.IPropertyStore;
import traction.mvc.interfaces.IObservableCommand;
import traction.mvc.interfaces.IPOJO;
for(int i=0;i<chains.length;i++)
{
if (currentContext == null)
return null;
String member = chains[i];
if (currentContext instanceof IPOJO)
prop = ((IPOJO)currentContext).getProperty(member);
else
prop = (Property<Object, Object>) PropertyStore.find(currentContext.getClass(), member);
if (i + 1 < chains.length)
{
currentContext = extractByProxy(prop.get(currentContext));
}
}
if (prop == null)
throw new InvalidParameterException("invalid path supplied: "+path);
return prop.getType();
}
public void clearAll()
{
map.clear();
}
//will not support property store!
@Override
|
protected IPropertyStore getPropertyStore() {
|
ni3po42/traction.mvc
|
traction/src/main/java/traction/mvc/observables/ObservableObject.java
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObjectListener.java
// public interface IObjectListener
// {
// public static class Utility
// {
// public static String generatePropagationId(String currentPropagationId, String currentSource)
// {
// if (currentSource == null || currentSource.equals(""))
// return currentPropagationId;
// else if (currentPropagationId == null || currentPropagationId.equals(""))
// return currentSource;
// else
// return currentSource + "." + currentPropagationId;
// }
// }
//
// /**
// * Fired when listener is signalled of something, anything really.
// */
// void onEvent(String propagationId);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import traction.mvc.interfaces.IObjectListener;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
import android.util.Property;
|
}
}
}
}
public void notifyListener()
{
notifyListenerInternal(null, null, null);
}
// @SuppressWarnings("unchecked")
// @Override
// public <T extends IProxyObservableObject> T registerAs(String propertyName, IProxyObservableObject parentObj)
// {
// if (getProxyObservableObject() == null || parentObj == null || parentObj.getProxyObservableObject() == null)
// return null;
//
// //let the parent object listen to 'this' (this being the getSource() which can be overriden to be anything)
// getProxyObservableObject().getProxyObservableObject().unregisterListener(propertyName, parentObj.getProxyObservableObject());
// getProxyObservableObject().getProxyObservableObject().registerListener(propertyName, parentObj.getProxyObservableObject());
// return (T)this;
//
// }
@Override
public void onEvent(String propagationId)
{
notifyListenerInternal(propagationId, null, null);
}
|
// Path: traction/src/main/java/traction/mvc/interfaces/IObjectListener.java
// public interface IObjectListener
// {
// public static class Utility
// {
// public static String generatePropagationId(String currentPropagationId, String currentSource)
// {
// if (currentSource == null || currentSource.equals(""))
// return currentPropagationId;
// else if (currentPropagationId == null || currentPropagationId.equals(""))
// return currentSource;
// else
// return currentSource + "." + currentPropagationId;
// }
// }
//
// /**
// * Fired when listener is signalled of something, anything really.
// */
// void onEvent(String propagationId);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPOJO.java
// public interface IPOJO
// {
// /**
// * Access property from property store.
// * @param name
// * @return if property exists, return property object, or null if not found
// */
// Property<Object,Object> getProperty(String name);
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IPropertyStore.java
// public interface IPropertyStore
// {
// Property<?,?> getProperty(String name);
// }
// Path: traction/src/main/java/traction/mvc/observables/ObservableObject.java
import java.util.ArrayList;
import java.util.HashMap;
import traction.mvc.interfaces.IObjectListener;
import traction.mvc.interfaces.IPOJO;
import traction.mvc.interfaces.IPropertyStore;
import android.util.Property;
}
}
}
}
public void notifyListener()
{
notifyListenerInternal(null, null, null);
}
// @SuppressWarnings("unchecked")
// @Override
// public <T extends IProxyObservableObject> T registerAs(String propertyName, IProxyObservableObject parentObj)
// {
// if (getProxyObservableObject() == null || parentObj == null || parentObj.getProxyObservableObject() == null)
// return null;
//
// //let the parent object listen to 'this' (this being the getSource() which can be overriden to be anything)
// getProxyObservableObject().getProxyObservableObject().unregisterListener(propertyName, parentObj.getProxyObservableObject());
// getProxyObservableObject().getProxyObservableObject().registerListener(propertyName, parentObj.getProxyObservableObject());
// return (T)this;
//
// }
@Override
public void onEvent(String propagationId)
{
notifyListenerInternal(propagationId, null, null);
}
|
protected abstract IPropertyStore getPropertyStore();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ScopeExampleController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/TestScope.java
// public interface TestScope
// {
// String getATextField();
// void setATextField(String str);
// }
|
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.TestScope;
|
package ni3po42.android.tractiondemo.controllers;
public class ScopeExampleController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.scopedview);
}
@Override
public void onStart()
{
super.onStart();
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/TestScope.java
// public interface TestScope
// {
// String getATextField();
// void setATextField(String str);
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/ScopeExampleController.java
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.TestScope;
package ni3po42.android.tractiondemo.controllers;
public class ScopeExampleController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.scopedview);
}
@Override
public void onStart()
{
super.onStart();
|
TestScope scope = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/CalculatorController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
// public interface ICalculatorModel
// {
// String getDisplay();
// void setDisplay(String str);
//
// Command getNumberUpdate();
// Command getOperation();
// Command getClearDisplay();
// Command getSwitchToDecimal();
// }
|
import android.os.Bundle;
import org.json.JSONException;
import org.json.JSONObject;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.ICalculatorModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
/**
* A simple calculator. not perfect, but fine for a demonstration
*/
public class CalculatorController extends FragmentController
{
private static final int MAX_DIGITS = 7;
private double currentValue = 0;
private int decimalPlace = 0;
private int totalDigits = 0;
private double stack = 0;
private int stackSize = 0;
private String currentAction = null;
public void doOperation(JSONObject argument)
{
String action = null;
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
// public interface ICalculatorModel
// {
// String getDisplay();
// void setDisplay(String str);
//
// Command getNumberUpdate();
// Command getOperation();
// Command getClearDisplay();
// Command getSwitchToDecimal();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/CalculatorController.java
import android.os.Bundle;
import org.json.JSONException;
import org.json.JSONObject;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.ICalculatorModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
/**
* A simple calculator. not perfect, but fine for a demonstration
*/
public class CalculatorController extends FragmentController
{
private static final int MAX_DIGITS = 7;
private double currentValue = 0;
private int decimalPlace = 0;
private int totalDigits = 0;
private double stack = 0;
private int stackSize = 0;
private String currentAction = null;
public void doOperation(JSONObject argument)
{
String action = null;
|
ICalculatorModel model = View.getScope();
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/CalculatorController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
// public interface ICalculatorModel
// {
// String getDisplay();
// void setDisplay(String str);
//
// Command getNumberUpdate();
// Command getOperation();
// Command getClearDisplay();
// Command getSwitchToDecimal();
// }
|
import android.os.Bundle;
import org.json.JSONException;
import org.json.JSONObject;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.ICalculatorModel;
|
currentAction = action;
pushStack();
}
totalDigits = 0;
}
public void pushStack()
{
stackSize++;
stack = currentValue;
decimalPlace = 0;
currentValue = 0;
}
public void popStack()
{
if (stackSize != 0)
stackSize--;
decimalPlace = 0;
}
public void doClearDisplay()
{
currentValue = 0;
decimalPlace = 0;
totalDigits = 0;
ICalculatorModel model = View.getScope();
model.setDisplay(String.valueOf(currentValue));
}
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
// public interface ICalculatorModel
// {
// String getDisplay();
// void setDisplay(String str);
//
// Command getNumberUpdate();
// Command getOperation();
// Command getClearDisplay();
// Command getSwitchToDecimal();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/CalculatorController.java
import android.os.Bundle;
import org.json.JSONException;
import org.json.JSONObject;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.ICalculatorModel;
currentAction = action;
pushStack();
}
totalDigits = 0;
}
public void pushStack()
{
stackSize++;
stack = currentValue;
decimalPlace = 0;
currentValue = 0;
}
public void popStack()
{
if (stackSize != 0)
stackSize--;
decimalPlace = 0;
}
public void doClearDisplay()
{
currentValue = 0;
decimalPlace = 0;
totalDigits = 0;
ICalculatorModel model = View.getScope();
model.setDisplay(String.valueOf(currentValue));
}
|
public void updateCurrentNumber(CommandArgument argument)
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/CalculatorController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
// public interface ICalculatorModel
// {
// String getDisplay();
// void setDisplay(String str);
//
// Command getNumberUpdate();
// Command getOperation();
// Command getClearDisplay();
// Command getSwitchToDecimal();
// }
|
import android.os.Bundle;
import org.json.JSONException;
import org.json.JSONObject;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.ICalculatorModel;
|
currentValue = currentValue * 10 + (currentValue > 0 ? nextInput : -nextInput);
}
else
{
currentValue = currentValue + ((currentValue > 0 ? nextInput : -nextInput) * Math.pow(10, -decimalPlace));
decimalPlace++;
}
totalDigits++;
ICalculatorModel model = View.getScope();
model.setDisplay(String.valueOf(currentValue));
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.calculator);
}
@Override
public void onStart()
{
super.onStart();
ICalculatorModel model = View.getScope();
currentValue = 0;
stack = 0;
model.setDisplay(String.valueOf(currentValue));
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: traction/src/main/java/traction/mvc/implementations/CommandArgument.java
// public class CommandArgument
// {
// private String commandName;
// private boolean eventCancelled;
// private JSONObject tagProperties;
//
// public boolean isEventCancelled()
// {
// return eventCancelled;
// }
//
// public void setEventCancelled(boolean isCancelled)
// {
// eventCancelled = isCancelled;
// }
//
// public CommandArgument(String commandName)
// {
// this(commandName, null);
// }
//
// public CommandArgument(String commandName, JSONObject tagProperties)
// {
// this.commandName = commandName;
// this.eventCancelled = false;
// this.tagProperties = tagProperties;
// }
//
// public JSONObject getEventData()
// {
// return tagProperties;
// }
//
// public String getCommandName()
// {
// return commandName;
// }
// }
//
// Path: traction/src/main/java/traction/mvc/interfaces/IOnExecuteListener.java
// public interface IOnExecuteListener
// {
// void onExecuted(CommandArgument arg);
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/ICalculatorModel.java
// public interface ICalculatorModel
// {
// String getDisplay();
// void setDisplay(String str);
//
// Command getNumberUpdate();
// Command getOperation();
// Command getClearDisplay();
// Command getSwitchToDecimal();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/CalculatorController.java
import android.os.Bundle;
import org.json.JSONException;
import org.json.JSONObject;
import traction.mvc.controllers.FragmentController;
import traction.mvc.implementations.CommandArgument;
import traction.mvc.interfaces.IOnExecuteListener;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.ICalculatorModel;
currentValue = currentValue * 10 + (currentValue > 0 ? nextInput : -nextInput);
}
else
{
currentValue = currentValue + ((currentValue > 0 ? nextInput : -nextInput) * Math.pow(10, -decimalPlace));
decimalPlace++;
}
totalDigits++;
ICalculatorModel model = View.getScope();
model.setDisplay(String.valueOf(currentValue));
}
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.calculator);
}
@Override
public void onStart()
{
super.onStart();
ICalculatorModel model = View.getScope();
currentValue = 0;
stack = 0;
model.setDisplay(String.valueOf(currentValue));
|
model.getNumberUpdate().setExecuteListener(new IOnExecuteListener() {
|
ni3po42/traction.mvc
|
Demo/src/main/java/ni3po42/android/tractiondemo/controllers/RelativeContextFragmentController.java
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IRelativeRootModel.java
// public interface IRelativeRootModel
// {
// IRelativeContextModel getMyModel();
// }
|
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IRelativeRootModel;
|
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class RelativeContextFragmentController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.relativecontextroot);
}
@Override
public void onStart()
{
super.onStart();
|
// Path: traction/src/main/java/traction/mvc/controllers/FragmentController.java
// public class FragmentController
// extends Fragment
// {
// /**
// * Helper to implement Controller logic.
// */
// protected final ControllerHelper View = new ControllerHelper(this);
//
// @Override
// public void onCreate(Bundle savedInstanceState)
// {
// super.onCreate(savedInstanceState);
// setRetainInstance(true);
// }
//
// @Override
// public View onCreateView(LayoutInflater notUsed, ViewGroup container, Bundle savedInstanceState)
// {
// View v = View.inflateView(View.getContentView(), container, container != null);
// IViewBinding vb = ViewFactory.getViewBinding(v);
// if (vb != null) {
// View.ensureMenuInflator(vb.getBindingInventory());
// }
// return v;
// }
//
// @Override
// public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
// {
// View.onCreateOptionsMenu(menu);
// }
//
// @Override
// public void onDestroyView()
// {
// super.onDestroyView();
// ViewFactory.DetachContext(getView());
// }
//
// @Override
// public void onAttach(Activity activity)
// {
// super.onAttach(activity);
// View.registerFragmentToActivity(this, activity);
// }
//
// @Override
// public void onDetach()
// {
// super.onDetach();
// View.unregisterFragmentFromActivity(this, getActivity());
// }
//
// @Override
// public void onStart()
// {
// super.onStart();
// View.connectFragmentViewToParentView(this);
// }
// }
//
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/models/IRelativeRootModel.java
// public interface IRelativeRootModel
// {
// IRelativeContextModel getMyModel();
// }
// Path: Demo/src/main/java/ni3po42/android/tractiondemo/controllers/RelativeContextFragmentController.java
import android.os.Bundle;
import traction.mvc.controllers.FragmentController;
import ni3po42.android.tractiondemo.R;
import ni3po42.android.tractiondemo.models.IRelativeRootModel;
/* Copyright 2013 Tim Stratton
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package ni3po42.android.tractiondemo.controllers;
public class RelativeContextFragmentController
extends FragmentController
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
View.setContentView(R.layout.relativecontextroot);
}
@Override
public void onStart()
{
super.onStart();
|
IRelativeRootModel model = View.getScope();
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/PaletteActivity2.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/PaletteGridAdapter.java
// public class PaletteGridAdapter extends RecyclerView.Adapter<PaletteGridAdapter.PaletteGridViewHolder> {
//
// final int[] picResId = new int[]{R.mipmap.p1, R.mipmap.p2, R.mipmap.p3, R.mipmap.p4, R.mipmap.p5,
// R.mipmap.p6, R.mipmap.p7, R.mipmap.p8, R.mipmap.p9, R.mipmap.p10, R.mipmap.p11, R.mipmap.p12,
// R.mipmap.p13, R.mipmap.p14, R.mipmap.p15, R.mipmap.p16, R.mipmap.p17, R.mipmap.p18,
// R.mipmap.p19, R.mipmap.p20, R.mipmap.p21, R.mipmap.p22, R.mipmap.p23, R.mipmap.p24,
// R.mipmap.p25, R.mipmap.p26, R.mipmap.p27, R.mipmap.p28, R.mipmap.p29, R.mipmap.p30,
// R.mipmap.p31, R.mipmap.p32, R.mipmap.p33, R.mipmap.p34, R.mipmap.p35, R.mipmap.p36,
// R.mipmap.p37, R.mipmap.p38, R.mipmap.p39, R.mipmap.p40, R.mipmap.p41, R.mipmap.p42, R.mipmap.p43, R.mipmap.p44};
//
// @Override
// public PaletteGridViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_palette, parent, false);
// return new PaletteGridViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(final PaletteGridViewHolder holder, final int position) {
// holder.mIvPic.setImageResource(picResId[position]);
// BitmapDrawable bitmapDrawable = (BitmapDrawable) holder.mIvPic.getDrawable();
// Bitmap bitmap = bitmapDrawable.getBitmap();
//
// Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
// @Override
// public void onGenerated(Palette palette) {
// // 对于一张图片,它可能分析不出来暗、亮色,返回值为空,我这里采取的方案是当获取不到色调样品,则获取其他色调样品。
// Palette.Swatch swatch = palette.getDarkMutedSwatch();
// if (swatch == null) {
// swatch = palette.getDarkVibrantSwatch();
// }
// if (swatch == null) {
// swatch = palette.getLightMutedSwatch();
// }
// if (swatch == null) {
// swatch = palette.getLightVibrantSwatch();
// }
// if (swatch == null) {
// swatch = palette.getMutedSwatch();
// }
// if (swatch == null) {
// swatch = palette.getVibrantSwatch();
// }
// int titleTextColor = swatch.getTitleTextColor();
// int rgb = swatch.getRgb();
//
// holder.mTvTitle.setText(Cheeses.sCheeseStrings[position]);
// holder.mTvTitle.setTextColor(titleTextColor);
// holder.mTvTitle.setBackgroundColor(generateTransparentColor(0.5f, rgb));
//
// }
// });
// }
//
// private int generateTransparentColor(float percent, int rgb) {
// int red = Color.red(rgb);
// int green = Color.green(rgb);
// int blue = Color.blue(rgb);
// int alpha = Color.alpha(rgb);
// alpha = (int) (percent * alpha);
// return Color.argb(alpha, red, green, blue);
// }
//
// @Override
// public int getItemCount() {
// return picResId.length;
// }
//
// class PaletteGridViewHolder extends RecyclerView.ViewHolder {
//
// ImageView mIvPic;
// TextView mTvTitle;
//
// public PaletteGridViewHolder(View itemView) {
// super(itemView);
// mIvPic = (ImageView) itemView.findViewById(R.id.ivPic);
// mTvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
// }
// }
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.PaletteGridAdapter;
|
package com.lqr.materialdesigndemo.activity;
public class PaletteActivity2 extends AppCompatActivity {
private RecyclerView mRvPalette;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_palette2);
mRvPalette = (RecyclerView) findViewById(R.id.rvPalette);
mRvPalette.setLayoutManager(new GridLayoutManager(this, 2));
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/PaletteGridAdapter.java
// public class PaletteGridAdapter extends RecyclerView.Adapter<PaletteGridAdapter.PaletteGridViewHolder> {
//
// final int[] picResId = new int[]{R.mipmap.p1, R.mipmap.p2, R.mipmap.p3, R.mipmap.p4, R.mipmap.p5,
// R.mipmap.p6, R.mipmap.p7, R.mipmap.p8, R.mipmap.p9, R.mipmap.p10, R.mipmap.p11, R.mipmap.p12,
// R.mipmap.p13, R.mipmap.p14, R.mipmap.p15, R.mipmap.p16, R.mipmap.p17, R.mipmap.p18,
// R.mipmap.p19, R.mipmap.p20, R.mipmap.p21, R.mipmap.p22, R.mipmap.p23, R.mipmap.p24,
// R.mipmap.p25, R.mipmap.p26, R.mipmap.p27, R.mipmap.p28, R.mipmap.p29, R.mipmap.p30,
// R.mipmap.p31, R.mipmap.p32, R.mipmap.p33, R.mipmap.p34, R.mipmap.p35, R.mipmap.p36,
// R.mipmap.p37, R.mipmap.p38, R.mipmap.p39, R.mipmap.p40, R.mipmap.p41, R.mipmap.p42, R.mipmap.p43, R.mipmap.p44};
//
// @Override
// public PaletteGridViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_palette, parent, false);
// return new PaletteGridViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(final PaletteGridViewHolder holder, final int position) {
// holder.mIvPic.setImageResource(picResId[position]);
// BitmapDrawable bitmapDrawable = (BitmapDrawable) holder.mIvPic.getDrawable();
// Bitmap bitmap = bitmapDrawable.getBitmap();
//
// Palette.from(bitmap).generate(new Palette.PaletteAsyncListener() {
// @Override
// public void onGenerated(Palette palette) {
// // 对于一张图片,它可能分析不出来暗、亮色,返回值为空,我这里采取的方案是当获取不到色调样品,则获取其他色调样品。
// Palette.Swatch swatch = palette.getDarkMutedSwatch();
// if (swatch == null) {
// swatch = palette.getDarkVibrantSwatch();
// }
// if (swatch == null) {
// swatch = palette.getLightMutedSwatch();
// }
// if (swatch == null) {
// swatch = palette.getLightVibrantSwatch();
// }
// if (swatch == null) {
// swatch = palette.getMutedSwatch();
// }
// if (swatch == null) {
// swatch = palette.getVibrantSwatch();
// }
// int titleTextColor = swatch.getTitleTextColor();
// int rgb = swatch.getRgb();
//
// holder.mTvTitle.setText(Cheeses.sCheeseStrings[position]);
// holder.mTvTitle.setTextColor(titleTextColor);
// holder.mTvTitle.setBackgroundColor(generateTransparentColor(0.5f, rgb));
//
// }
// });
// }
//
// private int generateTransparentColor(float percent, int rgb) {
// int red = Color.red(rgb);
// int green = Color.green(rgb);
// int blue = Color.blue(rgb);
// int alpha = Color.alpha(rgb);
// alpha = (int) (percent * alpha);
// return Color.argb(alpha, red, green, blue);
// }
//
// @Override
// public int getItemCount() {
// return picResId.length;
// }
//
// class PaletteGridViewHolder extends RecyclerView.ViewHolder {
//
// ImageView mIvPic;
// TextView mTvTitle;
//
// public PaletteGridViewHolder(View itemView) {
// super(itemView);
// mIvPic = (ImageView) itemView.findViewById(R.id.ivPic);
// mTvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
// }
// }
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/PaletteActivity2.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.PaletteGridAdapter;
package com.lqr.materialdesigndemo.activity;
public class PaletteActivity2 extends AppCompatActivity {
private RecyclerView mRvPalette;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_palette2);
mRvPalette = (RecyclerView) findViewById(R.id.rvPalette);
mRvPalette.setLayoutManager(new GridLayoutManager(this, 2));
|
mRvPalette.setAdapter(new PaletteGridAdapter());
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationThree.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/utils/PinyinUtils.java
// public class PinyinUtils {
//
// /**
// * 根据传入的字符串(包含汉字),得到拼音
// * 沧晓 -> CANGXIAO
// * 沧 晓*& -> CANGXIAO
// * 沧晓f5 -> CANGXIAO
// *
// * @param str 字符串
// * @return
// */
// public static String getPinyin(String str) {
//
// HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
// format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
// format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
//
// StringBuilder sb = new StringBuilder();
//
// char[] charArray = str.toCharArray();
// for (int i = 0; i < charArray.length; i++) {
// char c = charArray[i];
// // 如果是空格, 跳过
// if (Character.isWhitespace(c)) {
// continue;
// }
// if (c >= -127 && c < 128 || !(c >= 0x4E00 && c <= 0x9FA5)) {
// // 肯定不是汉字
// sb.append(c);
// } else {
// String s = "";
// try {
// // 通过char得到拼音集合. 单 -> dan, shan
// s = PinyinHelper.toHanyuPinyinStringArray(c, format)[0];
// sb.append(s);
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// sb.append(s);
// }
// }
// }
//
// return sb.toString();
// }
//
// }
|
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import com.lqr.materialdesigndemo.utils.PinyinUtils;
import java.util.List;
|
public MyDecorationThree(Context context, List<String> data) {
mContext = context;
mData = data;
paint.setTextSize(sp2px(16));
paint.setColor(Color.RED);
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDraw(c, parent, state);
drawLetterToItemLeft(c, parent);
}
private void drawLetterToItemLeft(Canvas c, RecyclerView parent) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (!(layoutManager instanceof LinearLayoutManager))
return;
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
int position = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition() + i;
View child = parent.getChildAt(i);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
float left = 0;
float top = child.getTop() - params.topMargin;
float right = child.getLeft() - params.leftMargin;
float bottom = child.getBottom() + params.bottomMargin;
float width = right - left;
float height = bottom - (bottom - top) / 2;
//当前名字拼音的第一个字母
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/utils/PinyinUtils.java
// public class PinyinUtils {
//
// /**
// * 根据传入的字符串(包含汉字),得到拼音
// * 沧晓 -> CANGXIAO
// * 沧 晓*& -> CANGXIAO
// * 沧晓f5 -> CANGXIAO
// *
// * @param str 字符串
// * @return
// */
// public static String getPinyin(String str) {
//
// HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
// format.setCaseType(HanyuPinyinCaseType.UPPERCASE);
// format.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
//
// StringBuilder sb = new StringBuilder();
//
// char[] charArray = str.toCharArray();
// for (int i = 0; i < charArray.length; i++) {
// char c = charArray[i];
// // 如果是空格, 跳过
// if (Character.isWhitespace(c)) {
// continue;
// }
// if (c >= -127 && c < 128 || !(c >= 0x4E00 && c <= 0x9FA5)) {
// // 肯定不是汉字
// sb.append(c);
// } else {
// String s = "";
// try {
// // 通过char得到拼音集合. 单 -> dan, shan
// s = PinyinHelper.toHanyuPinyinStringArray(c, format)[0];
// sb.append(s);
// } catch (BadHanyuPinyinOutputFormatCombination e) {
// e.printStackTrace();
// sb.append(s);
// }
// }
// }
//
// return sb.toString();
// }
//
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationThree.java
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
import com.lqr.materialdesigndemo.utils.PinyinUtils;
import java.util.List;
public MyDecorationThree(Context context, List<String> data) {
mContext = context;
mData = data;
paint.setTextSize(sp2px(16));
paint.setColor(Color.RED);
}
@Override
public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
super.onDraw(c, parent, state);
drawLetterToItemLeft(c, parent);
}
private void drawLetterToItemLeft(Canvas c, RecyclerView parent) {
RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
if (!(layoutManager instanceof LinearLayoutManager))
return;
int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
int position = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition() + i;
View child = parent.getChildAt(i);
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
float left = 0;
float top = child.getTop() - params.topMargin;
float right = child.getLeft() - params.leftMargin;
float bottom = child.getBottom() + params.bottomMargin;
float width = right - left;
float height = bottom - (bottom - top) / 2;
//当前名字拼音的第一个字母
|
String letter = PinyinUtils.getPinyin(mData.get(position)).charAt(0) + "";
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/TabLayoutActivity.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/fragment/TextFragment.java
// public class TextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// TextView textView = new TextView(getContext());
// Bundle bundle = getArguments();
// String title = (String) bundle.get("title");
// textView.setText(title);
// return textView;
// }
// }
|
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.fragment.TextFragment;
import java.lang.reflect.Field;
|
e.printStackTrace();
}
int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, leftDip, Resources.getSystem().getDisplayMetrics());
int right = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rightDip, Resources.getSystem().getDisplayMetrics());
for (int i = 0; i < llTab.getChildCount(); i++) {
View child = llTab.getChildAt(i);
child.setPadding(0, 0, 0, 0);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
params.leftMargin = left;
params.rightMargin = right;
child.setLayoutParams(params);
child.invalidate();
}
}
class MyViewPagerAdapter extends FragmentPagerAdapter {
private final String[] title = new String[]{
"推荐", "热点", "视频", "深圳", "通信",
"互联网", "问答", "图片", "电影",
"网络安全", "软件"};
public MyViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/fragment/TextFragment.java
// public class TextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// TextView textView = new TextView(getContext());
// Bundle bundle = getArguments();
// String title = (String) bundle.get("title");
// textView.setText(title);
// return textView;
// }
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/TabLayoutActivity.java
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.util.TypedValue;
import android.view.View;
import android.widget.LinearLayout;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.fragment.TextFragment;
import java.lang.reflect.Field;
e.printStackTrace();
}
int left = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, leftDip, Resources.getSystem().getDisplayMetrics());
int right = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, rightDip, Resources.getSystem().getDisplayMetrics());
for (int i = 0; i < llTab.getChildCount(); i++) {
View child = llTab.getChildAt(i);
child.setPadding(0, 0, 0, 0);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1);
params.leftMargin = left;
params.rightMargin = right;
child.setLayoutParams(params);
child.invalidate();
}
}
class MyViewPagerAdapter extends FragmentPagerAdapter {
private final String[] title = new String[]{
"推荐", "热点", "视频", "深圳", "通信",
"互联网", "问答", "图片", "电影",
"网络安全", "软件"};
public MyViewPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int i) {
|
Fragment fragment = new TextFragment();
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityTwo.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationTwo.java
// public class MyDecorationTwo extends RecyclerView.ItemDecoration {
//
// private final Drawable mDivider;
//
// public MyDecorationTwo(Context context) {
// // int attrs[] = new int[]{android.R.attr.listDivider};
// // TypedArray a = context.obtainStyledAttributes(attrs);
// // mDivider = a.getDrawable(0);
// // a.recycle();
//
// mDivider = context.getResources().getDrawable(R.drawable.divider);
// }
//
// @Override
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// super.onDraw(c, parent, state);
// drawVertical(c, parent);
// drawHorizontal(c, parent);
// }
//
// private void drawVertical(Canvas c, RecyclerView parent) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getRight() + params.rightMargin;
// int top = child.getTop() - params.topMargin;
// int right = left + mDivider.getIntrinsicWidth();
// int bottom = child.getBottom() + params.bottomMargin;
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// private void drawHorizontal(Canvas c, RecyclerView parent) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getLeft() - params.leftMargin;
// int top = child.getBottom() + params.bottomMargin;
// int right = child.getRight() + params.rightMargin;
// int bottom = top + mDivider.getMinimumHeight();
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// @Override
// public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
// super.getItemOffsets(outRect, itemPosition, parent);
// int right = mDivider.getIntrinsicWidth();
// int bottom = mDivider.getIntrinsicHeight();
//
// if (isLastSpan(itemPosition, parent)) {
// right = 0;
// }
//
// if (isLastRow(itemPosition, parent)) {
// bottom = 0;
// }
// outRect.set(0, 0, right, bottom);
// }
//
// // @Override
// // public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// // super.getItemOffsets(outRect, view, parent, state);
// // outRect.set(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
// // }
//
// public boolean isLastRow(int itemPosition, RecyclerView parent) {
// RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
// if (layoutManager instanceof GridLayoutManager) {
// int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
// int itemCount = parent.getAdapter().getItemCount();
// if ((itemCount - itemPosition - 1) < spanCount)
// return true;
// }
// return false;
// }
//
// public boolean isLastSpan(int itemPosition, RecyclerView parent) {
// RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
// if (layoutManager instanceof GridLayoutManager) {
// int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
// if ((itemPosition + 1) % spanCount == 0)
// return true;
// }
// return false;
// }
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationTwo;
import java.util.ArrayList;
import java.util.List;
|
package com.lqr.materialdesigndemo.activity;
/**
* @创建者 CSDN_LQR
* @描述 RecyclerView的表格样式
*/
public class RecyclerVIewDecorationActivityTwo extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationTwo.java
// public class MyDecorationTwo extends RecyclerView.ItemDecoration {
//
// private final Drawable mDivider;
//
// public MyDecorationTwo(Context context) {
// // int attrs[] = new int[]{android.R.attr.listDivider};
// // TypedArray a = context.obtainStyledAttributes(attrs);
// // mDivider = a.getDrawable(0);
// // a.recycle();
//
// mDivider = context.getResources().getDrawable(R.drawable.divider);
// }
//
// @Override
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// super.onDraw(c, parent, state);
// drawVertical(c, parent);
// drawHorizontal(c, parent);
// }
//
// private void drawVertical(Canvas c, RecyclerView parent) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getRight() + params.rightMargin;
// int top = child.getTop() - params.topMargin;
// int right = left + mDivider.getIntrinsicWidth();
// int bottom = child.getBottom() + params.bottomMargin;
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// private void drawHorizontal(Canvas c, RecyclerView parent) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getLeft() - params.leftMargin;
// int top = child.getBottom() + params.bottomMargin;
// int right = child.getRight() + params.rightMargin;
// int bottom = top + mDivider.getMinimumHeight();
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// @Override
// public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
// super.getItemOffsets(outRect, itemPosition, parent);
// int right = mDivider.getIntrinsicWidth();
// int bottom = mDivider.getIntrinsicHeight();
//
// if (isLastSpan(itemPosition, parent)) {
// right = 0;
// }
//
// if (isLastRow(itemPosition, parent)) {
// bottom = 0;
// }
// outRect.set(0, 0, right, bottom);
// }
//
// // @Override
// // public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// // super.getItemOffsets(outRect, view, parent, state);
// // outRect.set(0, 0, mDivider.getIntrinsicWidth(), mDivider.getIntrinsicHeight());
// // }
//
// public boolean isLastRow(int itemPosition, RecyclerView parent) {
// RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
// if (layoutManager instanceof GridLayoutManager) {
// int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
// int itemCount = parent.getAdapter().getItemCount();
// if ((itemCount - itemPosition - 1) < spanCount)
// return true;
// }
// return false;
// }
//
// public boolean isLastSpan(int itemPosition, RecyclerView parent) {
// RecyclerView.LayoutManager layoutManager = parent.getLayoutManager();
// if (layoutManager instanceof GridLayoutManager) {
// int spanCount = ((GridLayoutManager) layoutManager).getSpanCount();
// if ((itemPosition + 1) % spanCount == 0)
// return true;
// }
// return false;
// }
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityTwo.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationTwo;
import java.util.ArrayList;
import java.util.List;
package com.lqr.materialdesigndemo.activity;
/**
* @创建者 CSDN_LQR
* @描述 RecyclerView的表格样式
*/
public class RecyclerVIewDecorationActivityTwo extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
|
private MyAdapter mMyAdapter;
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerViewActivity.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyStaggeredAdapter.java
// public class MyStaggeredAdapter extends RecyclerView.Adapter<MyStaggeredAdapter.MyViewHolder> {
//
// private List<String> mData;
// private Random mRandom = new Random();
//
// public MyStaggeredAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// // LayoutInflater layoutInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// // View itemView = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1,parent,false);
// View itemView = View.inflate(parent.getContext(), R.layout.item_layout, null);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// // ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mRandom.nextInt(200) + 200);
// ViewGroup.LayoutParams params = holder.mTv.getLayoutParams();
// Log.e("CSDN_LQR", "params == null : " + (params == null));
// params.height = mRandom.nextInt(200) + 200;
// holder.mTv.setLayoutParams(params);
// holder.mTv.setBackgroundColor(Color.argb(255, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30));
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.adapter.MyStaggeredAdapter;
import java.util.ArrayList;
import java.util.List;
|
package com.lqr.materialdesigndemo.activity;
public class RecyclerViewActivity extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyStaggeredAdapter.java
// public class MyStaggeredAdapter extends RecyclerView.Adapter<MyStaggeredAdapter.MyViewHolder> {
//
// private List<String> mData;
// private Random mRandom = new Random();
//
// public MyStaggeredAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// // LayoutInflater layoutInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// // View itemView = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1,parent,false);
// View itemView = View.inflate(parent.getContext(), R.layout.item_layout, null);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// // ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mRandom.nextInt(200) + 200);
// ViewGroup.LayoutParams params = holder.mTv.getLayoutParams();
// Log.e("CSDN_LQR", "params == null : " + (params == null));
// params.height = mRandom.nextInt(200) + 200;
// holder.mTv.setLayoutParams(params);
// holder.mTv.setBackgroundColor(Color.argb(255, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30));
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerViewActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.adapter.MyStaggeredAdapter;
import java.util.ArrayList;
import java.util.List;
package com.lqr.materialdesigndemo.activity;
public class RecyclerViewActivity extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
|
private MyAdapter mMyAdapter;
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerViewActivity.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyStaggeredAdapter.java
// public class MyStaggeredAdapter extends RecyclerView.Adapter<MyStaggeredAdapter.MyViewHolder> {
//
// private List<String> mData;
// private Random mRandom = new Random();
//
// public MyStaggeredAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// // LayoutInflater layoutInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// // View itemView = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1,parent,false);
// View itemView = View.inflate(parent.getContext(), R.layout.item_layout, null);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// // ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mRandom.nextInt(200) + 200);
// ViewGroup.LayoutParams params = holder.mTv.getLayoutParams();
// Log.e("CSDN_LQR", "params == null : " + (params == null));
// params.height = mRandom.nextInt(200) + 200;
// holder.mTv.setLayoutParams(params);
// holder.mTv.setBackgroundColor(Color.argb(255, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30));
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.adapter.MyStaggeredAdapter;
import java.util.ArrayList;
import java.util.List;
|
mRv.setAdapter(mMyAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.recycler_view, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.linear_ver:
mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.linear_hor:
mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.grid_ver:
mRv.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.grid_hor:
mRv.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.HORIZONTAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.staggered_ver:
mRv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyStaggeredAdapter.java
// public class MyStaggeredAdapter extends RecyclerView.Adapter<MyStaggeredAdapter.MyViewHolder> {
//
// private List<String> mData;
// private Random mRandom = new Random();
//
// public MyStaggeredAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// // LayoutInflater layoutInflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
// // View itemView = LayoutInflater.from(parent.getContext()).inflate(android.R.layout.simple_list_item_1,parent,false);
// View itemView = View.inflate(parent.getContext(), R.layout.item_layout, null);
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// // ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mRandom.nextInt(200) + 200);
// ViewGroup.LayoutParams params = holder.mTv.getLayoutParams();
// Log.e("CSDN_LQR", "params == null : " + (params == null));
// params.height = mRandom.nextInt(200) + 200;
// holder.mTv.setLayoutParams(params);
// holder.mTv.setBackgroundColor(Color.argb(255, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30, 180 + mRandom.nextInt(60) + 30));
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerViewActivity.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.adapter.MyStaggeredAdapter;
import java.util.ArrayList;
import java.util.List;
mRv.setAdapter(mMyAdapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
new MenuInflater(this).inflate(R.menu.recycler_view, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.linear_ver:
mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.linear_hor:
mRv.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.grid_ver:
mRv.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.grid_hor:
mRv.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.HORIZONTAL, false));
mRv.setAdapter(mMyAdapter);
break;
case R.id.staggered_ver:
mRv.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL));
|
mRv.setAdapter(new MyStaggeredAdapter(mData));
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/adapter/ItemTouchHelperAdapter.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/listener/ItemDragListener.java
// public interface ItemDragListener {
// void onStartDrags(RecyclerView.ViewHolder viewHolder);
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/listener/ItemMoveListener.java
// public interface ItemMoveListener {
// boolean onItemMove(int fromPosition, int toPosition);
//
// boolean onItemRemove(int position);
// }
|
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.listener.ItemDragListener;
import com.lqr.materialdesigndemo.listener.ItemMoveListener;
import java.util.Collections;
import java.util.List;
|
package com.lqr.materialdesigndemo.adapter;
public class ItemTouchHelperAdapter extends RecyclerView.Adapter<ItemTouchHelperAdapter.ItemTouchHelperViewHolder> implements ItemMoveListener {
private List<String> mData;
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/listener/ItemDragListener.java
// public interface ItemDragListener {
// void onStartDrags(RecyclerView.ViewHolder viewHolder);
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/listener/ItemMoveListener.java
// public interface ItemMoveListener {
// boolean onItemMove(int fromPosition, int toPosition);
//
// boolean onItemRemove(int position);
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/ItemTouchHelperAdapter.java
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.listener.ItemDragListener;
import com.lqr.materialdesigndemo.listener.ItemMoveListener;
import java.util.Collections;
import java.util.List;
package com.lqr.materialdesigndemo.adapter;
public class ItemTouchHelperAdapter extends RecyclerView.Adapter<ItemTouchHelperAdapter.ItemTouchHelperViewHolder> implements ItemMoveListener {
private List<String> mData;
|
private ItemDragListener mItemDragListener;
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityOne.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java
// public class MyDecorationOne extends RecyclerView.ItemDecoration {
//
// int orientation = RecyclerView.HORIZONTAL;
// private final Drawable mDivider;
//
// public MyDecorationOne(Context context, int orientation) {
// this.orientation = orientation;
// int[] attrs = new int[]{android.R.attr.listDivider};
// TypedArray a = context.obtainStyledAttributes(attrs);
// mDivider = a.getDrawable(0);
// a.recycle();
// }
//
// /**
// * 画线
// */
// @Override
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// super.onDraw(c, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// drawVertical(c, parent, state);
// } else if (orientation == RecyclerView.VERTICAL) {
// drawHorizontal(c, parent, state);
// }
// }
//
// private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getRight() + params.rightMargin;
// int top = child.getTop() - params.topMargin;
// int right = left + mDivider.getIntrinsicWidth();
// int bottom = child.getBottom() + params.bottomMargin;
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getLeft() - params.leftMargin;
// int top = child.getBottom() + params.bottomMargin;
// int right = child.getRight() + params.rightMargin;
// int bottom = top + mDivider.getIntrinsicHeight();
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
//
// /**
// * 设置条目周边的偏移量
// */
// @Override
// public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// super.getItemOffsets(outRect, view, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// //画垂直线
// outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
// } else if (orientation == RecyclerView.VERTICAL) {
// //画水平线
// outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
// }
// }
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
import java.util.ArrayList;
import java.util.List;
|
package com.lqr.materialdesigndemo.activity;
/**
* @创建者 CSDN_LQR
* @描述 RecyclerView的分割线
*/
public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java
// public class MyDecorationOne extends RecyclerView.ItemDecoration {
//
// int orientation = RecyclerView.HORIZONTAL;
// private final Drawable mDivider;
//
// public MyDecorationOne(Context context, int orientation) {
// this.orientation = orientation;
// int[] attrs = new int[]{android.R.attr.listDivider};
// TypedArray a = context.obtainStyledAttributes(attrs);
// mDivider = a.getDrawable(0);
// a.recycle();
// }
//
// /**
// * 画线
// */
// @Override
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// super.onDraw(c, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// drawVertical(c, parent, state);
// } else if (orientation == RecyclerView.VERTICAL) {
// drawHorizontal(c, parent, state);
// }
// }
//
// private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getRight() + params.rightMargin;
// int top = child.getTop() - params.topMargin;
// int right = left + mDivider.getIntrinsicWidth();
// int bottom = child.getBottom() + params.bottomMargin;
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getLeft() - params.leftMargin;
// int top = child.getBottom() + params.bottomMargin;
// int right = child.getRight() + params.rightMargin;
// int bottom = top + mDivider.getIntrinsicHeight();
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
//
// /**
// * 设置条目周边的偏移量
// */
// @Override
// public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// super.getItemOffsets(outRect, view, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// //画垂直线
// outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
// } else if (orientation == RecyclerView.VERTICAL) {
// //画水平线
// outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
// }
// }
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityOne.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
import java.util.ArrayList;
import java.util.List;
package com.lqr.materialdesigndemo.activity;
/**
* @创建者 CSDN_LQR
* @描述 RecyclerView的分割线
*/
public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
|
private MyAdapter mMyAdapter;
|
GitLqr/MaterialDesignDemo
|
app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityOne.java
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java
// public class MyDecorationOne extends RecyclerView.ItemDecoration {
//
// int orientation = RecyclerView.HORIZONTAL;
// private final Drawable mDivider;
//
// public MyDecorationOne(Context context, int orientation) {
// this.orientation = orientation;
// int[] attrs = new int[]{android.R.attr.listDivider};
// TypedArray a = context.obtainStyledAttributes(attrs);
// mDivider = a.getDrawable(0);
// a.recycle();
// }
//
// /**
// * 画线
// */
// @Override
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// super.onDraw(c, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// drawVertical(c, parent, state);
// } else if (orientation == RecyclerView.VERTICAL) {
// drawHorizontal(c, parent, state);
// }
// }
//
// private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getRight() + params.rightMargin;
// int top = child.getTop() - params.topMargin;
// int right = left + mDivider.getIntrinsicWidth();
// int bottom = child.getBottom() + params.bottomMargin;
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getLeft() - params.leftMargin;
// int top = child.getBottom() + params.bottomMargin;
// int right = child.getRight() + params.rightMargin;
// int bottom = top + mDivider.getIntrinsicHeight();
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
//
// /**
// * 设置条目周边的偏移量
// */
// @Override
// public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// super.getItemOffsets(outRect, view, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// //画垂直线
// outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
// } else if (orientation == RecyclerView.VERTICAL) {
// //画水平线
// outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
// }
// }
// }
|
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
import java.util.ArrayList;
import java.util.List;
|
package com.lqr.materialdesigndemo.activity;
/**
* @创建者 CSDN_LQR
* @描述 RecyclerView的分割线
*/
public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
private MyAdapter mMyAdapter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
mRv = (RecyclerView) findViewById(R.id.rv);
initView();
initData();
setRecyclerView();
}
private void initView() {
|
// Path: app/src/main/java/com/lqr/materialdesigndemo/adapter/MyAdapter.java
// public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {
//
// private List<String> mData;
//
// public MyAdapter(List<String> data) {
// mData = data;
// }
//
// @Override
// public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
// View itemView = View.inflate(parent.getContext(), android.R.layout.simple_list_item_1, null);
// itemView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
// return new MyViewHolder(itemView);
// }
//
// @Override
// public void onBindViewHolder(MyViewHolder holder, int position) {
// holder.mTv.setText(mData.get(position));
// }
//
// @Override
// public int getItemCount() {
// return mData.size();
// }
//
// class MyViewHolder extends RecyclerView.ViewHolder {
//
// TextView mTv;
//
// public MyViewHolder(View itemView) {
// super(itemView);
// mTv = (TextView) itemView.findViewById(android.R.id.text1);
// }
// }
//
// }
//
// Path: app/src/main/java/com/lqr/materialdesigndemo/decoration/MyDecorationOne.java
// public class MyDecorationOne extends RecyclerView.ItemDecoration {
//
// int orientation = RecyclerView.HORIZONTAL;
// private final Drawable mDivider;
//
// public MyDecorationOne(Context context, int orientation) {
// this.orientation = orientation;
// int[] attrs = new int[]{android.R.attr.listDivider};
// TypedArray a = context.obtainStyledAttributes(attrs);
// mDivider = a.getDrawable(0);
// a.recycle();
// }
//
// /**
// * 画线
// */
// @Override
// public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
// super.onDraw(c, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// drawVertical(c, parent, state);
// } else if (orientation == RecyclerView.VERTICAL) {
// drawHorizontal(c, parent, state);
// }
// }
//
// private void drawVertical(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getRight() + params.rightMargin;
// int top = child.getTop() - params.topMargin;
// int right = left + mDivider.getIntrinsicWidth();
// int bottom = child.getBottom() + params.bottomMargin;
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
// private void drawHorizontal(Canvas c, RecyclerView parent, RecyclerView.State state) {
// int childCount = parent.getChildCount();
// for (int i = 0; i < childCount; i++) {
// View child = parent.getChildAt(i);
// RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
// int left = child.getLeft() - params.leftMargin;
// int top = child.getBottom() + params.bottomMargin;
// int right = child.getRight() + params.rightMargin;
// int bottom = top + mDivider.getIntrinsicHeight();
// mDivider.setBounds(left, top, right, bottom);
// mDivider.draw(c);
// }
// }
//
//
// /**
// * 设置条目周边的偏移量
// */
// @Override
// public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
// super.getItemOffsets(outRect, view, parent, state);
// if (orientation == RecyclerView.HORIZONTAL) {
// //画垂直线
// outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
// } else if (orientation == RecyclerView.VERTICAL) {
// //画水平线
// outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
// }
// }
// }
// Path: app/src/main/java/com/lqr/materialdesigndemo/activity/RecyclerVIewDecorationActivityOne.java
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.lqr.materialdesigndemo.R;
import com.lqr.materialdesigndemo.adapter.MyAdapter;
import com.lqr.materialdesigndemo.decoration.MyDecorationOne;
import java.util.ArrayList;
import java.util.List;
package com.lqr.materialdesigndemo.activity;
/**
* @创建者 CSDN_LQR
* @描述 RecyclerView的分割线
*/
public class RecyclerVIewDecorationActivityOne extends AppCompatActivity {
private List<String> mData = new ArrayList<>();
private RecyclerView mRv;
private MyAdapter mMyAdapter;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recycler_view);
mRv = (RecyclerView) findViewById(R.id.rv);
initView();
initData();
setRecyclerView();
}
private void initView() {
|
MyDecorationOne decorationOne = new MyDecorationOne(this, LinearLayoutManager.VERTICAL);
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Term.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
|
}
public void setSentimentModifier(String val) {
sentimentModifier = val;
}
public boolean hasSentimentMarker() {
return sentimentMarker != null;
}
public String getSentimentMarker() {
return sentimentMarker;
}
public void setSentimentMarker(String val) {
sentimentMarker = val;
}
public boolean hasSentimentProductFeature() {
return sentimentProductFeature != null;
}
public String getSentimentProductFeature() {
return sentimentProductFeature;
}
public void setSentimentProductFeature(String val) {
sentimentProductFeature = val;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Term.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
}
public void setSentimentModifier(String val) {
sentimentModifier = val;
}
public boolean hasSentimentMarker() {
return sentimentMarker != null;
}
public String getSentimentMarker() {
return sentimentMarker;
}
public void setSentimentMarker(String val) {
sentimentMarker = val;
}
public boolean hasSentimentProductFeature() {
return sentimentProductFeature != null;
}
public String getSentimentProductFeature() {
return sentimentProductFeature;
}
public void setSentimentProductFeature(String val) {
sentimentProductFeature = val;
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Predicate.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
|
}
public String getSemRole() {
return this.semRole;
}
public void setSemRole(String semRole) {
this.semRole = semRole;
}
public Span<Term> getSpan() {
return this.span;
}
public void setSpan(Span<Term> span) {
this.span = span;
}
public List<Term> getTerms() {
return this.span.getTargets();
}
public void addTerm(Term term) {
this.span.addTarget(term);
}
public void addTerm(Term term, boolean isHead) {
this.span.addTarget(term, isHead);
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Predicate.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
}
public String getSemRole() {
return this.semRole;
}
public void setSemRole(String semRole) {
this.semRole = semRole;
}
public Span<Term> getSpan() {
return this.span;
}
public void setSpan(Span<Term> span) {
this.span = span;
}
public List<Term> getTerms() {
return this.span.getTargets();
}
public void addTerm(Term term) {
this.span.addTarget(term);
}
public void addTerm(Term term, boolean isHead) {
this.span.addTarget(term, isHead);
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/TLink.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
|
}
public void setFrom(TLinkReferable from) {
this.from = from;
}
public TLinkReferable getTo() {
return this.to;
}
public void setTo(TLinkReferable to) {
this.to = to;
}
public String getFromType() {
return (this.from instanceof Predicate) ? "event" : "timex";
}
public String getToType() {
return (this.to instanceof Predicate) ? "event" : "timex";
}
public String getRelType() {
return this.relType;
}
public void setRelType(String relType) {
this.relType = relType;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/TLink.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
}
public void setFrom(TLinkReferable from) {
this.from = from;
}
public TLinkReferable getTo() {
return this.to;
}
public void setTo(TLinkReferable to) {
this.to = to;
}
public String getFromType() {
return (this.from instanceof Predicate) ? "event" : "timex";
}
public String getToType() {
return (this.to instanceof Predicate) ? "event" : "timex";
}
public String getRelType() {
return this.relType;
}
public void setRelType(String relType) {
this.relType = relType;
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Factvalue.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package ixa.kaflib;
/**
* Factuality layer
*/
public class Factvalue extends Annotation implements SentenceLevelAnnotation {
private WF word;
private String prediction;
private Double confidence;
//ArrayList<FactualityPart> factualityParts = new ArrayList<FactualityPart>();
Factvalue(WF word, String prediction) {
this.word = word;
this.prediction = prediction;
}
public String getId() {
return this.word.getId();
}
public WF getWF() {
return word;
}
public String getPrediction() {
return this.prediction;
}
public void setPrediction(String prediction) {
this.prediction = prediction;
}
public boolean hasConfidence() {
return this.confidence != null;
}
public void setConfidence(Double confidence) {
this.confidence = confidence;
}
public Double getConfidence() {
return this.confidence;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Factvalue.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package ixa.kaflib;
/**
* Factuality layer
*/
public class Factvalue extends Annotation implements SentenceLevelAnnotation {
private WF word;
private String prediction;
private Double confidence;
//ArrayList<FactualityPart> factualityParts = new ArrayList<FactualityPart>();
Factvalue(WF word, String prediction) {
this.word = word;
this.prediction = prediction;
}
public String getId() {
return this.word.getId();
}
public WF getWF() {
return word;
}
public String getPrediction() {
return this.prediction;
}
public void setPrediction(String prediction) {
this.prediction = prediction;
}
public boolean hasConfidence() {
return this.confidence != null;
}
public void setConfidence(Double confidence) {
this.confidence = confidence;
}
public Double getConfidence() {
return this.confidence;
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Entity.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
|
package ixa.kaflib;
/** A named entity is a term (or a multiword) that clearly identifies one item. The optional Named Entity layer is used to reference terms that are named entities. */
public class Entity extends IdentifiableAnnotation implements Relational, SentenceLevelAnnotation {
/** Type of the named entity (optional). Currently, 8 values are possible:
* - Person
* - Organization
* - Location
* - Date
* - Time
* - Money
* - Percent
* - Misc
* - GPE (stands for Geo-Political Entity)
*/
private String type;
private String source;
/** Reference to different occurrences of the same named entity in the document (at least one required) */
private List<Span<Term>> references;
/** External references (optional) */
private List<ExternalRef> externalReferences;
Entity(String id, List<Span<Term>> references) {
super(id);
if (references.size() < 1) {
throw new IllegalStateException("Entities must contain at least one reference span");
}
if (references.get(0).size() < 1) {
throw new IllegalStateException("Entities' reference's spans must contain at least one target");
}
this.references = references;
this.externalReferences = new ArrayList<ExternalRef>();
}
Entity(Entity entity, HashMap<String, Term> terms) {
super(entity.getId());
this.type = entity.type;
/* Copy references */
String id = entity.getId();
this.references = new ArrayList<Span<Term>>();
for (Span<Term> span : entity.getSpans()) {
/* Copy span */
List<Term> targets = span.getTargets();
List<Term> copiedTargets = new ArrayList<Term>();
for (Term term : targets) {
Term copiedTerm = terms.get(term.getId());
if (copiedTerm == null) {
throw new IllegalStateException("Term not found when copying " + id);
}
copiedTargets.add(copiedTerm);
}
if (span.hasHead()) {
Term copiedHead = terms.get(span.getHead().getId());
this.references.add(new Span<Term>(copiedTargets, copiedHead));
}
else {
this.references.add(new Span<Term>(copiedTargets));
}
}
/* Copy external references */
this.externalReferences = new ArrayList<ExternalRef>();
for (ExternalRef externalRef : entity.getExternalRefs()) {
this.externalReferences.add(new ExternalRef(externalRef));
}
}
public boolean hasType() {
return type != null;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean hasSource() {
return source != null;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
/** Returns the term targets of the first span. When targets of other spans are needed getReferences() method should be used. */
public List<Term> getTerms() {
return this.references.get(0).getTargets();
}
/** Adds a term to the first span. */
public void addTerm(Term term) {
this.references.get(0).addTarget(term);
}
/** Adds a term to the first span. */
public void addTerm(Term term, boolean isHead) {
this.references.get(0).addTarget(term, isHead);
}
public List<Span<Term>> getSpans() {
return this.references;
}
public void addSpan(Span<Term> span) {
this.references.add(span);
}
public List<ExternalRef> getExternalRefs() {
return externalReferences;
}
public void addExternalRef(ExternalRef externalRef) {
externalReferences.add(externalRef);
}
public void addExternalRefs(List<ExternalRef> externalRefs) {
externalReferences.addAll(externalRefs);
}
public String getSpanStr(Span<Term> span) {
String str = "";
for (Term term : span.getTargets()) {
if (!str.isEmpty()) {
str += " ";
}
str += term.getStr();
}
return str;
}
public String getStr() {
return getSpanStr(this.getSpans().get(0));
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Entity.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
package ixa.kaflib;
/** A named entity is a term (or a multiword) that clearly identifies one item. The optional Named Entity layer is used to reference terms that are named entities. */
public class Entity extends IdentifiableAnnotation implements Relational, SentenceLevelAnnotation {
/** Type of the named entity (optional). Currently, 8 values are possible:
* - Person
* - Organization
* - Location
* - Date
* - Time
* - Money
* - Percent
* - Misc
* - GPE (stands for Geo-Political Entity)
*/
private String type;
private String source;
/** Reference to different occurrences of the same named entity in the document (at least one required) */
private List<Span<Term>> references;
/** External references (optional) */
private List<ExternalRef> externalReferences;
Entity(String id, List<Span<Term>> references) {
super(id);
if (references.size() < 1) {
throw new IllegalStateException("Entities must contain at least one reference span");
}
if (references.get(0).size() < 1) {
throw new IllegalStateException("Entities' reference's spans must contain at least one target");
}
this.references = references;
this.externalReferences = new ArrayList<ExternalRef>();
}
Entity(Entity entity, HashMap<String, Term> terms) {
super(entity.getId());
this.type = entity.type;
/* Copy references */
String id = entity.getId();
this.references = new ArrayList<Span<Term>>();
for (Span<Term> span : entity.getSpans()) {
/* Copy span */
List<Term> targets = span.getTargets();
List<Term> copiedTargets = new ArrayList<Term>();
for (Term term : targets) {
Term copiedTerm = terms.get(term.getId());
if (copiedTerm == null) {
throw new IllegalStateException("Term not found when copying " + id);
}
copiedTargets.add(copiedTerm);
}
if (span.hasHead()) {
Term copiedHead = terms.get(span.getHead().getId());
this.references.add(new Span<Term>(copiedTargets, copiedHead));
}
else {
this.references.add(new Span<Term>(copiedTargets));
}
}
/* Copy external references */
this.externalReferences = new ArrayList<ExternalRef>();
for (ExternalRef externalRef : entity.getExternalRefs()) {
this.externalReferences.add(new ExternalRef(externalRef));
}
}
public boolean hasType() {
return type != null;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public boolean hasSource() {
return source != null;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
/** Returns the term targets of the first span. When targets of other spans are needed getReferences() method should be used. */
public List<Term> getTerms() {
return this.references.get(0).getTargets();
}
/** Adds a term to the first span. */
public void addTerm(Term term) {
this.references.get(0).addTarget(term);
}
/** Adds a term to the first span. */
public void addTerm(Term term, boolean isHead) {
this.references.get(0).addTarget(term, isHead);
}
public List<Span<Term>> getSpans() {
return this.references;
}
public void addSpan(Span<Term> span) {
this.references.add(span);
}
public List<ExternalRef> getExternalRefs() {
return externalReferences;
}
public void addExternalRef(ExternalRef externalRef) {
externalReferences.add(externalRef);
}
public void addExternalRefs(List<ExternalRef> externalRefs) {
externalReferences.addAll(externalRefs);
}
public String getSpanStr(Span<Term> span) {
String str = "";
for (Term term : span.getTargets()) {
if (!str.isEmpty()) {
str += " ";
}
str += term.getStr();
}
return str;
}
public String getStr() {
return getSpanStr(this.getSpans().get(0));
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Statement.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
|
}
public void setTarget(StatementTarget target) {
this.target = target;
}
public Boolean hasSource() {
return this.source != null;
}
public StatementSource getSource() {
return this.source;
}
public void setSource(StatementSource source) {
this.source = source;
}
public Boolean hasCue() {
return this.cue != null;
}
public StatementCue getCue() {
return this.cue;
}
public void setCue(StatementCue cue) {
this.cue = cue;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Statement.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
}
public void setTarget(StatementTarget target) {
this.target = target;
}
public Boolean hasSource() {
return this.source != null;
}
public StatementSource getSource() {
return this.source;
}
public void setSource(StatementSource source) {
this.source = source;
}
public Boolean hasCue() {
return this.cue != null;
}
public StatementCue getCue() {
return this.cue;
}
public void setCue(StatementCue cue) {
this.cue = cue;
}
|
public Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Topic.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
//
// Path: src/main/java/ixa/kaflib/Statement.java
// public static class StatementSource extends Annotation {
// private Span<Term> span;
//
// public StatementSource(Span<Term> span) {
// this.span = span;
// }
//
// public Span<Term> getSpan() {
// return this.span;
// }
//
// public void setSpan(Span<Term> span) {
// this.span = span;
// }
//
// public Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
// Map<AnnotationType, List<Annotation>> refs = new HashMap<AnnotationType, List<Annotation>>();
// List<Annotation> terms = new ArrayList<Annotation>();
// for (Term t : this.getSpan().getTargets()) {
// terms.add(t);
// }
// refs.put(AnnotationType.TERM, terms);
// return refs;
// }
//
// /*
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof StatementSource)) return false;
// StatementSource ann = (StatementSource) o;
// return Utils.areEquals(this.span, ann.span);
// }
// */
// }
|
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import ixa.kaflib.Statement.StatementSource;
|
}
public void setConfidence(Float val) {
confidence = val;
}
public boolean hasConfidence() {
return this.confidence != null;
}
public String getURI() {
return this.URI;
}
public void setURI(String val) {
URI = val;
}
public boolean hasURI() {
return this.URI != null;
}
public String getTopicValue() {
return this.value;
}
public void setTopicValue(String val) {
value = val;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
//
// Path: src/main/java/ixa/kaflib/Statement.java
// public static class StatementSource extends Annotation {
// private Span<Term> span;
//
// public StatementSource(Span<Term> span) {
// this.span = span;
// }
//
// public Span<Term> getSpan() {
// return this.span;
// }
//
// public void setSpan(Span<Term> span) {
// this.span = span;
// }
//
// public Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
// Map<AnnotationType, List<Annotation>> refs = new HashMap<AnnotationType, List<Annotation>>();
// List<Annotation> terms = new ArrayList<Annotation>();
// for (Term t : this.getSpan().getTargets()) {
// terms.add(t);
// }
// refs.put(AnnotationType.TERM, terms);
// return refs;
// }
//
// /*
// @Override
// public boolean equals(Object o) {
// if (this == o) return true;
// if (!(o instanceof StatementSource)) return false;
// StatementSource ann = (StatementSource) o;
// return Utils.areEquals(this.span, ann.span);
// }
// */
// }
// Path: src/main/java/ixa/kaflib/Topic.java
import java.util.HashMap;
import java.util.Map;
import java.util.List;
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import ixa.kaflib.Statement.StatementSource;
}
public void setConfidence(Float val) {
confidence = val;
}
public boolean hasConfidence() {
return this.confidence != null;
}
public String getURI() {
return this.URI;
}
public void setURI(String val) {
URI = val;
}
public boolean hasURI() {
return this.URI != null;
}
public String getTopicValue() {
return this.value;
}
public void setTopicValue(String val) {
value = val;
}
|
public Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Mark.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
|
}
public void setSpan(Span<WF> span) {
this.span = span;
}
public boolean hasSentiment() {
return this.sentiment != null;
}
public Term.Sentiment getSentiment() {
return this.sentiment;
}
public void setSentiment(Term.Sentiment sentiment) {
this.sentiment = sentiment;
}
public List<ExternalRef> getExternalRefs() {
return externalReferences;
}
public void addExternalRef(ExternalRef externalRef) {
externalReferences.add(externalRef);
}
public void addExternalRefs(List<ExternalRef> externalRefs) {
externalReferences.addAll(externalRefs);
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Mark.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
}
public void setSpan(Span<WF> span) {
this.span = span;
}
public boolean hasSentiment() {
return this.sentiment != null;
}
public Term.Sentiment getSentiment() {
return this.sentiment;
}
public void setSentiment(Term.Sentiment sentiment) {
this.sentiment = sentiment;
}
public List<ExternalRef> getExternalRefs() {
return externalReferences;
}
public void addExternalRef(ExternalRef externalRef) {
externalReferences.add(externalRef);
}
public void addExternalRefs(List<ExternalRef> externalRefs) {
externalReferences.addAll(externalRefs);
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/CLink.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
|
}
public Predicate getFrom() {
return this.from;
}
public void setFrom(Predicate from) {
this.from = from;
}
public Predicate getTo() {
return this.to;
}
public void setTo(Predicate to) {
this.to = to;
}
public boolean hasRelType() {
return this.relType != null;
}
public String getRelType() {
return this.relType;
}
public void setRelType(String relType) {
this.relType = relType;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/CLink.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
}
public Predicate getFrom() {
return this.from;
}
public void setFrom(Predicate from) {
this.from = from;
}
public Predicate getTo() {
return this.to;
}
public void setTo(Predicate to) {
this.to = to;
}
public boolean hasRelType() {
return this.relType != null;
}
public String getRelType() {
return this.relType;
}
public void setRelType(String relType) {
this.relType = relType;
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Factuality.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
|
package ixa.kaflib;
public class Factuality extends IdentifiableAnnotation implements SentenceLevelAnnotation {
private Span<Term> span;
private List<FactVal> factVals;
Factuality(String id, Span<Term> span) {
super(id);
this.span = span;
this.factVals = new ArrayList<FactVal>();
}
public String getId() {
return this.id;
}
public Span<Term> getSpan() {
return this.span;
}
public List<FactVal> getFactVals() {
return this.factVals;
}
public void addFactVal(FactVal factVal) {
this.factVals.add(factVal);
}
@Override
public Integer getPara() {
return this.span.getFirstTarget().getPara();
}
@Override
public Integer getSent() {
return this.span.getFirstTarget().getSent();
}
@Override
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Factuality.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;
package ixa.kaflib;
public class Factuality extends IdentifiableAnnotation implements SentenceLevelAnnotation {
private Span<Term> span;
private List<FactVal> factVals;
Factuality(String id, Span<Term> span) {
super(id);
this.span = span;
this.factVals = new ArrayList<FactVal>();
}
public String getId() {
return this.id;
}
public Span<Term> getSpan() {
return this.span;
}
public List<FactVal> getFactVals() {
return this.factVals;
}
public void addFactVal(FactVal factVal) {
this.factVals.add(factVal);
}
@Override
public Integer getPara() {
return this.span.getFirstTarget().getPara();
}
@Override
public Integer getSent() {
return this.span.getFirstTarget().getSent();
}
@Override
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/Timex3.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
|
}
public Integer getPara() {
return this.span.getFirstTarget().getPara();
}
*/
public boolean hasSpan() {
return this.span != null;
}
public Span<WF> getSpan() {
return this.span;
}
public void setSpan(Span<WF> span) {
this.span = span;
}
public String getSpanStr(Span<WF> span) {
String str = "";
for (WF wf : span.getTargets()) {
if (!str.isEmpty()) {
str += " ";
}
str += wf.getForm();
}
return str;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/Timex3.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
}
public Integer getPara() {
return this.span.getFirstTarget().getPara();
}
*/
public boolean hasSpan() {
return this.span != null;
}
public Span<WF> getSpan() {
return this.span;
}
public void setSpan(Span<WF> span) {
this.span = span;
}
public String getSpanStr(Span<WF> span) {
String str = "";
for (WF wf : span.getTargets()) {
if (!str.isEmpty()) {
str += " ";
}
str += wf.getForm();
}
return str;
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/LinkedEntity.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
|
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public double getConfidence() {
return confidence;
}
public void setConfidence(double confidence) {
this.confidence = confidence;
}
public Span<WF> getSpan() {
return this.mentions;
}
public String getSpanStr() {
String str = "";
for (WF wf : mentions.getTargets()) {
if (!str.isEmpty()) {
str += " ";
}
str += wf.getForm();
}
return str;
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// static class Utils {
// static boolean areEquals(Object a, Object b) {
// return (a == null) ? (b == null) : a.equals(b);
// }
// }
// Path: src/main/java/ixa/kaflib/LinkedEntity.java
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public double getConfidence() {
return confidence;
}
public void setConfidence(double confidence) {
this.confidence = confidence;
}
public Span<WF> getSpan() {
return this.mentions;
}
public String getSpanStr() {
String str = "";
for (WF wf : mentions.getTargets()) {
if (!str.isEmpty()) {
str += " ";
}
str += wf.getForm();
}
return str;
}
|
Map<AnnotationType, List<Annotation>> getReferencedAnnotations() {
|
ixa-ehu/kaflib
|
src/main/java/ixa/kaflib/ReadWriteManager.java
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum Layer {
// TEXT,
// TERMS,
// ENTITIES,
// CHUNKS,
// DEPS,
// CONSTITUENCY,
// COREFERENCES,
// OPINIONS,
// CAUSAL_RELATIONS,
// TEMPORAL_RELATIONS,
// SRL,
// TIME_EXPRESSIONS,
// FACTUALITIES,
// FACTUALITY_LAYER,
// MARKABLES,
// PROPERTIES,
// CATEGORIES,
// RELATIONS,
// LINKED_ENTITIES,
// TOPICS,
// ATTRIBUTION,
// }
|
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.jdom2.CDATA;
import org.jdom2.output.XMLOutputter;
import org.jdom2.output.Format;
import org.jdom2.output.LineSeparator;
import org.jdom2.input.SAXBuilder;
import org.jdom2.JDOMException;
import org.jdom2.xpath.XPathExpression;
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Layer;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Collections;
import java.util.Comparator;
import java.util.Set;
import java.io.File;
import java.io.Writer;
import java.io.Reader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.regex.*;
import org.apache.commons.lang3.StringEscapeUtils;
|
Element roleElem = new Element("role");
roleElem.setAttribute("id", role.getId());
roleElem.setAttribute("semRole", role.getSemRole());
Span<Term> roleSpan = role.getSpan();
if (roleSpan.getTargets().size() > 0) {
Comment spanComment = new Comment(StringEscapeUtils.escapeXml11(role.getStr()));
Element spanElem = new Element("span");
roleElem.addContent(spanComment);
roleElem.addContent(spanElem);
for (Term target : roleSpan.getTargets()) {
Element targetElem = new Element("target");
targetElem.setAttribute("id", target.getId());
if (target == roleSpan.getHead()) {
targetElem.setAttribute("head", "yes");
}
spanElem.addContent(targetElem);
}
}
List<ExternalRef> rExternalReferences = role.getExternalRefs();
if (rExternalReferences.size() > 0) {
Element externalReferencesElem = externalReferencesToDOM(rExternalReferences);
roleElem.addContent(externalReferencesElem);
}
predicateElem.addContent(roleElem);
}
predicatesElem.addContent(predicateElem);
}
root.addContent(predicatesElem);
}
|
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum AnnotationType {
// WF,
// TERM,
// MW,
// COMPONENT,
// SENTIMENT,
// ENTITY,
// CHUNK,
// DEP,
// TREE,
// NON_TERMINAL,
// TERMINAL,
// EDGE,
// COREF,
// OPINION, /* DOC_LVL */
// OPINION_HOLDER,
// OPINION_TARGET,
// OPINION_EXPRESSION,
// CLINK,
// TLINK,
// PREDICATE_ANCHOR,
// PREDICATE,
// ROLE,
// TIMEX3,
// FACTUALITY,
// FACTVALUE,
// MARK,
// PROPERTY,
// CATEGORY,
// LINKED_ENTITY,
// RELATION,
// TOPIC,
// STATEMENT,
// STATEMENT_TARGET,
// STATEMENT_SOURCE,
// STATEMENT_CUE,
// }
//
// Path: src/main/java/ixa/kaflib/KAFDocument.java
// public enum Layer {
// TEXT,
// TERMS,
// ENTITIES,
// CHUNKS,
// DEPS,
// CONSTITUENCY,
// COREFERENCES,
// OPINIONS,
// CAUSAL_RELATIONS,
// TEMPORAL_RELATIONS,
// SRL,
// TIME_EXPRESSIONS,
// FACTUALITIES,
// FACTUALITY_LAYER,
// MARKABLES,
// PROPERTIES,
// CATEGORIES,
// RELATIONS,
// LINKED_ENTITIES,
// TOPICS,
// ATTRIBUTION,
// }
// Path: src/main/java/ixa/kaflib/ReadWriteManager.java
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.Namespace;
import org.jdom2.CDATA;
import org.jdom2.output.XMLOutputter;
import org.jdom2.output.Format;
import org.jdom2.output.LineSeparator;
import org.jdom2.input.SAXBuilder;
import org.jdom2.JDOMException;
import org.jdom2.xpath.XPathExpression;
import ixa.kaflib.KAFDocument.AnnotationType;
import ixa.kaflib.KAFDocument.Layer;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Collections;
import java.util.Comparator;
import java.util.Set;
import java.io.File;
import java.io.Writer;
import java.io.Reader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.regex.*;
import org.apache.commons.lang3.StringEscapeUtils;
Element roleElem = new Element("role");
roleElem.setAttribute("id", role.getId());
roleElem.setAttribute("semRole", role.getSemRole());
Span<Term> roleSpan = role.getSpan();
if (roleSpan.getTargets().size() > 0) {
Comment spanComment = new Comment(StringEscapeUtils.escapeXml11(role.getStr()));
Element spanElem = new Element("span");
roleElem.addContent(spanComment);
roleElem.addContent(spanElem);
for (Term target : roleSpan.getTargets()) {
Element targetElem = new Element("target");
targetElem.setAttribute("id", target.getId());
if (target == roleSpan.getHead()) {
targetElem.setAttribute("head", "yes");
}
spanElem.addContent(targetElem);
}
}
List<ExternalRef> rExternalReferences = role.getExternalRefs();
if (rExternalReferences.size() > 0) {
Element externalReferencesElem = externalReferencesToDOM(rExternalReferences);
roleElem.addContent(externalReferencesElem);
}
predicateElem.addContent(roleElem);
}
predicatesElem.addContent(predicateElem);
}
root.addContent(predicatesElem);
}
|
List<String> treeTypes = annotationContainer.getGroupIDs(AnnotationType.TREE);
|
pivotal-bank/web-ui
|
src/main/java/io/pivotal/web/service/AccountService.java
|
// Path: src/main/java/io/pivotal/web/domain/Account.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// @Data
// public class Account {
//
// @JsonProperty("id")
// private Integer id;
//
// @JsonProperty("name")
// private String name;
//
// @JsonProperty("creationdate")
// @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss")
// private Date creationdate;
//
// @JsonProperty("openbalance")
// private BigDecimal openbalance;
//
// @JsonProperty("balance")
// private BigDecimal balance;
//
// @JsonProperty("type")
// private String type;
//
// @JsonProperty("currency")
// private String currency;
//
// }
|
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.Account;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.hystrix.HystrixCommands;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import java.util.ArrayList;
import java.util.List;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
|
package io.pivotal.web.service;
@Service
@RefreshScope
public class AccountService {
private static final Logger logger = LoggerFactory
.getLogger(AccountService.class);
@Autowired
private WebClient webClient;
@Value("${pivotal.accountsService.name}")
private String accountsService;
@Trace(async = true)
|
// Path: src/main/java/io/pivotal/web/domain/Account.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// @Data
// public class Account {
//
// @JsonProperty("id")
// private Integer id;
//
// @JsonProperty("name")
// private String name;
//
// @JsonProperty("creationdate")
// @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss")
// private Date creationdate;
//
// @JsonProperty("openbalance")
// private BigDecimal openbalance;
//
// @JsonProperty("balance")
// private BigDecimal balance;
//
// @JsonProperty("type")
// private String type;
//
// @JsonProperty("currency")
// private String currency;
//
// }
// Path: src/main/java/io/pivotal/web/service/AccountService.java
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.Account;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.hystrix.HystrixCommands;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import java.util.ArrayList;
import java.util.List;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
package io.pivotal.web.service;
@Service
@RefreshScope
public class AccountService {
private static final Logger logger = LoggerFactory
.getLogger(AccountService.class);
@Autowired
private WebClient webClient;
@Value("${pivotal.accountsService.name}")
private String accountsService;
@Trace(async = true)
|
public void createAccount(Account account, OAuth2AuthorizedClient oAuth2AuthorizedClient ) {
|
pivotal-bank/web-ui
|
src/main/java/io/pivotal/web/controller/UserController.java
|
// Path: src/main/java/io/pivotal/web/domain/RegistrationRequest.java
// @Data
// public class RegistrationRequest {
//
// @NotNull
// @NotEmpty
// private String givenNames;
//
// private String surname;
//
// @NotNull
// @NotEmpty
// @Email
// private String email;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String password;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String confirmPassword;
// }
|
import io.pivotal.web.domain.RegistrationRequest;
import io.pivotal.web.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.validation.Valid;
import java.security.Principal;
|
@Autowired
private PortfolioService portfolioService;
@Autowired
private MarketSummaryService summaryService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String showHome(Model model,Principal princ, @AuthenticationPrincipal OAuth2User principal){
//check if user is logged in!
if (principal != null) {
return "redirect:/home";
}
model.addAttribute("marketSummary", summaryService.getMarketSummary());
return "index";
}
@GetMapping("/home")
public String authorizedHome(Model model, @AuthenticationPrincipal OAuth2User principal, @RegisteredOAuth2AuthorizedClient("pivotalbank") OAuth2AuthorizedClient oAuth2AuthorizedClient) {
model.addAttribute("marketSummary", summaryService.getMarketSummary());
String currentUserName = principal.getName();
log.debug("User logged in: " + currentUserName);
model.addAttribute("accounts",accountService.getAccounts(oAuth2AuthorizedClient));
model.addAttribute("portfolio",portfolioService.getPortfolio(oAuth2AuthorizedClient));
model.addAttribute("user", userService.getUser(currentUserName, oAuth2AuthorizedClient, principal));
return "index";
}
@RequestMapping(value = "/registration", method = RequestMethod.GET)
public String registration(Model model) {
|
// Path: src/main/java/io/pivotal/web/domain/RegistrationRequest.java
// @Data
// public class RegistrationRequest {
//
// @NotNull
// @NotEmpty
// private String givenNames;
//
// private String surname;
//
// @NotNull
// @NotEmpty
// @Email
// private String email;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String password;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String confirmPassword;
// }
// Path: src/main/java/io/pivotal/web/controller/UserController.java
import io.pivotal.web.domain.RegistrationRequest;
import io.pivotal.web.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.validation.Valid;
import java.security.Principal;
@Autowired
private PortfolioService portfolioService;
@Autowired
private MarketSummaryService summaryService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String showHome(Model model,Principal princ, @AuthenticationPrincipal OAuth2User principal){
//check if user is logged in!
if (principal != null) {
return "redirect:/home";
}
model.addAttribute("marketSummary", summaryService.getMarketSummary());
return "index";
}
@GetMapping("/home")
public String authorizedHome(Model model, @AuthenticationPrincipal OAuth2User principal, @RegisteredOAuth2AuthorizedClient("pivotalbank") OAuth2AuthorizedClient oAuth2AuthorizedClient) {
model.addAttribute("marketSummary", summaryService.getMarketSummary());
String currentUserName = principal.getName();
log.debug("User logged in: " + currentUserName);
model.addAttribute("accounts",accountService.getAccounts(oAuth2AuthorizedClient));
model.addAttribute("portfolio",portfolioService.getPortfolio(oAuth2AuthorizedClient));
model.addAttribute("user", userService.getUser(currentUserName, oAuth2AuthorizedClient, principal));
return "index";
}
@RequestMapping(value = "/registration", method = RequestMethod.GET)
public String registration(Model model) {
|
model.addAttribute("registration", new RegistrationRequest());
|
pivotal-bank/web-ui
|
src/main/java/io/pivotal/web/controller/AccountsController.java
|
// Path: src/main/java/io/pivotal/web/domain/Account.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// @Data
// public class Account {
//
// @JsonProperty("id")
// private Integer id;
//
// @JsonProperty("name")
// private String name;
//
// @JsonProperty("creationdate")
// @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss")
// private Date creationdate;
//
// @JsonProperty("openbalance")
// private BigDecimal openbalance;
//
// @JsonProperty("balance")
// private BigDecimal balance;
//
// @JsonProperty("type")
// private String type;
//
// @JsonProperty("currency")
// private String currency;
//
// }
//
// Path: src/main/java/io/pivotal/web/domain/Order.java
// @Data
// public class Order {
//
// private Integer orderId;
//
// private Integer accountId;
//
// private String symbol;
//
// private BigDecimal orderFee;
//
// private Date completionDate;
//
// private OrderType orderType;
//
// private BigDecimal price;
//
// private Integer quantity;
//
// private String currency;
//
//
//
// }
|
import java.math.BigDecimal;
import java.security.Principal;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import io.pivotal.web.domain.Account;
import io.pivotal.web.domain.Order;
import io.pivotal.web.domain.Search;
import io.pivotal.web.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.servlet.ModelAndView;
|
package io.pivotal.web.controller;
@Controller
@PreAuthorize("hasAuthority('ROLE_ACCOUNT')")
public class AccountsController {
private static final Logger logger = LoggerFactory
.getLogger(AccountsController.class);
@Autowired
private AccountService accountService;
@Autowired
private MarketSummaryService summaryService;
@RequestMapping(value = "/accounts", method = RequestMethod.GET)
public String accounts(Model model, @RegisteredOAuth2AuthorizedClient("pivotalbank") OAuth2AuthorizedClient oAuth2AuthorizedClient) {
logger.debug("/accounts");
model.addAttribute("marketSummary", summaryService.getMarketSummary());
model.addAttribute("accounts",accountService.getAccounts(oAuth2AuthorizedClient));
return "accounts";
}
@RequestMapping(value = "/openaccount", method = RequestMethod.GET)
public String openAccount(Model model) {
|
// Path: src/main/java/io/pivotal/web/domain/Account.java
// @JsonIgnoreProperties(ignoreUnknown = true)
// @Data
// public class Account {
//
// @JsonProperty("id")
// private Integer id;
//
// @JsonProperty("name")
// private String name;
//
// @JsonProperty("creationdate")
// @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd'T'HH:mm:ss")
// private Date creationdate;
//
// @JsonProperty("openbalance")
// private BigDecimal openbalance;
//
// @JsonProperty("balance")
// private BigDecimal balance;
//
// @JsonProperty("type")
// private String type;
//
// @JsonProperty("currency")
// private String currency;
//
// }
//
// Path: src/main/java/io/pivotal/web/domain/Order.java
// @Data
// public class Order {
//
// private Integer orderId;
//
// private Integer accountId;
//
// private String symbol;
//
// private BigDecimal orderFee;
//
// private Date completionDate;
//
// private OrderType orderType;
//
// private BigDecimal price;
//
// private Integer quantity;
//
// private String currency;
//
//
//
// }
// Path: src/main/java/io/pivotal/web/controller/AccountsController.java
import java.math.BigDecimal;
import java.security.Principal;
import java.util.Date;
import javax.servlet.http.HttpServletRequest;
import io.pivotal.web.domain.Account;
import io.pivotal.web.domain.Order;
import io.pivotal.web.domain.Search;
import io.pivotal.web.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.servlet.ModelAndView;
package io.pivotal.web.controller;
@Controller
@PreAuthorize("hasAuthority('ROLE_ACCOUNT')")
public class AccountsController {
private static final Logger logger = LoggerFactory
.getLogger(AccountsController.class);
@Autowired
private AccountService accountService;
@Autowired
private MarketSummaryService summaryService;
@RequestMapping(value = "/accounts", method = RequestMethod.GET)
public String accounts(Model model, @RegisteredOAuth2AuthorizedClient("pivotalbank") OAuth2AuthorizedClient oAuth2AuthorizedClient) {
logger.debug("/accounts");
model.addAttribute("marketSummary", summaryService.getMarketSummary());
model.addAttribute("accounts",accountService.getAccounts(oAuth2AuthorizedClient));
return "accounts";
}
@RequestMapping(value = "/openaccount", method = RequestMethod.GET)
public String openAccount(Model model) {
|
Account account = new Account();
|
pivotal-bank/web-ui
|
src/main/java/io/pivotal/web/service/PortfolioService.java
|
// Path: src/main/java/io/pivotal/web/domain/Order.java
// @Data
// public class Order {
//
// private Integer orderId;
//
// private Integer accountId;
//
// private String symbol;
//
// private BigDecimal orderFee;
//
// private Date completionDate;
//
// private OrderType orderType;
//
// private BigDecimal price;
//
// private Integer quantity;
//
// private String currency;
//
//
//
// }
|
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.Order;
import io.pivotal.web.domain.Portfolio;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.hystrix.HystrixCommands;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
|
package io.pivotal.web.service;
@Service
@RefreshScope
public class PortfolioService {
private static final Logger logger = LoggerFactory
.getLogger(PortfolioService.class);
@Autowired
private WebClient webClient;
@Value("${pivotal.portfolioService.name}")
private String portfolioService;
@Trace(async = true)
|
// Path: src/main/java/io/pivotal/web/domain/Order.java
// @Data
// public class Order {
//
// private Integer orderId;
//
// private Integer accountId;
//
// private String symbol;
//
// private BigDecimal orderFee;
//
// private Date completionDate;
//
// private OrderType orderType;
//
// private BigDecimal price;
//
// private Integer quantity;
//
// private String currency;
//
//
//
// }
// Path: src/main/java/io/pivotal/web/service/PortfolioService.java
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.Order;
import io.pivotal.web.domain.Portfolio;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.hystrix.HystrixCommands;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
package io.pivotal.web.service;
@Service
@RefreshScope
public class PortfolioService {
private static final Logger logger = LoggerFactory
.getLogger(PortfolioService.class);
@Autowired
private WebClient webClient;
@Value("${pivotal.portfolioService.name}")
private String portfolioService;
@Trace(async = true)
|
public Order sendOrder(Order order, OAuth2AuthorizedClient oAuth2AuthorizedClient ) {
|
pivotal-bank/web-ui
|
src/main/java/io/pivotal/web/service/UserService.java
|
// Path: src/main/java/io/pivotal/web/domain/RegistrationRequest.java
// @Data
// public class RegistrationRequest {
//
// @NotNull
// @NotEmpty
// private String givenNames;
//
// private String surname;
//
// @NotNull
// @NotEmpty
// @Email
// private String email;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String password;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String confirmPassword;
// }
//
// Path: src/main/java/io/pivotal/web/domain/User.java
// @Data
// public class User implements Serializable {
//
// private String id;
// private String email;
// private String givenNames;
// private String surname;
// private DateTime createdDate;
// private String jwt;
// }
|
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.RegistrationRequest;
import io.pivotal.web.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
|
package io.pivotal.web.service;
@Service
@RefreshScope
@Slf4j
public class UserService {
@Autowired(required = false)
private WebClient webClient;
@Value("${pivotal.userService.name}")
private String userService;
@Trace(async = true)
|
// Path: src/main/java/io/pivotal/web/domain/RegistrationRequest.java
// @Data
// public class RegistrationRequest {
//
// @NotNull
// @NotEmpty
// private String givenNames;
//
// private String surname;
//
// @NotNull
// @NotEmpty
// @Email
// private String email;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String password;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String confirmPassword;
// }
//
// Path: src/main/java/io/pivotal/web/domain/User.java
// @Data
// public class User implements Serializable {
//
// private String id;
// private String email;
// private String givenNames;
// private String surname;
// private DateTime createdDate;
// private String jwt;
// }
// Path: src/main/java/io/pivotal/web/service/UserService.java
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.RegistrationRequest;
import io.pivotal.web.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
package io.pivotal.web.service;
@Service
@RefreshScope
@Slf4j
public class UserService {
@Autowired(required = false)
private WebClient webClient;
@Value("${pivotal.userService.name}")
private String userService;
@Trace(async = true)
|
public void registerUser(RegistrationRequest registrationRequest) {
|
pivotal-bank/web-ui
|
src/main/java/io/pivotal/web/service/UserService.java
|
// Path: src/main/java/io/pivotal/web/domain/RegistrationRequest.java
// @Data
// public class RegistrationRequest {
//
// @NotNull
// @NotEmpty
// private String givenNames;
//
// private String surname;
//
// @NotNull
// @NotEmpty
// @Email
// private String email;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String password;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String confirmPassword;
// }
//
// Path: src/main/java/io/pivotal/web/domain/User.java
// @Data
// public class User implements Serializable {
//
// private String id;
// private String email;
// private String givenNames;
// private String surname;
// private DateTime createdDate;
// private String jwt;
// }
|
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.RegistrationRequest;
import io.pivotal.web.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
|
package io.pivotal.web.service;
@Service
@RefreshScope
@Slf4j
public class UserService {
@Autowired(required = false)
private WebClient webClient;
@Value("${pivotal.userService.name}")
private String userService;
@Trace(async = true)
public void registerUser(RegistrationRequest registrationRequest) {
log.debug("Creating user with userId: " + registrationRequest.getEmail());
|
// Path: src/main/java/io/pivotal/web/domain/RegistrationRequest.java
// @Data
// public class RegistrationRequest {
//
// @NotNull
// @NotEmpty
// private String givenNames;
//
// private String surname;
//
// @NotNull
// @NotEmpty
// @Email
// private String email;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String password;
//
// @NotEmpty
// @NotNull
// //TODO - more complex validation on password
// private String confirmPassword;
// }
//
// Path: src/main/java/io/pivotal/web/domain/User.java
// @Data
// public class User implements Serializable {
//
// private String id;
// private String email;
// private String givenNames;
// private String surname;
// private DateTime createdDate;
// private String jwt;
// }
// Path: src/main/java/io/pivotal/web/service/UserService.java
import com.newrelic.api.agent.Trace;
import io.pivotal.web.domain.RegistrationRequest;
import io.pivotal.web.domain.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.MediaType;
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.security.oauth2.core.oidc.user.OidcUser;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import static org.springframework.security.oauth2.client.web.reactive.function.client.ServletOAuth2AuthorizedClientExchangeFilterFunction.oauth2AuthorizedClient;
package io.pivotal.web.service;
@Service
@RefreshScope
@Slf4j
public class UserService {
@Autowired(required = false)
private WebClient webClient;
@Value("${pivotal.userService.name}")
private String userService;
@Trace(async = true)
public void registerUser(RegistrationRequest registrationRequest) {
log.debug("Creating user with userId: " + registrationRequest.getEmail());
|
User user = webClient
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
|
import android.util.Log;
import com.wootric.androidsdk.Constants;
import java.util.Date;
|
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.utils;
/**
* Created by maciejwitowski on 11/24/15.
*/
public final class Utils {
private Utils(){}
public static <T> T checkNotNull(T object, String objectDescription) {
if(object == null) {
throw new IllegalArgumentException(objectDescription + " must not be null");
}
return object;
}
public static boolean isNotEmpty(String s) {
return s != null && !s.isEmpty() && !isWhitespaceString(s);
}
public static boolean isBlank(String s) {
return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
}
private static boolean isWhitespaceString(String s) {
return s.trim().length() == 0;
}
public static void checkDate(long date) {
if (date > 9999999999L) {
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
import android.util.Log;
import com.wootric.androidsdk.Constants;
import java.util.Date;
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.utils;
/**
* Created by maciejwitowski on 11/24/15.
*/
public final class Utils {
private Utils(){}
public static <T> T checkNotNull(T object, String objectDescription) {
if(object == null) {
throw new IllegalArgumentException(objectDescription + " must not be null");
}
return object;
}
public static boolean isNotEmpty(String s) {
return s != null && !s.isEmpty() && !isWhitespaceString(s);
}
public static boolean isBlank(String s) {
return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
}
private static boolean isWhitespaceString(String s) {
return s.trim().length() == 0;
}
public static void checkDate(long date) {
if (date > 9999999999L) {
|
Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/CreateDeclineTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/OfflineDataHandler.java
// public class OfflineDataHandler {
//
// private static final String LOG_TAG = OfflineDataHandler.class.getName();
//
// private static final String KEY_ORIGIN_URL = "origin_url";
// private static final String KEY_END_USER_ID = "end_user_id";
// private static final String KEY_USER_ID = "user_id";
// private static final String KEY_ACCOUNT_ID = "account_id";
// private static final String KEY_SCORE = "score";
// private static final String KEY_PRIORITY = "priority";
// private static final String KEY_TEXT = "text";
// private static final String KEY_UNIQUE_LINK = "survey[unique_link]";
//
// private final PreferencesUtils preferencesUtils;
//
// public OfflineDataHandler(PreferencesUtils preferencesUtils) {
// this.preferencesUtils = preferencesUtils;
// }
//
// public void processOfflineData(WootricRemoteClient wootricRemoteClient, String accessToken) {
// processResponse(wootricRemoteClient, accessToken);
// processDecline(wootricRemoteClient, accessToken);
// }
//
// private void processResponse(WootricRemoteClient wootricRemoteClient, String accessToken) {
// String offlineResponse = preferencesUtils.getResponse();
// if(offlineResponse == null) return;
//
// try {
// JSONObject jsonResponse = new JSONObject(preferencesUtils.getResponse());
// wootricRemoteClient.createResponse(
// jsonResponse.getLong(KEY_END_USER_ID),
// jsonResponse.getLong(KEY_USER_ID),
// jsonResponse.getLong(KEY_ACCOUNT_ID),
// accessToken,
// jsonResponse.getString(KEY_ORIGIN_URL),
// jsonResponse.getInt(KEY_SCORE),
// jsonResponse.getInt(KEY_PRIORITY),
// jsonResponse.getString(KEY_TEXT),
// jsonResponse.getString(KEY_UNIQUE_LINK)
// );
//
// Log.d(LOG_TAG, "Processed offline Response with data: " + offlineResponse);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// preferencesUtils.putResponse(null);
// }
//
// private void processDecline(WootricRemoteClient wootricRemoteClient, String accessToken) {
// String offlineDecline = preferencesUtils.getDecline();
// if(offlineDecline == null) return;
//
// try {
// JSONObject jsonDecline = new JSONObject(preferencesUtils.getDecline());
// wootricRemoteClient.createDecline(
// jsonDecline.getLong(KEY_END_USER_ID),
// jsonDecline.getLong(KEY_USER_ID),
// jsonDecline.getLong(KEY_ACCOUNT_ID),
// jsonDecline.getInt(KEY_PRIORITY),
// accessToken,
// jsonDecline.getString(KEY_ORIGIN_URL),
// jsonDecline.getString(KEY_UNIQUE_LINK)
// );
//
// Log.d(LOG_TAG, "Processed offline Decline with data: " + offlineDecline);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// preferencesUtils.putDecline(null);
// }
//
// public void saveOfflineResponse(long endUserId, long userId, long accountId, String originUrl, int score, int priority, String text, String uniqueLink) {
// JSONObject jsonResponse = new JSONObject();
// try {
// jsonResponse.put(KEY_END_USER_ID, endUserId);
// jsonResponse.put(KEY_USER_ID, userId);
// jsonResponse.put(KEY_ACCOUNT_ID, accountId);
// jsonResponse.put(KEY_ORIGIN_URL, originUrl);
// jsonResponse.put(KEY_SCORE, score);
// jsonResponse.put(KEY_PRIORITY, priority);
// jsonResponse.put(KEY_TEXT, text);
// jsonResponse.put(KEY_UNIQUE_LINK, uniqueLink);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// final String stringResponse = jsonResponse.toString();
// preferencesUtils.putResponse(jsonResponse.toString());
// Log.d(LOG_TAG, "Saved offline Response with data: " + stringResponse);
//
// }
//
// public void saveOfflineDecline(long endUserId, long userId, long accountId, int priority, String originUrl, String uniqueLink) {
// JSONObject jsonDecline = new JSONObject();
// try {
// jsonDecline.put(KEY_END_USER_ID, endUserId);
// jsonDecline.put(KEY_USER_ID, userId);
// jsonDecline.put(KEY_ACCOUNT_ID, accountId);
// jsonDecline.put(KEY_PRIORITY, priority);
// jsonDecline.put(KEY_ORIGIN_URL, originUrl);
// jsonDecline.put(KEY_UNIQUE_LINK, uniqueLink);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// final String stringDecline = jsonDecline.toString();
// preferencesUtils.putDecline(stringDecline);
// Log.d(LOG_TAG, "Saved offline Decline with data: " + stringDecline);
// }
// }
|
import com.wootric.androidsdk.OfflineDataHandler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class CreateDeclineTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
private static final String UNIQUE_LINK = "12345qwerty";
private static final String ORIGIN_URL = "com.test.app";
private static final long END_USER_ID = 123;
private static final long USER_ID = 1234;
private static final long ACCOUNT_ID = 100;
private static final int PRIORITY = 0;
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/OfflineDataHandler.java
// public class OfflineDataHandler {
//
// private static final String LOG_TAG = OfflineDataHandler.class.getName();
//
// private static final String KEY_ORIGIN_URL = "origin_url";
// private static final String KEY_END_USER_ID = "end_user_id";
// private static final String KEY_USER_ID = "user_id";
// private static final String KEY_ACCOUNT_ID = "account_id";
// private static final String KEY_SCORE = "score";
// private static final String KEY_PRIORITY = "priority";
// private static final String KEY_TEXT = "text";
// private static final String KEY_UNIQUE_LINK = "survey[unique_link]";
//
// private final PreferencesUtils preferencesUtils;
//
// public OfflineDataHandler(PreferencesUtils preferencesUtils) {
// this.preferencesUtils = preferencesUtils;
// }
//
// public void processOfflineData(WootricRemoteClient wootricRemoteClient, String accessToken) {
// processResponse(wootricRemoteClient, accessToken);
// processDecline(wootricRemoteClient, accessToken);
// }
//
// private void processResponse(WootricRemoteClient wootricRemoteClient, String accessToken) {
// String offlineResponse = preferencesUtils.getResponse();
// if(offlineResponse == null) return;
//
// try {
// JSONObject jsonResponse = new JSONObject(preferencesUtils.getResponse());
// wootricRemoteClient.createResponse(
// jsonResponse.getLong(KEY_END_USER_ID),
// jsonResponse.getLong(KEY_USER_ID),
// jsonResponse.getLong(KEY_ACCOUNT_ID),
// accessToken,
// jsonResponse.getString(KEY_ORIGIN_URL),
// jsonResponse.getInt(KEY_SCORE),
// jsonResponse.getInt(KEY_PRIORITY),
// jsonResponse.getString(KEY_TEXT),
// jsonResponse.getString(KEY_UNIQUE_LINK)
// );
//
// Log.d(LOG_TAG, "Processed offline Response with data: " + offlineResponse);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// preferencesUtils.putResponse(null);
// }
//
// private void processDecline(WootricRemoteClient wootricRemoteClient, String accessToken) {
// String offlineDecline = preferencesUtils.getDecline();
// if(offlineDecline == null) return;
//
// try {
// JSONObject jsonDecline = new JSONObject(preferencesUtils.getDecline());
// wootricRemoteClient.createDecline(
// jsonDecline.getLong(KEY_END_USER_ID),
// jsonDecline.getLong(KEY_USER_ID),
// jsonDecline.getLong(KEY_ACCOUNT_ID),
// jsonDecline.getInt(KEY_PRIORITY),
// accessToken,
// jsonDecline.getString(KEY_ORIGIN_URL),
// jsonDecline.getString(KEY_UNIQUE_LINK)
// );
//
// Log.d(LOG_TAG, "Processed offline Decline with data: " + offlineDecline);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// preferencesUtils.putDecline(null);
// }
//
// public void saveOfflineResponse(long endUserId, long userId, long accountId, String originUrl, int score, int priority, String text, String uniqueLink) {
// JSONObject jsonResponse = new JSONObject();
// try {
// jsonResponse.put(KEY_END_USER_ID, endUserId);
// jsonResponse.put(KEY_USER_ID, userId);
// jsonResponse.put(KEY_ACCOUNT_ID, accountId);
// jsonResponse.put(KEY_ORIGIN_URL, originUrl);
// jsonResponse.put(KEY_SCORE, score);
// jsonResponse.put(KEY_PRIORITY, priority);
// jsonResponse.put(KEY_TEXT, text);
// jsonResponse.put(KEY_UNIQUE_LINK, uniqueLink);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// final String stringResponse = jsonResponse.toString();
// preferencesUtils.putResponse(jsonResponse.toString());
// Log.d(LOG_TAG, "Saved offline Response with data: " + stringResponse);
//
// }
//
// public void saveOfflineDecline(long endUserId, long userId, long accountId, int priority, String originUrl, String uniqueLink) {
// JSONObject jsonDecline = new JSONObject();
// try {
// jsonDecline.put(KEY_END_USER_ID, endUserId);
// jsonDecline.put(KEY_USER_ID, userId);
// jsonDecline.put(KEY_ACCOUNT_ID, accountId);
// jsonDecline.put(KEY_PRIORITY, priority);
// jsonDecline.put(KEY_ORIGIN_URL, originUrl);
// jsonDecline.put(KEY_UNIQUE_LINK, uniqueLink);
// } catch (JSONException e) {
// e.printStackTrace();
// }
//
// final String stringDecline = jsonDecline.toString();
// preferencesUtils.putDecline(stringDecline);
// Log.d(LOG_TAG, "Saved offline Decline with data: " + stringDecline);
// }
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/CreateDeclineTaskTest.java
import com.wootric.androidsdk.OfflineDataHandler;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class CreateDeclineTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
private static final String UNIQUE_LINK = "12345qwerty";
private static final String ORIGIN_URL = "com.test.app";
private static final long END_USER_ID = 123;
private static final long USER_ID = 1234;
private static final long ACCOUNT_ID = 100;
private static final int PRIORITY = 0;
|
@Mock OfflineDataHandler offlineDataHandler;
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/WootricRemoteRequestTask.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import com.wootric.androidsdk.BuildConfig;
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.utils.Utils;
|
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.network.tasks;
/**
* Created by maciejwitowski on 10/13/15.
*/
public abstract class WootricRemoteRequestTask extends AsyncTask<Void, Void, String> {
private static final String HTTP_AGENT = "Wootric-Mobile-SDK";
static final String REQUEST_TYPE_POST = "POST";
static final String REQUEST_TYPE_PUT = "PUT";
static final String REQUEST_TYPE_GET = "GET";
protected static final String API_ENDPOINT = "https://api.wootric.com";
protected static final String SURVEY_ENDPOINT = "https://survey.wootric.com";
protected static final String EU_API_ENDPOINT = "https://app.wootric.eu";
protected static final String EU_SURVEY_ENDPOINT = "https://eligibility.wootric.eu";
protected static final String END_USERS_PATH = "/api/v1/end_users";
protected static final String OAUTH_PATH = "/oauth/token";
protected static final String ELIGIBLE_PATH = "/eligible.json";
protected static final String REGISTERED_EVENTS_PATH = "/registered_events.json";
private final String requestType;
private final String accessToken;
private final String accountToken;
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/WootricRemoteRequestTask.java
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import com.wootric.androidsdk.BuildConfig;
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.utils.Utils;
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.network.tasks;
/**
* Created by maciejwitowski on 10/13/15.
*/
public abstract class WootricRemoteRequestTask extends AsyncTask<Void, Void, String> {
private static final String HTTP_AGENT = "Wootric-Mobile-SDK";
static final String REQUEST_TYPE_POST = "POST";
static final String REQUEST_TYPE_PUT = "PUT";
static final String REQUEST_TYPE_GET = "GET";
protected static final String API_ENDPOINT = "https://api.wootric.com";
protected static final String SURVEY_ENDPOINT = "https://survey.wootric.com";
protected static final String EU_API_ENDPOINT = "https://app.wootric.eu";
protected static final String EU_SURVEY_ENDPOINT = "https://eligibility.wootric.eu";
protected static final String END_USERS_PATH = "/api/v1/end_users";
protected static final String OAUTH_PATH = "/oauth/token";
protected static final String ELIGIBLE_PATH = "/eligible.json";
protected static final String REGISTERED_EVENTS_PATH = "/registered_events.json";
private final String requestType;
private final String accessToken;
private final String accountToken;
|
protected final WootricApiCallback wootricApiCallback;
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/WootricRemoteRequestTask.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
|
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import com.wootric.androidsdk.BuildConfig;
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.utils.Utils;
|
return builder.build().getEncodedQuery();
}
public String readInput(InputStream stream) throws IOException {
int ch;
StringBuilder sb = new StringBuilder();
while((ch = stream.read())!= -1)
sb.append((char)ch);
return sb.toString();
}
public void addOptionalParam(String key, Object param) {
if(param != null) {
paramsMap.put(key, String.valueOf(param));
}
}
protected void onError(Exception e) {
if(wootricApiCallback != null)
wootricApiCallback.onApiError(e);
}
protected void onInvalidResponse(String message) {
if(wootricApiCallback != null) {
RuntimeException exception = new IllegalArgumentException(message);
wootricApiCallback.onApiError(exception);
}
}
protected String getApiEndpoint() {
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/WootricRemoteRequestTask.java
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import com.wootric.androidsdk.BuildConfig;
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.utils.Utils;
return builder.build().getEncodedQuery();
}
public String readInput(InputStream stream) throws IOException {
int ch;
StringBuilder sb = new StringBuilder();
while((ch = stream.read())!= -1)
sb.append((char)ch);
return sb.toString();
}
public void addOptionalParam(String key, Object param) {
if(param != null) {
paramsMap.put(key, String.valueOf(param));
}
}
protected void onError(Exception e) {
if(wootricApiCallback != null)
wootricApiCallback.onApiError(e);
}
protected void onInvalidResponse(String message) {
if(wootricApiCallback != null) {
RuntimeException exception = new IllegalArgumentException(message);
wootricApiCallback.onApiError(exception);
}
}
protected String getApiEndpoint() {
|
return Utils.startsWithEU(this.accountToken) ? EU_API_ENDPOINT : API_ENDPOINT;
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/CreateEndUserTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class CreateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/CreateEndUserTaskTest.java
import com.wootric.androidsdk.network.WootricApiCallback;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class CreateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
|
@Mock WootricApiCallback wootricApiCallback;
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/GetAccessTokenTask.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import org.json.JSONException;
import org.json.JSONObject;
|
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.network.tasks;
/**
* Created by maciejwitowski on 10/13/15.
*/
public class GetAccessTokenTask extends WootricRemoteRequestTask {
private final String clientId;
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/GetAccessTokenTask.java
import com.wootric.androidsdk.network.WootricApiCallback;
import org.json.JSONException;
import org.json.JSONObject;
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.network.tasks;
/**
* Created by maciejwitowski on 10/13/15.
*/
public class GetAccessTokenTask extends WootricRemoteRequestTask {
private final String clientId;
|
public GetAccessTokenTask(String clientId, String accountToken, WootricApiCallback wootricApiCallback) {
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/objects/SettingsTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
|
import android.net.Uri;
import android.util.Log;
import com.wootric.androidsdk.Constants;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
|
package com.wootric.androidsdk.objects;
@RunWith(RobolectricTestRunner.class)
public class SettingsTest {
public static final String LOCALIZED_FINAL_THANK_YOU = "Localized final thank you!";
public static final String LOCALIZED_THANK_YOU_SETUP = "Localized thank you setup";
public static final String EMAIL = "nps@test.com";
@Mock
LocalizedTexts mockLocalizedTexts;
@Mock
WootricCustomMessage mockCustomMessage;
@Mock
WootricCustomThankYou mockCustomThankYou;
@Before
public void setUpMockito() {
MockitoAnnotations.initMocks(this);
}
@After
public void tearDownMockito() {
Mockito.validateMockitoUsage();
}
@Test
public void whenTimeFromIsNotSet_itReturnsTrue() throws Exception {
Settings settings = new Settings();
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/objects/SettingsTest.java
import android.net.Uri;
import android.util.Log;
import com.wootric.androidsdk.Constants;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import java.util.Date;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
package com.wootric.androidsdk.objects;
@RunWith(RobolectricTestRunner.class)
public class SettingsTest {
public static final String LOCALIZED_FINAL_THANK_YOU = "Localized final thank you!";
public static final String LOCALIZED_THANK_YOU_SETUP = "Localized thank you setup";
public static final String EMAIL = "nps@test.com";
@Mock
LocalizedTexts mockLocalizedTexts;
@Mock
WootricCustomMessage mockCustomMessage;
@Mock
WootricCustomThankYou mockCustomThankYou;
@Before
public void setUpMockito() {
MockitoAnnotations.initMocks(this);
}
@After
public void tearDownMockito() {
Mockito.validateMockitoUsage();
}
@Test
public void whenTimeFromIsNotSet_itReturnsTrue() throws Exception {
Settings settings = new Settings();
|
assertThat(settings.firstSurveyDelayPassed(Constants.NOT_SET)).isTrue();
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/GetEndUserByEmailTask.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
|
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.network.tasks;
/**
* Created by maciejwitowski on 10/13/15.
*/
public class GetEndUserByEmailTask extends WootricRemoteRequestTask {
private final String email;
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/tasks/GetEndUserByEmailTask.java
import com.wootric.androidsdk.network.WootricApiCallback;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
/*
* Copyright (c) 2016 Wootric (https://wootric.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.wootric.androidsdk.network.tasks;
/**
* Created by maciejwitowski on 10/13/15.
*/
public class GetEndUserByEmailTask extends WootricRemoteRequestTask {
private final String email;
|
public GetEndUserByEmailTask(String email, String accessToken, String accountToken, WootricApiCallback wootricApiCallback) {
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/GetEndUserByEmailTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class GetEndUserByEmailTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/GetEndUserByEmailTaskTest.java
import com.wootric.androidsdk.network.WootricApiCallback;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class GetEndUserByEmailTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
|
@Mock WootricApiCallback wootricApiCallback;
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/UpdateEndUserTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/EndUser.java
// public class EndUser implements Parcelable {
// private static final String UNKNOWN_EMAIL = "Unknown";
//
// private long id = -1;
// private String email;
// private String externalId;
// private String phoneNumber;
// private long createdAt = -1;
// private HashMap properties = new HashMap<>();
//
// public EndUser() {}
//
// public EndUser(EndUser endUser) {
// this.id = endUser.id;
// this.email = endUser.email;
// this.externalId = endUser.externalId;
// this.phoneNumber = endUser.phoneNumber;
// this.createdAt = endUser.createdAt;
// this.properties = endUser.properties;
// }
//
// public EndUser(String email) {
// this.email = email;
// }
//
// public EndUser(String email, HashMap properties) {
// this.email = email;
// this.properties = properties;
// }
//
// public long getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getExternalId() {
// return externalId;
// }
//
// public boolean hasExternalId() {
// return Utils.isNotEmpty(externalId);
// }
//
// public String getPhoneNumber() {
// return phoneNumber;
// }
//
// public boolean hasPhoneNumber() {
// return Utils.isNotEmpty(phoneNumber);
// }
//
// public String getEmailOrUnknown() {
// return Utils.isNotEmpty(email) ? email : UNKNOWN_EMAIL;
// }
//
// public long getCreatedAt() {
// return createdAt;
// }
//
// public boolean isCreatedAtSet() {
// return createdAt != -1;
// }
//
// public void setProperties(HashMap<String, String> properties) {
// this.properties = properties;
// }
//
// public HashMap<String, String> getProperties() {
// return properties;
// }
//
// public boolean hasProperties() {
// return properties != null && properties.size() > 0;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public void setExternalId(String externalId) {
// this.externalId = externalId;
// }
//
// public void setPhoneNumber(String phoneNumber) {
// this.phoneNumber = phoneNumber;
// }
//
// public void setCreatedAt(long createdAt) {
// this.createdAt = createdAt;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(this.id);
// dest.writeString(this.email);
// dest.writeString(this.externalId);
// dest.writeString(this.phoneNumber);
// dest.writeLong(this.createdAt);
// dest.writeSerializable(this.properties);
// }
//
// private EndUser(Parcel in) {
// this.id = in.readLong();
// this.email = in.readString();
// this.externalId = in.readString();
// this.phoneNumber = in.readString();
// this.createdAt = in.readLong();
// this.properties = (HashMap) in.readSerializable();
// }
//
// public static final Creator<EndUser> CREATOR = new Creator<EndUser>() {
// public EndUser createFromParcel(Parcel source) {
// return new EndUser(source);
// }
// public EndUser[] newArray(int size) {
// return new EndUser[size];
// }
// };
//
// public Long getCreatedAtOrNull() {
// return isCreatedAtSet() ? getCreatedAt() : null;
// }
// }
//
// Path: androidsdk/src/test/java/com/wootric/androidsdk/TestHelper.java
// public static EndUser testEndUser() {
// return new EndUser();
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.objects.EndUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static com.wootric.androidsdk.TestHelper.testEndUser;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class UpdateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
@Mock
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/EndUser.java
// public class EndUser implements Parcelable {
// private static final String UNKNOWN_EMAIL = "Unknown";
//
// private long id = -1;
// private String email;
// private String externalId;
// private String phoneNumber;
// private long createdAt = -1;
// private HashMap properties = new HashMap<>();
//
// public EndUser() {}
//
// public EndUser(EndUser endUser) {
// this.id = endUser.id;
// this.email = endUser.email;
// this.externalId = endUser.externalId;
// this.phoneNumber = endUser.phoneNumber;
// this.createdAt = endUser.createdAt;
// this.properties = endUser.properties;
// }
//
// public EndUser(String email) {
// this.email = email;
// }
//
// public EndUser(String email, HashMap properties) {
// this.email = email;
// this.properties = properties;
// }
//
// public long getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getExternalId() {
// return externalId;
// }
//
// public boolean hasExternalId() {
// return Utils.isNotEmpty(externalId);
// }
//
// public String getPhoneNumber() {
// return phoneNumber;
// }
//
// public boolean hasPhoneNumber() {
// return Utils.isNotEmpty(phoneNumber);
// }
//
// public String getEmailOrUnknown() {
// return Utils.isNotEmpty(email) ? email : UNKNOWN_EMAIL;
// }
//
// public long getCreatedAt() {
// return createdAt;
// }
//
// public boolean isCreatedAtSet() {
// return createdAt != -1;
// }
//
// public void setProperties(HashMap<String, String> properties) {
// this.properties = properties;
// }
//
// public HashMap<String, String> getProperties() {
// return properties;
// }
//
// public boolean hasProperties() {
// return properties != null && properties.size() > 0;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public void setExternalId(String externalId) {
// this.externalId = externalId;
// }
//
// public void setPhoneNumber(String phoneNumber) {
// this.phoneNumber = phoneNumber;
// }
//
// public void setCreatedAt(long createdAt) {
// this.createdAt = createdAt;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(this.id);
// dest.writeString(this.email);
// dest.writeString(this.externalId);
// dest.writeString(this.phoneNumber);
// dest.writeLong(this.createdAt);
// dest.writeSerializable(this.properties);
// }
//
// private EndUser(Parcel in) {
// this.id = in.readLong();
// this.email = in.readString();
// this.externalId = in.readString();
// this.phoneNumber = in.readString();
// this.createdAt = in.readLong();
// this.properties = (HashMap) in.readSerializable();
// }
//
// public static final Creator<EndUser> CREATOR = new Creator<EndUser>() {
// public EndUser createFromParcel(Parcel source) {
// return new EndUser(source);
// }
// public EndUser[] newArray(int size) {
// return new EndUser[size];
// }
// };
//
// public Long getCreatedAtOrNull() {
// return isCreatedAtSet() ? getCreatedAt() : null;
// }
// }
//
// Path: androidsdk/src/test/java/com/wootric/androidsdk/TestHelper.java
// public static EndUser testEndUser() {
// return new EndUser();
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/UpdateEndUserTaskTest.java
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.objects.EndUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static com.wootric.androidsdk.TestHelper.testEndUser;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class UpdateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
@Mock
|
WootricApiCallback wootricApiCallback;
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/UpdateEndUserTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/EndUser.java
// public class EndUser implements Parcelable {
// private static final String UNKNOWN_EMAIL = "Unknown";
//
// private long id = -1;
// private String email;
// private String externalId;
// private String phoneNumber;
// private long createdAt = -1;
// private HashMap properties = new HashMap<>();
//
// public EndUser() {}
//
// public EndUser(EndUser endUser) {
// this.id = endUser.id;
// this.email = endUser.email;
// this.externalId = endUser.externalId;
// this.phoneNumber = endUser.phoneNumber;
// this.createdAt = endUser.createdAt;
// this.properties = endUser.properties;
// }
//
// public EndUser(String email) {
// this.email = email;
// }
//
// public EndUser(String email, HashMap properties) {
// this.email = email;
// this.properties = properties;
// }
//
// public long getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getExternalId() {
// return externalId;
// }
//
// public boolean hasExternalId() {
// return Utils.isNotEmpty(externalId);
// }
//
// public String getPhoneNumber() {
// return phoneNumber;
// }
//
// public boolean hasPhoneNumber() {
// return Utils.isNotEmpty(phoneNumber);
// }
//
// public String getEmailOrUnknown() {
// return Utils.isNotEmpty(email) ? email : UNKNOWN_EMAIL;
// }
//
// public long getCreatedAt() {
// return createdAt;
// }
//
// public boolean isCreatedAtSet() {
// return createdAt != -1;
// }
//
// public void setProperties(HashMap<String, String> properties) {
// this.properties = properties;
// }
//
// public HashMap<String, String> getProperties() {
// return properties;
// }
//
// public boolean hasProperties() {
// return properties != null && properties.size() > 0;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public void setExternalId(String externalId) {
// this.externalId = externalId;
// }
//
// public void setPhoneNumber(String phoneNumber) {
// this.phoneNumber = phoneNumber;
// }
//
// public void setCreatedAt(long createdAt) {
// this.createdAt = createdAt;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(this.id);
// dest.writeString(this.email);
// dest.writeString(this.externalId);
// dest.writeString(this.phoneNumber);
// dest.writeLong(this.createdAt);
// dest.writeSerializable(this.properties);
// }
//
// private EndUser(Parcel in) {
// this.id = in.readLong();
// this.email = in.readString();
// this.externalId = in.readString();
// this.phoneNumber = in.readString();
// this.createdAt = in.readLong();
// this.properties = (HashMap) in.readSerializable();
// }
//
// public static final Creator<EndUser> CREATOR = new Creator<EndUser>() {
// public EndUser createFromParcel(Parcel source) {
// return new EndUser(source);
// }
// public EndUser[] newArray(int size) {
// return new EndUser[size];
// }
// };
//
// public Long getCreatedAtOrNull() {
// return isCreatedAtSet() ? getCreatedAt() : null;
// }
// }
//
// Path: androidsdk/src/test/java/com/wootric/androidsdk/TestHelper.java
// public static EndUser testEndUser() {
// return new EndUser();
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.objects.EndUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static com.wootric.androidsdk.TestHelper.testEndUser;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class UpdateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
@Mock
WootricApiCallback wootricApiCallback;
@Test
public void testGet_RequestWithEuToken() throws Exception {
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/EndUser.java
// public class EndUser implements Parcelable {
// private static final String UNKNOWN_EMAIL = "Unknown";
//
// private long id = -1;
// private String email;
// private String externalId;
// private String phoneNumber;
// private long createdAt = -1;
// private HashMap properties = new HashMap<>();
//
// public EndUser() {}
//
// public EndUser(EndUser endUser) {
// this.id = endUser.id;
// this.email = endUser.email;
// this.externalId = endUser.externalId;
// this.phoneNumber = endUser.phoneNumber;
// this.createdAt = endUser.createdAt;
// this.properties = endUser.properties;
// }
//
// public EndUser(String email) {
// this.email = email;
// }
//
// public EndUser(String email, HashMap properties) {
// this.email = email;
// this.properties = properties;
// }
//
// public long getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getExternalId() {
// return externalId;
// }
//
// public boolean hasExternalId() {
// return Utils.isNotEmpty(externalId);
// }
//
// public String getPhoneNumber() {
// return phoneNumber;
// }
//
// public boolean hasPhoneNumber() {
// return Utils.isNotEmpty(phoneNumber);
// }
//
// public String getEmailOrUnknown() {
// return Utils.isNotEmpty(email) ? email : UNKNOWN_EMAIL;
// }
//
// public long getCreatedAt() {
// return createdAt;
// }
//
// public boolean isCreatedAtSet() {
// return createdAt != -1;
// }
//
// public void setProperties(HashMap<String, String> properties) {
// this.properties = properties;
// }
//
// public HashMap<String, String> getProperties() {
// return properties;
// }
//
// public boolean hasProperties() {
// return properties != null && properties.size() > 0;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public void setExternalId(String externalId) {
// this.externalId = externalId;
// }
//
// public void setPhoneNumber(String phoneNumber) {
// this.phoneNumber = phoneNumber;
// }
//
// public void setCreatedAt(long createdAt) {
// this.createdAt = createdAt;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(this.id);
// dest.writeString(this.email);
// dest.writeString(this.externalId);
// dest.writeString(this.phoneNumber);
// dest.writeLong(this.createdAt);
// dest.writeSerializable(this.properties);
// }
//
// private EndUser(Parcel in) {
// this.id = in.readLong();
// this.email = in.readString();
// this.externalId = in.readString();
// this.phoneNumber = in.readString();
// this.createdAt = in.readLong();
// this.properties = (HashMap) in.readSerializable();
// }
//
// public static final Creator<EndUser> CREATOR = new Creator<EndUser>() {
// public EndUser createFromParcel(Parcel source) {
// return new EndUser(source);
// }
// public EndUser[] newArray(int size) {
// return new EndUser[size];
// }
// };
//
// public Long getCreatedAtOrNull() {
// return isCreatedAtSet() ? getCreatedAt() : null;
// }
// }
//
// Path: androidsdk/src/test/java/com/wootric/androidsdk/TestHelper.java
// public static EndUser testEndUser() {
// return new EndUser();
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/UpdateEndUserTaskTest.java
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.objects.EndUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static com.wootric.androidsdk.TestHelper.testEndUser;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class UpdateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
@Mock
WootricApiCallback wootricApiCallback;
@Test
public void testGet_RequestWithEuToken() throws Exception {
|
EndUser endUser = testEndUser();
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/UpdateEndUserTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/EndUser.java
// public class EndUser implements Parcelable {
// private static final String UNKNOWN_EMAIL = "Unknown";
//
// private long id = -1;
// private String email;
// private String externalId;
// private String phoneNumber;
// private long createdAt = -1;
// private HashMap properties = new HashMap<>();
//
// public EndUser() {}
//
// public EndUser(EndUser endUser) {
// this.id = endUser.id;
// this.email = endUser.email;
// this.externalId = endUser.externalId;
// this.phoneNumber = endUser.phoneNumber;
// this.createdAt = endUser.createdAt;
// this.properties = endUser.properties;
// }
//
// public EndUser(String email) {
// this.email = email;
// }
//
// public EndUser(String email, HashMap properties) {
// this.email = email;
// this.properties = properties;
// }
//
// public long getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getExternalId() {
// return externalId;
// }
//
// public boolean hasExternalId() {
// return Utils.isNotEmpty(externalId);
// }
//
// public String getPhoneNumber() {
// return phoneNumber;
// }
//
// public boolean hasPhoneNumber() {
// return Utils.isNotEmpty(phoneNumber);
// }
//
// public String getEmailOrUnknown() {
// return Utils.isNotEmpty(email) ? email : UNKNOWN_EMAIL;
// }
//
// public long getCreatedAt() {
// return createdAt;
// }
//
// public boolean isCreatedAtSet() {
// return createdAt != -1;
// }
//
// public void setProperties(HashMap<String, String> properties) {
// this.properties = properties;
// }
//
// public HashMap<String, String> getProperties() {
// return properties;
// }
//
// public boolean hasProperties() {
// return properties != null && properties.size() > 0;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public void setExternalId(String externalId) {
// this.externalId = externalId;
// }
//
// public void setPhoneNumber(String phoneNumber) {
// this.phoneNumber = phoneNumber;
// }
//
// public void setCreatedAt(long createdAt) {
// this.createdAt = createdAt;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(this.id);
// dest.writeString(this.email);
// dest.writeString(this.externalId);
// dest.writeString(this.phoneNumber);
// dest.writeLong(this.createdAt);
// dest.writeSerializable(this.properties);
// }
//
// private EndUser(Parcel in) {
// this.id = in.readLong();
// this.email = in.readString();
// this.externalId = in.readString();
// this.phoneNumber = in.readString();
// this.createdAt = in.readLong();
// this.properties = (HashMap) in.readSerializable();
// }
//
// public static final Creator<EndUser> CREATOR = new Creator<EndUser>() {
// public EndUser createFromParcel(Parcel source) {
// return new EndUser(source);
// }
// public EndUser[] newArray(int size) {
// return new EndUser[size];
// }
// };
//
// public Long getCreatedAtOrNull() {
// return isCreatedAtSet() ? getCreatedAt() : null;
// }
// }
//
// Path: androidsdk/src/test/java/com/wootric/androidsdk/TestHelper.java
// public static EndUser testEndUser() {
// return new EndUser();
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.objects.EndUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static com.wootric.androidsdk.TestHelper.testEndUser;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class UpdateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
@Mock
WootricApiCallback wootricApiCallback;
@Test
public void testGet_RequestWithEuToken() throws Exception {
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
//
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/EndUser.java
// public class EndUser implements Parcelable {
// private static final String UNKNOWN_EMAIL = "Unknown";
//
// private long id = -1;
// private String email;
// private String externalId;
// private String phoneNumber;
// private long createdAt = -1;
// private HashMap properties = new HashMap<>();
//
// public EndUser() {}
//
// public EndUser(EndUser endUser) {
// this.id = endUser.id;
// this.email = endUser.email;
// this.externalId = endUser.externalId;
// this.phoneNumber = endUser.phoneNumber;
// this.createdAt = endUser.createdAt;
// this.properties = endUser.properties;
// }
//
// public EndUser(String email) {
// this.email = email;
// }
//
// public EndUser(String email, HashMap properties) {
// this.email = email;
// this.properties = properties;
// }
//
// public long getId() {
// return id;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getExternalId() {
// return externalId;
// }
//
// public boolean hasExternalId() {
// return Utils.isNotEmpty(externalId);
// }
//
// public String getPhoneNumber() {
// return phoneNumber;
// }
//
// public boolean hasPhoneNumber() {
// return Utils.isNotEmpty(phoneNumber);
// }
//
// public String getEmailOrUnknown() {
// return Utils.isNotEmpty(email) ? email : UNKNOWN_EMAIL;
// }
//
// public long getCreatedAt() {
// return createdAt;
// }
//
// public boolean isCreatedAtSet() {
// return createdAt != -1;
// }
//
// public void setProperties(HashMap<String, String> properties) {
// this.properties = properties;
// }
//
// public HashMap<String, String> getProperties() {
// return properties;
// }
//
// public boolean hasProperties() {
// return properties != null && properties.size() > 0;
// }
//
// public void setId(long id) {
// this.id = id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public void setExternalId(String externalId) {
// this.externalId = externalId;
// }
//
// public void setPhoneNumber(String phoneNumber) {
// this.phoneNumber = phoneNumber;
// }
//
// public void setCreatedAt(long createdAt) {
// this.createdAt = createdAt;
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeLong(this.id);
// dest.writeString(this.email);
// dest.writeString(this.externalId);
// dest.writeString(this.phoneNumber);
// dest.writeLong(this.createdAt);
// dest.writeSerializable(this.properties);
// }
//
// private EndUser(Parcel in) {
// this.id = in.readLong();
// this.email = in.readString();
// this.externalId = in.readString();
// this.phoneNumber = in.readString();
// this.createdAt = in.readLong();
// this.properties = (HashMap) in.readSerializable();
// }
//
// public static final Creator<EndUser> CREATOR = new Creator<EndUser>() {
// public EndUser createFromParcel(Parcel source) {
// return new EndUser(source);
// }
// public EndUser[] newArray(int size) {
// return new EndUser[size];
// }
// };
//
// public Long getCreatedAtOrNull() {
// return isCreatedAtSet() ? getCreatedAt() : null;
// }
// }
//
// Path: androidsdk/src/test/java/com/wootric/androidsdk/TestHelper.java
// public static EndUser testEndUser() {
// return new EndUser();
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/UpdateEndUserTaskTest.java
import com.wootric.androidsdk.network.WootricApiCallback;
import com.wootric.androidsdk.objects.EndUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static com.wootric.androidsdk.TestHelper.testEndUser;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class UpdateEndUserTaskTest {
private static final String ACCESS_TOKEN = "accessToken";
@Mock
WootricApiCallback wootricApiCallback;
@Test
public void testGet_RequestWithEuToken() throws Exception {
|
EndUser endUser = testEndUser();
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricCustomThankYou.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
|
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import com.wootric.androidsdk.utils.Utils;
import org.json.JSONException;
import org.json.JSONObject;
|
this.detractorCommentInUrl = detractorCommentInUrl;
}
public void setPassiveCommentInUrl(boolean passiveCommentInUrl) {
this.passiveCommentInUrl = passiveCommentInUrl;
}
public void setPromoterCommentInUrl(boolean promoterCommentInUrl) {
this.promoterCommentInUrl = promoterCommentInUrl;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.text);
dest.writeString(this.detractorText);
dest.writeString(this.passiveText);
dest.writeString(this.promoterText);
dest.writeString(this.linkText);
dest.writeString(this.detractorLinkText);
dest.writeString(this.passiveLinkText);
dest.writeString(this.promoterLinkText);
dest.writeParcelable(this.linkUri, 0);
dest.writeParcelable(this.detractorLinkUri, 0);
dest.writeParcelable(this.passiveLinkUri, 0);
dest.writeParcelable(this.promoterLinkUri, 0);
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricCustomThankYou.java
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import com.wootric.androidsdk.utils.Utils;
import org.json.JSONException;
import org.json.JSONObject;
this.detractorCommentInUrl = detractorCommentInUrl;
}
public void setPassiveCommentInUrl(boolean passiveCommentInUrl) {
this.passiveCommentInUrl = passiveCommentInUrl;
}
public void setPromoterCommentInUrl(boolean promoterCommentInUrl) {
this.promoterCommentInUrl = promoterCommentInUrl;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.text);
dest.writeString(this.detractorText);
dest.writeString(this.passiveText);
dest.writeString(this.promoterText);
dest.writeString(this.linkText);
dest.writeString(this.detractorLinkText);
dest.writeString(this.passiveLinkText);
dest.writeString(this.promoterLinkText);
dest.writeParcelable(this.linkUri, 0);
dest.writeParcelable(this.detractorLinkUri, 0);
dest.writeParcelable(this.passiveLinkUri, 0);
dest.writeParcelable(this.promoterLinkUri, 0);
|
dest.writeByte(Utils.getByteValue(this.emailInUrl));
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/objects/LocalizedTexts.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
|
import java.util.HashMap;
import android.os.Parcel;
import android.os.Parcelable;
import com.wootric.androidsdk.Constants;
import org.json.JSONException;
import org.json.JSONObject;
|
dest.writeString(this.editScore);
dest.writeString(this.optOut);
dest.writeSerializable(this.socialShare);
}
private LocalizedTexts(Parcel in) {
this.surveyQuestion = in.readString();
this.anchors = (HashMap<String, String>) in.readSerializable();
this.followupQuestion = in.readString();
this.followupPlaceholder = in.readString();
this.finalThankYou = in.readString();
this.send = in.readString();
this.dismiss = in.readString();
this.editScore = in.readString();
this.optOut = in.readString();
this.socialShare = (HashMap<String, String>) in.readSerializable();
}
public static final Creator<LocalizedTexts> CREATOR = new Creator<LocalizedTexts>() {
public LocalizedTexts createFromParcel(Parcel source) {
return new LocalizedTexts(source);
}
public LocalizedTexts[] newArray(int size) {
return new LocalizedTexts[size];
}
};
static LocalizedTexts fromJson(JSONObject localizedTextsJson, String surveyType) throws JSONException {
LocalizedTexts localizedTexts = new LocalizedTexts();
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/LocalizedTexts.java
import java.util.HashMap;
import android.os.Parcel;
import android.os.Parcelable;
import com.wootric.androidsdk.Constants;
import org.json.JSONException;
import org.json.JSONObject;
dest.writeString(this.editScore);
dest.writeString(this.optOut);
dest.writeSerializable(this.socialShare);
}
private LocalizedTexts(Parcel in) {
this.surveyQuestion = in.readString();
this.anchors = (HashMap<String, String>) in.readSerializable();
this.followupQuestion = in.readString();
this.followupPlaceholder = in.readString();
this.finalThankYou = in.readString();
this.send = in.readString();
this.dismiss = in.readString();
this.editScore = in.readString();
this.optOut = in.readString();
this.socialShare = (HashMap<String, String>) in.readSerializable();
}
public static final Creator<LocalizedTexts> CREATOR = new Creator<LocalizedTexts>() {
public LocalizedTexts createFromParcel(Parcel source) {
return new LocalizedTexts(source);
}
public LocalizedTexts[] newArray(int size) {
return new LocalizedTexts[size];
}
};
static LocalizedTexts fromJson(JSONObject localizedTextsJson, String surveyType) throws JSONException {
LocalizedTexts localizedTexts = new LocalizedTexts();
|
if (surveyType.equals(Constants.CES) || surveyType.equals(Constants.CSAT)) {
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricSocial.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
|
import android.os.Parcel;
import android.os.Parcelable;
import com.wootric.androidsdk.utils.Utils;
import org.json.JSONException;
import org.json.JSONObject;
|
this.twitterPage = wootricSocial.twitterPage;
this.facebookEnabled = wootricSocial.facebookEnabled;
this.twitterEnabled = wootricSocial.twitterEnabled;
}
public void setFacebookPageId(String facebookPageId) { this.facebookPageId = facebookPageId; }
public String getFacebookPageId() { return this.facebookPageId; }
public void setTwitterPage(String twitterPage) { this.twitterPage = twitterPage; }
public String getTwitterPage() { return twitterPage; }
public Boolean isTwitterEnabled() {
return twitterEnabled;
}
public Boolean isFacebookEnabled() {
return facebookEnabled;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.facebookPageId);
dest.writeString(this.twitterPage);
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/Utils.java
// public final class Utils {
//
// private Utils(){}
//
// public static <T> T checkNotNull(T object, String objectDescription) {
// if(object == null) {
// throw new IllegalArgumentException(objectDescription + " must not be null");
// }
//
// return object;
// }
//
// public static boolean isNotEmpty(String s) {
// return s != null && !s.isEmpty() && !isWhitespaceString(s);
// }
//
// public static boolean isBlank(String s) {
// return s == null || (s != null && (s.isEmpty() || isWhitespaceString(s)));
// }
//
// private static boolean isWhitespaceString(String s) {
// return s.trim().length() == 0;
// }
//
// public static void checkDate(long date) {
// if (date > 9999999999L) {
// Log.d(Constants.TAG, "WARNING: The created date exceeds the maximum 10 characters allowed. " +
// "If you are using System.currentTimeMillis() divide it by 1000.");
// } else {
// Date d = new Date(date * 1000L);
// Date now = new Date();
// if (d.after(now)){
// Log.d(Constants.TAG, "WARNING: The created date is on the future");
// }
// }
// }
//
// public static byte getByteValue(Boolean bool) {
// if (bool != null) {
// return bool ? (byte) 1 : (byte) 0;
// } else {
// return (byte) 0;
// }
// }
//
// public static boolean startsWithEU(String aString) {
// return aString.startsWith("NPS-EU");
// }
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/objects/WootricSocial.java
import android.os.Parcel;
import android.os.Parcelable;
import com.wootric.androidsdk.utils.Utils;
import org.json.JSONException;
import org.json.JSONObject;
this.twitterPage = wootricSocial.twitterPage;
this.facebookEnabled = wootricSocial.facebookEnabled;
this.twitterEnabled = wootricSocial.twitterEnabled;
}
public void setFacebookPageId(String facebookPageId) { this.facebookPageId = facebookPageId; }
public String getFacebookPageId() { return this.facebookPageId; }
public void setTwitterPage(String twitterPage) { this.twitterPage = twitterPage; }
public String getTwitterPage() { return twitterPage; }
public Boolean isTwitterEnabled() {
return twitterEnabled;
}
public Boolean isFacebookEnabled() {
return facebookEnabled;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.facebookPageId);
dest.writeString(this.twitterPage);
|
dest.writeByte(Utils.getByteValue(facebookEnabled));
|
Wootric/WootricSDK-Android
|
androidsdk/src/main/java/com/wootric/androidsdk/utils/PreferencesUtils.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.wootric.androidsdk.Constants;
import java.lang.ref.WeakReference;
import java.util.Date;
|
}
public void touchLastSurveyed(boolean responseSent, Integer resurvey_days) {
final SharedPreferences prefs = prefs();
if(prefs == null) return;
SharedPreferences.Editor editor = prefs.edit();
if(editor == null) return;
editor.putLong(KEY_LAST_SURVEYED, new Date().getTime());
if (responseSent) {
editor.putString(KEY_TYPE, "response");
} else {
editor.putString(KEY_TYPE, "decline");
}
editor.putInt(KEY_RESURVEY_DAYS, resurvey_days);
editor.apply();
}
public boolean wasRecentlySurveyed() {
String type;
Integer days = 90;
final SharedPreferences prefs = prefs();
if(prefs != null) {
type = prefs.getString(KEY_TYPE, "");
Integer resurvey_days = prefs.getInt(KEY_RESURVEY_DAYS, -1);
if (resurvey_days >= 0){
days = resurvey_days;
} else {
if (type.equals("decline")){
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
// Path: androidsdk/src/main/java/com/wootric/androidsdk/utils/PreferencesUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.wootric.androidsdk.Constants;
import java.lang.ref.WeakReference;
import java.util.Date;
}
public void touchLastSurveyed(boolean responseSent, Integer resurvey_days) {
final SharedPreferences prefs = prefs();
if(prefs == null) return;
SharedPreferences.Editor editor = prefs.edit();
if(editor == null) return;
editor.putLong(KEY_LAST_SURVEYED, new Date().getTime());
if (responseSent) {
editor.putString(KEY_TYPE, "response");
} else {
editor.putString(KEY_TYPE, "decline");
}
editor.putInt(KEY_RESURVEY_DAYS, resurvey_days);
editor.apply();
}
public boolean wasRecentlySurveyed() {
String type;
Integer days = 90;
final SharedPreferences prefs = prefs();
if(prefs != null) {
type = prefs.getString(KEY_TYPE, "");
Integer resurvey_days = prefs.getInt(KEY_RESURVEY_DAYS, -1);
if (resurvey_days >= 0){
days = resurvey_days;
} else {
if (type.equals("decline")){
|
days = (int) Constants.DEFAULT_DECLINE_RESURVEY_DAYS;
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/utils/PreferencesUtilsTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
|
import android.content.Context;
import android.content.SharedPreferences;
import com.wootric.androidsdk.Constants;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import java.lang.ref.WeakReference;
import java.util.Date;
|
@Before
public void before() throws Exception {
this.context = Mockito.mock(Context.class);
this.weakReference = Mockito.mock(WeakReference.class);
this.prefs = Mockito.mock(SharedPreferences.class);
preferencesUtils = new PreferencesUtils(weakReference);
Mockito.when(weakReference.get()).thenReturn(context);
Mockito.when(context.getSharedPreferences(Mockito.anyString(), Mockito.anyInt())).thenReturn(prefs);
}
@Test
public void touchLastSurveyed_whenResponse() throws Exception {
SharedPreferences.Editor mockedEditor = Mockito.mock(SharedPreferences.Editor.class);
Mockito.when(prefs.edit()).thenReturn(mockedEditor);
preferencesUtils.touchLastSurveyed(true, 90);
Mockito.verify(mockedEditor).apply();
}
@Test
public void wasRecentlySurveyed_whenResponseAndSurveyedDefault() throws Exception {
long now = new Date().getTime();
Mockito.when(prefs.contains(Mockito.anyString())).thenReturn(true);
Mockito.when(prefs.getString(Mockito.eq("type"), Mockito.anyString())).thenReturn("response");
Mockito.when(prefs.getInt(Mockito.eq("resurvey_days"), Mockito.anyInt())).thenReturn(-1);
Mockito.when(prefs.getLong(Mockito.eq("surveyed"), Mockito.anyLong())).thenReturn(now);
Assert.assertEquals(true, preferencesUtils.wasRecentlySurveyed());
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/Constants.java
// public class Constants {
//
// public static final long DAY_IN_MILLIS = 1000L *60L *60L *24L;
//
// public static final int NOT_SET = -1;
//
// public static final long DEFAULT_RESURVEY_DAYS = 90L;
//
// public static final long DEFAULT_DECLINE_RESURVEY_DAYS = 30L;
//
// public static final String TAG = "WOOTRIC_SDK";
//
// public static final String CES = "CES";
//
// public static final String CSAT = "CSAT";
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/utils/PreferencesUtilsTest.java
import android.content.Context;
import android.content.SharedPreferences;
import com.wootric.androidsdk.Constants;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import java.lang.ref.WeakReference;
import java.util.Date;
@Before
public void before() throws Exception {
this.context = Mockito.mock(Context.class);
this.weakReference = Mockito.mock(WeakReference.class);
this.prefs = Mockito.mock(SharedPreferences.class);
preferencesUtils = new PreferencesUtils(weakReference);
Mockito.when(weakReference.get()).thenReturn(context);
Mockito.when(context.getSharedPreferences(Mockito.anyString(), Mockito.anyInt())).thenReturn(prefs);
}
@Test
public void touchLastSurveyed_whenResponse() throws Exception {
SharedPreferences.Editor mockedEditor = Mockito.mock(SharedPreferences.Editor.class);
Mockito.when(prefs.edit()).thenReturn(mockedEditor);
preferencesUtils.touchLastSurveyed(true, 90);
Mockito.verify(mockedEditor).apply();
}
@Test
public void wasRecentlySurveyed_whenResponseAndSurveyedDefault() throws Exception {
long now = new Date().getTime();
Mockito.when(prefs.contains(Mockito.anyString())).thenReturn(true);
Mockito.when(prefs.getString(Mockito.eq("type"), Mockito.anyString())).thenReturn("response");
Mockito.when(prefs.getInt(Mockito.eq("resurvey_days"), Mockito.anyInt())).thenReturn(-1);
Mockito.when(prefs.getLong(Mockito.eq("surveyed"), Mockito.anyLong())).thenReturn(now);
Assert.assertEquals(true, preferencesUtils.wasRecentlySurveyed());
|
Mockito.when(prefs.getLong(Mockito.eq("surveyed"), Mockito.anyLong())).thenReturn(now - Constants.DAY_IN_MILLIS * 32L);
|
Wootric/WootricSDK-Android
|
androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/GetAccessTokenTaskTest.java
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
|
import com.wootric.androidsdk.network.WootricApiCallback;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
|
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class GetAccessTokenTaskTest {
|
// Path: androidsdk/src/main/java/com/wootric/androidsdk/network/WootricApiCallback.java
// public interface WootricApiCallback {
// void onAuthenticateSuccess(String accessToken);
// void onGetEndUserIdSuccess(long endUserId);
// void onEndUserNotFound();
// void onCreateEndUserSuccess(long endUserId);
// void onApiError(Exception error);
// }
// Path: androidsdk/src/test/java/com/wootric/androidsdk/network/tasks/GetAccessTokenTaskTest.java
import com.wootric.androidsdk.network.WootricApiCallback;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.RobolectricTestRunner;
import static org.assertj.core.api.Assertions.assertThat;
package com.wootric.androidsdk.network.tasks;
@RunWith(RobolectricTestRunner.class)
public class GetAccessTokenTaskTest {
|
@Mock WootricApiCallback wootricApiCallback;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.