Java Code Examples for android.support.annotation.Nullable

The following are top voted examples for showing how to use android.support.annotation.Nullable. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: q-mail   File: TextPartFinder.java   View source code 6 votes vote down vote up
@Nullable
public Part findFirstTextPart(@NonNull Part part) {
    String mimeType = part.getMimeType();
    Body body = part.getBody();

    if (body instanceof Multipart) {
        Multipart multipart = (Multipart) body;
        if (isSameMimeType(mimeType, "multipart/alternative")) {
            return findTextPartInMultipartAlternative(multipart);
        } else {
            return findTextPartInMultipart(multipart);
        }
    } else if (isSameMimeType(mimeType, "text/plain") || isSameMimeType(mimeType, "text/html")) {
        return part;
    }

    return null;
}
 
Example 2
Project: DateTimePicker   File: CalendarView.java   View source code 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public CalendarView(@NonNull Context context, @Nullable AttributeSet attrs,
                    @AttrRes int defStyleAttr, @StyleRes int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    attrHandler(context, attrs, defStyleAttr, defStyleRes);
    /*final TypedArray a = context.obtainStyledAttributes(
            attrs, R.styleable.CalendarView, defStyleAttr, defStyleRes);
    final int mode = a.getInt(R.styleable.CalendarView_calendarViewMode, MODE_HOLO);
    a.recycle();

    switch (mode) {
        case MODE_HOLO:
            mDelegate = new CalendarViewLegacyDelegate(
                    this, context, attrs, defStyleAttr, defStyleRes);
            break;
        case MODE_MATERIAL:
            mDelegate = new CalendarViewMaterialDelegate(
                    this, context, attrs, defStyleAttr, defStyleRes);
            break;
        default:
            throw new IllegalArgumentException("invalid calendarViewMode attribute");
    }*/
}
 
Example 3
Project: android_additive_animations   File: RepeatingChainedAnimationsDemoFragment.java   View source code 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    rootView = (ViewGroup) inflater.inflate(R.layout.fragment_tap_to_move_demo, container, false);
    animatedView = rootView.findViewById(R.id.animated_view);

    rootView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if(event.getAction() == MotionEvent.ACTION_DOWN) {
                AdditiveAnimator.cancelAnimation(animatedView, View.ROTATION);
            }
            return true;
        }
    });

    animate();
    return rootView;
}
 
Example 4
Project: API-Example-App   File: FragmentDemoInteraction.java   View source code 6 votes vote down vote up
/**
 * Append results on the main thread.
 */
private void appendText(@Nullable final String words) {

    if (getActivity() != null) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                if (words != null) {
                    tvResults.append("\n" + words);
                } else {
                    tvResults.setText("");
                }
            }
        });
    }
}
 
Example 5
Project: ViewPagerZoomTransformer   File: WatchDetailInfoActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.watch_detail_info_layout);
    mPosition = getIntent().getIntExtra("position", 0);

    Toolbar toolbar = (Toolbar) findViewById(R.id.infoToolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    mTitleImage = (ImageView)findViewById(R.id.infoTitleImage);
    mIntroImage_1 = (ImageView)findViewById(R.id.imageIntro_1);
    mIntroImage_2 = (ImageView)findViewById(R.id.imageIntro_2);
    mIntroImage_3 = (ImageView)findViewById(R.id.imageIntro_3);

    setImagesRes(mTitleImage, mIntroImage_1, mIntroImage_2, mIntroImage_3);
}
 
Example 6
Project: MiniDownloader   File: Task.java   View source code 6 votes vote down vote up
private Task(
        @Nullable TaskUrl taskUrl,
        @Nullable String urlStr,
        @NonNull String filePath,
        @NonNull Listener listener,
        @NonNull ErrorListener errorListener,
        @NonNull Priority priority) {

    checkTask(taskUrl, urlStr, filePath, listener, errorListener, priority);

    this.taskUrl = taskUrl;
    this.urlStr = taskUrl != null ? taskUrl.toUrl() : urlStr;

    this.filePath = filePath;
    this.listener = listener;
    this.errorListener = errorListener;
    this.priority = priority;
}
 
