private void debugOutput(List<Feature> features) { Timber.i(String.format("Got %s features", features.size())); for (Feature feature : features) { if (feature != null) { Timber.i( String.format( "Got feature %s with %s properties and Geometry %s", feature.getId(), feature.getProperties() != null ? feature.getProperties().entrySet().size() : "<null>", feature.getGeometry() != null ? feature.getGeometry().getClass().getSimpleName() : "<null>")); if (feature.getProperties() != null) { for (Map.Entry<String, JsonElement> entry : feature.getProperties().entrySet()) { Timber.i(String.format("Prop %s - %s", entry.getKey(), entry.getValue())); } } } else { // TODO Question: Why not formatting here?? Timber.i("Got NULL feature %s"); } } }
/* * onConnected is called when our Activity successfully connects to Google * Play services. onConnected indicates that an account was selected on the * device, that the selected account has granted any requested permissions * to our app and that we were able to establish a service connection to * Google Play services. */ @Override public void onConnected(Bundle connectionHint) { // Reaching onConnected means we consider the user signed in. Timber.i(TAG, "onConnected"); // Update the user interface to reflect that the user is signed in. mSignInButton.setEnabled(false); mSignOutButton.setEnabled(true); mRevokeButton.setEnabled(true); // Retrieve some profile information to personalize our app for the // user. Person currentUser = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient); Timber.i("UserInfo[" + currentUser.toString() + "]"); Timber.i("ImageUrl[" + currentUser.getImage().getUrl() + "]"); // mStatus.setText(String.format(getResources().getString(R.string.signed_in_as), // currentUser.getDisplayName())); // Plus.PeopleApi.loadVisible(mGoogleApiClient, // null).setResultCallback(this); // Indicate that the sign in process is complete. mSignInProgress = STATE_DEFAULT; // on successful login move to wall feed activity startActivity(new Intent(this, WallFeedActivity.class)); // startActivity(new Intent(this, DummyActivity.class)); // startActivity(new Intent(this, NewPictureActivity.class)); LoginActivity.this.finish(); }
@Override public void onReceive(Context context, Intent intent) { Timber.v("onReceive: %s", intent); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); if (!prefs.getBoolean(SettingsFragment.PREF_TOGGLE_WITH_FLITCHIO, true)) { Timber.i("Toggling with Flitchio is disabled"); return; } final int statusCode = intent.getIntExtra(EXTRA_STATUS, Status.UNKNOWN); switch (statusCode) { case Status.CONNECTED: Timber.i("Flitchio has connected"); if (!ServiceUtils.isServiceRunning(context, FlitchioBindingService.class)) { context.startService(new Intent(context, FlitchioBindingService.class)); } break; case Status.DISCONNECTED: Timber.i("Flitchio has disconnected"); context.sendBroadcast(new Intent(FlitchioBindingService.ACTION_STOP_SERVICE)); break; default: Timber.wtf("Invalid intent: " + intent); } }
@Override public void setCurrentConversation( IConversation conversation, ConversationChangeRequester conversationChangerSender) { if (conversation instanceof InboxLinkConversation) { conversation = inboxList.get(0); } if (conversation != null) { conversation.setArchived(false); } if (conversation != null) { Timber.i( "Set current conversation to %s, requester %s", conversation.getName(), conversationChangerSender); } else { Timber.i("Set current conversation to null, requester %s", conversationChangerSender); } this.conversationChangeRequester = conversationChangerSender; IConversation oldConversation = conversationChangerSender == ConversationChangeRequester.FIRST_LOAD ? null : selectedConversation; conversationsList.setSelectedConversation(conversation); if (oldConversation == null || (oldConversation != null && conversation != null && oldConversation.getId().equals(conversation.getId()))) { // Notify explicitly if the conversation doesn't change, the UiSginal notifies only when the // conversation changes notifyCurrentConversationHasChanged(oldConversation, conversation, conversationChangerSender); } }
/** * Stores a custom dictionary for a given deck. * * @param dictionary integer number of dictionary, -1 if not set (standard dictionary will be * used) */ public static void storeLookupDictionary(Context context, long did, int dictionary) { openDBIfClosed(context); Cursor cur = null; try { cur = mMetaDb.rawQuery("SELECT _id FROM customDictionary" + " WHERE did = " + did, null); if (cur.moveToNext()) { mMetaDb.execSQL( "UPDATE customDictionary " + "SET did = " + did + ", " + "dictionary=" + Integer.toString(dictionary) + " " + "WHERE _id=" + cur.getString(0) + ";"); Timber.i("MetaDB:: Store custom dictionary (%d) for deck %d", dictionary, did); } else { mMetaDb.execSQL( "INSERT INTO customDictionary (did, dictionary) VALUES (?, ?)", new Object[] {did, dictionary}); Timber.i("MetaDB:: Store custom dictionary (%d) for deck %d", dictionary, did); } } catch (Exception e) { Timber.e(e, "Error storing custom dictionary to MetaDB "); } finally { if (cur != null && !cur.isClosed()) { cur.close(); } } }
@Override public void retrieveStaleApplications() { SubscriptionHelper.unsubscribe(retrievalSubscription); retrievalSubscription = interactor .getAppEntryList() .zipWith( interactor.getActiveApplicationPackageNames().toList(), (allEntries, packageNames) -> { final Set<PadLockEntry.AllEntries> liveLocations = new HashSet<>(); final Set<String> stalePackageNames = new HashSet<>(); // Remove all active applications from the list of entries for (final String packageName : packageNames) { Timber.i("Look for package: %s", packageName); final List<PadLockEntry.AllEntries> foundLocations = new ArrayList<>(); //noinspection Convert2streamapi for (final PadLockEntry.AllEntries entry : allEntries) { if (entry.packageName().equals(packageName)) { foundLocations.add(entry); } } liveLocations.addAll(foundLocations); } // Remove any found locations for (final PadLockEntry.AllEntries liveLocation : liveLocations) { Timber.d( "Remove live location: %s %s", liveLocation.packageName(), liveLocation.activityName()); allEntries.remove(liveLocation); } // The remaining entries in the database are stale for (final PadLockEntry.AllEntries entry : allEntries) { Timber.i( "Stale database entry: %s %s", entry.packageName(), entry.activityName()); stalePackageNames.add(entry.packageName()); } return stalePackageNames; }) .flatMap(Observable::from) .sorted(String::compareToIgnoreCase) .subscribeOn(getSubscribeScheduler()) .observeOn(getObserveScheduler()) .subscribe( s -> getView(view -> view.onStaleApplicationRetrieved(s)), throwable -> { Timber.e(throwable, "onError retrieveStaleApplications"); getView(View::onRetrievalComplete); }, () -> { SubscriptionHelper.unsubscribe(retrievalSubscription); getView(View::onRetrievalComplete); }); }
@Override public void onDataSetChanged(IEventRepo repo) { Timber.d("startLoadingData"); Observable<IEvent> events = repo.getEventsSubscribedOnProperScheduler(); Timber.i("archive"); events.subscribe( new EventRepoSerializerToFileDecorator(repoAccessor, new EventRepoSerializer(clock))); Timber.i("set next alarm on %s at %d", alarmGenerator, clock.hour()); alarmGenerator.generate(repo.getEventsSubscribedOnProperScheduler(), clock.now(), clock.hour()); }
/** * Stores the current state of the widget. * * <p>It replaces any stored state for the widget. * * @param decks an array of {@link DeckStatus} objects, one for each of the know decks. */ public static void storeWidgetStatus(Context context, DeckStatus[] decks) { openDBIfClosed(context); try { mMetaDb.beginTransaction(); try { // First clear all the existing content. mMetaDb.execSQL("DELETE FROM widgetStatus"); for (DeckStatus deck : decks) { mMetaDb.execSQL( "INSERT INTO widgetStatus(deckId, deckName, newCards, lrnCards, dueCards, progress, eta) " + "VALUES (?, ?, ?, ?, ?, ?, ?)", new Object[] { deck.mDeckId, deck.mDeckName, deck.mNewCards, deck.mLrnCards, deck.mDueCards, deck.mProgress, deck.mEta }); } mMetaDb.setTransactionSuccessful(); } finally { mMetaDb.endTransaction(); } } catch (IllegalStateException e) { Timber.e(e, "MetaDB.storeWidgetStatus: failed"); } catch (SQLiteException e) { Timber.e(e, "MetaDB.storeWidgetStatus: failed"); closeDB(); Timber.i("MetaDB:: Trying to reset Widget: " + resetWidget(context)); } }
private void baseCommandEvent(BaseCommand event) { Timber.i("BaseCommand: %1$s", event); Intent intent = new Intent(_app, CommandIntentService.class); intent.putExtra(ARG_COMMAND_CLASS, event); intent.putExtra(CommandIntentService.ARG_RESULT_RECEIVER, getResultReceiver()); _app.startService(intent); }
/* * onConnectionFailed is called when our Activity could not connect to * Google Play services. onConnectionFailed indicates that the user needs to * select an account, grant permissions or resolve an error in order to sign * in. */ @Override public void onConnectionFailed(ConnectionResult result) { // Refer to the javadoc for ConnectionResult to see what error codes // might be returned in onConnectionFailed. Timber.i(TAG, "onConnectionFailed: ConnectionResult.getErrorCode() = " + result.getErrorCode()); if (mSignInProgress != STATE_IN_PROGRESS) { // We do not have an intent in progress so we should store the // latest error resolution intent for use when the sign in button is // clicked. mSignInIntent = result.getResolution(); mSignInError = result.getErrorCode(); if (mSignInProgress == STATE_SIGN_IN) { // STATE_SIGN_IN indicates the user already clicked the sign in // button so we should continue processing errors until the user // is signed in or they click cancel. resolveSignInError(); } } // In this sample we consider the user signed out whenever they do not // have a connection to Google Play services. onSignedOut(); }
@Provides @Singleton RealmConfiguration provideRealmConfiguration(@NonNull Context context) { RealmConfiguration configuration = RealmFactory.newRealmConfiguration(context); Timber.i( "DI provide RealmConfiguration. path=%s, version=%s", configuration.getPath(), configuration.getSchemaVersion()); return configuration; }
// Restart the activity @SuppressLint("NewApi") protected void restartActivity() { Timber.i("AnkiActivity -- restartActivity()"); Intent intent = new Intent(); intent.setClass(this, this.getClass()); intent.putExtras(new Bundle()); this.startActivityWithoutAnimation(intent); this.finishWithoutAnimation(); }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { Timber.i("DeckOptions - onBackPressed()"); closeWithResult(); return true; } return super.onKeyDown(keyCode, event); }
private void handleActivityResult(@NonNull Intent data, int reqCode) throws SecurityException { final Uri uri; String filePath = null; if (reqCode == REQUEST_PICK_FILE) { uri = data.getData(); if (uri != null) { filePath = uri.getPath(); } } else { uri = null; filePath = data.getStringExtra("path"); } Timber.i("uri: %s, filepath: %s", uri, filePath); if (!Utils.fileExists(filePath) && uri != null) { final ContentResolver cr = getContentResolver(); Cursor cursor = null; try { cursor = cr.query(uri, null, null, null, null); if (cursor != null && cursor.moveToNext()) { int index = cursor.getColumnIndex(MediaStore.MediaColumns.DATA); if (index >= 0) { filePath = cursor.getString(index); } else if (Build.VERSION.SDK_INT >= 19 && uri.toString().startsWith(ContentResolver.SCHEME_CONTENT)) { String newUri = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(uri.getAuthority()) .appendPath("document") .build() .toString(); String path = uri.toString(); index = filePath.indexOf(":"); if (path.startsWith(newUri) && index >= 0) { String firstPath = filePath.substring(0, index); filePath = filePath.substring(index + 1); String storage = IOUtils.get().getPrimarySdCard(); if (!firstPath.contains(ROOT_ID_PRIMARY_EMULATED)) { storage = IOUtils.get().getSecondarySdCard(); } filePath = storage + "/" + filePath; } else { filePath = null; } } } } finally { if (cursor != null) cursor.close(); } } if (sCallback != null) { sCallback.fileRequested(filePath); } }
public static void saveIntentInformation(Context context, String fields) { openDBIfClosed(context); try { mMetaDb.execSQL( "INSERT INTO intentInformation (fields) " + " VALUES (?);", new Object[] {fields}); Timber.i("MetaDB:: Store intentInformation: " + fields); } catch (Exception e) { Timber.e(e, "Error storing intentInformation in MetaDB "); } }
@Override public void sendMessage( IConversation conversation, AudioAssetForUpload audioAssetForUpload, MessageContent.Asset.ErrorHandler errorHandler) { if (conversation != null) { Timber.i("Send audio file to %s", conversation.getName()); conversation.sendMessage(new MessageContent.Asset(audioAssetForUpload, errorHandler)); } }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { Timber.i("onBackPressed()"); setResult(RESULT_CANCELED); finishWithAnimation(); return true; } return super.onKeyDown(keyCode, event); }
/** * Resets all the language associates for a given deck. * * @return whether an error occurred while resetting the language for the deck */ public static boolean resetDeckLanguages(Context context, long did) { openDBIfClosed(context); try { mMetaDb.execSQL("DELETE FROM languages WHERE did = " + did + ";"); Timber.i("MetaDB:: Resetting language assignment for deck %d", did); return true; } catch (Exception e) { Timber.e(e, "Error resetting deck language"); } return false; }
private boolean isValidOptionsForDiskCache() { if (mDiskCacheEnabled) { if (null == mDiskCacheLocation) { return false; } else if (!mDiskCacheLocation.canWrite()) { Timber.i("Disk Cache Location is not write-able, disabling disk caching."); return false; } return true; } return false; }
public static boolean removeIntentInformation(Context context, String id) { if (mMetaDb == null || !mMetaDb.isOpen()) { openDB(context); } try { Timber.i("MetaDB:: Deleting intent information " + id); mMetaDb.execSQL("DELETE FROM intentInformation WHERE id = " + id + ";"); return true; } catch (Exception e) { Timber.e(e, "Error deleting intentInformation " + id + ": "); } return false; }
/** Reset the language associations for all the decks and card models. */ public static boolean resetLanguages(Context context) { if (mMetaDb == null || !mMetaDb.isOpen()) { openDB(context); } try { Timber.i("MetaDB:: Resetting all language assignments"); mMetaDb.execSQL("DROP TABLE IF EXISTS languages;"); upgradeDB(mMetaDb, DATABASE_VERSION); return true; } catch (Exception e) { Timber.e(e, "Error resetting MetaDB "); } return false; }
/** Reset the intent information. */ public static boolean resetIntentInformation(Context context) { if (mMetaDb == null || !mMetaDb.isOpen()) { openDB(context); } try { Timber.i("MetaDB:: Resetting intent information"); mMetaDb.execSQL("DROP TABLE IF EXISTS intentInformation;"); upgradeDB(mMetaDb, DATABASE_VERSION); return true; } catch (Exception e) { Timber.e(e, "Error resetting intentInformation "); } return false; }
/** Reset the widget status. */ public static boolean resetWidget(Context context) { if (mMetaDb == null || !mMetaDb.isOpen()) { openDB(context); } try { Timber.i("MetaDB:: Resetting widget status"); mMetaDb.execSQL("DROP TABLE IF EXISTS widgetStatus;"); mMetaDb.execSQL("DROP TABLE IF EXISTS smallWidgetStatus;"); upgradeDB(mMetaDb, DATABASE_VERSION); return true; } catch (Exception e) { Timber.e(e, "Error resetting widgetStatus and smallWidgetStatus"); } return false; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); if (TokenSession.getTokenType(this) == -1) { Intent intentAuth = new Intent(); intentAuth.setClass(this, WBAuthActivity.class); startActivity(intentAuth); } else { Timber.i("查询用户信息"); Intent intent = new Intent(this, MainActivity.class); startActivity(intent); finish(); } }
protected void cacheValues() { Timber.i("DeckOptions - CacheValues"); try { mOptions = mCol.getDecks().confForDid(mDeck.getLong("id")); mValues.put("name", mDeck.getString("name")); mValues.put("desc", mDeck.getString("desc")); mValues.put("deckConf", mDeck.getString("conf")); // general mValues.put("maxAnswerTime", mOptions.getString("maxTaken")); mValues.put("showAnswerTimer", Boolean.toString(mOptions.getInt("timer") == 1)); mValues.put("autoPlayAudio", Boolean.toString(mOptions.getBoolean("autoplay"))); mValues.put("replayQuestion", Boolean.toString(mOptions.getBoolean("replayq"))); // new JSONObject newOptions = mOptions.getJSONObject("new"); mValues.put("newSteps", StepsPreference.convertFromJSON(newOptions.getJSONArray("delays"))); mValues.put("newGradIvl", newOptions.getJSONArray("ints").getString(0)); mValues.put("newEasy", newOptions.getJSONArray("ints").getString(1)); mValues.put("newFactor", Integer.toString(newOptions.getInt("initialFactor") / 10)); mValues.put("newOrder", newOptions.getString("order")); mValues.put("newPerDay", newOptions.getString("perDay")); mValues.put("newBury", Boolean.toString(newOptions.optBoolean("bury", true))); // rev JSONObject revOptions = mOptions.getJSONObject("rev"); mValues.put("revPerDay", revOptions.getString("perDay")); mValues.put("easyBonus", Integer.toString((int) (revOptions.getDouble("ease4") * 100))); mValues.put("revIvlFct", Integer.toString((int) (revOptions.getDouble("ivlFct") * 100))); mValues.put("revMaxIvl", revOptions.getString("maxIvl")); mValues.put("revBury", Boolean.toString(revOptions.optBoolean("bury", true))); // lapse JSONObject lapOptions = mOptions.getJSONObject("lapse"); mValues.put("lapSteps", StepsPreference.convertFromJSON(lapOptions.getJSONArray("delays"))); mValues.put("lapNewIvl", Integer.toString((int) (lapOptions.getDouble("mult") * 100))); mValues.put("lapMinIvl", lapOptions.getString("minInt")); mValues.put("lapLeechThres", lapOptions.getString("leechFails")); mValues.put("lapLeechAct", lapOptions.getString("leechAction")); // options group management mValues.put( "currentConf", mCol.getDecks().getConf(mDeck.getLong("conf")).getString("name")); } catch (JSONException e) { addMissingValues(); finish(); } }
private void handleInitializeFinished(Boolean success) { if (hasNavigated) { Timber.i("Has navigated, do nothing"); } else if (success) { if (launchMainPending == null) { launchMainPending = new Runnable() { @Override public void run() { navigateToMain(); } }; autoLaunchMain(); } } else { // post an Exit Event } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); ButterKnife.bind(this); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(getTitle()); actionBar.setDisplayHomeAsUpEnabled(true); } Timber.i("source: login"); if (savedInstanceState == null) showLoginFragment(); }
public int getLayoutByItemId(int itemId) { Timber.i("Izvodim getLayoutByItemId na - " + Thread.currentThread().getName()); int viewId; switch (itemId) { case R.id.navSchedule: viewId = UiConstants.SCHEDULES; break; case R.id.navTriggers: viewId = UiConstants.TRIGGERS; break; case R.id.navHistory: viewId = UiConstants.HISTORY; break; default: viewId = UiConstants.SETTINGS; break; } return viewId; }
public static void storeSmallWidgetStatus(Context context, float[] progress) { openDBIfClosed(context); try { mMetaDb.beginTransaction(); try { // First clear all the existing content. mMetaDb.execSQL("DELETE FROM smallWidgetStatus"); mMetaDb.execSQL( "INSERT INTO smallWidgetStatus(progress, left, eta) VALUES (?, ?, ?)", new Object[] {(int) (progress[1] * 1000), (int) progress[2], (int) progress[3]}); mMetaDb.setTransactionSuccessful(); } finally { mMetaDb.endTransaction(); } } catch (IllegalStateException e) { Timber.e(e, "MetaDB.storeSmallWidgetStatus: failed"); } catch (SQLiteException e) { Timber.e(e, "MetaDB.storeSmallWidgetStatus: failed"); closeDB(); Timber.i("MetaDB:: Trying to reset Widget: " + resetWidget(context)); } }
/** Reset the content of the meta-db, erasing all its content. */ public static boolean resetDB(Context context) { openDBIfClosed(context); try { mMetaDb.execSQL("DROP TABLE IF EXISTS languages;"); Timber.i("MetaDB:: Resetting all language assignment"); mMetaDb.execSQL("DROP TABLE IF EXISTS whiteboardState;"); Timber.i("MetaDB:: Resetting whiteboard state"); mMetaDb.execSQL("DROP TABLE IF EXISTS customDictionary;"); Timber.i("MetaDB:: Resetting custom Dictionary"); mMetaDb.execSQL("DROP TABLE IF EXISTS widgetStatus;"); Timber.i("MetaDB:: Resetting widget status"); mMetaDb.execSQL("DROP TABLE IF EXISTS smallWidgetStatus;"); Timber.i("MetaDB:: Resetting small widget status"); mMetaDb.execSQL("DROP TABLE IF EXISTS intentInformation;"); Timber.i("MetaDB:: Resetting intentInformation"); upgradeDB(mMetaDb, DATABASE_VERSION); return true; } catch (Exception e) { Timber.e(e, "Error resetting MetaDB "); } return false; }