use of androidx.appcompat.app.AppCompatActivity in project apps-android-commons by commons-app.
the class MediaDetailPagerFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_media_detail_pager, container, false);
ButterKnife.bind(this, view);
pager.addOnPageChangeListener(this);
adapter = new MediaDetailAdapter(getChildFragmentManager());
((BaseActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (getActivity() != null) {
final ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
pager.setAdapter(adapter);
if (savedInstanceState != null) {
final int pageNumber = savedInstanceState.getInt("current-page");
pager.setCurrentItem(pageNumber, false);
getActivity().invalidateOptionsMenu();
}
adapter.notifyDataSetChanged();
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).hideTabs();
}
return view;
}
use of androidx.appcompat.app.AppCompatActivity in project MiMangaNu by raulhaag.
the class AppUpdateUtil method generateUpdateDialog.
@SuppressLint("StaticFieldLeak")
public static void generateUpdateDialog(final Context context) {
if (NetworkUtilsAndReceiver.isConnectedNonDestructive(context))
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
try {
final Triple<String, String, String> info = getCurrentVersion();
((AppCompatActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rootView = inflater.inflate(R.layout.dialog_update, null);
final TextView desc = rootView.findViewById(R.id.descrption);
final ProgressBar progressBar = rootView.findViewById(R.id.progress);
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
desc.setText(info.getThird());
dialogBuilder.setTitle(context.getString(R.string.new_version) + " " + info.getFirst());
dialogBuilder.setView(rootView);
dialogBuilder.setPositiveButton(context.getString(R.string.download), null);
dialogBuilder.setNegativeButton(context.getString(R.string.close), null);
AlertDialog dialog = dialogBuilder.create();
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {
final Button cancel = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
if (context instanceof MessageActivity) {
((MessageActivity) context).onBackPressed();
}
}
});
final Button accept = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
accept.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
AppCompatActivity activity = (AppCompatActivity) context;
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
((AlertDialog) dialog).setCancelable(false);
String init_download_text = context.getString(R.string.downloading) + " 0%";
desc.setText(init_download_text);
accept.setEnabled(false);
cancel.setEnabled(false);
progressBar.setVisibility(View.VISIBLE);
progressBar.setIndeterminate(true);
}
});
download(activity, info.getSecond(), progressBar, desc, dialog);
} catch (Exception e) {
Log.e(TAG, "Error while starting download");
e.printStackTrace();
}
}
});
}
});
dialog.show();
}
});
} catch (Exception e) {
Log.e(TAG, "Error while searching for new update");
e.printStackTrace();
}
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
use of androidx.appcompat.app.AppCompatActivity in project Signal-Android by WhisperSystems.
the class BaseKbsPinFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
initializeViews(view);
viewModel = initializeViewModel();
viewModel.getUserEntry().observe(getViewLifecycleOwner(), kbsPin -> {
boolean isEntryValid = kbsPin.length() >= KbsConstants.MINIMUM_PIN_LENGTH;
confirm.setEnabled(isEntryValid);
confirm.setAlpha(isEntryValid ? 1f : 0.5f);
});
viewModel.getKeyboard().observe(getViewLifecycleOwner(), keyboardType -> {
updateKeyboard(keyboardType);
keyboardToggle.setText(resolveKeyboardToggleText(keyboardType));
});
description.setOnLinkClickListener(v -> {
CommunicationActions.openBrowserLink(requireContext(), getString(R.string.BaseKbsPinFragment__learn_more_url));
});
Toolbar toolbar = view.findViewById(R.id.kbs_pin_toolbar);
((AppCompatActivity) requireActivity()).setSupportActionBar(toolbar);
((AppCompatActivity) requireActivity()).getSupportActionBar().setTitle(null);
initializeListeners();
}
use of androidx.appcompat.app.AppCompatActivity in project xabber-android by redsolution.
the class ContextMenuHelper method setContactContextMenuActions.
private static void setContactContextMenuActions(final Activity activity, final ContactListPresenter presenter, ContextMenu menu, final AccountJid account, final UserJid user) {
menu.findItem(R.id.action_edit_conference).setIntent(ConferenceAddActivity.createIntent(activity, account, user.getBareUserJid()));
menu.findItem(R.id.action_delete_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "MUC_DELETE");
return true;
}
});
menu.findItem(R.id.action_join_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCManager.getInstance().joinRoom(account, user.getJid().asEntityBareJidIfPossible(), true);
return true;
}
});
menu.findItem(R.id.action_leave_conference).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCManager.getInstance().leaveRoom(account, user.getJid().asEntityBareJidIfPossible());
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance().removeMessageNotification(account, user);
presenter.updateContactList();
return true;
}
});
menu.findItem(R.id.action_edit_contact_groups).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
activity.startActivity(GroupEditActivity.createIntent(activity, account, user));
return true;
}
});
menu.findItem(R.id.action_delete_contact).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
ContactDeleteDialogFragment.newInstance(account, user).show(activity.getFragmentManager(), "CONTACT_DELETE");
return true;
}
});
menu.findItem(R.id.action_block_contact).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
BlockContactDialog.newInstance(account, user).show(activity.getFragmentManager(), BlockContactDialog.class.getName());
return true;
}
});
menu.findItem(R.id.action_accept_subscription).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
PresenceManager.getInstance().acceptSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
activity.startActivity(GroupEditActivity.createIntent(activity, account, user));
return true;
}
});
menu.findItem(R.id.action_discard_subscription).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
PresenceManager.getInstance().discardSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
return true;
}
});
menu.findItem(R.id.action_mute_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
showSnoozeDialog((AppCompatActivity) activity, chat, presenter);
return true;
}
});
menu.findItem(R.id.action_unmute_chat).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat != null)
chat.setNotificationStateOrDefault(new NotificationState(NotificationState.NotificationMode.enabled, 0), true);
presenter.updateContactList();
return true;
}
});
menu.findItem(R.id.action_configure_notifications).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
activity.startActivity(CustomNotifySettings.createIntent(activity, account, user));
return true;
}
});
}
use of androidx.appcompat.app.AppCompatActivity in project Signal-Android by WhisperSystems.
the class MediaOverviewPageFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
voiceNoteMediaController = new VoiceNoteMediaController((AppCompatActivity) requireActivity());
}
Aggregations