Android Open Source - markj Jw Viewer






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;
//from  w w  w  . j  av  a  2 s.  co m
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Application;
import android.app.Dialog;
import android.content.Context;
import android.content.res.Resources;
import android.os.AsyncTask;
import android.os.Build;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.markjmind.mobile.api.hub.Store;


/**
 * start : 2013.11.17<br>
 * <br>
 * Base Viewer ?????<br>
 * ???? Viewer??? ?????? ??????<br>
 * BaseLayout ? ?????? view_init????? ????? ??????. 
 * 
 * @author ???
 * @phone 010-2898-7850
 * @email markjmind@gmail.com
 * @version 2013.11.17
 */

public class JwViewer {
  
  private static Store<Refresh> asyncTaskPool = new Store<Refresh>();
  private static int taskIndex = 0;
  private static ViewerXmlMapper vxm;
  private Context context;
  private Activity activity;
  private Dialog dialog;
  private View preViewer;
  private View viewer;
  private ViewGroup parentView;
  private OnClickListenerReceiver oclReceiver;
  private String id;
  private int layoutId;
  private Store<Object> loadingParam;
  private Store<Object> viewerParam;
  
  private Class<?> jwViewerClass;
  
  
  public static final int INSTANCE_NEW=0;
  public static final int INSTANCE_SAVE=2;
  
  public TYPE_MODE mode;
  enum TYPE_MODE{
    ACTIVITY,
    DIALOG
  }
  
  public static Store<Object> asyncStore = new Store<Object>();
  private boolean preload = false;
  
  /**
   * ???????
   */
  protected JwViewer(){
    viewerParam = new Store<Object>();
  }
  
  /**
   * ??????? Thread ?? ?? ????? ??????.
   * @return
   */
  public boolean loading(){
    return true;
  }
  
  /**
   * loading() ?????? true ???? ??????.<br>
   * Viewer? ???????? ??<br>
   * Viewer?? ???????????? ????? view???????? ?? ????.
   */
  public void view_init(){
    
  }
  
  /**
   * loading() ?????? false???? ??????.<br>
   * ????? ?????? ?? ????? ????? ??????.
   */
  public void view_fail(){
    
  }
  
  /**
   * Viewer? ??? ?
   * @param activity ? ????? activity
   * @param layout_id Viewer??? Layout ID
   */
  public void init(Activity activity,int layout_id){
    setLayoutId(layout_id);
    mode = TYPE_MODE.ACTIVITY;
    if(!activity.equals(this.activity)){
      this.activity = activity;
      this.context = activity;
    }
  }
  /**
   * Viewer? ??? ??.
   * @param dialog Viewer? ????? dialog
   * @param layout_id Viewer??? Layout ID
   */
  public void init(Dialog dialog,int layout_id){
    setLayoutId(layout_id);
    mode = TYPE_MODE.DIALOG;
    if(!dialog.equals(this.dialog)){
      this.dialog = dialog;
      this.context = dialog.getContext();
    }
  }
  
/********************************** Activity, Dialog ?? ***************************************************/
  /**
   * context? Activity???? Dialog???? ????<br>
   * ????? ???? ???? context? init??.
   * @param viewer
   * @param R_layout_id
   */
  private void initToContext(JwViewer viewer, int R_layout_id){
    if(mode==TYPE_MODE.DIALOG){
      viewer.init(dialog, R_layout_id);
    }else{
      viewer.init(activity, R_layout_id);
    }
  }
  
  /**
   * context? Activity???? Dialog???? ????<br>
   * ID?? ???? Parents? GroupView? ??
   * @param R_id_parents
   * @return
   */
  private ViewGroup getParentsToContext(int R_id_parents){
    ViewGroup parents;
    if(mode==TYPE_MODE.DIALOG){
      parents = (ViewGroup)Jwc.getView(R_id_parents, dialog);
    }else{
      parents = (ViewGroup)Jwc.getView(R_id_parents, activity);
    }
    return parents;
  }
  
  /**
   * context? Activity???? Dialog???? ????<br>
   * ID?? ???? View? ??
   * @param R_id_view
   * @return
   */
  private View getViewToContext(int R_id_view){
    if(mode.equals(TYPE_MODE.ACTIVITY)){
      return activity.findViewById(R_id_view);
    }else if(mode.equals(TYPE_MODE.DIALOG)){
      return dialog.findViewById(R_id_view);
    }else{
      return viewer.findViewById(R_id_view);
    }
  }
/*************************************************************************************/
  /**
   * Viewer? ??? Activity? ????.
   * @return Activity
   */
  public Activity getActivity(){
    return activity;
  }
  
