@SuppressWarnings("ConstantConditions") @Override public void onCreate(Bundle savedInstanceState) { SharedPreferences themePrefs = getActivity().getSharedPreferences("THEME", 0); if (themePrefs.getBoolean("isDark", false)) getActivity().setTheme(R.style.PrefsThemeDark); else getActivity().setTheme(R.style.PrefsTheme); super.onCreate(savedInstanceState); getActivity().getSupportFragmentManager().beginTransaction() .replace(android.R.id.content, new PrefsFrag()) .commit(); }
public void onBackPressed(){ mScanReceiver.unregister(); mConnectionReceiver.unregister(); Bundle bundle = new Bundle(); bundle.putBoolean(CONNECTED, mConnected); Intent intent = new Intent(); intent.putExtras(bundle); getActivity().setResult(AppCompatActivity.RESULT_OK, intent); getActivity().finish(); getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein); }
private void onInitializationError(final String message) { getActivity().runOnUiThread(new Runnable() { @Override public void run() { new FatalDialog(getString(R.string.initialization_error), message, message.contains(">"), getActivity()).show(); } }); }
public void onBackPressed() { getActivity().finish(); getActivity().overridePendingTransition(R.anim.fadeout, R.anim.fadein); } }
private void requestChangeBatteryOptimizations () { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { Intent intent = new Intent(); String packageName = getActivity().getPackageName(); PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE); if (pm.isIgnoringBatteryOptimizations(packageName)) intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS); else { intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); intent.setData(Uri.parse("package:" + packageName)); } getActivity().startActivity(intent); } }
private void startFragment(Fragment fragment) { Robolectric.setupActivity(FragmentActivity.class).getSupportFragmentManager() .beginTransaction() .add(fragment, null) .commit(); }
getActivity().finish(); return rootView; ((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle(parts.get(parts.size() - 1)); } else { getActivity().setTitle(parts.get(parts.size() - 1)); ((AppCompatActivity) getActivity()).getSupportActionBar().setSubtitle(R.string.stats_deck_collection); } else { getActivity().setTitle(R.string.stats_deck_collection);
@Override public void onConfigurationChanged(final Configuration newConfig) { super.onConfigurationChanged(newConfig); ViewGroup viewGroup = (ViewGroup) getView(); if (viewGroup != null) { viewGroup.removeAllViewsInLayout(); View view = onCreateView(requireActivity().getLayoutInflater(), viewGroup, null); viewGroup.addView(view); } }
private boolean initSystem() { // retry try { System.init(getActivity().getApplicationContext()); } catch (Exception e) { boolean isFatal = !(e instanceof NoRouteToHostException); if (isFatal) { System.errorLogging(e); onInitializationError(System.getLastError()); } return !isFatal; } registerPlugins(); return true; }
public void onClick(DialogInterface dialog, int id){ activity.finish(); } });
private void openReviewer() { Intent reviewer = new Intent(getActivity(), Reviewer.class); if (mFragmented) { getActivity().startActivityForResult(reviewer, AnkiActivity.REQUEST_REVIEW); } else { // Go to DeckPicker after studying when not tablet reviewer.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT); startActivity(reviewer); getActivity().finish(); } animateLeft(); getCol().startTimebox(); }
@Override @CallSuper protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); lifecycleSubject.onNext(ActivityEvent.CREATE); }
CameraView cameraView = getActivity().findViewById(R.id.camera_view);
@Override public void onPreExecute() { ((AnkiActivity) getActivity()).showProgressBar(); final InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(getView().getWindowToken(), 0); }
@Override public MaterialDialog onCreateDialog(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Resources res = getActivity().getResources(); String title = getArguments().getString("title"); return new MaterialDialog.Builder(getActivity()) .title(title.equals("") ? res.getString(R.string.app_name) : title) .content(getArguments().getString("message")) .positiveText(res.getString(R.string.dialog_ok)) .negativeText(res.getString(R.string.dialog_cancel)) .onPositive((dialog, which) -> mConfirm.run()) .onNegative((dialog, which) -> mCancel.run()) .show(); } }
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.target_list_item, parent, false); holder.itemTitle.setText(target.toString()); holder.itemTitle.setTextColor(ContextCompat.getColor(getActivity().getApplicationContext(), (target.isConnected() ? R.color.app_color : R.color.gray_text)));
@Override public void onViewCreated(View v, Bundle savedInstanceState) { SharedPreferences themePrefs = getActivity().getSharedPreferences("THEME", 0); Boolean isDark = themePrefs.getBoolean("isDark", false); if (isDark) { getActivity().setTheme(R.style.DarkTheme); v.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.background_window_dark)); getActivity().setTheme(R.style.AppTheme); v.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.background_window)); getActivity().setTitle("cSploit > " + mTarget); ((AppCompatActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true); theList = (ListView) getActivity().findViewById(R.id.android_list); mAvailable = System.getPluginsForTarget(); ActionsAdapter mActionsAdapter = new ActionsAdapter();
Resources res = getActivity().getResources(); View v = getActivity().getLayoutInflater().inflate(R.layout.styled_custom_study_details_dialog, null); TextView textView1 = (TextView) v.findViewById(R.id.custom_study_details_text1); TextView textView2 = (TextView) v.findViewById(R.id.custom_study_details_text2);
@Override public void onSuccess(String authorizeUrl) { if(getActivity() == null || state == State.CANCELLED) return; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(authorizeUrl)); intent.putExtra(Browser.EXTRA_APPLICATION_ID, getActivity().getPackageName()); intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); state = State.AUTHENTICATING_IN_BROWSER; }