Пример #1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   mActivityGraph =
       ((Application) getApplication()).getApplicationGraph().plus(new ActivityModule(this));
   mActivityGraph.inject(this);
 }
Пример #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    log = LoggerFactory.getLogger(this.getClass());
    setContentView(R.layout.log);
    RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view);

    // use this setting to improve performance if you know that changes
    // in content do not change the layout size of the RecyclerView
    mRecyclerView.setHasFixedSize(false);

    VerticalRecyclerViewFastScroller fastScroller =
        (VerticalRecyclerViewFastScroller) findViewById(R.id.fast_scroller);

    // Connect the recycler to the scroller (to let the scroller scroll the list)
    fastScroller.setRecyclerView(mRecyclerView);

    // Connect the scroller to the recycler (to let the recycler scroll the scroller's handle)
    mRecyclerView.addOnScrollListener(fastScroller.getOnScrollListener());

    // use a linear layout manager
    LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
    mRecyclerView.setLayoutManager(mLayoutManager);
    myDataset = new ArrayList<>();
    File logFile = getLogFile();
    try {
      TaskIo.loadFromFile(
          logFile,
          new LineProcessor<String>() {
            @Override
            public boolean processLine(String line) throws IOException {
              if (!line.trim().isEmpty()) {
                myDataset.add(line);
              }
              return true;
            }

            @Override
            public String getResult() {
              return null;
            }
          });
    } catch (IOException e) {
      log.error("Failed to load logfile", e);
    }

    // specify an adapter (see also next example)
    LogAdapter mAdapter = new LogAdapter(myDataset);
    mRecyclerView.setAdapter(mAdapter);
  }
Пример #3
0
 @Override
 protected void onDestroy() {
   mActivityGraph = null;
   super.onDestroy();
 }