  /**
   * Viewer? ??? Dialog? ????.
   * @return Dialog
   */
  public Dialog getDialog(){
    return dialog;
  }
  
  /**
   * ?? Viewer? ??? ??????? ????.
   * @param key Parameter Key
   * @param value Parameter Value
   */
  public JwViewer addParam(String key, Object value){
    viewerParam.add(key, value);
    return this;
  }
  
  /**
   * ?? Viewer? ??? ??????? ???.
   * @param key Parameter Key
   * @return Parameter Value
   */
  public Object getParam(String key){
    return viewerParam.get(key);
  }
  
  
  /**
   * ?? Viewer? ??? ??????? ???.<br>
   * key?? ?????? value? ??? defalut???? ????.
   * @param key Parameter Key
   * @param defalut value
   * @return Parameter Value
   */
  public Object optParam(String key, Object defalut){
    Object result = getParam(key);
    if(result==null)
      result = defalut;
    return result;
  }
  
  /**
   * ?? Viewer? ??? ??????? String??? ???.
   * @param key Parameter Key
   * @return Parameter String Value
   */
  public String getParamString(String key){
    return (String)getParam(key);
  }
  
  /**
   * ?? Viewer? ??? ??????? String??? ???.<br>
   * key?? ?????? value? ??? defalut???? ????.
   * @param key Parameter Key
   * @param defalut value
   * @return Parameter String Value
   */
  public String optParamString(String key, String defalut){
    return (String)optParam(key, defalut);
  }
  /**
   * ?? Viewer? ??? ??????? Int??? ???.
   * @param key Parameter Key
   * @return Parameter Int Value
   */
  public int getParamInt(String key){
    return (Integer)getParam(key);
  }
  
  /**
   * ?? Viewer? ??? ??????? Int??? ???.<br>
   * key?? ?????? value? ??? defalut???? ????.
   * @param key Parameter Key
   * @param defalut value
   * @return Parameter Int Value
   */
  public int optParamInt(String key, int defalut){
    return (Integer)optParam(key, defalut);
  }
  /**
   * ?? Viewer? ??? ?????? Store? ???.
   * @return Parameter store
   */
  public Store<Object> getParamStore(){
    return viewerParam;
  }
  
  /**
   *  ?? Viewer? ??? ?????? Store? ????.
   */
  public void setParamStore(Store<Object> store){
    viewerParam = store;
  }
  
  /**
   * Loading??? ??? Key??? ?????? ??????? ????.
   * @param key Parameter Key
   * @param value Parameter value
   */
  public void setLoadingParam(String key, Object value){
    loadingParam.add(key, value);
  }
  
  /**
   * Loading??? ??? Key??? ?????? ??????? ????.
   * @param key Parameter Key
   * @return Parameter value
   */
  public Object getLoadParam(String key){
    if(loadingParam==null){
      return null;
    }
    return loadingParam.get(key);
  }
  
  /**
   * Loading??? ??? Key??? ?????? ??????? ????.<br>
   * ???? ????? defalut???? ????.
   * @param key Parameter Key
   * @param defalut defalut Parameter value
   * @return Parameter value
   */
  public Object optLoadParam(String key, Object defalut){
    Object result = getLoadParam(key);
    if(result==null)
      result = defalut;
    return result;
  }
  
  /**
   * Loading??? ??? Key??? ?????? ??????? ????.<br>
   * ???? ????? defalut???? ????.
   * @param key Parameter Key
   * @param defalut defalut Parameter value
   * @return Parameter value
   */
  public Store<Object> getLoadParamStore(){
    return loadingParam;
  }
  
