List of usage examples for com.google.gson.internal LinkedTreeMap get
@Override
public V get(Object key)
From source file:com.magestore.app.pos.api.m2.config.POSConfigDataAccess.java
/** * Ly country trong config/*from w ww . j av a 2s . c o m*/ * * @return * @throws DataAccessException * @throws ConnectionException * @throws ParseException * @throws IOException * @throws ParseException */ @Override public Map<String, ConfigCountry> getCountryGroup() throws DataAccessException, ConnectionException, ParseException, IOException, ParseException { // nu cha load config, cn khi to ch default if (mConfig == null) mConfig = new PosConfigDefault(); List<LinkedTreeMap> countryList = (ArrayList) mConfig.getValue("country"); Map<String, ConfigCountry> listConfigCountry = new LinkedTreeMap<>(); Collections.sort(countryList, new Comparator<LinkedTreeMap>() { @Override public int compare(LinkedTreeMap linkedTreeMap, LinkedTreeMap linkedTreeMap1) { String name = linkedTreeMap.get("country_name").toString(); String name1 = linkedTreeMap1.get("country_name").toString(); return name.compareToIgnoreCase(name1); } }); for (LinkedTreeMap country : countryList) { ConfigCountry configCountry = new PosConfigCountry(); String country_id = country.get("country_id").toString(); String country_name = country.get("country_name").toString(); configCountry.setCountryID(country_id); configCountry.setCountryName(country_name); List<LinkedTreeMap> regionList = (ArrayList) country.get("regions"); if (regionList != null) { Map<String, ConfigRegion> listConfigRegion = new LinkedTreeMap<>(); Collections.sort(regionList, new Comparator<LinkedTreeMap>() { @Override public int compare(LinkedTreeMap linkedTreeMap, LinkedTreeMap linkedTreeMap1) { String name = linkedTreeMap.get("name").toString(); String name1 = linkedTreeMap1.get("name").toString(); return name.compareToIgnoreCase(name1); } }); for (LinkedTreeMap region : regionList) { ConfigRegion configRegion = new PosConfigRegion(); String code = region.get("code").toString(); String name = region.get("name").toString(); String id = region.get("id").toString(); configRegion.setID(id); configRegion.setCode(code); configRegion.setName(name); listConfigRegion.put(id, configRegion); } configCountry.setRegions(listConfigRegion); } listConfigCountry.put(country_id, configCountry); } return listConfigCountry; }
From source file:com.melchor629.musicote.MainActivity.java
License:Apache License
private void sis() { if (songList == null) { Log.e("MainActivity", "songList viene vaco..."); return;/*w w w. j ava 2 s.c o m*/ } /** * Updating parsed JSON data into ListView * */ ListAdapter adapter = new SimpleAdapter(this, songList, R.layout.list_item, new String[] { "titulo", "artista", "album", "downloaded" }, new int[] { R.id.name, R.id.email, R.id.mobile, R.id.mainStatusSong }); setListAdapter(adapter); // selecting single ListView item ListView lv = getListView(); lv.setFastScrollEnabled(true); // Launching new screen on Selecting Single ListItem lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // getting values from selected ListItem LinkedTreeMap<String, String> datos = songList.get(position); // Starting new intent Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class); in.putExtra("obj", datos); startActivity(in); } }); lv.setLongClickable(true); lv.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, final View v, final int which, long id) { final boolean isDownloaded = Utils.isDownloaded(songList.get(which).get("archivo")); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(((TextView) v.findViewById(R.id.name)).getText().toString()) .setItems(isDownloaded ? R.array.song_options_array2 : R.array.song_options_array, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which2) { LinkedTreeMap<String, String> obj = songList.get(which); String url = obj.get("archivo"); if (which2 == 0) { if (Reproductor.a == -1) { PlaylistManager.self.startPlaying(obj.get("titulo"), obj.get("artista"), obj.get("album"), url); } else { PlaylistManager.self.stopPlaying(); PlaylistManager.self.addSong(obj.get("titulo"), obj.get("artista"), obj.get("album"), url); } } else if (which2 == 1) { if (!isDownloaded) { Intent inte = new Intent(getApplicationContext(), DownloadManager.class); inte.putExtra("file", url); inte.putExtra("id", which); startService(inte); } else { if (new File(Utils.getUrl(url)).delete()) { Utils.setFileAsDownloaded(which, false); Toast.makeText(MainActivity.this, getString(R.string.done_delete), Toast.LENGTH_LONG) .show(); } else Toast.makeText(MainActivity.this, getString(R.string.err_delete), Toast.LENGTH_LONG) .show(); } } else if (which2 == 2) { PlaylistManager.self.addSong(obj.get("titulo"), obj.get("artista"), obj.get("album"), url); } } }) .create().show(); return true; } }); }
From source file:com.microsoft.activitytracker.Activities.CheckInActivity.java
License:Open Source License
private void CreateActivity() { mProgressDialog.setIndeterminate(true); mProgressDialog.setMessage(getResources().getString(R.string.creating_activity)); mProgressDialog.show();/* w w w . j a v a2 s . co m*/ EditText subject = (EditText) findViewById(R.id.etSubject); EditText notes = (EditText) findViewById(R.id.etNotes); String body = Utils.getSerializedCheckIn(subject.getText().toString(), mDate.getTime(), notes.getText().toString()); NetworkCalls.oDataPostRequest(this, body, String.format("ContactSet(guid'%s')/Contact_Tasks", mThisEntity.getId()), new Callback<LinkedTreeMap<String, Object>>() { @Override public void success(LinkedTreeMap<String, Object> stringObjectLinkedTreeMap, Response response) { LinkedTreeMap<String, Object> newActivity = (LinkedTreeMap<String, Object>) stringObjectLinkedTreeMap .get("d"); CompleteActivity(newActivity.get("ActivityId").toString()); } @Override public void failure(RetrofitError error) { error.printStackTrace(); } }); }
From source file:com.microsoft.activitytracker.Activities.ItemActivity.java
License:Open Source License
private void getDetailInfo() { HashMap<String, String> queries = new HashMap<String, String>(); queries.put("$select", Constants.CONTACT_SELECT); NetworkCalls.oDataGetRequest(this, String.format("ContactSet(guid'%s')", mThisEntity.getId()), queries, new Callback<LinkedTreeMap<String, Object>>() { @Override/* w ww. jav a 2s.com*/ public void success(LinkedTreeMap<String, Object> stringObjectLinkedTreeMap, Response response) { // drill into the response to get to the properties which is in the 'd' namespace LinkedTreeMap<String, Object> propResponse = (LinkedTreeMap<String, Object>) stringObjectLinkedTreeMap .get("d"); // pull the keys of the properties and check if we have it yet // if not add them to the entity attributes hashmap Set<String> keys = propResponse.keySet(); for (String key : keys) { if (!mThisEntity.attributes.containsKey(key.toLowerCase())) { mThisEntity.attributes.put(key.toLowerCase(), propResponse.get(key)); } } loadItemDetails(); } @Override public void failure(RetrofitError error) { error.getCause().printStackTrace(); } }); }
From source file:com.microsoft.activitytracker.Activities.ItemActivity.java
License:Open Source License
private void getRecentActivities() { mSwipeRefresh.setRefreshing(true);/* w ww .j a va 2s . com*/ HashMap<String, String> queries = new HashMap<String, String>(); queries.put("$select", Constants.ACTIVITY_SELECT); queries.put("$filter", "ActualEnd ne null"); queries.put("$orderby", "ActualEnd desc"); queries.put("$top", "10"); NetworkCalls.oDataGetRequest(this, String.format("ContactSet(guid'%s')/Contact_ActivityPointers", mThisEntity.getId()), queries, new Callback<LinkedTreeMap<String, Object>>() { @Override public void success(LinkedTreeMap<String, Object> stringObjectLinkedTreeMap, Response response) { ArrayList results = (ArrayList) ((LinkedTreeMap) stringObjectLinkedTreeMap.get("d")) .get("results"); if (results != null && results.size() > 0) { mActivityList.setAdapter(new ActivitiesItemAdapter(getApplicationContext(), results)); } else { ArrayList<String> noResult = new ArrayList<String>(); noResult.add(getString(R.string.no_complete_activites)); mActivityList.setAdapter(new ActivitiesItemAdapter(getApplicationContext(), noResult)); } mSwipeRefresh.setRefreshing(false); } @Override public void failure(RetrofitError error) { error.getCause().printStackTrace(); } }); }
From source file:com.microsoft.activitytracker.Adapters.ActivitiesItemAdapter.java
License:Open Source License
@Override public View getView(int position, View convertView, ViewGroup parent) { final Object thisItem = this.getItem(position); if (getItemViewType(position) == 0) { final LinkedTreeMap thisActivity = (LinkedTreeMap) thisItem; final ViewHolder thisHolder; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); thisHolder = new ViewHolder(); convertView = inflater.inflate(R.layout.activity_item_layout, parent, false); thisHolder.date = (TextView) convertView.findViewById(R.id.activity_date); thisHolder.title = (TextView) convertView.findViewById(R.id.activity_title); thisHolder.type = (ImageView) convertView.findViewById(R.id.activityImage); convertView.setTag(thisHolder); } else {// w w w.j a v a 2 s .c o m thisHolder = (ViewHolder) convertView.getTag(); } thisHolder.title.setText(thisActivity.get("Subject").toString()); thisHolder.date.setText(Utils.getDatefromJsonDate(thisActivity.get("ActualEnd").toString())); try { switch (ActivityTypeCode.valueOf(thisActivity.get("ActivityTypeCode").toString().toUpperCase())) { case TASK: thisHolder.type.setImageResource(R.drawable.ic_activity_check); break; case APPOINTMENT: thisHolder.type.setImageResource(R.drawable.ic_activity_appt); break; case LETTER: thisHolder.type.setImageResource(R.drawable.ic_activity_note); break; case PHONECALL: thisHolder.type.setImageResource(R.drawable.ic_activity_phone); break; default: thisHolder.type.setImageResource(R.drawable.ic_activity_generic); break; } } catch (IllegalArgumentException ex) { Log.d("ItemActivityAdapter", thisActivity.get("ActivityTypeCode").toString() + " not in Activity Enum, setting to generic activity"); thisHolder.type.setImageResource(R.drawable.ic_activity_generic); } } else { final String thisText = thisItem.toString(); final TextViewHolder thisHolder; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.item_text_layout, parent, false); thisHolder = new TextViewHolder(); thisHolder.message = (TextView) convertView.findViewById(R.id.message_text); convertView.setTag(thisHolder); } else { thisHolder = (TextViewHolder) convertView.getTag(); } thisHolder.message.setText(thisText); } return convertView; }
From source file:com.optimizely.ab.internal.ConditionUtils.java
License:Apache License
static public <T> Condition parseConditions(Class<T> clazz, Object object) throws InvalidAudienceCondition { if (object instanceof List) { List<Object> objectList = (List<Object>) object; return ConditionUtils.<T>parseConditions(clazz, objectList); } else if (object instanceof String) { // looking for audience conditions in experiment AudienceIdCondition audienceIdCondition = new AudienceIdCondition<T>((String) object); if (clazz.isInstance(audienceIdCondition)) { return audienceIdCondition; } else {/*from www .j a va 2 s . c om*/ throw new InvalidAudienceCondition( String.format("Expected AudienceIdCondition got %s", clazz.getCanonicalName())); } } else { try { if (object instanceof LinkedTreeMap) { // gson if (clazz != UserAttribute.class) { throw new InvalidAudienceCondition( String.format("Expected UserAttributes got %s", clazz.getCanonicalName())); } LinkedTreeMap<String, ?> conditionMap = (LinkedTreeMap<String, ?>) object; return new UserAttribute((String) conditionMap.get("name"), (String) conditionMap.get("type"), (String) conditionMap.get("match"), conditionMap.get("value")); } } catch (NoClassDefFoundError ex) { // no gson loaded... not sure we need to log this if they don't use gson. logger.debug("parser: gson library not loaded"); } try { if (object instanceof JSONObject) { // simple json if (clazz != UserAttribute.class) { throw new InvalidAudienceCondition( String.format("Expected UserAttributes got %s", clazz.getCanonicalName())); } JSONObject conditionMap = (JSONObject) object; return new UserAttribute((String) conditionMap.get("name"), (String) conditionMap.get("type"), (String) conditionMap.get("match"), conditionMap.get("value")); } } catch (NoClassDefFoundError ex) { logger.debug("parser: simple json not found"); } try { if (object instanceof org.json.JSONArray) { // json return ConditionUtils.<T>parseConditions(clazz, (org.json.JSONArray) object); } else if (object instanceof org.json.JSONObject) { //json if (clazz != UserAttribute.class) { throw new InvalidAudienceCondition( String.format("Expected UserAttributes got %s", clazz.getCanonicalName())); } org.json.JSONObject conditionMap = (org.json.JSONObject) object; String match = null; Object value = null; if (conditionMap.has("match")) { match = (String) conditionMap.get("match"); } if (conditionMap.has("value")) { value = conditionMap.get("value"); } return new UserAttribute((String) conditionMap.get("name"), (String) conditionMap.get("type"), match, value); } } catch (NoClassDefFoundError ex) { logger.debug("parser: json package not found."); } if (clazz != UserAttribute.class) { throw new InvalidAudienceCondition( String.format("Expected UserAttributes got %s", clazz.getCanonicalName())); } Map<String, ?> conditionMap = (Map<String, ?>) object; return new UserAttribute((String) conditionMap.get("name"), (String) conditionMap.get("type"), (String) conditionMap.get("match"), conditionMap.get("value")); } }
From source file:com.sat.common.CommonFunctions.java
License:Open Source License
/** * Json to linked has map.//from ww w.j a v a 2 s .c om * * @param strReturn the str return * @return the linked hash map */ public LinkedHashMap<String, String> jsonToLinkedHasMap(String strReturn) { LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>(); Gson gson = new Gson(); LinkedTreeMap<?, ?> result = gson.fromJson(strReturn, LinkedTreeMap.class); Set<?> keys = result.keySet(); for (Iterator<?> i = keys.iterator(); i.hasNext();) { Object key = i.next(); Object value = (Object) result.get(key); System.out.println(key + " <=> " + value); String key1 = (String) key; String value1; try { value1 = (String) value; } catch (ClassCastException e) { value1 = value.toString(); } lhm.put(key1, value1); } return lhm; }
From source file:com.tremolosecurity.unison.openshiftv3.wf.OpenShiftWorkflows.java
License:Apache License
@Override public List<Map<String, String>> generateWorkflows(WorkflowType wf, ConfigManager cfg, HashMap<String, Attribute> params) throws ProvisioningException { ArrayList<Map<String, String>> wfData = new ArrayList<Map<String, String>>(); String targetName = params.get("target").getValues().get(0); HashSet<String> nameFilter = new HashSet<String>(); Attribute attr = params.get("filter"); if (attr != null) { nameFilter.addAll(attr.getValues()); }// w w w .j a va 2 s . c o m OpenShiftTarget target = (OpenShiftTarget) cfg.getProvisioningEngine().getTarget(targetName).getProvider(); String kind = params.get("kind").getValues().get(0); try { String token = target.getAuthToken(); HttpCon con = target.createClient(); try { String json = target.callWS(token, con, kind); Gson gson = new Gson(); TypeToken<com.tremolosecurity.unison.openshiftv3.model.List<Item>> tokenType = new TypeToken<com.tremolosecurity.unison.openshiftv3.model.List<Item>>() { }; com.tremolosecurity.unison.openshiftv3.model.List<Item> list = gson.fromJson(json, tokenType.getType()); for (Item item : list.getItems()) { HashMap<String, String> wfParams = new HashMap<String, String>(); String name = (String) item.getMetadata().get("name"); if (nameFilter.contains(name)) { continue; } wfParams.put("name", name); if (item.getMetadata().containsKey("annotations")) { com.google.gson.internal.LinkedTreeMap annotations = (com.google.gson.internal.LinkedTreeMap) item .getMetadata().get("annotations"); for (Object key : annotations.keySet()) { String keyName = (String) key; keyName = keyName.replace("-", "_"); keyName = keyName.replace(".", "_"); wfParams.put((String) keyName, (String) annotations.get(key)); } } wfData.add(wfParams); } } finally { con.getBcm().close(); con.getHttp().close(); } } catch (Exception e) { throw new ProvisioningException("Could not load", e); } return wfData; }
From source file:config.emotion.EmotionContext.java
public LinkedTreeMap<String, Object> sendImage(String url) { try {/*from w w w.jav a2 s .com*/ Image image = new Image(); image.Url = url; Call<ArrayList> promise = emotion.sendPic(image); ArrayList array = promise.execute().body(); System.out.println(array); LinkedTreeMap<String, Object> result = (LinkedTreeMap<String, Object>) array.get(0); System.out.println(result.get("faceRectangle")); return result; } catch (Exception e) { } return null; }