Пример #1
0
  public void showShowcase() {
    final ShowcaseView sv =
        new ShowcaseView.Builder(getActivity())
            .setStyle(R.style.ShowcaseTheme)
            .setTarget(new ActionViewTarget(getActivity(), ActionViewTarget.Type.HOME))
            .setContentTitle(R.string.cm_player_home_title)
            .setContentText(R.string.cm_player_home_content)
            .build();
    sv.setButtonText(getString(R.string.cm_next));

    sv.overrideButtonClick(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            switch (mShowcaseCounter) {
              case 0:
                sv.setShowcase(new ViewTarget(myPager), true);
                sv.setContentTitle(getString(R.string.cm_player_swipe_title));
                sv.setContentText(getString(R.string.cm_player_swipe_content));
                break;
              case 1:
                sv.setShowcase(new ViewTarget(mPlayerPageFragment.getImageArt()), true);
                sv.setContentTitle(getString(R.string.cm_player_lyrics_title));
                sv.setContentText(getString(R.string.cm_player_lyrics_content));
                break;
              case 2:
                sv.setButtonText(getString(R.string.cm_close));
                sv.setShowcase(new ViewTarget(mBtnPlayPause), true);
                sv.setContentTitle(getString(R.string.cm_player_hold_pause_title));
                sv.setContentText(getString(R.string.cm_player_hold_pause_content));
                break;
              case 3:
                sv.hide();
                break;
            }
            mShowcaseCounter++;
          }
        });

    RelativeLayout.LayoutParams lps =
        new RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lps.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    int margin = ((Number) (getResources().getDisplayMetrics().density * 12)).intValue();
    lps.setMargins(margin, margin * 3, margin, margin);

    sv.setButtonPosition(lps);
  }
Пример #2
0
  @Override
  public void onClick(View view) {
    switch (counter) {
      case 0:
        showcaseView.setShowcase(new ViewTarget(findViewById(R.id.bNewSession)), false);
        showcaseView.setContentTitle("Create Sessions");
        showcaseView.setContentText("Click here to Create new Session.");
        showcaseView.setButtonText("GOT IT");
        break;

      case 1:
        showcaseView.hide();
        break;
    }
    counter++;
  }
Пример #3
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);
  }