@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // TODO Auto-generated method stub view = inflater.inflate(R.layout.parking_lot, container, false); layout = (RelativeLayout) view.findViewById(R.id.parking_lotLayout); floor_numbertTextView = (TextView) view.findViewById(R.id.floor); temperature = (TextView) view.findViewById(R.id.tempereture); car_number = (TextView) view.findViewById(R.id.car_number); parkingName = (TextView) view.findViewById(R.id.parking_lot_name); lastButton = (Button) view.findViewById(R.id.last); nextButton = (Button) view.findViewById(R.id.next); floor_number = parkingInfo.getFloorNumber(); progressBar = (ProgressBar) view.findViewById(R.id.progressBar); updataButton = (Button) view.findViewById(R.id.updata); DataManager.setCarViewHandler(showHandler); dataManager = (DataManager) getActivity().getApplication(); setTimeUpdata updata = new setTimeUpdata(); dataManager.setTimeThread(updata); dataManager.setStop(false); updata.start(); dataManager.setCurrentView("Parking_lot"); parkingName.setText(dataManager.getParkingName()); return view; }
/** * A private method to read the connection string parameter from the web.xml file * * @return the database connection string */ private String getConnectionString() { if (InputUtils.isValid(rdf.getContextParam("databaseConnectionString")) == false) { throw new RuntimeException( "Unable to read the connection string parameter from the web.xml file"); } else { return rdf.getContextParam("databaseConnectionString"); } }
// The name we accept is: // /filter/mediatype/k/{set} // where k is the media type we want. @Override public MediaObject createMediaObject(Path path) { int matchType = mMatcher.match(path); int mediaType = mMatcher.getIntVar(0); String setsName = mMatcher.getVar(1); DataManager dataManager = mApplication.getDataManager(); MediaSet[] sets = dataManager.getMediaSetsFromString(setsName); switch (matchType) { case FILTER_BY_MEDIATYPE: return new FilterSet(path, dataManager, sets[0], mediaType); default: throw new RuntimeException("bad path: " + path); } }
@Override public MediaObject createMediaObject(Path path) { switch (mMatcher.match(path)) { case SECURE_ALBUM: { DataManager dataManager = mApplication.getDataManager(); MediaItem unlock = (MediaItem) dataManager.getMediaObject("/secure/unlock"); return new SecureAlbum(path, mApplication, unlock); } case SECURE_UNLOCK: return new UnlockImage(path, mApplication); default: throw new RuntimeException("bad path: " + path); } }
// Complete constructor public DeviceItem( Integer itemId, String name, String unit, int bitSize, double minValue2, double maxValue2, double resolution, double factor, int offset, boolean signed, boolean isFloat) { super(); this.itemId = itemId; this.name = name; this.unit = unit; this.bitSize = bitSize; this.minValue = minValue2; this.maxValue = maxValue2; this.resolution = resolution; this.factor = factor; this.offset = offset; this.signed = signed; this.isFloat = isFloat; values = Collections.synchronizedList(new ArrayList<Data>()); DataManager.getInstance().addCpt(); setValue(0.0); }
public static boolean addMapping(Item item, Category c) throws SQLException { final String sql = "insert into " + TABLE_NAME + " (" + ITEM_ID_FIELD_NAME + ", " + CATEGORY_ID_FIELD_NAME + ") values (?, ?);"; final PreparedStatement st = DataManager.getCon().prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); st.setQueryTimeout(5); final int res; try { st.setLong(1, item.getID()); st.setLong(2, c.getID()); try { res = st.executeUpdate(); } catch (MySQLIntegrityConstraintViolationException s) { return false; } } finally { try { if (st != null) { st.close(); } } catch (final SQLException e) { System.out.println("Error closing prepared statement : " + e.getMessage()); } } return res == 1; }
/** Dispatch onStart() to all fragments. Ensure any created loaders are now started. */ @Override protected void onStart() { super.onStart(); initView(); if ((mSubsciptions == null) || (mSubsciptions.isUnsubscribed())) { mSubsciptions = new SubscriptionList(); } /* * DataManager is a static instance, it will not be released by GC * so, the Observable won't be released, as well as the Subscriber, even the MemoryLeakDemoActivity * because the instance of a anonymous inner class will hold the outer class's reference */ mSubsciptions.add( DataManager.getInstance() .getDataObservable() .subscribe( new Subscriber() { @Override public void onCompleted() {} @Override public void onError(Throwable e) {} @Override public void onNext(final Object o) { Logger.d("received " + o); printLogToScreen(o.toString()); } })); }
public static boolean removeMapping(Item item, Category c) throws SQLException { final String sql = "delete from " + TABLE_NAME + " where " + ITEM_ID_FIELD_NAME + " = ? AND " + CATEGORY_ID_FIELD_NAME + " = ?;"; final PreparedStatement st = DataManager.getCon().prepareStatement(sql); final int res; try { st.setLong(1, item.getID()); st.setLong(2, c.getID()); try { res = st.executeUpdate(); } catch (MySQLIntegrityConstraintViolationException s) { return false; } } finally { try { if (st != null) { st.close(); } } catch (final SQLException e) { System.out.println("Error closing prepared statement : " + e.getMessage()); } } return res == 1; }
/** Thread run method */ public void run() { if (NiagraServer.RUNNING_NIPROF) JProf.registerThreadName(this.getName()); if (NiagraServer.TIME_OPERATORS) { cpuTimer = new CPUTimer(); cpuTimer.start(); } boolean shutdown = false; String message = "normal"; try { sr = new SAXDOMReader(dm.getInputStreamFor(resource)); sr.readDocuments(outputStream); } catch (SAXException saxE) { System.err.println( "StreamThread::SAX exception parsing document. Message: " + saxE.getMessage()); shutdown = true; message = "SAX Exception " + saxE.getMessage(); } catch (java.io.IOException ioe) { System.err.println("StreamThread::IOException. Message: " + ioe.getMessage()); shutdown = true; message = "StreamThread::IOException " + ioe.getMessage(); } catch (ShutdownException se) { System.err.println("StreamThread::ShutdownException. Message " + se.getMessage()); shutdown = true; message = se.getMessage(); } cleanUp(shutdown, message); return; }
// Method to load file from BioJava structure to Jmol Display public void loadFileToJmol(Structure struc) { createUserModel(struc); String pdb = DataManager.modelToPDB(modelList); viewer.openStringInline(pdb); toolPanel.setModelText(modelList); logger.log(Level.INFO, "After load File: "); }
// define minimizer, for minimizing molecule. public void minimizeModel() { // viewer.ms.setAtomCoord(0, 0.0f, 0.0f, 0.0f); Minimizer minimizer = new Minimizer(this); minimizer.setupMinimizing(modelList.get(viewer.getDisplayModelIndex())); minimizer.startMinimizing(); System.out.println(DataManager.modelToPDB(modelList)); minimizeMode = false; }
@Override public void onDisable() { PluginDescriptionFile pdf = getDescription(); GamesManager.endAll(); DataManager.saveArenas(); logger.info("[" + pdf.getName() + "] disabled!"); }
public static SmsMessage createSmsMessage(Contact contact, String content) throws FailedToCreateSmsMessageException { // TODO: Set message direction Calendar calendar; long dateNumber; DataManager dm; String messageId; String contactId; int messageCount; SmsMessage smsMessage; try { // Get sms message information from calendar and manager calendar = new GregorianCalendar(TimeZone.getDefault()); // dateNumber = calendar.getTime().getTime(); dateNumber = calendar.getTimeInMillis(); // Create sms message into storage dm = DataManager.getInstance(); // get key to encrypt messages byte[] salt = Cryptography.decodeFromStorage(dm.getAttributeString(dm.USER, dm.SALT)); byte[] iv = Cryptography.decodeFromStorage(dm.getAttributeString(dm.USER, dm.IV)); SecretKey key = KeyManager.getInstance().generateStorageKey(salt); // setup message id contactId = contact.getId(); messageCount = dm.getAttributeInt(contactId, dm.MESSAGE_COUNT); messageId = contactId + dm.MESSAGE_CLASS + String.format("%04d", messageCount); messageCount++; smsMessage = new SmsMessage(messageId, contact, dateNumber, content); String encryptedContent = smsMessage.encryptToStore(key, iv); // set attributes dm.setAttribute(contactId, dm.MESSAGE_COUNT, messageCount); dm.addAttribute(contactId, dm.MESSAGE_TABLE, messageId); dm.setAttribute(messageId, dm.MESSAGE_DATE_NUMBER, dateNumber); dm.setAttribute(messageId, dm.ENCRYPTED_CONTENT, encryptedContent); return smsMessage; } catch (FailedToLoadDataBaseException | KeyStoreIsLockedException | FailedToGenerateKeyException | FailedToStoreException | FailedToEncryptSmsMessageException | FailedToGetAttributeException | FailedToAddAttributeException exception) { throw new FailedToCreateSmsMessageException(exception); } }
public static void deleteSmsMessage(Contact contact, SmsMessage message) throws FailedToDeleteSmsMessageException { String contactId; String messageId; DataManager dm; try { // Remove sms message from storage dm = DataManager.getInstance(); contactId = contact.getId(); messageId = message.getId(); dm.cleanAttribute(messageId); dm.removeAttribute(contactId, dm.MESSAGE_TABLE, messageId); } catch (FailedToLoadDataBaseException | FailedToRemoveAttributeException exception) { throw new FailedToDeleteSmsMessageException(exception); } }
private boolean navigateInRequestedEditor() { DataContext ctx = DataManager.getInstance().getDataContext(); Editor e = NAVIGATE_IN_EDITOR.getData(ctx); if (e == null) return false; if (FileDocumentManager.getInstance().getFile(e.getDocument()) != myFile) return false; navigateIn(e); return true; }
private void checkSavedApps() { List<AppItem> cache = mDataManager.getCache(); List<ApplicationInfo> allAppInfos = mDataManager.getAllAppInfos(); for (AppItem next : cache) { boolean currHas = false; for (ApplicationInfo applicationInfo : allAppInfos) { if (applicationInfo.packageName.equals(next.getPackageName())) { currHas = true; break; } } if (!currHas) { deleteApp(next); LOGGER.i(TAG, "delete = " + next); } } }
public InitMyBDD(DataManager dataManager) { this.dataManager = dataManager; if (dataManager.getQuestionsByTheme("JEE") == null) { populateTableJoueur(); populateTableQuestion(); populateTableChoix(); } }
public void getData(String name) { DataManager dataManager = new DataManager(); try { String url = getURL(name); // url:"https://mobile.twitter.com/" + name; // user information persistence Userbean userBean = new Userbean(); userBean = dataManager.getPersonalInformation(url); UserPersistance userPersistance = new UserPersistance(); userPersistance.userPersistance(userBean); // followers persistence } catch (Exception e) { // TODO Auto-generated catch block // e.printStackTrace(); System.out.println("############exception in Hail>> getData() >>" + e.getMessage()); } // System.out.println("done one person's tweets"); }
@Override public String getDataToSend(Map<String, Object> param) { Object data = dataManager.getDataToTransfer(param); try { return JacksonMapper.objectMapper.writeValueAsString(data); } catch (JsonProcessingException e) { log.error("get data to string error", e); } return null; }
@Override public void delete() { ItemConsumer consumer = new ItemConsumer() { public void consume(int index, MediaItem item) { if ((item.getSupportedOperations() & SUPPORT_DELETE) != 0) { item.delete(); } } }; mDataManager.mapMediaItems(mPaths, consumer, 0); }
private void checkCurrApps() { List<ApplicationInfo> allAppInfos = mDataManager.getAllAppInfos(); List<AppItem> cache = mDataManager.getCache(); for (ApplicationInfo next : allAppInfos) { boolean hasSave = false; for (AppItem appItem : cache) { if (appItem.getPackageName().equals(next.packageName)) { hasSave = true; } } if (!hasSave) { try { AppItem appItem = getAppItem(next); saveAppItem(appItem); LOGGER.i(TAG, "add = " + appItem); } catch (SQLException | FileNotFoundException e) { e.printStackTrace(); } } } }
public final void updateGeofence(Geofence geofence) { geofencesLock.writeLock().lock(); try { geofences.put(geofence.getId(), geofence); } finally { geofencesLock.writeLock().unlock(); } try { dataManager.updateGeofence(geofence); } catch (SQLException error) { Log.warning(error); } }
private void moveDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Move to.."); final Spinner spinner = new Spinner(this); ArrayAdapter<String> adapter = new ArrayAdapter<>( this, android.R.layout.simple_spinner_dropdown_item, data.getListAlbumNames()); spinner.setAdapter(adapter); spinner.setOnItemSelectedListener( new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) { albumChoice = spinner.getSelectedItem().toString(); } @Override public void onNothingSelected(AdapterView<?> arg0) { // do nothing } }); builder.setView(spinner); builder.setPositiveButton( "Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); albumChoice = null; } }); builder.setNegativeButton( "Move", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { data.moveTrack(selected, albumChoice); populateListView(); Toast.makeText( ActivityTracksListView.this, "Track moved to " + albumChoice, Toast.LENGTH_SHORT) .show(); } }); builder.show(); }
@Override protected HashMap<String, DownloadedImages> doInBackground(List<String>... lists) { DownloadedImages downloadedImage; int totalNumberOfPhotos; try { List<String> photoIds = lists[0]; String photoSizesResult = "", url; totalNumberOfPhotos = DataManager.getInstance().getReceivedPhotos().getReceivedPhoto().getPhotos().size(); for (int i = 0; i < photoIds.size(); i++) { String currentPhotoId = photoIds.get(i); url = String.format(FlickrURL.flickr_photos_getSizes, Constants.API_KEY, currentPhotoId); HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); int statusCode = connection.getResponseCode(); if (statusCode == HttpURLConnection.HTTP_OK) { photoSizesResult = Utility.convertInputStreamToString(connection.getInputStream()); } connection.disconnect(); ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); photoSizesResult = photoSizesResult.replace("jsonFlickrApi(", "").replace(")", ""); ResponsePhotoSizes photoSizeResponse = mapper.readValue(photoSizesResult, ResponsePhotoSizes.class); List<ResponsePhotoSizes.Sizes.Size> photoSizes = photoSizeResponse.getReceivedPhotoSize().getSizes(); String thumbnailURL = photoSizes.get(2).getSource(); String mediumURL = photoSizes.get(5).getSource(); InputStream inputStreamThumbnail = null, inputStreamMedium = null; inputStreamThumbnail = new URL(thumbnailURL).openStream(); inputStreamMedium = new URL(mediumURL).openStream(); Bitmap bitmapThumbnail = BitmapFactory.decodeStream(inputStreamThumbnail); Bitmap bitmapMedium = BitmapFactory.decodeStream(inputStreamMedium); publishProgress(DataManager.startIndex + i, totalNumberOfPhotos); downloadedImage = new DownloadedImages(); downloadedImage.setImage( new DownloadedImages.ImageDetails(currentPhotoId, bitmapThumbnail, bitmapMedium)); downloadedImagesHashMap.put(currentPhotoId, downloadedImage); } } catch (Exception e) { e.printStackTrace(); } return downloadedImagesHashMap; }
/** * Almost all commands supported by this plugin are actually handled by the DataManager, because * that is where most of the global data is actually stored and maintained. Commands are passed to * it thru this method. In essence, this method checks whether the plugins required to perform the * command are available, and if so, the command is executed. */ @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (isEnabled()) { if (sender instanceof Player) { Player player = (Player) sender; if (command == getCommand("makecasino")) { database.registerJob(player, JobType.CASINO_CREATE, args); } else if (command == getCommand("makemachine")) { database.registerJob(player, JobType.GAME_CREATE, args); } else if (command == getCommand("testcasino")) { // TODO test casino database.testCasino(player.getName()); } else if (command == getCommand("destroycasino")) { database.destroyCasino(player.getName()); } } else System.out.println("[CasinoManager] You can't do that from here!"); return true; } else { sender.sendMessage("CasinoManager plugin is not disabled. Waiting for iConomy, probably."); System.out.println("[CasinoManager] Plugin is disabled. Waiting for iConomy, probably."); } return false; }
public void reload() { mAllData.clear(); mDisplayedData.clear(); notifyDataSetChanged(); Object data = DataManager.loadLocalJSON(getActivity(), getTemplateString()); if (data != null) { addAllJSONData((JSONArray) data); search(); updateJSONData(false); } else { updateJSONData(true); } }
public void updateJSONData(boolean force) { final int template = mTemplate; DataManager.loadRemoteJSON( getActivity(), getTemplateString(), force, new DataManager.JSONHandler() { @Override public void onSuccess(Object data) { if (template != mTemplate) return; addAllJSONData((JSONArray) data); search(); } }); }
public void search() { mDisplayedData.clear(); for (UnitItem item : mAllData) if ((mRare == 0 || item.rare == mRare || (mRare == 6 && item.rare > 2) || (mRare == 7 && item.rare > 3)) && (mElement == 0 || item.element == mElement || (mElement == 6 && item.element > 0 && item.element < 4) || (mElement == 7 && item.element > 3 && item.element < 6)) && (mWeapon == 0 || item.weapon == mWeapon || (mWeapon == 8 && item.weapon > 0 && item.weapon < 4) || (mWeapon == 9 && item.weapon > 3 && item.weapon < 7)) && (mType == 0 || item.type == mType) && (mSkin == 0 || item.skin == mSkin) && (mGender == 0 || item.gender == mGender) && (mServer == 0 || item.server == mServer) && (mAarea == 0 || (mAarea == 1 && item.aarea <= 50) || (mAarea == 2 && item.aarea > 50 && item.aarea <= 150) || (mAarea == 3 && item.aarea > 150)) && (mAge == 0 || (mAge == 1 && item.age <= 0) || (mAge == 2 && item.age > 0 && item.age <= 10) || (mAge == 3 && item.age > 10 && item.age <= 15) || (mAge == 4 && item.age > 15 && item.age <= 20) || (mAge == 5 && item.age > 20 && item.age <= 25) || (mAge == 6 && item.age > 25 && item.age <= 30) || (mAge == 7 && item.age > 30 && item.age <= 35) || (mAge == 8 && item.age > 35 && item.age <= 40) || (mAge == 9 && item.age > 40)) && (mAnum == 0 || item.anum == mAnum || (mAnum == 6 && item.anum > 1 && item.anum < 4) || (mAnum == 7 && item.anum > 3 && item.anum < 6)) && (mCountry == null || item.country.equals(mCountry)) && (mSkill == null || item.getSkillShortString().equals(mSkill)) && (!mLike || DataManager.checkLike(getActivity(), getTemplateString() + " " + item.id)) && (mQuery == null || item.name.contains(mQuery) || item.title.contains(mQuery) || String.valueOf(item.id).contains(mQuery))) mDisplayedData.add(item); sort(); }
private static MediaItem loadOrUpdateItem( Path path, Cursor cursor, DataManager dataManager, GalleryApp app, boolean isImage) { synchronized (DataManager.LOCK) { LocalMediaItem item = (LocalMediaItem) dataManager.peekMediaObject(path); if (item == null) { if (isImage) { item = new LocalImage(path, app, cursor); } else { // item = new LocalVideo(path, app, cursor); } } else { item.updateContent(cursor); } return item; } }
public boolean hasPermission(Player player, int permission, boolean ignoreOPstatus) { if (player == null) return false; if (useNewPermissionSystem) { return player.hasPermission(PermissionData.permissionNames[permission]); } try { if (permissions == null) { if (ignoreOPstatus) { // OPs don't get special treatment return false; } else { return player.isOp(); } } else { PermissionData data = dataManager.getPermissionData(player); long time = System.currentTimeMillis(); if (data.lastUpdate[permission] + 10000 < time) { data.lastUpdate[permission] = time; data.cache[permission] = permissions.has(player, PermissionData.permissionNames[permission]); } return data.cache[permission]; } } catch (Throwable e) { if (this.exceptionWithPermissions + 60000 < System.currentTimeMillis()) { // Prevent spam and recursion by definitely doing this only once this.exceptionWithPermissions = System.currentTimeMillis(); String logtext = "Asking Permissions-Plugin if " + player.getName() + " has permission " + PermissionData.permissionNames[permission] + " caused an Exception " + e.getMessage() + ". Please review your permissions config file. This message is displayed at most once every 60 seconds."; log(Level.SEVERE, logtext); for (StackTraceElement s : e.getStackTrace()) { config.logger.log(Level.SEVERE, s.toString()); } } return false; } }