Java Code Examples for com.facebook.stetho.dumpapp.DumperContext#getArgsAsList()

The following examples show how to use com.facebook.stetho.dumpapp.DumperContext#getArgsAsList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseFrescoStethoPlugin.java    From fresco with MIT License 6 votes vote down vote up
/**
 * Entry point for the Stetho dumpapp script.
 *
 * <p>{@link #initialize} must have been called in the app before running dumpapp.
 */
@Override
public void dump(DumperContext dumpContext) throws DumpException {
  ensureInitialized();
  List<String> args = dumpContext.getArgsAsList();
  PrintStream writer = dumpContext.getStdout();

  String cmd = args.isEmpty() ? null : args.get(0);
  List<String> rest = args.isEmpty() ? new ArrayList<String>() : args.subList(1, args.size());

  if (cmd != null && cmd.equals("memcache")) {
    memcache(writer, rest);
  } else if (cmd != null && cmd.equals("diskcache")) {
    diskcache(mMainFileCache, "Main", writer, rest);
    diskcache(mSmallFileCache, "Small", writer, rest);
  } else if (cmd != null && cmd.equals("clear")) {
    mImagePipeline.clearCaches();
  } else {
    usage(writer);
    if (TextUtils.isEmpty(cmd)) {
      throw new DumpUsageException("Missing command");
    } else {
      throw new DumpUsageException("Unknown command: " + cmd);
    }
  }
}
 
Example 2
Source File: AppDumperPlugin.java    From droidconat-2016 with Apache License 2.0 5 votes vote down vote up
@Override
public void dump(DumperContext dumpContext) throws DumpException {
    final PrintStream writer = dumpContext.getStdout();
    List<String> args = dumpContext.getArgsAsList();
    String commandName = args.isEmpty() ? "" : args.remove(0);

    switch (commandName) {
        case "alarms":
            displayAlarms(writer);
            break;
        case "appInfo":
            displayAppInfo(writer);
            break;
        case "bootReceiver":
            displayBootReceiverState(writer);
            break;
        case "currentSession":
            displayCurrentSessionData(writer);
            break;
        case "endpoint":
            changeEndpoint(writer, args);
            break;
        case "notif":
            displayNotificationReminder();
            break;
        default:
            doUsage(writer);
            break;
    }
}
 
Example 3
Source File: SharedPreferencesDumperPlugin.java    From stetho with MIT License 5 votes vote down vote up
@Override
public void dump(DumperContext dumpContext) throws DumpUsageException {
  PrintStream writer = dumpContext.getStdout();
  List<String> args = dumpContext.getArgsAsList();

  String commandName = args.isEmpty() ? "" : args.remove(0);

  if (commandName.equals("print")) {
    doPrint(writer, args);
  } else if (commandName.equals("write")) {
    doWrite(args);
  } else {
    doUsage(writer);
  }
}
 
Example 4
Source File: GattPlugin.java    From bitgatt with Mozilla Public License 2.0 4 votes vote down vote up
private String getCommand(DumperContext dumpContext) {
    List<String> argsList = dumpContext.getArgsAsList();
    Iterator<String> args = argsList.iterator();
    return ArgsHelper.nextOptionalArg(args, null);
}