  /**
   * Activity?? LinearLayout??? ContentView? ?????. 
   * @param activity ContentView? ???? Activity
   * @return ?????? LinearLayout
   */
  public static LinearLayout setContentLinear(Activity activity){
    LinearLayout layout = new LinearLayout(activity);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT);
    layout.setLayoutParams(params);
    activity.setContentView(layout);
    return layout;
  }
  
  /**
   * Activity?? FrameLayout??? ContentView? ?????. 
   * @param activity ContentView? ???? Activity
   * @return ?????? FrameLayout
   */
  public static FrameLayout setContentFrame(Activity activity){
    FrameLayout layout = new FrameLayout(activity);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,FrameLayout.LayoutParams.MATCH_PARENT);
    layout.setLayoutParams(params);
    activity.setContentView(layout);
    return layout;
  }
  
  
  private boolean isCache=false;
  public JwViewer cache(boolean isCache){
    this.isCache = isCache;
    return this;
  }
  
  /**
   * Viewer??? Layout??? ?????.
   */
  public void viewerInit(boolean newViewer){
    if(newViewer){
      viewer = (ViewGroup)getLayoutInfalter(layoutId);
      if(isCache){
        JwViewerCache.put(this);
      }
    }else{
      if(isCache){
        JwViewer jv = JwViewerCache.get(layoutId,getParent()); 
        if(jv==null){
          Log.e("??", "?? ????");
          viewer = (ViewGroup)getLayoutInfalter(layoutId);
          //????? ??
          JwViewerCache.put(this);
        }else{
          Log.e("??", "?????? ?? ??");
          viewer = jv.getView();
        }
        
      }else{
        viewer = (ViewGroup)getLayoutInfalter(layoutId);
        Log.e("??", "????!");
      }
    }
    
    if(inAnimation!=null){
      viewer.setAnimation(inAnimation);
    }
  }
  

  
  /**
   * ????? ?? XML??? ????.
   * @param R_raw_xml ??? xml id
   * @param app Application
   */
  public static void xmlLoad(int R_raw_xml, Application app){
    if(vxm == null){
      vxm = new ViewerXmlMapper(app);
      vxm.load(R_raw_xml);
    }
  }
  
  /**
   * Viewer? ?????.
   * @param id Viewer ID name
   * @param R_layout_id layout ID
   * @param viewerClass Viewer Class
   */
  public static void addViewer(String id, int R_layout_id, Class<?> viewerClass){
    JwViewer.addViewer(id, R_layout_id, "",  viewerClass);
  }
  /**
   * Viewer? ?????.
   * @param id Viewer ID name
   * @param R_layout_id  layout ID
   * @param desc ??
   * @param viewerClass Viewer Class
   */
  public static void addViewer(String id, int R_layout_id, String desc, Class<?> viewerClass){
    vxm.add(id, R_layout_id, desc, null, viewerClass);
  }
  /**
   * Viewer? ?????. 
   * @param id id Viewer ID name
   * @param jwViewer JwViewer ???
   */
  public static void addViewer(String id, JwViewer jwViewer){
    jwViewer.setId(id);
    vxm.add(id, jwViewer.getLayoutId(), "", jwViewer, jwViewer.getClass());
  }

  /**
   * ?? Viewer? ???? context? jwViewerClass???<br>
   * ????? instance? ????? Viewer? ??? ?????.
   * @param R_layout_id ???? Viewer??? layout ID
   * @param jwViewerClass ???? Viewer ?????
   * @return ?? Viewer
   */
  public JwViewer getViewer(int R_layout_id, Class<?> jwViewerClass){
    try {
      JwViewer jv = (JwViewer)jwViewerClass.newInstance();
      jv.jwViewerClass = jwViewerClass;
      initToContext(jv, R_layout_id);
      return jv;
    } catch (InstantiationException e) {
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    }
    return null;
  }
  
  /**
   * R_layout_id?? jwViewerClass? ?????? Viewer? ????.
   * @param R_layout_id layout ID
   * @param activity activity
   * @return JwViewer
   */
  public static JwViewer getViewer(int R_layout_id, Class<?> jwViewerClass, Activity activity){
    try {
      JwViewer jv = (JwViewer)jwViewerClass.newInstance();
      jv.jwViewerClass = jwViewerClass;
      jv.init(activity, R_layout_id);
      return jv;
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
      e.printStackTrace();
    }
    return null;
  }
  
  
  /**
   * R_layout_id?? jwViewerClass? ?????? Viewer? ????.
   * @param R_layout_id layout ID
   * @param jwViewerClass JwViewer? ????? Class
   * @param dialog dialog
   * @return JwViewer
   */
  public static JwViewer getViewer(int R_layout_id, Class<?> jwViewerClass, Dialog dialog){
    try {
      JwViewer jv = (JwViewer)jwViewerClass.newInstance();
      jv.jwViewerClass = jwViewerClass;
      jv.init(dialog, R_layout_id);
      return jv;
    } catch (IllegalAccessException e) {
      e.printStackTrace();
    } catch (InstantiationException e) {
      e.printStackTrace();
    }
    return null;
  }
  
  /**
   * R_layout_id?? jwViewerClass? ?????? Viewer? ????.
   * @param R_layout_id layout ID
   * @param jwViewerClass JwViewer? ????? Class
   * @param jwViewer jwViewer
   * @return JwViewer
   */
  public static JwViewer getViewer(int R_layout_id, Class<?> jwViewerClass, JwViewer jwViewer){
    if(jwViewer.mode==JwViewer.TYPE_MODE.ACTIVITY){
      return JwViewer.getViewer(R_layout_id, jwViewerClass, jwViewer.getActivity());
    }else if(jwViewer.mode==JwViewer.TYPE_MODE.DIALOG){
      return JwViewer.getViewer(R_layout_id, jwViewerClass, jwViewer.getDialog());
    }
    return null;
  }
  
  /**
   * R_layout_id?? jwViewerClass? ?????? Viewer? ????.<br>
   * layout ID? jwViewerClass??? layout Annotation??? ?????<br>
   * ??? Viewer Class? layout Annotation??? ????????.
   * @param activity activity
   * @return JwViewer
   */
  public static JwViewer getViewer(Class<?> jwViewerClass, Activity activity){
    return JwViewer.getViewer(JwMemberMapper.injectionLayout(jwViewerClass), jwViewerClass, activity);
  }
  /**
   * R_layout_id?? jwViewerClass? ?????? Viewer? ????.<br>
   * layout ID? jwViewerClass??? layout Annotation??? ?????<br>
   * ??? Viewer Class? layout Annotation??? ????????.
   * @param Dialog dialog
   * @return JwViewer
   */
  public static JwViewer getViewer(Class<?> jwViewerClass, Dialog dialog){
    return JwViewer.getViewer(JwMemberMapper.injectionLayout(jwViewerClass), jwViewerClass, dialog);
  }
  
  /**
   * R_layout_id?? jwViewerClass? ?????? Viewer? ????.<br>
   * layout ID? jwViewerClass??? layout Annotation??? ?????<br>
   * ??? Viewer Class? layout Annotation??? ????????.
   * @param JwViewer jwViewer
   * @return JwViewer
   */
  public static JwViewer getViewer(Class<?> jwViewerClass, JwViewer jwViewer){
    return JwViewer.getViewer(JwMemberMapper.injectionLayout(jwViewerClass), jwViewerClass, jwViewer);
  }
  
  
  /**
   * Viewer? ????? Xml??? id?? ???? Viewer? ????.
   * @param id Viewer ID
   * @param activity activity
   * @return Viewer
   */
  public static JwViewer getViewer(String id, Activity activity){
    return vxm.getViewer(id, activity);
  }
  /**
   * Viewer? ????? Xml??? id?? ???? Viewer? ????.
   * @param id Viewer ID
   * @param dialog dialog
   * @return Viewer
   */
  public static JwViewer getViewer(String id, Dialog dialog){
    return vxm.getViewer(id, dialog);
  }
  
  
  
  
