Search in sources :

Example 1 with CommonsApplication

use of fr.free.nrw.commons.CommonsApplication in project apps-android-commons by commons-app.

the class ContributionsActivity method setUploadCount.

private void setUploadCount() {
    UploadCountClient uploadCountClient = new UploadCountClient();
    CommonsApplication application = CommonsApplication.getInstance();
    ListenableFuture<Integer> future = uploadCountClient.getUploadCount(application.getCurrentAccount().name);
    Futures.addCallback(future, new FutureCallback<Integer>() {

        @Override
        public void onSuccess(Integer uploadCount) {
            getSupportActionBar().setSubtitle(getResources().getQuantityString(R.plurals.contributions_subtitle, uploadCount, uploadCount));
        }

        @Override
        public void onFailure(@NonNull Throwable t) {
            Timber.e(t, "Fetching upload count failed");
        }
    }, ExecutorUtils.uiExecutor());
}
Also used : CommonsApplication(fr.free.nrw.commons.CommonsApplication)

Example 2 with CommonsApplication

use of fr.free.nrw.commons.CommonsApplication in project apps-android-commons by commons-app.

the class MoreBottomSheetFragment method onLogoutClicked.

@OnClick(R.id.more_logout)
public void onLogoutClicked() {
    new AlertDialog.Builder(getActivity()).setMessage(R.string.logout_verification).setCancelable(false).setPositiveButton(R.string.yes, (dialog, which) -> {
        BaseLogoutListener logoutListener = new BaseLogoutListener();
        CommonsApplication app = (CommonsApplication) getContext().getApplicationContext();
        app.clearApplicationData(getContext(), logoutListener);
    }).setNegativeButton(R.string.no, (dialog, which) -> dialog.cancel()).show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) Context(android.content.Context) Bundle(android.os.Bundle) AlertDialog(androidx.appcompat.app.AlertDialog) ButterKnife(butterknife.ButterKnife) NonNull(androidx.annotation.NonNull) SettingsActivity(fr.free.nrw.commons.settings.SettingsActivity) Uri(android.net.Uri) R(fr.free.nrw.commons.R) Intent(android.content.Intent) WelcomeActivity(fr.free.nrw.commons.WelcomeActivity) OnClick(butterknife.OnClick) BindView(butterknife.BindView) CommonsApplication(fr.free.nrw.commons.CommonsApplication) Inject(javax.inject.Inject) LoginActivity(fr.free.nrw.commons.auth.LoginActivity) Toast(android.widget.Toast) View(android.view.View) Named(javax.inject.Named) JsonKvStore(fr.free.nrw.commons.kvstore.JsonKvStore) AccountManager(android.accounts.AccountManager) ReviewActivity(fr.free.nrw.commons.review.ReviewActivity) Account(android.accounts.Account) LayoutInflater(android.view.LayoutInflater) ApplicationlessInjection(fr.free.nrw.commons.di.ApplicationlessInjection) AboutActivity(fr.free.nrw.commons.AboutActivity) CommonsLogSender(fr.free.nrw.commons.logging.CommonsLogSender) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) ActivityNotFoundException(android.content.ActivityNotFoundException) BuildConfig(fr.free.nrw.commons.BuildConfig) ProfileActivity(fr.free.nrw.commons.profile.ProfileActivity) CommonsApplication(fr.free.nrw.commons.CommonsApplication) OnClick(butterknife.OnClick)

Aggregations

CommonsApplication (fr.free.nrw.commons.CommonsApplication)2 Account (android.accounts.Account)1 AccountManager (android.accounts.AccountManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Context (android.content.Context)1 Intent (android.content.Intent)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 TextView (android.widget.TextView)1 Toast (android.widget.Toast)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 AlertDialog (androidx.appcompat.app.AlertDialog)1 BindView (butterknife.BindView)1 ButterKnife (butterknife.ButterKnife)1 OnClick (butterknife.OnClick)1 BottomSheetDialogFragment (com.google.android.material.bottomsheet.BottomSheetDialogFragment)1