Exemplo n.º 1
0
  private void handleDownloadObject(Context context, View view, MutableEntity m, Downloadable obj) {
    if (obj != null) {
      // TODO save in local?
      //            if(obj instanceof Entity){
      //                saveInDatabase((Entity) obj);
      //            }

      // TODO what about more
      //            if(obj instanceof Moreable){
      //                //clone params etc
      //                Object original = (Object) m.getEntity();
      //                if(original != null){
      //                    ((Moreable)obj).loadMore(original);
      //                }
      //                //set content
      ////				setContent(context, view, obj, m);
      //            }else{
      //            }

      setContent(context, view, obj);
      //			if(obj instanceof Downloadable){
      m.setEntity(obj);
      m.onStoring();
      obj.onDownLoadResponse(context);
      if (m.getNotifiable() != null) {
        m.getNotifiable().onDownloadResponse();
      }
      //			}
    }
  }
Exemplo n.º 2
0
  /**
   * inject a mutable entity for view
   *
   * @param context
   * @param view
   * @param m
   * @return
   */
  public boolean inject(Context context, View view, MutableEntity m) {
    checkInit();
    if (m == null || m.getEntity() == null) {
      return false;
    }

    Object bean = m.getEntity();
    if (bean instanceof Postable) {
      setDataPost(context, view, (Postable) m.getEntity());
    }
    //        else if (bean instanceof Getable){
    //            setDataPost(context, view, (Getable) m.getEntity());
    //        }

    /** if the state is stored */
    if (m.isStateStored()) {
      setContent(context, view, bean);
      return true;
    }
    if (bean instanceof Downloadable) {
      loadEntity(context, view, (MutableEntity) m);
      return true;
    }

    setContent(context, view, bean);
    return false;
  }
Exemplo n.º 3
0
  /** inject a mutable entity used for Activity */
  public void inject(Context context, MutableEntity m) {
    if (m == null || m.getEntity() == null) {
      return;
    }

    View view = setContentView(context, m.getEntity());
    inject(context, view, m);
  }
Exemplo n.º 4
0
  private void loadEntity(final Context context, final View view, final MutableEntity m) {
    final Downloadable downloadable = (Downloadable) m.getEntity();
    Object downloadParams = downloadable.onDownloadParams();

    Map<String, String> params = objToMap(downloadParams);

    String uri = downloadable.onDownLoadUrl(context);

    AbsDataProvider dataProvider = configurations.dataProvider;
    handleData(dataProvider, context, view, m, uri, downloadable, params);
  }