//*************************************************** binder *********************************************//
  
  public final static String TASK_ACV="acv";
  public final static String TASK_APUT="aput";
  private String task;
  private boolean async=true;

  public JwViewer setPreLoad(boolean isPreload){
    this.preload = isPreload;
    return this;
  }
  
  public String getTaskName(){
    return task;
  }
  
  public JwViewer setAsync(boolean isAsync){
    this.async = isAsync;
    return this;
  }
  
  private void removeAllViews(){
    if(outAnimation!=null){
      final View[] childArr = new View[parentView.getChildCount()];
      for(int i=0;i<childArr.length;i++){
        childArr[i] = parentView.getChildAt(i);
        outAnimation.setAnimationListener(new RemoveAnimation(childArr[i]));
        childArr[i].startAnimation(outAnimation);
      }
    }else{
      parentView.removeAllViews();
    }
  }
  class RemoveAnimation implements AnimationListener{
    View view;
    public RemoveAnimation(View view){
      this.view = view;
    }
    @Override
    public void onAnimationEnd(Animation arg0) {
    }
    @Override
    public void onAnimationRepeat(Animation arg0) {
    }
    @Override
    public void onAnimationStart(Animation arg0) {
      if(view!=null){
        parentView.removeView(view);
      }
    }
  }
  /**
   * index?? ???? ?? ViewGroup?? JwViewer? ????.
   * @param parents ?? ViewGroup
   * @param index index
   * @return
   */
  private JwViewer add(ViewGroup parents, int index){
    JwViewer jv = getViewer(getLayoutId(),jwViewerClass);
    jv.parentView = parents;
    jv.setAsync(this.async);
    jv.setParamStore(viewerParam);
    jv.setAnimation(this.inAnimation, this.outAnimation, this.outEndAnimate);
    if(jv.async){
      jv.excute(TASK_APUT);
    }else{
      jv.viewerInit(true);
      if(index==-1){
        jv.parentView.addView(jv.viewer);
      }else{
        jv.parentView.addView(jv.viewer);
      }
      jv.view_init();
    }
    return this;
  }
  private View getLayoutInfalter(int layout_id){
    View v = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(layout_id, null);
    return v;
  }
  
  /**
   * index?? ???? ?? ViewGroup?? JwViewer? ????.
   * @param parents ?? ViewGroup ID
   * @param index index
   * @return
   */
  public JwViewer add(int R_id_parents, int index) {
    ViewGroup parents = getParentsToContext(R_id_parents);
    return add(parents, index);
  }
  
  /**
   * ?? ViewGroup?? JwViewer? ????.
   * @param parents ?? ViewGroup
   * @return
   */
  public JwViewer add(ViewGroup parents) {
    return add(parents,-1);
  }
  
  /**
   * ?? ViewGroup?? JwViewer? ????.
   * @param R_id_parents ?? ViewGroup ID
   * @return
   */
  public JwViewer add(int R_id_parents) {
    ViewGroup parents = getParentsToContext(R_id_parents);
    return add(parents);
  }
  
  public JwViewer clearCache(){
    JwViewerCache.clear(layoutId, parentView);
    return this;
  }
  
  public static void clearAllCache(){
    JwViewerCache.clear();
  }
  
  boolean isRefresh = false;
  boolean ableRefresh = false;
  
  public boolean ableRefresh(){
    return ableRefresh;
  }
  
  public JwViewer refresh(){
    if(ableRefresh){
      if(async){
        excute(TASK_ACV);
      }else{
        cancelTaskAcv();
        viewerInit(true);
        removeAllViews();
        parentView.addView(viewer);
        view_init();
      }
      ableRefresh = true;
      return this;
    }
    return this;
  }
  
  public static JwViewer getViewerCache(int layoutId, ViewGroup parents){
    JwViewer jv = JwViewerCache.get(layoutId, parents);
    return jv;
  }
  public static JwViewer getViewerCache(int layoutId, int parents_id,Activity activity){
    ViewGroup parents = (ViewGroup)Jwc.getView(parents_id, activity);
    return getViewerCache(layoutId, parents);
  }
  public static JwViewer getViewerCache(int layoutId, int parents_id,Dialog dialog){
    ViewGroup parents = (ViewGroup)Jwc.getView(parents_id, dialog);
    return getViewerCache(layoutId, parents);
  }
  /**
   * ?? ViewGroup ????? View???? ??? ???<br>
   * ?? Viewer? ????.
   * @param parents ?? ViewGroup
   * @return
   */
  public JwViewer change(ViewGroup parents){
    parentView = parents;
    boolean cache = (isCache && JwViewerCache.contain(layoutId,parents));
    if(async && !cache){
      excute(TASK_ACV);
    }else{
      cancelTaskAcv();
      viewerInit(false);
      removeAllViews();
      parentView.addView(viewer);
      if(!cache){
        view_init();
      }
    }
    ableRefresh = true;
    return this;
  }
  
  /**
   * ?? ViewGroup ????? View???? ??? ???<br>
   * ?? Viewer? ????.
   * @param parents ?? ViewGroup ID
   * @return
   */
  public JwViewer change(int R_id_parents){
    ViewGroup parents = getParentsToContext(R_id_parents);
    return change(parents);
  }
  
  
  public ViewGroup setPreView(int R_layout_id){
    if(parentView!=null){
      if(TASK_ACV.equals(task)){
        removeAllViews();
      }
    }
    // TODO ????? ???? Add? viewer? AsyncTask???? 1:1? ????????
    //??? jwviewer instance ???? ??? async?? 
    //????? instance? add? ??????? ??? ?? ??? ??? ???
    //?? ??? ???? ????? Add ???
    preViewer = (ViewGroup) getLayoutInfalter(R_layout_id);
    preViewer.setLayoutParams(getParent().getLayoutParams());
    ((ViewGroup)getParent()).addView(preViewer);
    return (ViewGroup)preViewer;
  }
  
  @SuppressLint("NewApi") 
  private void excute(String taskName){
    this.task = taskName;
    String taskKey = getTaskKey(taskName);
    if(TASK_APUT.equals(taskName)){
      taskIndex++;
    }else{
      cancelTaskAput();
      cancelTaskAcv();
    }
    Refresh ref = new Refresh(taskKey, this);
    asyncTaskPool.add(taskKey, ref);
    
    if( Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB ) {
      ref.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
      ref.execute();
    }
  }

  public void view_pre(){
    if(parentView!=null){
      if(TASK_ACV.equals(task)){
        removeAllViews();
      }
    }
  }
  public void onProgressUpdate(Integer... values){
  }
  public void onCancelled(){
  }
  
  private class Refresh extends AsyncTask<Object, Integer, Object>{
    private String taskKey;
    private boolean isStop;
    private JwViewer jv;
    
    public Refresh(String taskKey, JwViewer jv){
      this.taskKey = taskKey;
      this.isStop = false;
      this.jv = jv;
    }
    
    public void stop(){
      cancel(true);
      isStop = true;
      asyncTaskPool.remove(taskKey);
      Log.w("JwViewer","Stop AsyncTask : "+taskKey);
    }
    
    @Override
    protected void onPreExecute() {
      if(preload){
        viewerInit(true);
        if(TASK_ACV.equals(task)){
          jv.removeAllViews();
        }
        parentView.addView(viewer,parentView.getLayoutParams());  
      }else{
        jv.view_pre();
      }
    }
    @Override
    protected void onCancelled() {
      jv.onCancelled();
    }
    @Override
    protected void onProgressUpdate(Integer... values) {
      jv.onProgressUpdate(values);
    }
    @Override
    protected Object doInBackground(Object... params) {
      loadingParam = new Store<Object>();
      loadingParam.clear();
      return loading(); //??????? ????
    }
    @Override
    protected void onPostExecute(Object result) {
      if (isStop) {
        return;
      }
      boolean isView = (Boolean)result;
      if(isView){
        if(preload){
          
        }else{
          viewerBind(jv, task);
        }
        JwMemberMapper.injectField(JwViewer.this);
        view_init();
      }else{
        view_fail();
      }
      asyncTaskPool.remove(taskKey);
    }
  }
  
  private synchronized static void viewerBind(JwViewer jv, String task){
    ViewGroup parentView = jv.getParent();
    int viewerIndex = -1;
    if(TASK_ACV.equals(task)){
      jv.removeAllViews();
    }else{
      for(int i=0;i<parentView.getChildCount();i++){
        if(jv.preViewer == parentView.getChildAt(i)){
          viewerIndex = i;
          break;
        }
      }
      parentView.removeView(jv.preViewer);
    }
    jv.viewerInit(true);
    if(viewerIndex>=0){
      parentView.addView(jv.viewer,viewerIndex,parentView.getLayoutParams());
    }else{
      parentView.addView(jv.viewer,parentView.getLayoutParams());
    }
  }
  
  public String getTaskKey(String taskName){
    String taskKey = taskName+"_"+parentView.hashCode();
    if(TASK_APUT.equals(taskName)){
      taskKey+=taskIndex;
    }
    return taskKey;
  }
  
  public static void cancelTask(String taskKey){
    Refresh ref = asyncTaskPool.get(taskKey);
    if(ref!=null){
      ref.stop();
    }
  }
  
  public static void cancelTaskAcv(View parents){
    String taskKey = TASK_ACV+"_"+parents.hashCode();
    cancelTask(taskKey);
  }
  public static void cancelTaskAput(View parents){
    String[] keys = getRunTaskKeys();
    for(int i=0;i<keys.length;i++){
      String tempKey = TASK_APUT+"_"+parents.hashCode();
      if(keys[i].indexOf(tempKey)>=0){
        cancelTask(keys[i]);
      }
    }
  }
  
  public void cancelTaskAput(){
    cancelTaskAput(parentView);
  }
  
  public void cancelTaskAcv(){
    String taskKey = getTaskKey(TASK_ACV);
    cancelTask(taskKey);
  }
  
  public void cancelTaskAput(View parents, int taskIndex){
    String taskKey = TASK_APUT+"_"+parents.hashCode()+"_"+taskIndex;
    cancelTask(taskKey);
  }
  public void cancelTaskAput(int taskIndex){
    cancelTaskAput(parentView,taskIndex);
  }
  public static int getRunTaskCount(){
    return asyncTaskPool.size();
  }
  
  public static String[] getRunTaskKeys(){
    return asyncTaskPool.getKeys();
  }
  
  
  
  
