Android Open Source - markj Jw Member Mapper From Project Back to project page markj .
License The source code is released under:
GNU Lesser General Public License
If you think the Android project markj listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.markjmind.mobile.api.android.controller;
/ * w w w . j a v a 2 s . c o m * /
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import android.view.View;
/**
*
* @author ???
* @email markjmind@gmail.com
*/
public class JwMemberMapper {
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.FIELD )
public @interface getView
{
int value() default -1;
String click() default "" ;
}
@Retention( RetentionPolicy.RUNTIME )
@Target( ElementType.FIELD )
public @interface getViewClick
{
int value() default -1;
String click() default "" ;
}
@Retention( RetentionPolicy.RUNTIME )
@Target(ElementType.TYPE)
public @interface layout
{
int value();
}
public static int injectionLayout(Class<?> viewerClass){
if (viewerClass.isAnnotationPresent(layout.class)){
layout lytId = viewerClass.getAnnotation(layout.class);
return lytId.value();
}else {
throw new JwMapperException("\n[" +viewerClass.getName()+"] ?? Viewer?? layout??? ???? annotation??? ????." ,null);
}
}
public static void injectField(JwViewer obj){
Field[] fields = obj.getClass().getDeclaredFields();
for (int i=0;i<fields.length;i++){
if (fields[i].isAnnotationPresent(getView.class)){
getView ab = fields[i].getAnnotation(getView.class);
int id = ab.value();
id = setField(obj,id,fields[i]);
String click = ab.click();
if (!"" .equals(click) && click.length()>0){
obj.setOnClickListener(click, id);
}
}else if (fields[i].isAnnotationPresent(getViewClick.class)){
getViewClick ab = fields[i].getAnnotation(getViewClick.class);
int id = ab.value();
id = setField(obj,id,fields[i]);
String click = ab.click();
if (!"" .equals(click) && click.length()>0){
}else {
click = fields[i].getName();
}
obj.setOnClickListener(click, id);
}
}
}
private static int setField(JwViewer obj, int id, Field field){
if (id==-1){
id = JwStringID.getID(field.getName(), obj.getActivity().getApplication());
}
View v = obj.getView(id);
if (v==null){
throw new JwMapperException("\n[" +obj.getClass().getName()+"] Field:" +field.getName()+", Filed?? ???? ID(Null)? ?? ?????????." ,null);
}
try {
field.setAccessible(true);
field.set(obj, v);
} catch (IllegalArgumentException e) {
throw new JwMapperException("\n[" +obj.getClass().getName()+"] Field:" +field.getName()+", ????? Field?? ???? ID? ????? ????." ,e);
} catch (IllegalAccessException e) {
throw new JwMapperException("\n[" +obj.getClass().getName()+"] Field:" +field.getName()+", ??????? ?? ?????." ,e);
}
return id;
}
}
Java Source Code List com.markjmind.mobile.api.android.controller.JwAsyncTask.java com.markjmind.mobile.api.android.controller.JwMapperException.java com.markjmind.mobile.api.android.controller.JwMemberMapper.java com.markjmind.mobile.api.android.controller.JwStringID.java com.markjmind.mobile.api.android.controller.JwViewController.java com.markjmind.mobile.api.android.controller.JwViewerCache.java com.markjmind.mobile.api.android.controller.JwViewer.java com.markjmind.mobile.api.android.controller.Jwc.java com.markjmind.mobile.api.android.controller.OnClickListenerReceiver.java com.markjmind.mobile.api.android.controller.ViewerXmlMapper.java com.markjmind.mobile.api.android.exception.JwErrorCode.java com.markjmind.mobile.api.android.exception.JwException.java com.markjmind.mobile.api.android.json.JSONMsgString.java com.markjmind.mobile.api.android.json.JwJOSNTreeArray.java com.markjmind.mobile.api.android.json.JwJSONReader.java com.markjmind.mobile.api.android.ui.JwAnimation.java com.markjmind.mobile.api.android.ui.JwGroup.java com.markjmind.mobile.api.android.ui.JwMenu.java com.markjmind.mobile.api.android.ui.JwOnGroupSelect.java com.markjmind.mobile.api.android.ui.JwTabGroup.java com.markjmind.mobile.api.android.ui.JwTouchGroupListener.java com.markjmind.mobile.api.android.ui.JwTouchGroup.java com.markjmind.mobile.api.android.ui.JwTouchMotionGroupLisener.java com.markjmind.mobile.api.android.ui.JwTouchMotionGroup.java com.markjmind.mobile.api.android.ui.drawgraph.GraphBoard.java com.markjmind.mobile.api.android.ui.drawgraph.GraphSkin.java com.markjmind.mobile.api.android.ui.drawgraph.HBackLineSkin.java com.markjmind.mobile.api.android.ui.drawgraph.LineGraphSkin.java com.markjmind.mobile.api.android.ui.drawgraph.PieGraph.java com.markjmind.mobile.api.android.ui.drawgraph.RectGraphSkin.java com.markjmind.mobile.api.android.ui.drawgraph.SimpleStyle.java com.markjmind.mobile.api.android.ui.drawgraph.TextArraySkin.java com.markjmind.mobile.api.android.ui.drawgraph.VBackLineSkin.java com.markjmind.mobile.api.android.ui.graph.Arc.java com.markjmind.mobile.api.android.ui.graph.BarElement.java com.markjmind.mobile.api.android.ui.graph.BarLayout.java com.markjmind.mobile.api.android.ui.graph.Bar.java com.markjmind.mobile.api.android.ui.graph.IPieSkin.java com.markjmind.mobile.api.android.ui.graph.LineLayout.java com.markjmind.mobile.api.android.ui.graph.MeasureLayout.java com.markjmind.mobile.api.android.ui.graph.PieArcRoundSkin.java com.markjmind.mobile.api.android.ui.graph.PieLayout.java com.markjmind.mobile.api.android.ui.graph.PiePercentSkin.java com.markjmind.mobile.api.android.ui.view.JwBaseDropDown.java com.markjmind.mobile.api.android.ui.view.JwDropDown.java com.markjmind.mobile.api.android.ui.view.JwSlidingLayout.java com.markjmind.mobile.api.android.ui.view.JwWheelView.java com.markjmind.mobile.api.android.ui.view.StickerListener.java com.markjmind.mobile.api.android.ui.view.StickerView.java com.markjmind.mobile.api.android.ui.view.textview.JwTextViewAutoScale.java com.markjmind.mobile.api.android.ui.view.textview.JwTextViewFonts.java com.markjmind.mobile.api.android.ui.view.textview.JwTextViewWrapScale.java com.markjmind.mobile.api.android.ui.wrapper.JwAlertDialog.java com.markjmind.mobile.api.android.ui.wrapper.JwToast.java com.markjmind.mobile.api.android.util.JwFile.java com.markjmind.mobile.api.android.util.JwPreferenceList.java com.markjmind.mobile.api.android.util.JwPreference.java com.markjmind.mobile.api.android.util.JwSound.java com.markjmind.mobile.api.android.util.JwTextUtils.java com.markjmind.mobile.api.android.util.PhoneInfo.java com.markjmind.mobile.api.android.util.WebConnection.java com.markjmind.mobile.api.android.xml.JwDomHandler.java com.markjmind.mobile.api.android.xml.JwDomLoader.java com.markjmind.mobile.api.android.xml.JwEditElementHandler.java com.markjmind.mobile.api.android.xml.JwXmlLoader.java com.markjmind.mobile.api.android.xml.JwXmlResoure.java com.markjmind.mobile.api.hub.ArrayJDhub.java com.markjmind.mobile.api.hub.DBhub.java com.markjmind.mobile.api.hub.JDhub.java com.markjmind.mobile.api.hub.Loader.java com.markjmind.mobile.api.hub.StoreList.java com.markjmind.mobile.api.hub.Store.java