android.support.v7.app.AppCompatActivity Java Examples
The following examples show how to use
android.support.v7.app.AppCompatActivity.
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 File: EditorAction.java From mua with MIT License | 5 votes |
/** * Toggle keyboard according flag. If flag equals 0, hide or close keyboard. Otherwise, open. * @param flag A flag which indicate it should open keyboard or not. */ public void toggleKeyboard(int flag) { InputMethodManager inputMethodManager = (InputMethodManager) (context.getSystemService(Context.INPUT_METHOD_SERVICE)); if (inputMethodManager != null) { if (flag == 0) { View currentFocus = ((AppCompatActivity) context).getCurrentFocus(); if (currentFocus != null) { inputMethodManager.hideSoftInputFromWindow(currentFocus.getWindowToken(), 0); } } else { inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } } }
Example #2
Source File: Proxmark3Device.java From Walrus with GNU General Public License v3.0 | 5 votes |
@Override @UiThread public void createReadCardDataOperation(final AppCompatActivity activity, Class<? extends CardData> cardDataClass, final int callbackId) { ensureOperationCreatedCallbackSupported(activity); if (cardDataClass == HIDCardData.class) { ((OnOperationCreatedCallback) activity).onOperationCreated(new ReadHIDOperation(this), callbackId); } else if (cardDataClass == MifareCardData.class) { MifareReadSetupDialogFragment dialog = MifareReadSetupDialogFragment.create(callbackId); dialog.show(activity.getSupportFragmentManager(), "proxmark3_device_mifare_read_setup_dialog"); activity.getSupportFragmentManager().executePendingTransactions(); dialog.getViewModel().getSelectedReadSteps().observeForever( new Observer<List<MifareReadStep>>() { @Override public void onChanged(@Nullable List<MifareReadStep> readSteps) { ((OnOperationCreatedCallback) activity).onOperationCreated( new ReadMifareOperation(Proxmark3Device.this, readSteps), callbackId); } }); } else { throw new RuntimeException("Invalid card data class"); } }
Example #3
Source File: DropdownProxy.java From actionbarextras with MIT License | 5 votes |
@Override public void handleCreationDict(KrollDict options) { final ActionBar actionBar = ((AppCompatActivity)getActivity()).getSupportActionBar(); final boolean keepTitle; if (options.containsKey("keepTitle")) { keepTitle = options.getBoolean("keepTitle"); }else{ keepTitle = false; } add(keepTitle); if (options.containsKey("titles")) { final String[] dropdownValues = options.getStringArray("titles"); ArrayAdapter<String> adapter = new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_spinner_item, android.R.id.text1, dropdownValues); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); actionBar.setListNavigationCallbacks(adapter, navigationListener); } if (options.containsKey("index")) { int activeItem = options.getInt("index"); setActiveItem(activeItem); } super.handleCreationDict(options); }
Example #4
Source File: SettingsFragment.java From mua with MIT License | 5 votes |
@Override public void onCreatePreferencesFix(Bundle savedInstanceState, String rootKey) { setPreferencesFromResource(R.xml.preferences, rootKey); context = (AppCompatActivity) getContext(); sharedPref = PreferenceManager.getDefaultSharedPreferences(context); settingPreferences(); }
Example #5
Source File: SignInFragment.java From playa with MIT License | 5 votes |
@OnClick(R.id.link_signup) public void switchToSignup() { ((AppCompatActivity) context).getSupportFragmentManager() .beginTransaction() .replace(R.id.fragment_container, new SignUpFragment()) .commit(); }
Example #6
Source File: BaseFragment.java From homeassist with Apache License 2.0 | 5 votes |
public void setSubtitle(String title) { AppCompatActivity activity = (AppCompatActivity) getActivity(); if (activity != null) { ActionBar actionBar = activity.getSupportActionBar(); if (actionBar != null) { actionBar.setSubtitle(title); } } }
Example #7
Source File: RxBusMeunIView.java From MeiZiNews with MIT License | 5 votes |
public void initColorful(AppCompatActivity appCompatActivity) { mColorful = new Colorful.Builder(appCompatActivity) // 设置view的背景 .backgroundColor(navigationView.getHeaderView(0), R.attr.side_nav_bar) .backgroundColor(R.id.nav_view, R.attr.root_view_bg) .backgroundColor(R.id.toolbar, R.attr.colorPrimary) .backgroundColor(R.id.tabLayout, R.attr.colorPrimary) .backgroundColor(R.id.rl_main, R.attr.root_view_bg) .navigationViewItemColor(R.id.nav_view, R.attr.text_color) .drawerLayoutStatusBarBackgroundSetter(R.id.drawer_layout, R.attr.colorPrimaryDark) .create(); boolean isDay = MyProfile.getInstance(appCompatActivity).getTheme().equals(ConstantData.MY_PROFILE_THEME_DAY); setTheme(isDay); }
Example #8
Source File: ScreenUtils.java From FriendBook with GNU General Public License v3.0 | 5 votes |
/** * 获取整个手机屏幕的大小(包括虚拟按钮) * 必须在onWindowFocus方法之后使用 * * @param activity * @return */ public static int[] getScreenSize(AppCompatActivity activity) { int[] size = new int[2]; View decorView = activity.getWindow().getDecorView(); size[0] = decorView.getWidth(); size[1] = decorView.getHeight(); return size; }
Example #9
Source File: AppFileListFragment.java From AppPlus with MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View rootView = inflater.inflate(initLayout(), container, false); Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name); toolbar.setSubtitle(R.string.tab_exported); final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); ab.setDisplayHomeAsUpEnabled(true); setupSwipeLayout(rootView); setupRecyclerView(rootView); return rootView; }
Example #10
Source File: ErrorFragment.java From ShoppingList with Apache License 2.0 | 5 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); Bundle b = getArguments(); this.errorDescription = b.getString("error_code"); if(((AppCompatActivity)getActivity()).getSupportActionBar() != null) { ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(getResources().getString(R.string.title_main)); } }
Example #11
Source File: DismissibleImageView.java From DismissibleImageView with Apache License 2.0 | 5 votes |
@CallSuper @Override public void onClick(View v) { FragmentManager fragmentManager = null; if (this.fragmentManager != null) { fragmentManager = this.fragmentManager; } else if (getContext() instanceof FragmentActivity) { fragmentManager = ((AppCompatActivity) getContext()).getSupportFragmentManager(); } if (fragmentManager != null) { FullScreenImageFragment fragment; if (TextUtils.isEmpty(finalUrl)) { fragment = new FullScreenImageFragment.Builder(getDrawingCache(true)) .withLoadingBlur(blurOnLoading).build(); } else { fragment = new FullScreenImageFragment.Builder(finalUrl) .withLoadingBitmap(getDrawingCache(true)) .withLoadingBlur(blurOnLoading).build(); } fragment.show(fragmentManager); } }
Example #12
Source File: MRLPanelFragment.java From VCL-Android with Apache License 2.0 | 5 votes |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){ ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.open_mrl_dialog_title); View v = inflater.inflate(R.layout.mrl_panel, container, false); mRootView = v.findViewById(R.id.mrl_root); mEditText = (TextInputLayout) v.findViewById(R.id.mrl_edit); mEditText.getEditText().setOnKeyListener(this); mEditText.getEditText().setOnEditorActionListener(this); mEditText.setHint(getString(R.string.open_mrl_dialog_msg)); mRecyclerView = (RecyclerView) v.findViewById(R.id.mrl_list); mLayoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(mLayoutManager); mAdapter = new MRLAdapter(mHistory); mRecyclerView.setAdapter(mAdapter); return v; }
Example #13
Source File: PermissionListFragment.java From android-permission-checker-app with Apache License 2.0 | 5 votes |
private void setUpToolBar() { Toolbar toolbar = getActivity().findViewById(R.id.toolbar); TextView titleTextView = toolbar.findViewById(R.id.toolbar_title); titleTextView.setText("Permission Groups"); toolbar.setTitle(""); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false); }
Example #14
Source File: MxUtils.java From MxVideoPlayer with Apache License 2.0 | 5 votes |
static AppCompatActivity getAppComptActivity(Context context) { if (context == null) { return null; } if (context instanceof AppCompatActivity) { return (AppCompatActivity) context; } else if (context instanceof ContextThemeWrapper) { return getAppComptActivity(((ContextThemeWrapper)context).getBaseContext()); } return null; }
Example #15
Source File: CustomerHandler.java From mobikul-standalone-pos with MIT License | 5 votes |
public void openAddCustomerFragment(Customer customer) { FragmentManager fragmentManager = ((AppCompatActivity) context).getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left); Fragment fragment; fragment = fragmentManager.findFragmentByTag(AddCustomerFragment.class.getSimpleName()); if (fragment == null) fragment = new AddCustomerFragment(); Bundle bundle = new Bundle(); bundle.putSerializable("customer", customer); // bundle.putBoolean("edit", false); fragment.setArguments(bundle); fragmentTransaction.add(((CustomerActivity) context).binding.customerFl.getId(), fragment, fragment.getClass().getSimpleName()); fragmentTransaction.addToBackStack(fragment.getClass().getSimpleName()).commit(); }
Example #16
Source File: AppRateController.java From IslamicLibraryAndroid with GNU General Public License v3.0 | 5 votes |
public void showChangeLogDialog(AppCompatActivity activity) { if (!activity.isFinishing()) { DialogFragment donationReminderDialogFragment = new ChangeLogDialogFragment(); donationReminderDialogFragment.show(activity.getSupportFragmentManager(), "donationReminderDialogFragment"); PreferenceHelper.updateLastViewdChangeLog(activity); } }
Example #17
Source File: ColorChooserDialog.java From APlayer with GNU General Public License v3.0 | 5 votes |
@NonNull public ColorChooserDialog show(AppCompatActivity context) { String tag; Builder builder = getBuilder(); if (builder.mColorsTop != null) { tag = TAG_CUSTOM; } else if (builder.mAccentMode) { tag = TAG_ACCENT; } else { tag = TAG_PRIMARY; } dismissIfNecessary(context, tag); show(context.getSupportFragmentManager(), tag); return this; }
Example #18
Source File: BaseDialog.java From dapp-wallet-demo with Apache License 2.0 | 5 votes |
public void show(AppCompatActivity activity){ activity .getSupportFragmentManager() .beginTransaction() .add(this,this.getTag()) .commitAllowingStateLoss(); }
Example #19
Source File: SystemBarMetrics.java From ShaderEditor with MIT License | 5 votes |
public static void initSystemBars(AppCompatActivity activity, Rect insets) { View mainLayout; if (activity != null && (mainLayout = activity.findViewById(R.id.main_layout)) != null && setSystemBarColor( activity.getWindow(), ShaderEditorApp.preferences.getSystemBarColor(), true)) { setWindowInsets(mainLayout, insets); } }
Example #20
Source File: AppListFragment.java From AppPlus with MIT License | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(initLayout(), container, false); Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar); ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar); toolbar.setTitle(R.string.app_name_inner); toolbar.setSubtitle(getTitleString(mType)); final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar(); ab.setHomeAsUpIndicator(R.drawable.ic_menu_white_24dp); ab.setDisplayHomeAsUpEnabled(true); setupSwipeLayout(rootView); setupRecyclerView(rootView); return rootView; }
Example #21
Source File: BaseFragment.java From AndroidMaterialDesign with Apache License 2.0 | 5 votes |
protected void showTitleBack(View view, String title) { Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar); if (toolbar != null) { //toolbar.setNavigationIcon(R.mipmap.ic_back_white); //or //change gray icon to white Drawable icon = getResources().getDrawable(R.mipmap.ic_back_gray); Drawable drawable = getTintedDrawable(icon, 0xffffffff); toolbar.setNavigationIcon(drawable); if (title != null) { toolbar.setTitle(title); } AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true); } }
Example #22
Source File: JZVideoPlayer.java From JZVideoDemo with MIT License | 5 votes |
public void init(Context context) { View.inflate(context, getLayoutId(), this); startButton = findViewById(R.id.start); fullscreenButton = findViewById(R.id.fullscreen); currentTimeTextView = findViewById(R.id.current); totalTimeTextView = findViewById(R.id.total); progressBar = findViewById(R.id.bottom_seek_progress); bottomContainer = findViewById(R.id.layout_bottom); textureViewContainer = findViewById(R.id.surface_container); topContainer = findViewById(R.id.layout_top); startButton.setOnClickListener(this); fullscreenButton.setOnClickListener(this); progressBar.setOnSeekBarChangeListener(this); bottomContainer.setOnClickListener(this); textureViewContainer.setOnClickListener(this); textureViewContainer.setOnTouchListener(this); mScreenWidth = getContext().getResources().getDisplayMetrics().widthPixels; mScreenHeight = getContext().getResources().getDisplayMetrics().heightPixels; mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); try { if (isCurrentPlay()) { NORMAL_ORIENTATION = ((AppCompatActivity) context).getRequestedOrientation(); } } catch (Exception e) { e.printStackTrace(); } }
Example #23
Source File: CatalogModule.java From CourseraDemoApp with Apache License 2.0 | 4 votes |
public CatalogModule(AppCompatActivity activity) { this.activity = activity; }
Example #24
Source File: ContactsCoverFragment.java From talk-android with MIT License | 4 votes |
private void setupToolbar() { toolbar.setBackgroundColor(0x00ffffff); toolbar.setNavigationIcon(R.drawable.ic_action_close_contact); toolbar.setTitleTextColor(0xde0f3666); toolbar.setTitle(R.string.local_contacts); ((AppCompatActivity)getActivity()).setSupportActionBar(toolbar); ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayShowHomeEnabled(true); }
Example #25
Source File: EntityHeaderController.java From MiPushFramework with GNU General Public License v3.0 | 4 votes |
private EntityHeaderController(AppCompatActivity activity, Fragment fragment, View header) { mAppContext = activity.getApplicationContext(); mFragment = fragment; if (header != null) { mHeader = header; } else { mHeader = LayoutInflater.from(fragment.getContext()) .inflate(R.layout.settings_entity_header, null /* root */); } }
Example #26
Source File: TrackProperties.java From Androzic with GNU General Public License v3.0 | 4 votes |
@Override public void onResume() { super.onResume(); ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.trackproperties_name); }
Example #27
Source File: WaypointProperties.java From Androzic with GNU General Public License v3.0 | 4 votes |
@Override public void onResume() { super.onResume(); ((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.waypointproperties_name); //tooltipCallback.postDelayed(showTooltip, TooltipManager.TOOLTIP_DELAY_SHORT); }
Example #28
Source File: NavigationDrawerFragment.java From NightWatch with GNU General Public License v3.0 | 4 votes |
private android.support.v7.app.ActionBar getActionBar() { return ((AppCompatActivity) getActivity()).getSupportActionBar(); }
Example #29
Source File: GoogleRecaptchaVerifyActivityModule.java From v9porn with MIT License | 4 votes |
@Provides AppCompatActivity provideAppCompatActivity(GoogleRecaptchaVerifyActivity googleRecaptchaVerifyActivity) { return googleRecaptchaVerifyActivity; }
Example #30
Source File: EditTextDialog.java From Cornowser with MIT License | 4 votes |
public EditTextDialog(Context context, AppCompatActivity activity, String title, String defaultText) { this(context, activity, title, defaultText, ""); }