Search in sources :

Example 91 with NonNull

use of androidx.annotation.NonNull in project Douya by DreaminginCodeZH.

the class ArrayAdapterCompat method createViewFromResource.

/*
     * @see ArrayAdapter#createViewFromResource(LayoutInflater, int, View, ViewGroup, int)
     */
@NonNull
private View createViewFromResource(@NonNull LayoutInflater inflater, int position, @Nullable View convertView, @NonNull ViewGroup parent, int resource) {
    final View view;
    final TextView text;
    if (convertView == null) {
        view = inflater.inflate(resource, parent, false);
    } else {
        view = convertView;
    }
    try {
        if (mFieldId == 0) {
            // If no custom field is assigned, assume the whole resource is a TextView
            text = (TextView) view;
        } else {
            // Otherwise, find the TextView field within the layout
            text = view.findViewById(mFieldId);
            if (text == null) {
                throw new RuntimeException("Failed to find view with ID " + getContext().getResources().getResourceName(mFieldId) + " in item layout");
            }
        }
    } catch (ClassCastException e) {
        Log.e("ArrayAdapter", "You must supply a resource ID for a TextView");
        throw new IllegalStateException("ArrayAdapter requires the resource ID to be a TextView", e);
    }
    final T item = getItem(position);
    if (item instanceof CharSequence) {
        text.setText((CharSequence) item);
    } else {
        text.setText(item.toString());
    }
    return view;
}
Also used : TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View) NonNull(androidx.annotation.NonNull)

Example 92 with NonNull

use of androidx.annotation.NonNull in project RSAndroidApp by RailwayStations.

the class InboxAdapter method getView.

@Override
@NonNull
public View getView(final int position, final View convertView, @NonNull final ViewGroup parent) {
    var rowView = convertView;
    // reuse views
    final ItemInboxBinding binding;
    if (rowView == null) {
        binding = ItemInboxBinding.inflate(context.getLayoutInflater(), parent, false);
        rowView = binding.getRoot();
        rowView.setTag(binding);
    } else {
        binding = (ItemInboxBinding) rowView.getTag();
    }
    // fill data
    final var item = publicInboxes.get(position);
    binding.txtStationName.setText(item.getTitle());
    if (item.getStationId() != null) {
        binding.txtStationId.setText(item.getCountryCode().concat(":").concat(item.getStationId()));
    } else {
        binding.txtStationId.setText(R.string.missing_station);
    }
    binding.txtCoordinates.setText(String.valueOf(item.getLat()).concat(",").concat(String.valueOf(item.getLon())));
    return rowView;
}
Also used : ItemInboxBinding(de.bahnhoefe.deutschlands.bahnhofsfotos.databinding.ItemInboxBinding) NonNull(androidx.annotation.NonNull)

Example 93 with NonNull

use of androidx.annotation.NonNull in project RSAndroidApp by RailwayStations.

the class HighScoreAdapter method getView.

@Override
@NonNull
public View getView(final int position, final View convertView, @NonNull final ViewGroup parent) {
    var rowView = convertView;
    // reuse views
    final ItemHighscoreBinding binding;
    if (rowView == null) {
        binding = ItemHighscoreBinding.inflate(context.getLayoutInflater(), parent, false);
        rowView = binding.getRoot();
        rowView.setTag(binding);
    } else {
        binding = (ItemHighscoreBinding) rowView.getTag();
    }
    final var item = highScore.get(position);
    binding.highscoreName.setText(item.getName());
    binding.highscorePhotos.setText(String.valueOf(item.getPhotos()));
    binding.highscorePosition.setText(String.valueOf(item.getPosition()).concat("."));
    switch(item.getPosition()) {
        case 1:
            binding.highscoreAward.setImageResource(R.drawable.ic_crown_gold);
            binding.highscoreAward.setVisibility(View.VISIBLE);
            binding.highscorePosition.setVisibility(View.GONE);
            break;
        case 2:
            binding.highscoreAward.setImageResource(R.drawable.ic_crown_silver);
            binding.highscoreAward.setVisibility(View.VISIBLE);
            binding.highscorePosition.setVisibility(View.GONE);
            break;
        case 3:
            binding.highscoreAward.setImageResource(R.drawable.ic_crown_bronze);
            binding.highscoreAward.setVisibility(View.VISIBLE);
            binding.highscorePosition.setVisibility(View.GONE);
            break;
        default:
            binding.highscoreAward.setVisibility(View.GONE);
            binding.highscorePosition.setVisibility(View.VISIBLE);
            break;
    }
    if (position % 2 == 1) {
        rowView.setBackgroundResource(R.drawable.item_list_backgroundcolor);
    } else {
        rowView.setBackgroundResource(R.drawable.item_list_backgroundcolor2);
    }
    return rowView;
}
Also used : ItemHighscoreBinding(de.bahnhoefe.deutschlands.bahnhofsfotos.databinding.ItemHighscoreBinding) NonNull(androidx.annotation.NonNull)

Example 94 with NonNull

use of androidx.annotation.NonNull in project RSAndroidApp by RailwayStations.

the class NearbyBahnhofNotificationManager method getStationPendingIntent.

/**
 * Build an intent for an action to view a map.
 *
 * @return the PendingIntent built.
 */
@NonNull
protected PendingIntent getStationPendingIntent() {
    // Build an intent for an action to see station details
    final var stationIntent = new Intent().setClassName(DB_BAHNHOF_LIVE_PKG, DB_BAHNHOF_LIVE_CLASS);
    stationIntent.putExtra(DetailsActivity.EXTRA_STATION, notificationStation);
    return pendifyMe(stationIntent, REQUEST_STATION);
}
Also used : Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) NonNull(androidx.annotation.NonNull)

Example 95 with NonNull

use of androidx.annotation.NonNull in project Paper by pilgr.

the class MultiThreadTest method startWritingLargeDataSetInSeparateThread.

@NonNull
private CountDownLatch startWritingLargeDataSetInSeparateThread(@SuppressWarnings("SameParameterValue") final String key) throws InterruptedException {
    final CountDownLatch writeStartLatch = new CountDownLatch(1);
    final CountDownLatch writeFinishLatch = new CountDownLatch(1);
    new Thread() {

        final List<Person> dataset = TestDataGenerator.genPersonList(10000);

        @Override
        public void run() {
            Log.d(TAG, "write '" + key + "': start");
            writeStartLatch.countDown();
            Paper.book().write(key, dataset);
            Log.d(TAG, "write '" + key + "': finish");
            writeFinishLatch.countDown();
        }
    }.start();
    writeStartLatch.await(5, TimeUnit.SECONDS);
    // A small delay is required to let writer thread start writing data and acquire a lock
    Thread.sleep(100);
    return writeFinishLatch;
}
Also used : CountDownLatch(java.util.concurrent.CountDownLatch) Person(io.paperdb.testdata.Person) 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