コード例 #1
0
  private void settingShowcase() {
    SharedPreferences settings = getSharedPreferences("Showcase", 0);
    if (settings.getBoolean(Variables.editShowcase, true)) {
      ViewTarget imageTarget = new ViewTarget(R.id.avatarEditProfile, this);
      ShowcaseView showcase =
          new ShowcaseView.Builder(this)
              .setTarget(imageTarget)
              .setContentTitle(Variables.showcaseTitle)
              .withMaterialShowcase()
              .setStyle(R.style.CustomShowcaseTheme)
              .setContentText("Tap here to change your avatar")
              .build();
      showcase.setOnShowcaseEventListener(
          new OnShowcaseEventListener() {
            @Override
            public void onShowcaseViewHide(ShowcaseView showcaseView) {
              SharedPreferences settings = getSharedPreferences("Showcase", 0);
              SharedPreferences.Editor editor = settings.edit();
              editor.putBoolean(Variables.editShowcase, false);
              editor.commit();
            }

            @Override
            public void onShowcaseViewDidHide(ShowcaseView showcaseView) {}

            @Override
            public void onShowcaseViewShow(ShowcaseView showcaseView) {}

            @Override
            public void onShowcaseViewTouchBlocked(MotionEvent motionEvent) {}
          });
    }
  }
コード例 #2
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 private static void insertShowcaseView(ShowcaseView showcaseView, Activity activity) {
   ((ViewGroup) activity.getWindow().getDecorView()).addView(showcaseView);
   if (!showcaseView.hasShot()) {
     showcaseView.show();
   } else {
     showcaseView.hideImmediate();
   }
 }
コード例 #3
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);
  }
コード例 #4
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++;
  }
コード例 #5
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 public Builder setShowcaseEventListener(OnShowcaseEventListener showcaseEventListener) {
   showcaseView.setOnShowcaseEventListener(showcaseEventListener);
   return this;
 }
コード例 #6
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /**
  * Set the ShowcaseView to only ever show once.
  *
  * @param shotId a unique identifier (<em>across the app</em>) to store whether this
  *     ShowcaseView has been shown.
  */
 public Builder singleShot(long shotId) {
   showcaseView.setSingleShot(shotId);
   return this;
 }
コード例 #7
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /**
  * Make this ShowcaseView hide when the user touches outside the showcased area. This enables
  * {@link #doNotBlockTouches()} as well.
  *
  * <p>By default, the ShowcaseView doesn't hide on touch.
  */
 public Builder hideOnTouchOutside() {
   showcaseView.setBlocksTouches(true);
   showcaseView.setHideOnTouchOutside(true);
   return this;
 }
コード例 #8
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /**
  * Don't make the ShowcaseView block touches on itself. This doesn't block touches in the
  * showcased area.
  *
  * <p>By default, the ShowcaseView does block touches
  */
 public Builder doNotBlockTouches() {
   showcaseView.setBlocksTouches(false);
   return this;
 }
コード例 #9
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /**
  * Set a listener which will override the button clicks.
  *
  * <p>Note that you will have to manually hide the ShowcaseView
  */
 public Builder setOnClickListener(OnClickListener onClickListener) {
   showcaseView.overrideButtonClick(onClickListener);
   return this;
 }
コード例 #10
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /** Set the style of the ShowcaseView. See the sample app for example styles. */
 public Builder setStyle(int theme) {
   showcaseView.setStyle(theme);
   return this;
 }
コード例 #11
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /**
  * Set the target of the showcase.
  *
  * @param target a {@link com.github.amlcurran.showcaseview.targets.Target} representing the
  *     item to showcase (e.g., a button, or action item).
  */
 public Builder setTarget(Target target) {
   showcaseView.setTarget(target);
   return this;
 }
コード例 #12
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /** Set the descriptive text shown on the ShowcaseView. */
 public Builder setContentText(CharSequence text) {
   showcaseView.setContentText(text);
   return this;
 }
コード例 #13
0
ファイル: ShowcaseView.java プロジェクト: BeniG/ShowcaseView
 /** Set the title text shown on the ShowcaseView. */
 public Builder setContentTitle(CharSequence title) {
   showcaseView.setContentTitle(title);
   return this;
 }
コード例 #14
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);
  }