Search in sources :

Example 96 with NonNull

use of androidx.annotation.NonNull in project Weather by Sparker0i.

the class WeatherFragment method showNoInternet.

public void showNoInternet() {
    new MaterialDialog.Builder(context()).title(getString(R.string.no_internet_title)).cancelable(false).content(getString(R.string.no_internet_content)).positiveText(getString(R.string.no_internet_mobile_data)).onPositive(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            Intent intent = new Intent();
            intent.setComponent(new ComponentName("com.android.settings", "com.android.settings.Settings$DataUsageSummaryActivity"));
            startActivityForResult(intent, 0);
        }
    }).negativeText(getString(R.string.no_internet_wifi)).onNegative(new MaterialDialog.SingleButtonCallback() {

        @Override
        public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
            startActivityForResult(new Intent(Settings.ACTION_WIFI_SETTINGS), 0);
        }
    }).show();
}
Also used : MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) ComponentName(android.content.ComponentName)

Example 97 with NonNull

use of androidx.annotation.NonNull in project Weather by Sparker0i.

the class WeatherActivity method checkForCity.

private void checkForCity(final String city) {
    final FetchWeather wt = new FetchWeather(this);
    final Context context = this;
    new Thread() {

        @Override
        public void run() {
            try {
                json = wt.execute(city).get();
            } catch (InterruptedException | ExecutionException ex) {
                ex.printStackTrace();
            }
            if (json == null) {
                handler.post(new Runnable() {

                    @Override
                    public void run() {
                        new MaterialDialog.Builder(context).title(getString(R.string.city_not_found)).content(getString(R.string.city_not_found)).onAny(new MaterialDialog.SingleButtonCallback() {

                            @Override
                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                dialog.dismiss();
                            }
                        }).negativeText(getString(android.R.string.ok)).onNegative(new MaterialDialog.SingleButtonCallback() {

                            @Override
                            public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                dialog.dismiss();
                            }
                        });
                    }
                });
            } else {
                if (dbHelper.cityExists(json.day.getName() + "," + json.day.getSys().getCountry())) {
                    handler.post(new Runnable() {

                        @Override
                        public void run() {
                            new MaterialDialog.Builder(context).title(getString(R.string.city_already_exists)).content(getString(R.string.need_not_add)).negativeText(getString(android.R.string.ok)).onNegative(new MaterialDialog.SingleButtonCallback() {

                                @Override
                                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
                                    dialog.dismiss();
                                }
                            }).show();
                        }
                    });
                } else {
                    dbHelper.addCity(json.day.getName() + "," + json.day.getSys().getCountry());
                    handler.post(new Runnable() {

                        @Override
                        public void run() {
                            SecondaryDrawerItem itemx = new SecondaryDrawerItem().withName(json.day.getName() + "," + json.day.getSys().getCountry()).withIcon(new IconicsDrawable(context).icon(GoogleMaterial.Icon.gmd_place)).withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() {

                                @Override
                                public boolean onItemClick(View view, int position, IDrawerItem drawerItem) {
                                    if (!(f instanceof WeatherFragment)) {
                                        wf = new WeatherFragment().setCity(json.day.getName() + "," + json.day.getSys().getCountry());
                                        getSupportFragmentManager().beginTransaction().replace(R.id.fragment, wf).commit();
                                    }
                                    return true;
                                }
                            });
                            drawer.addItemAtPosition(itemx, ++i);
                        }
                    });
                }
            }
        }
    }.start();
}
Also used : Context(android.content.Context) IDrawerItem(com.mikepenz.materialdrawer.model.interfaces.IDrawerItem) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) WeatherFragment(com.a5corp.weather.fragment.WeatherFragment) Drawer(com.mikepenz.materialdrawer.Drawer) SecondaryDrawerItem(com.mikepenz.materialdrawer.model.SecondaryDrawerItem) View(android.view.View) FetchWeather(com.a5corp.weather.internet.FetchWeather) DialogAction(com.afollestad.materialdialogs.DialogAction) NonNull(androidx.annotation.NonNull) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 98 with NonNull

use of androidx.annotation.NonNull in project Weather by Sparker0i.

the class MyAdapter method onCreateViewHolder.

// Create new views (invoked by the layout manager)
@NonNull
@Override
public MyAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    // create a new view
    TextView v = (TextView) LayoutInflater.from(parent.getContext()).inflate(R.layout.about_card, parent, false);
    ViewHolder vh = new ViewHolder(v);
    return vh;
}
Also used : TextView(android.widget.TextView) NonNull(androidx.annotation.NonNull)

Example 99 with NonNull

use of androidx.annotation.NonNull in project Conversations by siacs.

the class ShortcutService method createShortcut.

@NonNull
public Intent createShortcut(Contact contact, boolean legacy) {
    Intent intent;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !legacy) {
        ShortcutInfo shortcut = getShortcutInfo(contact);
        ShortcutManager shortcutManager = xmppConnectionService.getSystemService(ShortcutManager.class);
        intent = shortcutManager.createShortcutResultIntent(shortcut);
    } else {
        intent = createShortcutResultIntent(contact);
    }
    return intent;
}
Also used : ShortcutInfo(android.content.pm.ShortcutInfo) ShortcutManager(android.content.pm.ShortcutManager) Intent(android.content.Intent) NonNull(androidx.annotation.NonNull)

Example 100 with NonNull

use of androidx.annotation.NonNull in project Conversations by siacs.

the class CountryAdapter method onCreateViewHolder.

@NonNull
@Override
public CountryViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    LayoutInflater layoutInflater = LayoutInflater.from(parent.getContext());
    CountryItemBinding binding = DataBindingUtil.inflate(layoutInflater, R.layout.country_item, parent, false);
    return new CountryViewHolder(binding);
}
Also used : CountryItemBinding(eu.siacs.conversations.databinding.CountryItemBinding) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull)

Aggregations

NonNull (androidx.annotation.NonNull)1197 View (android.view.View)191 ArrayList (java.util.ArrayList)154 Context (android.content.Context)128 Nullable (androidx.annotation.Nullable)128 TextView (android.widget.TextView)117 Intent (android.content.Intent)115 List (java.util.List)110 Recipient (org.thoughtcrime.securesms.recipients.Recipient)109 IOException (java.io.IOException)103 Bundle (android.os.Bundle)102 WorkerThread (androidx.annotation.WorkerThread)94 LayoutInflater (android.view.LayoutInflater)89 RecipientId (org.thoughtcrime.securesms.recipients.RecipientId)82 AlertDialog (androidx.appcompat.app.AlertDialog)76 Log (org.signal.core.util.logging.Log)76 Cursor (android.database.Cursor)68 ViewGroup (android.view.ViewGroup)65 LinkedList (java.util.LinkedList)64 Stream (com.annimon.stream.Stream)62