Ejemplo n.º 1
0
        @Override
        public void onReceive(Context context, Intent intent) {
          if (intent.getAction().equalsIgnoreCase(INTENT_REFRESH)) {
            ArrayList<Session> sessionsList = SessionsUtil.getSessionList();
            sessionListAdapter.setDataList(sessionsList);
            sessionListAdapter.notifyDataSetChanged();
          }

          if (sessionListAdapter.getItemCount() == 1) {
            findViewById(R.id.tvNoSessions).setVisibility(View.VISIBLE);
            findViewById(R.id.lvSessions).setVisibility(View.GONE);
          } else {
            findViewById(R.id.tvNoSessions).setVisibility(View.GONE);
            findViewById(R.id.lvSessions).setVisibility(View.VISIBLE);
          }
        }
Ejemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.sessions_activity);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    try {
      final ActionBar ab = getSupportActionBar();
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
      ab.setTitle("Sessions");
    } catch (Exception ex) {
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
      Window window = getWindow();
      window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
      window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
    }

    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.lvSessions);
    recyclerView.setLayoutManager(new LinearLayoutManager(this));

    ArrayList<Session> sessionsList = SessionsUtil.getSessionList();
    if (sessionsList.size() != 0) {
      Session session = new Session();
      session.setSessionName("---sep---");
      session.setLastUsed(0);
      sessionsList.add(session);
      findViewById(R.id.tvNoSessions).setVisibility(View.GONE);
      findViewById(R.id.lvSessions).setVisibility(View.VISIBLE);
    } else {
      findViewById(R.id.tvNoSessions).setVisibility(View.VISIBLE);
      findViewById(R.id.lvSessions).setVisibility(View.GONE);
    }

    sessionListAdapter =
        new RecyclerViewAdapter(getBaseContext(), sessionsList, SessionsListActivity.this);
    recyclerView.setAdapter(sessionListAdapter);

    findViewById(R.id.bNewSession)
        .setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                startActivity(new Intent(SessionsListActivity.this, CreateSessionActivity.class));
                finish();
                overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
              }
            });

    showcaseView =
        new ShowcaseView.Builder(this)
            .withMaterialShowcase()
            .setTarget(Target.NONE)
            .singleShot(10921)
            .setOnClickListener(this)
            .setStyle(R.style.CustomShowcaseTheme)
            .build();
    showcaseView.setContentTitle("Sessions");
    showcaseView.setContentText(
        "Click on a session to see\n"
            + "TODO and mastered words.\n\n"
            + "Click on the start button to Start Session\n\n"
            + "Swipe left to see more options.");
    showcaseView.setButtonText("Next");

    //            AttributeSet attr = apiUtils.
    RelativeLayout.LayoutParams mLayoutParams =
        new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    mLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    mLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
    //        mLayoutParams.setMargins(50, 0, 0, 200);
    int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
    mLayoutParams.setMargins(margin, margin, margin, margin);
    showcaseView.setButtonPosition(mLayoutParams);
  }