Java Code Examples for androidx.appcompat.app.AppCompatActivity

The following examples show how to use androidx.appcompat.app.AppCompatActivity. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: braintree_android   Source File: PayPalTwoFactorAuthUnitTest.java    License: MIT License 6 votes vote down vote up
@Test
public void onActivityResult_callsCancelCallbackWhenBrowserSwitchIsCancelled() {
    BraintreeFragment braintreeFragment = mMockFragmentBuilder.build();

    Intent intent = mock(Intent.class);
    Uri uri = mock(Uri.class);
    PayPalAccountNonce nonce = mock(PayPalAccountNonce.class);

    when(uri.getHost()).thenReturn("cancel");
    when(intent.getData()).thenReturn(uri);
    mockStatic(PayPalTwoFactorAuthSharedPreferences.class);
    when(PayPalTwoFactorAuthSharedPreferences.getPersistedPayPalAccountNonce(braintreeFragment)).thenReturn(nonce);

    PayPalTwoFactorAuth.onActivityResult(braintreeFragment, AppCompatActivity.RESULT_OK, intent);

    verify(braintreeFragment).sendAnalyticsEvent("paypal-two-factor.browser-switch.canceled");
    verify(braintreeFragment).postCancelCallback(BraintreeRequestCodes.PAYPAL_TWO_FACTOR_AUTH);
}
 
Example 2
Source Project: candybar   Source File: IconsLoaderTask.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onPostExecute(Boolean aBoolean) {
    super.onPostExecute(aBoolean);
    if (aBoolean) {
        if (mHome == null) return;
        if (mContext.get() == null) return;

        FragmentManager fm = ((AppCompatActivity) mContext.get()).getSupportFragmentManager();
        if (fm == null) return;

        Fragment fragment = fm.findFragmentByTag("home");
        if (fragment == null) return;

        HomeListener listener = (HomeListener) fragment;
        listener.onHomeDataUpdated(mHome);
    }
}
 
Example 3
Source Project: braintree_android   Source File: Venmo.java    License: MIT License 6 votes vote down vote up
static void onActivityResult(final BraintreeFragment fragment, int resultCode, Intent data) {
    if (resultCode == AppCompatActivity.RESULT_OK) {
        fragment.sendAnalyticsEvent("pay-with-venmo.app-switch.success");
        String nonce = data.getStringExtra(EXTRA_PAYMENT_METHOD_NONCE);

        if (shouldVault(fragment.getApplicationContext()) && fragment.getAuthorization() instanceof ClientToken) {
            vault(fragment, nonce);
        } else {
            String venmoUsername = data.getStringExtra(EXTRA_USERNAME);
            VenmoAccountNonce venmoAccountNonce = new VenmoAccountNonce(nonce, venmoUsername, venmoUsername);
            fragment.postCallback(venmoAccountNonce);
        }
    } else if (resultCode == AppCompatActivity.RESULT_CANCELED) {
        fragment.sendAnalyticsEvent("pay-with-venmo.app-switch.canceled");
    }
}
 
Example 4
private void setUpRecyclerView() {
    recyclerViewDragDropManager = new RecyclerViewDragDropManager();
    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator();

    playingQueueAdapter = new PlayingQueueAdapter(
            ((AppCompatActivity) getActivity()),
            MusicPlayerRemote.getPlayingQueue(),
            MusicPlayerRemote.getPosition(),
            R.layout.item_list,
            false,
            null);
    wrappedAdapter = recyclerViewDragDropManager.createWrappedAdapter(playingQueueAdapter);

    layoutManager = new LinearLayoutManager(getActivity());

    recyclerView.setLayoutManager(layoutManager);
    recyclerView.setAdapter(wrappedAdapter);
    recyclerView.setItemAnimator(animator);

    recyclerViewDragDropManager.attachRecyclerView(recyclerView);

    layoutManager.scrollToPositionWithOffset(MusicPlayerRemote.getPosition() + 1, 0);
}
 