Example 7
Project: android_nextgis_mobile   File: NGIDLoginFragment.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater,
        @Nullable
                ViewGroup container,
        @Nullable
                Bundle savedInstanceState)
{
    final View view = inflater.inflate(R.layout.fragment_ngid_login, container, false);
    mLogin = (EditText) view.findViewById(R.id.login);
    mPassword = (EditText) view.findViewById(R.id.password);
    mSignInButton = (Button) view.findViewById(R.id.signin);
    mSignInButton.setOnClickListener(this);
    TextView signUp = (TextView) view.findViewById(R.id.signup);
    signUp.setText(signUp.getText().toString().toUpperCase());
    signUp.setOnClickListener(this);
    return view;
}
 
Example 8
Project: ucar-weex-core   File: WXImageView.java   View source code 6 votes vote down vote up
public void setImageDrawable(@Nullable Drawable drawable, boolean isGif) {
  this.gif = isGif;
  ViewGroup.LayoutParams layoutParams;
  if ((layoutParams = getLayoutParams()) != null) {
    Drawable wrapDrawable = ImageDrawable.createImageDrawable(drawable,
                                                              getScaleType(), borderRadius,
                                                              layoutParams.width - getPaddingLeft() - getPaddingRight(),
                                                              layoutParams.height - getPaddingTop() - getPaddingBottom(),
                                                              isGif);
    if (wrapDrawable instanceof ImageDrawable) {
      ImageDrawable imageDrawable = (ImageDrawable) wrapDrawable;
      if (!Arrays.equals(imageDrawable.getCornerRadii(), borderRadius)) {
        imageDrawable.setCornerRadii(borderRadius);
      }
    }
    super.setImageDrawable(wrapDrawable);
    if (mWeakReference != null) {
      WXImage component = mWeakReference.get();
      if (component != null) {
        component.readyToRender();
      }
    }
  }
}
 
Example 9
Project: Android-2017   File: DetailActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.details_activity_layout);

    // buscamos si tenemos algun extra en esta activity
    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        String s = extras.getString(EXTRA_TITLE);
        TextView tvHeader = (TextView) findViewById(R.id.header);
        tvHeader.setText(s);
        s = extras.getString (EXTRA_CONTENT);
        TextView tvContent = (TextView) findViewById(R.id.content);
        tvContent.setText(s);
    }

}
 
Example 10
Project: Plamber-Android   File: LocalFileFragment.java   View source code 6 votes vote down vote up
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.local_file_fragment, container, false);
    ButterKnife.bind(this, v);
    if (listFile.isEmpty()) {
        loadFiles = new LoadFiles();
        loadFiles.execute(FilePickActivity.BOOK_FORMAT);
    } else {
        setAdapter();
    }
    setSwipe();
    mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
    return v;
}
 
Example 11
Project: memetastic   File: LanguagePreferenceCompat.java   View source code 5 votes vote down vote up
private void loadLangs(Context context, @Nullable AttributeSet attrs) {
    setDefaultValue(SYSTEM_LANGUAGE_CODE);

    // Fetch readable details
    ContextUtils contextUtils = new ContextUtils(context);
    List<String> languages = new ArrayList<>();
    Object bcof = contextUtils.getBuildConfigValue("APPLICATION_LANGUAGES");
    if (bcof instanceof String[]) {
        for (String langId : (String[]) bcof) {
            Locale locale = contextUtils.getLocaleByAndroidCode(langId);
            languages.add(summarizeLocale(locale) + ";" + langId);
        }
    }

    // Sort languages naturally
    Collections.sort(languages);

    // Show in UI
    String[] entries = new String[languages.size() + 2];
    String[] entryval = new String[languages.size() + 2];
    for (int i = 0; i < languages.size(); i++) {
        entries[i + 2] = languages.get(i).split(";")[0];
        entryval[i + 2] = languages.get(i).split(";")[1];
    }
    entryval[0] = SYSTEM_LANGUAGE_CODE;
    entries[0] = _systemLanguageName + "\n[" + summarizeLocale(context.getResources().getConfiguration().locale) + "]";
    entryval[1] = _defaultLanguageCode;
    entries[1] = summarizeLocale(contextUtils.getLocaleByAndroidCode(_defaultLanguageCode));

    setEntries(entries);
    setEntryValues(entryval);
}
 
