List of usage examples for android.util Pair Pair
public Pair(F first, S second)
From source file:Main.java
private static boolean isKnownRoot(X509Certificate root) throws NoSuchAlgorithmException, KeyStoreException { assert Thread.holdsLock(sLock); // Could not find the system key store. Conservatively report false. if (sSystemKeyStore == null) return false; // Check the in-memory cache first; avoid decoding the anchor from disk // if it has been seen before. Pair<X500Principal, PublicKey> key = new Pair<X500Principal, PublicKey>(root.getSubjectX500Principal(), root.getPublicKey());// ww w . j a v a 2 s .c om if (sSystemTrustAnchorCache.contains(key)) return true; // Note: It is not sufficient to call sSystemKeyStore.getCertificiateAlias. If the server // supplies a copy of a trust anchor, X509TrustManagerExtensions returns the server's // version rather than the system one. getCertificiateAlias will then fail to find an anchor // name. This is fixed upstream in https://android-review.googlesource.com/#/c/91605/ // // TODO(davidben): When the change trickles into an Android release, query sSystemKeyStore // directly. // System trust anchors are stored under a hash of the principal. In case of collisions, // a number is appended. String hash = hashPrincipal(root.getSubjectX500Principal()); for (int i = 0; true; i++) { String alias = hash + '.' + i; if (!new File(sSystemCertificateDirectory, alias).exists()) break; Certificate anchor = sSystemKeyStore.getCertificate("system:" + alias); // It is possible for this to return null if the user deleted a trust anchor. In // that case, the certificate remains in the system directory but is also added to // another file. Continue iterating as there may be further collisions after the // deleted anchor. if (anchor == null) continue; if (!(anchor instanceof X509Certificate)) { // This should never happen. String className = anchor.getClass().getName(); Log.e(TAG, "Anchor " + alias + " not an X509Certificate: " + className); continue; } // If the subject and public key match, this is a system root. X509Certificate anchorX509 = (X509Certificate) anchor; if (root.getSubjectX500Principal().equals(anchorX509.getSubjectX500Principal()) && root.getPublicKey().equals(anchorX509.getPublicKey())) { sSystemTrustAnchorCache.add(key); return true; } } return false; }
From source file:Main.java
/** * Adds all parameters within the Scanner to the list of * <code>parameters</code>, as encoded by <code>encoding</code>. For * example, a scanner containing the string <code>a=1&b=2&c=3</code> would * add the {@link Pair<String, String> NameValuePairs} a=1, b=2, and c=3 to the * list of parameters./*from w w w.j a v a 2 s. co m*/ * * @param parameters * List to add parameters to. * @param scanner * Input that contains the parameters to parse. * @param encoding * Encoding to use when decoding the parameters. */ public static void parse(final List<Pair<String, String>> parameters, final Scanner scanner, final String encoding) { scanner.useDelimiter(PARAMETER_SEPARATOR); while (scanner.hasNext()) { final String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR); if (nameValue.length == 0 || nameValue.length > 2) throw new IllegalArgumentException("bad parameter"); final String name = decode(nameValue[0], encoding); String value = null; if (nameValue.length == 2) value = decode(nameValue[1], encoding); parameters.add(new Pair<String, String>(name, value)); } }
From source file:cl.smartcities.isci.transportinspector.detectionService.StateLocationSender.java
public void addSingleLocation(Location location, boolean b) { addLocations(new Pair<>(location, b)); }
From source file:com.rastating.droidbeard.net.FetchShowTask.java
private Bitmap getBanner(long tvdbid) { ArrayList<Pair<String, Object>> params = new ArrayList<Pair<String, Object>>(); params.add(new Pair<String, Object>("tvdbid", tvdbid)); return getBitmap("show.getbanner", params); }
From source file:com.honu.giftwise.InfoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // REMOVE: for testing //WelcomeHelper.clearLastRunVersionCode(this); setContentView(R.layout.activity_info); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar);//from w ww . java 2 s . c o m getSupportActionBar().setDisplayShowTitleEnabled(true); } getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); getSupportActionBar().setTitle(R.string.app_name); getSupportActionBar().setLogo(R.mipmap.ic_launcher); List<Pair<String, String>> data; data = new ArrayList(); data.add(new Pair("Version", BuildConfig.VERSION_NAME)); data.add(new Pair("License", "ISC")); data.add(new Pair("Feedback", "Send feedback")); data.add(new Pair("Author", "Honu Apps")); ListView listView = (ListView) findViewById(R.id.info_listview); ListAdapter adapter = new PairAdapter(this, data); listView.setAdapter(adapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { case 0: break; case 1: showLicenseInfo(); break; case 2: sendEmail(); break; case 3: break; } } }); }
From source file:com.rastating.droidbeard.net.FetchShowTask.java
private List<Season> getSeasons(long tvdbid) { ArrayList<Pair<String, Object>> params = new ArrayList<Pair<String, Object>>(); params.add(new Pair<String, Object>("tvdbid", tvdbid)); try {/*from w ww . j av a2 s.co m*/ String json = getJson("show.seasons", params); if (json != null && !json.equals("")) { JSONObject data = new JSONObject(json).getJSONObject("data"); List<Season> seasons = new ArrayList<Season>(); Iterator<String> seasonKeys = data.keys(); while (seasonKeys.hasNext()) { String seasonKey = (String) seasonKeys.next(); JSONObject seasonData = data.getJSONObject(seasonKey); Iterator<String> episodeKeys = seasonData.keys(); Season season = new Season(); season.setSeasonNumber(Integer.valueOf(seasonKey)); season.setTVDBID(tvdbid); while (episodeKeys.hasNext()) { String episodeKey = episodeKeys.next(); JSONObject episodeData = seasonData.getJSONObject(episodeKey); Episode episode = new Episode(); episode.setEpisodeNumber(Integer.valueOf(episodeKey)); episode.setAirdate(episodeData.getString("airdate")); episode.setName(episodeData.getString("name")); episode.setQuality(episodeData.getString("quality")); episode.setStatus(episodeData.getString("status")); episode.setSeasonNumber(Integer.valueOf(seasonKey)); episode.setTVDBID(tvdbid); season.addEpisode(episode); } seasons.add(season); } return seasons; } else { return null; } } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:at.diamonddogs.data.adapter.parcelable.ParcelableAdapterWebRequest.java
/** * Required by Parcelable mechanism//from ww w . java 2 s . c om * * @param in * the input parcel */ public ParcelableAdapterWebRequest(Parcel in) { super(in); if (dataObject == null) { dataObject = new WebRequest(); } dataObject.setProcessorId(in.readInt()); dataObject.setRequestType((Type) in.readSerializable()); dataObject.setUrl((URL) in.readSerializable()); dataObject.setReadTimeout(in.readInt()); dataObject.setConnectionTimeout(in.readInt()); dataObject.setFollowRedirects(in.readInt() == 1); boolean first = (in.readInt() == 1); if (first) { ParcelableAdapterTempFile tmp = in.readParcelable(ClassLoader.getSystemClassLoader()); dataObject.setTmpFile(new Pair<Boolean, TempFile>(first, tmp.getDataObject())); } dataObject.setHeader(readStringMap(in)); dataObject.setCacheTime(in.readLong()); dataObject.setNumberOfRetries(in.readInt()); dataObject.setRetryInterval(in.readInt()); dataObject.setCancelled(in.readInt() == 1); dataObject.setCheckConnectivity(in.readInt() == 1); dataObject.setCheckConnectivityPing(in.readInt() == 1); dataObject.setUseOfflineCache(in.readInt() == 1); }
From source file:com.lzy.demo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initToolBar(toolbar, false, ""); items = new ArrayList<>(); items.add(new Pair<String, Fragment>("OkGo", new OkGoFragment())); items.add(new Pair<String, Fragment>("?", new PayFragment())); items.add(new Pair<String, Fragment>("OkRx2", new OkRx2Fragment())); items.add(new Pair<String, Fragment>("OkRx", new OkRxFragment())); items.add(new Pair<String, Fragment>("OkDownload", new OkDownloadFragment())); items.add(new Pair<String, Fragment>("OkUpload", new OkUploadFragment())); viewPager.setAdapter(new MainAdapter(getSupportFragmentManager())); tab.setupWithViewPager(viewPager);/* ww w . jav a 2s .c om*/ }
From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.AppMessageHandlerHealthify.java
private byte[] encodeHelthifyWeatherMessage(WeatherSpec weatherSpec) { if (weatherSpec == null) { return null; }/*from w w w .jav a 2s .c om*/ ArrayList<Pair<Integer, Object>> pairs = new ArrayList<>(2); pairs.add(new Pair<>(KEY_CONDITIONS, (Object) weatherSpec.currentCondition)); pairs.add(new Pair<>(KEY_TEMPERATURE, (Object) (weatherSpec.currentTemp - 273))); byte[] weatherMessage = mPebbleProtocol .encodeApplicationMessagePush(PebbleProtocol.ENDPOINT_APPLICATIONMESSAGE, mUUID, pairs); ByteBuffer buf = ByteBuffer.allocate(weatherMessage.length); buf.put(weatherMessage); return buf.array(); }
From source file:conexionSiabra.ConexionSiabra.java
public boolean check() { boolean result = false; Pair<String, String> elemento = new Pair<String, String>("", ""); if (!db.exiteOauth()) { Log.wtf("Token", "No existe"); result = false;//from w ww.j a va 2 s.c om } else { JSONObject jsonObject = oauth.peticionGet(elemento, url_check); if (jsonObject.has("Exito")) { result = true; } else if (jsonObject.has("detail")) { Log.wtf("Token", "Caducado"); db.eraseOauth(); result = false; } else if (jsonObject.has("Error")) { Log.wtf("Conexion", "Fallo"); result = false; } } return result; }