Example 5
public HtmlRawElementBlock reduce(
		@NonNull final HtmlTextAttributes activeAttributes,
		@NonNull final AppCompatActivity activity) {

	final ArrayList<HtmlRawElement> reduced = new ArrayList<>();
	final ArrayList<LinkButtonDetails> linkButtons = new ArrayList<>();

	for(final HtmlRawElement child : mChildren) {
		child.reduce(activeAttributes, activity, reduced, linkButtons);
	}

	for(final LinkButtonDetails details : linkButtons) {
		reduced.add(new HtmlRawElementLinkButton(details));
	}

	return new HtmlRawElementBlock(mBlockType, reduced);
}
 
Example 6
public static MaterialDatePicker<Long> showDatePicker(
    ActivityTestRule<? extends AppCompatActivity> activityTestRule,
    int themeResId,
    CalendarConstraints calendarConstraints) {
  FragmentManager fragmentManager = activityTestRule.getActivity().getSupportFragmentManager();
  String tag = "Date DialogFragment";

  MaterialDatePicker<Long> dialogFragment =
      MaterialDatePicker.Builder.datePicker()
          .setCalendarConstraints(calendarConstraints)
          .setTheme(themeResId)
          .build();
  dialogFragment.show(fragmentManager, tag);
  InstrumentationRegistry.getInstrumentation().waitForIdleSync();
  return dialogFragment;
}
 
Example 7
Source Project: braintree_android   Source File: VenmoUnitTest.java    License: MIT License 6 votes vote down vote up
@Test
public void onActivityResult_postsPaymentMethodNonceOnSuccess() {
    BraintreeFragment fragment = new MockFragmentBuilder()
            .build();
    Intent intent = new Intent()
            .putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "123456-12345-12345-a-adfa")
            .putExtra(Venmo.EXTRA_USERNAME, "username");

    Venmo.onActivityResult(fragment, AppCompatActivity.RESULT_OK, intent);

    ArgumentCaptor<VenmoAccountNonce> captor = ArgumentCaptor.forClass(VenmoAccountNonce.class);
    verify(fragment).postCallback(captor.capture());
    assertEquals("123456-12345-12345-a-adfa", captor.getValue().getNonce());
    assertEquals("username", captor.getValue().getDescription());
    assertEquals("username", captor.getValue().getUsername());
}
 
Example 8
@Override
public View generateView(
		@NonNull final AppCompatActivity activity,
		@Nullable final Integer textColor,
		@Nullable final Float textSize,
		final boolean showLinkButtons) {

	final int paddingPx = General.dpToPixels(activity, 3);
	final int thicknessPx = General.dpToPixels(activity, 1);

	final View divider = new View(activity);

	final ViewGroup.MarginLayoutParams layoutParams
			= new ViewGroup.MarginLayoutParams(
					ViewGroup.LayoutParams.MATCH_PARENT,
					thicknessPx);

	layoutParams.leftMargin = paddingPx;
	layoutParams.rightMargin = paddingPx;

	divider.setBackgroundColor(Color.GRAY);
	divider.setLayoutParams(layoutParams);

	return divider;
}
 
Example 9
Source Project: braintree_android   Source File: VenmoUnitTest.java    License: MIT License 6 votes vote down vote up
@Test
public void onActivityResult_withFailedVaultCall_sendsAnalyticsEvent() throws InvalidArgumentException {
    Configuration configuration = getConfigurationFromFixture();

    Authorization clientToken = Authorization.fromString(stringFromFixture("base_64_client_token.txt"));

    disableSignatureVerification();
    BraintreeFragment fragment = new MockFragmentBuilder()
            .context(VenmoInstalledContextFactory.venmoInstalledContext(true, RuntimeEnvironment.application))
            .configuration(configuration)
            .authorization(clientToken)
            .sessionId("session-id")
            .errorResponse(new AuthorizationException("Bad fingerprint"))
            .build();

    Venmo.authorizeAccount(fragment, true);

    Intent responseIntent = new Intent()
            .putExtra(Venmo.EXTRA_PAYMENT_METHOD_NONCE, "nonce");
    Venmo.onActivityResult(fragment, AppCompatActivity.RESULT_OK, responseIntent);

    verify(fragment).sendAnalyticsEvent(endsWith("pay-with-venmo.vault.failed"));
}
 