Example 12
Project: mi-firma-android   File: NFCWatchdogRefresher.java   View source code 5 votes vote down vote up
@Nullable
private Tag getTag() {
    final IsoDep isoDep = mIsoDep.get();
    if (isoDep != null) {
        return isoDep.getTag();
    }
    return null;
}
 
Example 13
Project: BlackList   File: DatabaseAccessHelper.java   View source code 5 votes vote down vote up
/**
 * Creates 'LIKE part' of 'WHERE' clause
 */

@Nullable
static String getLikeClause(String column, String filter) {
    return (filter == null ? null :
            column + " LIKE '%" + filter + "%' ");
}
 
Example 14
Project: PureNews   File: BaseFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    mView = inflater.inflate(getLayoutId(), null);
    unbinder = ButterKnife.bind(this, mView);
    return mView;
}
 
Example 15
Project: OSchina_resources_android   File: SettingsFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater,
                         @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_settings, container,
            false);
    ButterKnife.bind(this, view);
    initView(view);
    initData();
    return view;
}
 
Example 16
Project: Phoenix-for-VK   File: DocPreviewFragment.java   View source code 5 votes vote down vote up
public static Bundle buildArgs(int accountId, int docId, int docOwnerId, @Nullable Document document) {
    Bundle args = new Bundle();
    args.putInt(Extra.ACCOUNT_ID, accountId);
    args.putInt(Extra.DOC_ID, docId);
    args.putInt(Extra.OWNER_ID, docOwnerId);

    if (document != null) {
        args.putParcelable(Extra.DOC, document);
    }

    return args;
}
 
Example 17
Project: Renrentou   File: XFragment.java   View source code 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (useEventBus()) {
        BusProvider.getBus().register(this);
    }
    bindEvent();
    initData(savedInstanceState);
}
 
Example 18
Project: FastTextView   File: ItalicReplacementSpan.java   View source code 5 votes vote down vote up
private void setHeightIfNeed(CharSequence text, @IntRange(from = 0) int start, @IntRange(from = 0) int end, @Nullable Paint.FontMetricsInt fm) {
  if (fm != null && text.length() == end - start) {
    // Extending classes can set the height of the span by updating
    // attributes of {@link android.graphics.Paint.FontMetricsInt}. If the span covers the whole
    // text, and the height is not set,
    // {@link #draw(Canvas, CharSequence, int, int, float, int, int, int, Paint)} will not be
    // called for the span.
    fm.top = mRect.top;
    fm.bottom = mRect.bottom;
  }
}
 
Example 19
Project: Trivia-Knowledge   File: ScienceEasyTab.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.f_sci_easy, container, false);
    gridview = (GridView) v.findViewById(R.id.gridview);
    Progress= (BootstrapProgressBar) v.findViewById(R.id.Progress);
    progressText = (TextView) v.findViewById(R.id.progressText);
    return v;
}
 
Example 20
Project: FragmentCapsulation   File: BasicToolbarFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    initToolbar();
    setupToolbar();
    adaptStatusBar();
    return view;
}
 
Example 21
Project: GitHub   File: SecondBackstackMviLifecycleFragment.java   View source code 5 votes vote down vote up
@Nullable @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
    @Nullable Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.fragment_mvi, container, false);
  TextView tv = (TextView) view.findViewById(R.id.text);
  tv.setText(getClass().getSimpleName());
  return view;
}
 
Example 22
Project: GitHub   File: AuthFragment.java   View source code 5 votes vote down vote up
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);

  authView = view.findViewById(R.id.authView);
  authView.setOnClickListener(new View.OnClickListener() {
    @Override public void onClick(View v) {
      onAuthViewClicked();
    }
  });
}
 
