private void addCard(SharedPreferences sharedPreferences,String key){
  String json=sharedPreferences.getString(key,null);
  if (json != null) {
    try {
      JSONObject jsonData=new JSONObject(json);
      if (jsonData.has(IMAGE_KEY)) {
        String image=jsonData.getString(IMAGE_KEY);
        List<ITopic> cards=getSourceTopicModel();
switch (key) {
case POOL_KEY:
          cards.add(0,Cards.pool(image,getActivity()));
        removeDuplicates(POOL_KEY,cards);
      break;
case VIDEO_KEY:
switch (jsonData.getString(ID_KEY)) {
case POOL_CAMERA_ID:
      mGreatShotUrl=jsonData.getString(URL_KEY);
    mElv.setOnGroupClickListener(greatShotListener);
  cards.add(0,Cards.poolVideo(mGreatShotUrl,getActivity()));
removeDuplicates(VIDEO_KEY,cards);
break;
}
break;
case FOOD_KEY:
cards.add(0,Cards.food(image,getActivity()));
removeDuplicates(FOOD_KEY,cards);
break;
case PRINTER_3D_KEY:
cards.add(0,Cards.printer3d(image,getActivity()));
removeDuplicates(PRINTER_3D_KEY,cards);
break;
}
}
 else if (jsonData.has(MESSAGE_KEY)) {
String message=jsonData.getString(MESSAGE_KEY);
List<ITopic> cards=getSourceTopicModel();
cards.add(0,Cards.test(message,getActivity()));
}
UI.execute(null);
}
 catch (JSONException e) {
e.printStackTrace();
}
}
}

private void addCard ( SharedPreferences sharedPreferences , String key ) { String json = sharedPreferences . getString ( key , null ) ; if ( json != null ) { try { JSONObject jsonData = new JSONObject ( json ) ; if ( jsonData . has ( IMAGE_KEY ) ) { String image = jsonData . getString ( IMAGE_KEY ) ; List < ITopic > cards = getSourceTopicModel ( ) ; switch ( key ) { case POOL_KEY : cards . add ( 0 , Cards . pool ( image , getActivity ( ) ) ) ; removeDuplicates ( POOL_KEY , cards ) ; break ; case VIDEO_KEY : switch ( jsonData . getString ( ID_KEY ) ) { case POOL_CAMERA_ID : mGreatShotUrl = jsonData . getString ( URL_KEY ) ; mElv . setOnGroupClickListener ( greatShotListener ) ; cards . add ( 0 , Cards . poolVideo ( mGreatShotUrl , getActivity ( ) ) ) ; removeDuplicates ( VIDEO_KEY , cards ) ; break ; } break ; case FOOD_KEY : cards . add ( 0 , Cards . food ( image , getActivity ( ) ) ) ; removeDuplicates ( FOOD_KEY , cards ) ; break ; case PRINTER_3D_KEY : cards . add ( 0 , Cards . printer3d ( image , getActivity ( ) ) ) ; removeDuplicates ( PRINTER_3D_KEY , cards ) ; break ; } } else if ( jsonData . has ( MESSAGE_KEY ) ) { String message = jsonData . getString ( MESSAGE_KEY ) ; List < ITopic > cards = getSourceTopicModel ( ) ; cards . add ( 0 , Cards . test ( message , getActivity ( ) ) ) ; } UI . execute ( null ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } } }
adds the card to the view