Example 10
private void setupToolbar() {
  String query = viewModel.getSearchQueryModel()
      .getFinalQuery();
  if (query.isEmpty() && !noResults) {
    toolbar.setTitle(R.string.search_hint_title);
    toolbar.setTitleMarginStart(100);
  } else if (query.isEmpty()) {
    toolbar.setTitle(R.string.search_hint_title);
  } else {
    toolbar.setTitle(query);
  }

  final AppCompatActivity activity = (AppCompatActivity) getActivity();
  activity.setSupportActionBar(toolbar);
  actionBar = activity.getSupportActionBar();
  if (actionBar != null) {
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(toolbar.getTitle());
  }
}
 
Example 11
Source Project: MovieGuide   Source File: MovieDetailsFragment.java    License: MIT License 6 votes vote down vote up
private void setToolbar() {
    collapsingToolbar.setContentScrimColor(ContextCompat.getColor(getContext(), R.color.colorPrimary));
    collapsingToolbar.setTitle(getString(R.string.movie_details));
    collapsingToolbar.setCollapsedTitleTextAppearance(R.style.CollapsedToolbar);
    collapsingToolbar.setExpandedTitleTextAppearance(R.style.ExpandedToolbar);
    collapsingToolbar.setTitleEnabled(true);

    if (toolbar != null) {
        ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);

        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    } else {
        // Don't inflate. Tablet is in landscape mode.
    }
}
 
Example 12
Source Project: tindroid   Source File: AccNotificationsFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void updateFormValues(final AppCompatActivity activity, final MeTopic<VxCard> me) {
    if (activity == null || me == null) {
        return;
    }

    // Incognito mode
    Switch ctrl = activity.findViewById(R.id.switchIncognitoMode);
    ctrl.setChecked(me.isMuted());
}
 
Example 13
@Before
public void setupMonthAdapters() {
  ApplicationProvider.getApplicationContext().setTheme(R.style.Theme_MaterialComponents_Light);
  AppCompatActivity activity = Robolectric.buildActivity(AppCompatActivity.class).setup().get();
  context = activity.getApplicationContext();
  GridView gridView = new GridView(context);
  rangeDateSelector = new RangeDateSelector();
  adapter =
      new MonthAdapter(
          Month.create(2016, Calendar.FEBRUARY),
          rangeDateSelector,
          new CalendarConstraints.Builder().build());
  gridView.setAdapter(adapter);
}
 
Example 14
public void setupToolbarTitle() {
  toolbar.setTitle(getViewTitle(currentModel));
  ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
  final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(false);
  actionBar.setTitle(toolbar.getTitle());
}
 
Example 15
@Override
public void generate(
		@NonNull final AppCompatActivity activity,
		@NonNull final ArrayList<BodyElement> destination) {

	destination.add(new BodyElementHorizontalRule());
}
 
Example 16
private void accept() {
    Intent intent = new Intent();

    String blurb = getResources().getString(shuffleCheckbox.isChecked() ? R.string.tasker_start_playing_shuffled : R.string.tasker_start_playing);
    intent.putExtra("com.twofortyfouram.locale.intent.extra.BLURB", blurb);

    // Get settings user specified
    Bundle data = new Bundle();
    boolean shuffle = shuffleCheckbox.isChecked();
    data.putBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, shuffle);
    if (shuffle) {
        if (startYearCheckbox.isChecked()) {
            data.putString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, startYearBox.getText().toString());
        }
        if (endYearCheckbox.isChecked()) {
            data.putString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, endYearBox.getText().toString());
        }
        String genre = genreButton.getText().toString();
        if (!genre.equals(doNothing)) {
            data.putString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, genre);
        }
    }

    int offline = offlineSpinner.getSelectedItemPosition();
    if (offline != 0) {
        data.putInt(Constants.PREFERENCES_KEY_OFFLINE, offline);
    }

    intent.putExtra(Constants.TASKER_EXTRA_BUNDLE, data);

    setResult(AppCompatActivity.RESULT_OK, intent);
    finish();
}
 