Example 23
Project: GitHub   File: UndoHelper.java   View source code 5 votes vote down vote up
/**
 * convenience method to be used if you have previously set a {@link Snackbar} with {@link #withSnackBar(Snackbar, String)}
 *
 * @param positions the positions where the items were removed
 * @return the snackbar or null if {@link #withSnackBar(Snackbar, String)} was not previously called
 */
public @Nullable Snackbar remove(Set<Integer> positions) {
    if (mSnackBar == null) {
        return null;
    }

    View snackbarView = mSnackBar.getView();
    TextView snackbarText = (TextView) snackbarView.findViewById(android.support.design.R.id.snackbar_text);

    return remove(snackbarView, snackbarText.getText().toString(), mSnackbarActionText, mSnackBar.getDuration(), positions);
}
 
Example 24
Project: dagger-test-example   File: SearchFragment.java   View source code 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    binding.setVm(searchViewModel);
    binding.recyclerView.setLayoutManager(
            new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false)
    );
    compositeDisposable.add(
        searchViewModel.onNewAdapterAvailable().subscribe(searchAdapter -> {
            binding.recyclerView.setAdapter(searchAdapter);
        })
    );
    searchViewModel.onAttach();
}
 
Example 25
Project: AndroidSkinAnimator   File: MainActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDataBinding.setListener(this);
    initToolbar(mDataBinding.toolBar);
    initNavigationView(mDataBinding.navigationView);
    configAnimator();
    configFragments();
    initConfigAnimatorDialog();
}
 
Example 26
Project: android-titanium-imagecropper   File: CropImage.java   View source code 5 votes vote down vote up
/** Get {@link CropImageActivity} intent to start the activity. */
public Intent getIntent(@NonNull Context context, @Nullable Class<?> cls) {
  mOptions.validate();

  Intent intent = new Intent();
  intent.setClass(context, cls);
  Bundle bundle = new Bundle();
  bundle.putParcelable(CROP_IMAGE_EXTRA_SOURCE, mSource);
  bundle.putParcelable(CROP_IMAGE_EXTRA_OPTIONS, mOptions);
  intent.putExtra(CropImage.CROP_IMAGE_EXTRA_BUNDLE, bundle);
  return intent;
}
 
Example 27
Project: lighthouse   File: PodcastsUtils.java   View source code 5 votes vote down vote up
static boolean hasSplashColors(Context context, Podcast podcast, @Nullable String splashUrl) {
    PodcastsOpenHelper helper = new PodcastsOpenHelper(context, PODCASTS_DATABASE_NAME);
    String[] args = args(podcast.getId());
    try (SQLiteDatabase database = helper.getReadableDatabase(); Cursor cursor = database.rawQuery(PODCAST_COLORS_SELECT_SQL, args)) {
        if (cursor.moveToNext()) {
            return hasColors(cursor, 3, splashUrl);
        }
    }
    return false;
}
 
Example 28
Project: GitHub   File: AboutFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                         @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_about, container, false);

    ActivityComponent component = getActivityComponent();
    if (component != null) {
        component.inject(this);
        setUnBinder(ButterKnife.bind(this, view));
        mPresenter.onAttach(this);
    }

    return view;
}
 
Example 29
Project: Orin   File: LibraryFragment.java   View source code 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    setStatusbarColorAuto(view);
    getMainActivity().setNavigationbarColorAuto();
    getMainActivity().setTaskDescriptionColorAuto();

    setUpToolbar();
    setUpViewPager();
}
 
Example 30
Project: Rx-Android-Samples   File: MapOperatorFragment.java   View source code 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    mRepoListView = view.findViewById(R.id.repo_list_view);
    mObserverLog = view.findViewById(R.id.observer_log);
    mObserverLog.setMovementMethod(new ScrollingMovementMethod());

    mApi.getObservableRepositories(Utils.USER)
            //For every repository, this method will add the number of this repository.
            .map(new Function<List<RepositoryResponse>, List<RepositoryResponse>>() {
                @Override
                public List<RepositoryResponse> apply(@NonNull List<RepositoryResponse> repositoryResponses) throws Exception {

                    for (int i = 1; i <= repositoryResponses.size(); i++) {
                        repositoryResponses.get(i - 1).name = "Repository N° "
                                + i
                                + ": "
                                + repositoryResponses.get(i - 1).name;
                    }
                    return repositoryResponses;
                }
            })
            //Subscribe the Network call in io Thread.
            .subscribeOn(Schedulers.io())
            //Subscribe the Observer in MainThread so it can updates the UI with the result.
            .observeOn(AndroidSchedulers.mainThread())
            //Choose the subscribed Observer for items emitted by this observable.
            .subscribe(mListBaseObserver);
}
 