//*************************************************** changeViewer *********************************************//
  
  
  /**
   * Viewer ID? ????.
   * @return Viewer ID
   */
  public String getId(){
    return id;
  }
  
  /**
   * Viewer ID? ????.
   * @param Viewer ID
   */
  public void setId(String id){
    this.id =id;
  }
  
  /**
   * Layout ID? ????.
   * @return Layout ID
   */
  public int getLayoutId(){
    return layoutId;
  }
  
  /**
   * Layout ID? ????.
   * @param Layout ID
   */
  public void setLayoutId(int layoutId){
    this.layoutId = layoutId;
  }
  
  /**
   * Context ???? ????.
   * @return Context
   */
  public Context getContext(){
    return context;
  }
  /**
   * viewer??? Context ???? ????.
   * @return Context
   */
  public Context getViewerContext(){
    return viewer.getContext();
  }
  
  /**
   * Resources? ????.
   * @return Resources
   */
  public Resources getResources(){
    return context.getResources();
  }
  
  
  /**
   * id?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param R_id_view ?????? ???? id
   */
  public void setOnClickListener(String methodName, int R_id_view){
//    if(oclReceiver==null){
      oclReceiver = new OnClickListenerReceiver(context);
//    }
    oclReceiver.setOnClickListener(this, methodName, R_id_view, viewer);
  }
  /**
   * view?? ???? ??????  ?????.
   * @param methodName ????
   * @param view view 
   */
  public void setOnClickListener(String methodName, View view){
//    if(oclReceiver==null){
      oclReceiver = new OnClickListenerReceiver(context);
//    }
    oclReceiver.setOnClickListener(this, methodName, view);
  }
  
  /**
   * parents??? child view? tag?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param tag ?????? ???? tag
   * @param parents tag? ???? parents view 
   */
  public void setOnClickListener(String methodName, String tag, View parents){
    setOnClickListener(methodName,getViewTag(tag, parents));
  }
  
  
  
  /**
   * tag?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param tag ?????? ???? tag
   */
  public void setOnClickListener(String methodName, String tag){
    setOnClickListener(methodName, tag, viewer);
  }
  
  /**
   * tag?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param tag ?????? ???? tag
   */
  public void setOnClickParamListener(String methodName, String tag, Object param){
    setOnClickParamListener(methodName, tag, viewer,param);
  }
  
  /**
   * id?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param R_id_view ?????? ???? id
   */
  public void setOnClickParamListener(String methodName, int R_id_view, Object param){
//    if(oclReceiver==null){
      oclReceiver = new OnClickListenerReceiver(context);
//    }
    oclReceiver.setOnClickParamListener(this, methodName, R_id_view, viewer,param);
  }
  /**
   * parents??? child view? tag?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param tag ?????? ???? tag
   * @param parents tag? ???? parents view 
   */
  public void setOnClickParamListener(String methodName, View view, Object param){
//    if(oclReceiver==null){
      oclReceiver = new OnClickListenerReceiver(context);
//    }
    oclReceiver.setOnClickParamListener(this, methodName, view,param);
  }
  /**
   * parents??? child view? tag?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param tag ?????? ???? tag
   * @param parents tag? ???? parents view 
   */
  public void setOnClickParamListener(String methodName, String tag, View parents, Object param){
    setOnClickParamListener(methodName, getViewTag(tag, parents),param);
  }
  

  
  /**
   * tag?? ??????? ???? ?? ???? ??? ??????  ?????.
   * @param methodName ????
   * @param tag ?????? ???? tag
   */
  public void setOnClickListenerByTag(String tag){
    setOnClickListener(tag, tag, viewer);
  }
  
  /**
   * ????? view?  ????.
   * @return ?? View
   */
  public ViewGroup getParent(){
    return this.parentView;
  }
  
  /**
   * Viewer?????? Layout
   * @return Viewer?????? Layout
   */
  public ViewGroup getLayout(){
    return (ViewGroup)viewer;
  }
  
  /**
   * Viewer?????? View? ????.
   * @return Viewer?????? View
   */
  public View getView(){
    return viewer;
  }
  
  /**
   * activity??? ?? View? ???
   * @param R_id_view ???? View ID
   * @return View ?? View
   */
  public View findViewById(int R_id_view){
    return getViewToContext(R_id_view);
    
  }
  
  /**
   * ?? viewer?? ????? View? ???
   * @param R_id_view ???? View ID
   * @return View ?? View
   */
  public View getView(int R_id_view){
    return Jwc.getView(R_id_view, viewer);
  }
  /**
   * parents?? ????? View? ???
   * @param R_id_view ???? View ID
   * @return View  ?? View
   */
  public View getView(int R_id_view,View parents){
    return Jwc.getView(R_id_view, parents);
  }
  
  /**
   * ?? viewer?? ????? View? tag? ???
   * @param tag ???? tag
   * @param parents parnets View
   * @return View ?? View
   */
  public View getViewTag(String tag){
    return getViewTag(tag, viewer);
  }
  
  /**
   * parnets?? ????? View? tag? ???
   * @param tag ???? tag
   * @param parents parnets View
   * @return View ?? View
   */
  public View getViewTag(String tag,View parents){
    return Jwc.getViewTag(tag, parents);
  }
  
  /**
   * ID?? ???? Button??? ???
   * @param R_id_view button ID
   * @return Button ?? Button
   */
  public Button Button(int R_id_view){
    return (Button)getView(R_id_view);
  }
  /**
   * ?? parents ?? ID???? Button??? ???
   * @param R_id_view button ID
   * @param parents parnets View
   * @return ?? Button
   */
  public Button Button(int R_id_view,View parents){
    return (Button)getView(R_id_view,parents);
  }
  /**
   * ID?? ???? TextView??? ???
   * @param R_id_view TextView ID
   * @return TextView
   */
  public TextView TextView(int R_id_view){
    return (TextView)getView(R_id_view);
  }
  /**
   * ?? parents ?? ID???? TextView? ???
   * @param R_id_view TextView ID
   * @param parents parnets View
   * @returnTextView
   */
  public TextView TextView(int R_id_view,View parents){
    return (TextView)getView(R_id_view,parents);
  }
  
  /**
   * Viewer? visible??.
   */
  public void visible(){
    viewer.setVisibility(View.VISIBLE);
  }
  
  /**
   * Viewer? invisible??.
   */
  public void inVisible(){
    viewer.setVisibility(View.INVISIBLE);
  }
  
  /**
   * Viewer? gone??.
   */
  public void gone(){
    viewer.setVisibility(View.GONE);
  }
  
  /**
   * Viewer layout??? ????.
   */
  public void removeLayout(){
    if(parentView!=null){
      if(parentView instanceof ViewGroup){
        ((ViewGroup)parentView).removeView(this.getLayout());
      }
    }
  }
  
  Animation outAnimation;
  public JwViewer setOutAnim(Animation outAnimation){
    this.outAnimation = outAnimation;
    return this;
  }
  Animation inAnimation;
  public JwViewer setInAnim(Animation inAnimation){
    this.inAnimation = inAnimation;
    return this;
  }
  public JwViewer setAnimation(Animation animation){
    this.inAnimation = animation;
    return this;
  }
  public JwViewer setAnimation(int R_anim_id){
    return setAnimation(AnimationUtils.loadAnimation(getContext(), R_anim_id));
  }
  public JwViewer setAnimationOut(Animation animation){
    this.outAnimation = animation;
    return this;
  }
  public JwViewer setAnimationOut(int R_anim_id){
    return setAnimationOut(AnimationUtils.loadAnimation(getContext(), R_anim_id));
  }
  boolean outEndAnimate=false;
  public JwViewer setAnimation(Animation inAnimation,Animation outAnimation,boolean outEndAnimate){
    this.inAnimation = inAnimation;
    this.outAnimation = outAnimation;
    this.outEndAnimate=outEndAnimate;
    return this;
  }
  public JwViewer setAnimation(int R_anim_inId,int R_anim_outId,boolean outEndAnimate){
    return setAnimation(AnimationUtils.loadAnimation(getContext(), R_anim_inId), AnimationUtils.loadAnimation(getContext(), R_anim_outId),outEndAnimate);
  }
}




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