Ejemplo n.º 1
0
  /**
   * *********************************************************************************************
   * VOD시청
   */
  public void addWatchVod(Date watchDate, String assetId, String title) {
    // Realm Database **********************************************************************
    // Obtain a Realm instance
    Realm realm = Realm.getInstance(mContext);
    RealmResults<WatchVodObject> results = realm.where(WatchVodObject.class).findAll();
    long iSeq = 0;
    if (results == null) {
      //
    } else {
      if (results.size() == 0) {
        iSeq = 0;
      } else {
        iSeq = realm.where(WatchVodObject.class).maximumInt("iSeq") + 1;
      }
    }

    WatchVodObject obj = new WatchVodObject();
    obj.setiSeq((int) iSeq);
    obj.setdDate(watchDate);
    obj.setsAssetId(assetId);
    obj.setsTitle(title);
    realm.beginTransaction();
    WatchVodObject obj2 = realm.copyToRealm(obj);
    realm.commitTransaction();
    // Realm Database **********************************************************************
  }
Ejemplo n.º 2
0
 public void removeWatchVod(int iSeq) {
   // Realm Database **********************************************************************
   // Obtain a Realm instance
   Realm realm = Realm.getInstance(mContext);
   realm.beginTransaction();
   RealmResults<WatchVodObject> results =
       mRealm.where(WatchVodObject.class).equalTo("iSeq", iSeq).findAll();
   // RealmResults<WatchVodObject> results = mRealm.where(WatchVodObject.class).findAll();
   if (results.size() > 0) {
     WatchVodObject obj = results.get(0);
     obj.removeFromRealm();
   } else {
     //
   }
   realm.commitTransaction();
   // Realm Database **********************************************************************
 }
Ejemplo n.º 3
0
  public ArrayList<JSONObject> getAllWatchVodObject() {
    ArrayList<JSONObject> arr = new ArrayList<JSONObject>();
    RealmResults<WatchVodObject> results = mRealm.where(WatchVodObject.class).findAll();
    try {
      int loop = results.size() - 1;
      SimpleDateFormat sd = new SimpleDateFormat("MM.dd (E),HH:mm");
      for (int i = 0; i < results.size(); i++) {
        WatchVodObject obj = results.get(loop);
        JSONObject jo = new JSONObject();

        String sDate = sd.format(obj.getdDate()).toString();
        jo.put("iSeq", obj.getiSeq());
        jo.put("sDate", sDate);
        jo.put("sAssetId", obj.getsAssetId());
        jo.put("sTitle", obj.getsTitle());
        arr.add(jo);
        loop--;
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return arr;
  }