Example 31
Project: okdownload   File: QueueListener.java   View source code 5 votes vote down vote up
@Override
public void taskEnd(DownloadTask task, EndCause cause, @Nullable Exception realCause,
                    @NonNull Listener1Assist.Listener1Model model) {
    final String status = cause.toString();
    TagUtil.saveStatus(task, status);

    final QueueViewHolder holder = holderMap.get(task.getId());
    if (holder == null) return;

    holder.statusTv.setText(status);
    if (cause == EndCause.COMPLETED) {
        holder.progressBar.setProgress(holder.progressBar.getMax());
    }
}
 
Example 32
Project: mapbox-plugins-android   File: OfflineRegionDetailActivity.java   View source code 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_offline_region_detail);
  ButterKnife.bind(this);
  mapView.onCreate(savedInstanceState);
  offlinePlugin = OfflinePlugin.getInstance();

  Bundle bundle = getIntent().getExtras();
  if (bundle != null) {
    loadOfflineDownload(bundle);
  }
}
 
Example 33
Project: conductor-attacher   File: AnimatorChangeHandler2.java   View source code 5 votes vote down vote up
@Override
public void onAbortPush(@NonNull ControllerChangeHandler newHandler, @Nullable Controller newTop) {
  super.onAbortPush(newHandler, newTop);

  canceled = true;
  if (animator != null) {
    animator.cancel();
  }
}
 
Example 34
Project: rapid-io-android   File: CollectionProvider.java   View source code 5 votes vote down vote up
@Nullable
CollectionConnection findCollectionBySubscriptionId(String subscriptionId) {
	for(String channelName : mCollectionConnections.keySet()) {
		if(mCollectionConnections.get(channelName).hasSubscription(subscriptionId))
			return mCollectionConnections.get(channelName);
	}
	return null;
}
 
Example 35
Project: HeaderRecyclerViewAdapter-Android   File: HeaderRecyclerViewAdapter.java   View source code 5 votes vote down vote up
@Nullable
public final View getHeaderViewForType(int viewType) {
    for (View headerView : headerViews) {
        if (getViewTypeForHeaderOrFooter(headerView) == viewType) {
            return headerView;
        }
    }
    return null;
}
 
Example 36
Project: android_ui   File: LinearLayoutWidget.java   View source code 5 votes vote down vote up
/**
 */
@Nullable
@Override
public PorterDuff.Mode getBackgroundTintMode() {
	this.ensureDecorator();
	return mDecorator.getBackgroundTintMode();
}
 
Example 37
Project: passman-android   File: CredentialDisplay.java   View source code 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);

    label.setText(credential.getLabel());
    user.setText(credential.getUsername());
    password.setModePassword();
    password.setText(credential.getPassword());
    email.setModeEmail();
    email.setText(credential.getEmail());
    url.setText(credential.getUrl());
    description.setText(credential.getDescription());
    otp.setEnabled(false);
}
 
Example 38
Project: GitHub   File: SizeConfigStrategy.java   View source code 5 votes vote down vote up
@Override
@Nullable
public Bitmap removeLast() {
  Bitmap removed = groupedMap.removeLast();
  if (removed != null) {
    int removedSize = Util.getBitmapByteSize(removed);
    decrementBitmapOfSize(removedSize, removed);
  }
  return removed;
}
 
Example 39
Project: GitHub   File: Router.java   View source code 4 votes vote down vote up
public Router putShort(@Nullable String key, short value) {
    getBundleData().putShort(key, value);
    return this;
}
 
Example 40
Project: Protein   File: CurvedFrameLayout.java   View source code 4 votes vote down vote up
public CurvedFrameLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
}