Example 17
Source Project: haven   Source File: AccelerometerMonitor.java    License: GNU General Public License v3.0 5 votes vote down vote up
public AccelerometerMonitor(Context context) {
       prefs = new PreferenceManager(context);

	/*
	 * Set sensitivity value
	 */
try {
           shakeThreshold = Integer.parseInt(prefs.getAccelerometerSensitivity());
       }
       catch (Exception e)
       {
           shakeThreshold = 50;
       }

       context.bindService(new Intent(context,
               MonitorService.class), mConnection, Context.BIND_ABOVE_CLIENT);

       sensorMgr = (SensorManager) context.getSystemService(AppCompatActivity.SENSOR_SERVICE);
       accelerometer = sensorMgr.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

       if (accelerometer == null) {
           Log.i("AccelerometerFrament", "Warning: no accelerometer");
       } else {
           sensorMgr.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
       }

   }
 
Example 18
Source Project: braintree_android   Source File: BraintreeFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onBrowserSwitchResult(int requestCode, BrowserSwitchResult browserSwitchResult, @Nullable Uri uri) {
    String type = "";
    Intent intent = new Intent()
            .putExtra(EXTRA_WAS_BROWSER_SWITCH_RESULT, true);

    switch (requestCode) {
        case BraintreeRequestCodes.PAYPAL:
            type = "paypal";
            break;
        case BraintreeRequestCodes.THREE_D_SECURE:
            type =  "three-d-secure";
            break;
        case BraintreeRequestCodes.LOCAL_PAYMENT:
            type = "local-payment";
            break;
    }

    int resultCode = AppCompatActivity.RESULT_FIRST_USER;
    if (browserSwitchResult == BrowserSwitchResult.OK) {
        resultCode = AppCompatActivity.RESULT_OK;
        sendAnalyticsEvent(type + ".browser-switch.succeeded");
    } else if (browserSwitchResult == BrowserSwitchResult.CANCELED) {
        resultCode = AppCompatActivity.RESULT_CANCELED;
        sendAnalyticsEvent(type + ".browser-switch.canceled");
    } else if (browserSwitchResult == BrowserSwitchResult.ERROR) {
        if (browserSwitchResult.getErrorMessage().startsWith("No installed activities")) {
            sendAnalyticsEvent(type + ".browser-switch.failed.no-browser-installed");
        } else {
            sendAnalyticsEvent(type + ".browser-switch.failed.not-setup");
        }
    }

    onActivityResult(requestCode, resultCode, intent.setData(uri));
}
 
Example 19
Source Project: MusicPlayer   Source File: LayerController.java    License: GNU General Public License v3.0 5 votes vote down vote up
@SuppressLint("ClickableViewAccessibility")
public LayerController(AppCompatActivity activity) {
    this.activity =  activity;
    oneDp = Tool.getOneDps(activity);
    mMaxMarginTop =margin_inDp*oneDp;
    ScreenSize[0] = ((MainActivity)activity).mRootEverything.getWidth();
    ScreenSize[1] = ((MainActivity)activity).mRootEverything.getHeight();

    listeners_size =0;
    mBaseLayers = new ArrayList<>();
    mBaseAttrs = new ArrayList<>();
    this.status_height = (status_height==0)? 24*oneDp :status_height;

    this.bottom_navigation_height = activity.getResources().getDimension(R.dimen.bottom_navigation_height);

    mTouchListener = (view, motionEvent) -> {
        //Log.d(TAG,"onTouchEvent");
        for(int i = 0; i< mBaseLayers.size(); i++ )
            if(mBaseAttrs.get(i).parent== view)
                return onTouchEvent(i,view,motionEvent);
        return true;
    };

    final ViewConfiguration vc = ViewConfiguration.get(activity);
    mTouchSlop = vc.getScaledTouchSlop();
    mMaxVelocity = vc.getScaledMaximumFlingVelocity();
    mMinVelocity = vc.getScaledMinimumFlingVelocity();
    mGestureDetector = new GestureDetector(activity,mGestureListener);

}
 
