Ejemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mToolbar = (Toolbar) findViewById(R.id.toolBar);
    setSupportActionBar(mToolbar);

    mRvTable = (RecyclerView) findViewById(R.id.rv_table);
    mRvTable.setHasFixedSize(true);

    // use a linear layout manager
    mLayoutManager = new LinearLayoutManager(this);
    mRvTable.setLayoutManager(mLayoutManager);

    // initialize array
    mAssets = new ArrayList<>();
    mAdapter = new AssetAdapter(this, mAssets);
    mRvTable.setAdapter(mAdapter);

    mSnackbarLayout = (CoordinatorLayout) findViewById(R.id.snackbarPosition);

    if (STApplication.getInstance().getAssetList() == null
        || STApplication.getInstance().getAssetList().size() <= 0) {
      new Handler()
          .postDelayed(
              new Runnable() {

                /*
                 * Showing splash screen with a timer. This will be useful when you
                 * want to show case your app logo / company
                 */

                @Override
                public void run() {
                  // This method will be executed once the timer is over
                  // Start your app main activity
                  Intent i = new Intent(MainActivity.this, DownloaderActivity.class);
                  startActivityForResult(i, DOWNLOAD_TASK);
                }
              },
              3000);
    } else {
      mAdapter.refresh(STApplication.getInstance().getAssetList());
    }
  }
Ejemplo n.º 2
0
    @Override
    protected void onPostExecute(List<Asset> assets) {
      super.onPostExecute(assets);
      mDuration = System.currentTimeMillis() - mDuration;
      if (TextUtils.isEmpty(mError)) {
        Snackbar.make(
                mSnackbarLayout,
                "Size = " + assets.size() + "\n Parsed in " + mDuration + "ms",
                Snackbar.LENGTH_LONG)
            .show();
        STApplication.getInstance().setAssets(assets);
        mAdapter.refresh(assets);
      } else {
        Snackbar.make(mSnackbarLayout, mError, Snackbar.LENGTH_LONG).show();
      }

      if (mDialog.isShowing()) mDialog.dismiss();
    }