Example 20
Source Project: tindroid   Source File: AttachmentHandler.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("UnusedReturnValue")
static void enqueueUploadRequest(AppCompatActivity activity, String operation, Bundle args) {
    String topicName = args.getString(AttachmentHandler.ARG_TOPIC_NAME);
    // Create a new message which will be updated with upload progress.
    Drafty msg = new Drafty();
    long msgId = BaseDb.getInstance().getStore()
            .msgDraft(Cache.getTinode().getTopic(topicName), msg, Tinode.draftyHeadersFor(msg));
    if (msgId > 0) {
        Uri uri = args.getParcelable(AttachmentHandler.ARG_SRC_URI);
        assert uri != null;

        Data.Builder data = new Data.Builder()
                .putString(ARG_OPERATION, operation)
                .putString(ARG_SRC_URI, uri.toString())
                .putLong(ARG_MSG_ID, msgId)
                .putString(ARG_TOPIC_NAME, topicName)
                .putString(ARG_IMAGE_CAPTION, args.getString(ARG_IMAGE_CAPTION))
                .putString(ARG_FILE_PATH, args.getString(ARG_FILE_PATH));
        Constraints constraints = new Constraints.Builder()
                .setRequiredNetworkType(NetworkType.CONNECTED)
                .build();
        OneTimeWorkRequest upload = new OneTimeWorkRequest.Builder(AttachmentHandler.class)
                .setInputData(data.build())
                .setConstraints(constraints)
                .addTag(TAG_UPLOAD_WORK)
                .build();

        // If send or upload is retried,
        WorkManager.getInstance(activity).enqueueUniqueWork(Long.toString(msgId), ExistingWorkPolicy.REPLACE, upload);
    } else {
        Log.w(TAG, "Failed to insert new message to DB");
    }
}
 
Example 21
Source Project: talkback   Source File: TutorialMainFragment.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onResume() {
  super.onResume();
  // show general tutorial title, no up arrow
  AppCompatActivity activity = (AppCompatActivity) getActivity();
  ActionBar actionBar = (activity == null) ? null : activity.getSupportActionBar();
  if (actionBar != null) {
    actionBar.setTitle(R.string.tutorial_title);
    actionBar.setDisplayHomeAsUpEnabled(navigationUpFlag);
  }
}
 
Example 22
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.menu_sensor_item_label_details, menu);

  ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
  if (actionBar != null) {
    actionBar.setTitle(
        getActivity().getResources().getString(R.string.snapshot_label_details_title));
  }

  super.onCreateOptionsMenu(menu, inflater);
}
 
Example 23
@Override
public void reduce(
		@NonNull final HtmlTextAttributes activeAttributes,
		@NonNull final AppCompatActivity activity,
		@NonNull final ArrayList<HtmlRawElement> destination,
		@NonNull final ArrayList<LinkButtonDetails> linkButtons) {

	destination.add(reduce(activeAttributes, activity, linkButtons));
}
 
Example 24
Source Project: InAppUpdater   Source File: UpdateManager.java    License: MIT License 5 votes vote down vote up
public static UpdateManager Builder(AppCompatActivity activity) {
    if (instance == null) {
        instance = new UpdateManager(activity);
    }
    Log.d(TAG, "Instance created");
    return instance;
}
 
Example 25
Source Project: a   Source File: SettingNestedFragment.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected void setActionBarTitle(CharSequence title) {
    if (getActivity() != null) {
        ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
        String t = StringUtils.nullToText(title);
        if (actionBar != null && !t.equals(actionBar.getTitle())) {
            actionBar.setTitle(t);
        }
    }
}
 
Example 26
@NonNull
@Override
protected View.OnClickListener generateOnClickListener(
		@NonNull final AppCompatActivity activity,
		@Nullable final Integer textColor,
		@Nullable final Float textSize,
		final boolean showLinkButtons) {

	return (button) -> {
		final ScrollView scrollView = new ScrollView(activity);

		final View view = mSpoilerText.generateView(
				activity,
				textColor,
				textSize,
				true);

		scrollView.addView(view);

		final ViewGroup.MarginLayoutParams layoutParams
				= (FrameLayout.LayoutParams)view.getLayoutParams();

		final int marginPx = General.dpToPixels(activity, 14);
		layoutParams.setMargins(marginPx, marginPx, marginPx, marginPx);

		final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
		builder.setView(scrollView);

		builder.setNeutralButton(
				R.string.dialog_close,
				(dialog, which) -> {
				});

		final AlertDialog alert = builder.create();
		alert.show();
	};
}
 
Example 27
Source Project: MusicPlayer   Source File: IntroController.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void initBackStack(AppCompatActivity activity, Bundle savedInstanceState) {
    FragmentManager fm = activity.getSupportFragmentManager();
    mNavigationController = FragmentNavigationController.navigationController(fm, R.id.back_wall_container);
    mNavigationController.setAbleToPopRoot(true);
    mNavigationController.setPresentStyle(PRESENT_STYLE_DEFAULT);
    mNavigationController.setDuration(250);
    mNavigationController.setInterpolator(new AccelerateDecelerateInterpolator());
    mNavigationController.presentFragment(new IntroStepOneFragment());
    // mNavigationController.presentFragment(new MainFragment());
}
 
Example 28
@Override
protected void prepare(AppCompatActivity context, LinearLayout items) {

	final RedditPost post = getArguments().getParcelable("post");

	items.addView(propView(context, R.string.props_title, StringEscapeUtils.unescapeHtml4(post.title.trim()), true));
	items.addView(propView(context, R.string.props_author, post.author, false));
	items.addView(propView(context, R.string.props_url, StringEscapeUtils.unescapeHtml4(post.getUrl()), false));
	items.addView(propView(context, R.string.props_created, RRTime.formatDateTime(post.created_utc * 1000, context), false));

	if(post.edited instanceof Long) {
		items.addView(propView(context, R.string.props_edited, RRTime.formatDateTime((Long) post.edited * 1000, context), false));
	} else {
		items.addView(propView(context, R.string.props_edited, R.string.props_never, false));
	}

	items.addView(propView(context, R.string.props_subreddit, post.subreddit, false));
	items.addView(propView(context, R.string.props_score, String.valueOf(post.score), false));
	items.addView(propView(context, R.string.props_num_comments, String.valueOf(post.num_comments), false));

	if(post.selftext != null && post.selftext.length() > 0) {
		items.addView(propView(context, R.string.props_self_markdown, StringEscapeUtils.unescapeHtml4(post.selftext), false));

		if(post.selftext_html != null) {
			items.addView(propView(
					context,
					R.string.props_self_html,
					StringEscapeUtils.unescapeHtml4(post.selftext_html),
					false));
		}
	}
}
 
Example 29
private ActionBar setupActionBar() {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    final ActionBar actionBar = activity.getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    return actionBar;
}
 
Example 30
Source Project: material-components-android   Source File: DemoFragment.java    License: Apache License 2.0 5 votes vote down vote up
private void initDemoActionBar() {
  if (shouldShowDefaultDemoActionBar()) {
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    setDemoActionBarTitle(activity.getSupportActionBar());
  } else {
    toolbar.setVisibility(View.GONE);
  }
}