Java Code Examples for android.support.annotation.NonNull

The following are top voted examples for showing how to use android.support.annotation.NonNull. 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: AndroidSkinAnimator   File: SkinCompatDelegate.java   Source Code and License 6 votes vote down vote up
public View createView(View parent, final String name, @NonNull Context context,
                       @NonNull AttributeSet attrs) {
    final boolean isPre21 = Build.VERSION.SDK_INT < 21;

    if (mSkinCompatViewInflater == null) {
        mSkinCompatViewInflater = new SkinCompatViewInflater();
    }

    // We only want the View to inherit its context if we're running pre-v21
    final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent);

    return mSkinCompatViewInflater.createView(parent, name, context, attrs, inheritContext,
            isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */
            true, /* Read read app:theme as a fallback at all times for legacy reasons */
            VectorEnabledTintResources.shouldBeUsed() /* Only tint wrap the context if enabled */
    );
}
 
Example 2
Project: LucaHome-AndroidApplication   File: CoinEditActivity.java   Source Code and License 6 votes vote down vote up
private void navigateBack(@NonNull String message) {
    Snacky.builder()
            .setActivty(CoinEditActivity.this)
            .setText(message)
            .setDuration(Snacky.LENGTH_INDEFINITE)
            .success()
            .show();

    new Handler().postDelayed(() -> {
        NavigationService.NavigationResult navigationResult = NavigationService.getInstance().GoBack(CoinEditActivity.this);
        if (navigationResult != NavigationService.NavigationResult.SUCCESS) {
            Logger.getInstance().Error(TAG, String.format(Locale.getDefault(), "Navigation failed! navigationResult is %s!", navigationResult));
            displayFailSnacky("Failed to navigate back! Please contact LucaHome support!");
        }
    }, 1500);
}
 
Example 3
Project: CompositionAvatar   File: CompositionAvatarView.java   Source Code and License 6 votes vote down vote up
@Override
public void invalidateDrawable(@NonNull Drawable drawable) {
    if (hasSameDrawable(drawable)) {
        invalidate();
    } else {
        super.invalidateDrawable(drawable);
    }
}
 
Example 4
Project: Orin   File: GravityDelegate.java   Source Code and License 6 votes vote down vote up
public int[] calculateDistanceToFinalSnap(@NonNull RecyclerView.LayoutManager layoutManager,
                                          @NonNull View targetView) {
    int[] out = new int[2];

    if (layoutManager.canScrollHorizontally()) {
        if (gravity == Gravity.START) {
            out[0] = distanceToStart(targetView, getHorizontalHelper(layoutManager), false);
        } else { // END
            out[0] = distanceToEnd(targetView, getHorizontalHelper(layoutManager), false);
        }
    } else {
        out[0] = 0;
    }

    if (layoutManager.canScrollVertically()) {
        if (gravity == Gravity.TOP) {
            out[1] = distanceToStart(targetView, getVerticalHelper(layoutManager), false);
        } else { // BOTTOM
            out[1] = distanceToEnd(targetView, getVerticalHelper(layoutManager), false);
        }
    } else {
        out[1] = 0;
    }

    return out;
}
 
Example 5
Project: android-media-controller   File: BitmapUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a Material Design compliant {@link android.support.v7.widget.Toolbar} icon
 * from a given full sized icon.
 *
 * @param resources Resources for the current {@link android.content.Context}.
 * @param icon The bitmap to convert.
 * @return A scaled Bitmap of the appropriate size and in-built padding.
 */
public static Bitmap createToolbarIcon(@NonNull Resources resources,
                                       @NonNull final Bitmap icon) {
    final int padding = resources.getDimensionPixelSize(R.dimen.margin_small);
    final int iconSize = resources.getDimensionPixelSize(R.dimen.toolbar_icon_size);
    final int sizeWithPadding = iconSize + (2 * padding);

    // Create a Bitmap backed Canvas to be the toolbar icon.
    final Bitmap toolbarIcon =
            Bitmap.createBitmap(sizeWithPadding, sizeWithPadding, Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(toolbarIcon);
    canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

    // Resize the app icon to Material Design size.
    final Bitmap scaledIcon = Bitmap.createScaledBitmap(icon, iconSize, iconSize, false);
    canvas.drawBitmap(scaledIcon, padding, padding, null);

    return toolbarIcon;
}
 
Example 6
Project: ImmerseMode   File: TpSbTlNbwFCImmerseMode.java   Source Code and License 6 votes vote down vote up
@NonNull
private View setupContentViewAndStatusBarView(@NonNull Activity activity) throws IllegalStateException {
    ViewGroup contentViewGroup = (ViewGroup) activity.findViewById(android.R.id.content);
    View userView = contentViewGroup.getChildAt(0);
    if (userView == null) {
        throw new IllegalStateException("Plz invode setContentView() method first!");
    }

    userView.setFitsSystemWindows(false);

    mInsetsRect.top = ImmerseGlobalConfig.getInstance().getStatusBarHeight();

    View statusBarView = new View(activity);
    ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mInsetsRect.top);
    contentViewGroup.addView(statusBarView, params);

    return statusBarView;
}
 
Example 7
Project: mvvm-template   File: SchemeParser.java   Source Code and License 6 votes vote down vote up
@Nullable private static Intent convert(@NonNull Context context, Uri data, boolean showRepoBtn) {
    if (data == null) return null;
    if (InputHelper.isEmpty(data.getHost()) || InputHelper.isEmpty(data.getScheme())) {
        String host = data.getHost();
        if (InputHelper.isEmpty(host)) host = HOST_DEFAULT;
        String scheme = data.getScheme();
        if (InputHelper.isEmpty(scheme)) scheme = PROTOCOL_HTTPS;
        String prefix = scheme + "://" + host;
        String path = data.getPath();
        if (!InputHelper.isEmpty(path)) {
            if (path.charAt(0) == '/') {
                data = Uri.parse(prefix + path);
            } else {
                data = Uri.parse(prefix + '/' + path);
            }
        } else {
            data = Uri.parse(prefix);
        }
    }
    if (data.getPathSegments() != null && !data.getPathSegments().isEmpty()) {
        if (IGNORED_LIST.contains(data.getPathSegments().get(0))) return null;
        return getIntentForURI(context, data, showRepoBtn);
    }
    return null;
}
 
Example 8
Project: dbsync   File: BaseMainDbActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
    Log.i(TAG, "onConnectionFailed:" + connectionResult.getErrorMessage());

    // Viene chiamata nel caso la connect fallisca ad esempio
    // non è ancora stata data autorizzaiozne alla applicazione corrente
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
            // Unable to resolve, message user appropriately
        }
    } else {
        GoogleApiAvailability.getInstance().getErrorDialog(this, connectionResult.getErrorCode(), 0).show();
    }
}
 
Example 9
Project: LianXiZhihu   File: BookmarksAdapter.java   Source Code and License 6 votes vote down vote up
public BookmarksAdapter(@NonNull Context context,
                        ArrayList<ZhihuDailyNews.Question> zhihuList,
                        ArrayList<GuokrHandpickNews.result> guokrList,
                        ArrayList<DoubanMomentNews.posts> doubanList,
                        ArrayList<Integer> types) {
    this.context = context;
    this.inflater = LayoutInflater.from(context);

    this.zhihuList = zhihuList;
    this.guokrList = guokrList;
    this.doubanList = doubanList;

    // types.size = zhihuList.size + guokrList.size + doubanList.size
    this.types = types;

}
 
Example 10
Project: calendarview2   File: CalendarView2.java   Source Code and License 6 votes vote down vote up
@Override
public void writeToParcel(@NonNull Parcel out, int flags) {
    super.writeToParcel(out, flags);
    out.writeInt(color);
    out.writeInt(dateTextAppearance);
    out.writeInt(weekDayTextAppearance);
    out.writeInt(showOtherDates);
    out.writeByte((byte) (allowClickDaysOutsideCurrentMonth ? 1 : 0));
    out.writeParcelable(minDate, 0);
    out.writeParcelable(maxDate, 0);
    out.writeTypedList(selectedDates);
    out.writeInt(firstDayOfWeek);
    out.writeInt(orientation);
    out.writeInt(tileWidthPx);
    out.writeInt(tileHeightPx);
    out.writeInt(topbarVisible ? 1 : 0);
    out.writeInt(selectionMode);
    out.writeInt(dynamicHeightEnabled ? 1 : 0);
    out.writeInt(calendarMode == CalendarMode.WEEKS ? 1 : 0);
    out.writeParcelable(currentMonth, 0);
    out.writeByte((byte) (cacheCurrentPosition ? 1 : 0));
}
 
Example 11
Project: MyEyepetizer   File: HomeCollectionItemBinder.java   Source Code and License 6 votes vote down vote up
@Override
protected void onBindViewHolder(@NonNull ViewHold holder, @NonNull final CollectionItem item) {
    Glide.with(mActivity).load(item.data.cover.feedCover).into(holder.image);

    holder.title.setText(item.data.title);
    holder.title.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.DB1FontPath)));

    holder.info.setText("#" + item.data.category + " / " + TranslateDuration.translateSeconds(item.data.duration) + " / 开眼精选");
    holder.info.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.LFontPath)));

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(mActivity, MovieDetailActivity.class);
            Bundle bundle = new Bundle();
            bundle.putParcelable("DATA", item.data);
            intent.putExtras(bundle);

            mActivity.startActivity(intent);
        }
    });
}
 
Example 12
Project: Ghost-Android   File: GhostApiUtils.java   Source Code and License 6 votes vote down vote up
public static Retrofit getRetrofit(@NonNull String blogUrl, @NonNull OkHttpClient httpClient) {
    String baseUrl = NetworkUtils.makeAbsoluteUrl(blogUrl, "ghost/api/v0.1/");
    Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new DateDeserializer())
            .registerTypeAdapter(ConfigurationList.class, new ConfigurationListDeserializer())
            .registerTypeAdapterFactory(new PostTypeAdapterFactory())
            .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
            .setExclusionStrategies(new RealmExclusionStrategy(), new AnnotationExclusionStrategy())
            .create();
    return new Retrofit.Builder()
            .baseUrl(baseUrl)
            .client(httpClient)
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            // for HTML output (e.g., to get the client secret)
            .addConverterFactory(StringConverterFactory.create())
            // for raw JSONObject output (e.g., for the /configuration/about call)
            .addConverterFactory(JSONObjectConverterFactory.create())
            // for domain objects
            .addConverterFactory(GsonConverterFactory.create(gson))
            .build();
}
 
Example 13
Project: RxFirestore   File: RunTransactionOnSubscribe.java   Source Code and License 6 votes vote down vote up
@Override
public void subscribe(final CompletableEmitter emitter) throws Exception {

    final OnCompleteListener<T> listener = new OnCompleteListener<T>() {
        @Override
        public void onComplete(@NonNull Task<T> task) {

            if (!emitter.isDisposed()) {
                if (!task.isSuccessful()) {
                    emitter.onError(task.getException());
                } else {
                    emitter.onComplete();
                }
            }

        }
    };

    database.runTransaction(transaction).addOnCompleteListener(listener);
}
 
Example 14
Project: RunMap   File: PermissionManager.java   Source Code and License 5 votes vote down vote up
public void handlePermissionResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults){
    PermissionRequest request = mCurrentRequest.poll();
    PermissionCallBack callBack = request.getCallBack();
    if(requestCode != PERMISSION_CODE || callBack == null){
        return;
    }
    for(int i=0;i<grantResults.length;i++){
        if(grantResults[i] == PackageManager.PERMISSION_DENIED){
            callBack.onDenied();
            return;
        }
    }
     callBack.onAllPermissionGranted();
}
 
Example 15
Project: LucaHome-AndroidApplication   File: JsonDataToMovieConverter.java   Source Code and License 5 votes vote down vote up
@Override
public SerializableList<Movie> GetList(@NonNull String[] stringArray) {
    if (StringHelper.StringsAreEqual(stringArray)) {
        return parseStringToList(stringArray[0]);
    } else {
        String usedEntry = StringHelper.SelectString(stringArray, SEARCH_PARAMETER);
        return parseStringToList(usedEntry);
    }
}
 
Example 16
Project: lex   File: LexList.java   Source Code and License 5 votes vote down vote up
@NonNull
public CharSequence make() {
    switch (items.length) {
        case 0:
            return emptyText;
        case 1:
            return getWrappedItem(0);
        case 2:
            return makeTwoItems();
        default:
            return makeThreeOrMoreItems();
    }
}
 
Example 17
Project: android_ui   File: CalendarView.java   Source Code and License 5 votes vote down vote up
/**
 */
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
	dest.writeParcelable(dataSet, flags);
	dest.writeValue(selectedDate);
	dest.writeInt(selectedDay);
	dest.writeInt(selectedDayMonthPosition);
}
 
Example 18
Project: android_ui   File: WebViewWidget.java   Source Code and License 5 votes vote down vote up
/**
 */
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
	this.ensureDecorator();
	if (mDecorator.onTouchEvent(event) || super.onTouchEvent(event)) {
		return true;
	}
	mDecorator.hideSoftKeyboardOnTouch();
	return false;
}
 
Example 19
Project: tenor-android-core   File: AaidService.java   Source Code and License 5 votes vote down vote up
@Override
protected void onHandleWork(@NonNull Intent intent) {

    switch (intent.getAction()) {
        case ACTION_GET_AAID:
            AaidClient.init(getApplicationContext(), sListener);
            break;
        default:
            // do nothing
            break;
    }
}
 
Example 20
Project: BWS-Android   File: ImageFormatConverter.java   Source Code and License 5 votes vote down vote up
/**
 * Converts a Bitmap to a PNG image.
 */
@NonNull
public byte[] bitmapToPng(@NonNull Bitmap bitmap) {
    String stopwatchSessionId = log.startStopwatch(getStopwatchSessionId("bitmapToPng"));

    // compress Bitmap to PNG
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);

    log.stopStopwatch(stopwatchSessionId);
    return out.toByteArray();
}
 
Example 21
Project: ultra-debugger   File: DeviceInfoHelper.java   Source Code and License 5 votes vote down vote up
@NonNull
private String getMacAddress() {
    String mac = getMacAddress("wlan0");
    if (TextUtils.isEmpty(mac)) {
        mac = getMacAddress("eth0");
    }
    return mac;
}
 
Example 22
Project: android_ui   File: CalendarView.java   Source Code and License 5 votes vote down vote up
/**
 * Invoked from {@link #onBindViewHolder(ViewHolder, int)} with the given <var>dateInMillis</var>
 * that is associated with the {@link MonthView} at the <var>position</var> according to the
 * current data set size.
 *
 * @param holder       View holder to bind.
 * @param position     The position for which to perform binding.
 * @param dateInMillis Date in milliseconds obtained for the month position via
 *                     {@link CalendarDataSet#getMonthDate(int)}.
 */
@SuppressWarnings("ResourceType")
protected void onBindViewHolder(@NonNull ViewHolder holder, int position, long dateInMillis) {
	final MonthView monthView = (MonthView) holder.itemView;
	monthView.setLocale(locale);
	monthView.setDate(dateInMillis);
	if (selectedDayMonthPosition == position && selectedDay != NO_VALUE) {
		monthView.setSelection(selectedDay);
	} else {
		monthView.setSelection(0);
	}
}
 
Example 23
Project: redpacketui-open   File: PayTipsDialogFragment.java   Source Code and License 5 votes vote down vote up
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    //去掉Dialog的Title
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    if (dialog.getWindow() != null) {
        dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    }
    return dialog;
}
 
Example 24
Project: CalendarCheck   File: MilesHandler.java   Source Code and License 5 votes vote down vote up
private WeakRunnable wrapRunnable(@NonNull Runnable r) {
    //noinspection ConstantConditions
    if (r == null) {
        throw new NullPointerException("Runnable can't be null");
    }
    final ChainedRef hardRef = new ChainedRef(mLock, r);
    mRunnables.insertAfter(hardRef);
    return hardRef.wrapper;
}
 
Example 25
Project: Monolith   File: DataProvider.java   Source Code and License 5 votes vote down vote up
@Override
public int delete(@NonNull Uri uri, String selection, String[] selectionArgs) {

    final SQLiteDatabase db_g = mOpenHelper_gallery.getReadableDatabase();
    final SQLiteDatabase db_a = mOpenHelper_article.getReadableDatabase();
    final int match = sUriMatcher.match(uri);
    int rowDeleted;

    if (selection == null) selection = "1";

    switch (match) {
        case IMAGE:
            rowDeleted = db_g.delete(TABLE_NAME_GALLERY, selection, selectionArgs);
            break;

        case ARTICLE:
            rowDeleted = db_a.delete(TABLE_NAME_ARTICLE, selection, selectionArgs);
            break;

        default:
            throw new UnsupportedOperationException("Unknown uri: " + uri);
    }

    if (rowDeleted != 0) {
        getContext().getContentResolver().notifyChange(uri, null);
    }

    return rowDeleted;
}
 
Example 26
Project: AssistantBySDK   File: MonthView.java   Source Code and License 5 votes vote down vote up
@Override
public boolean dispatchHoverEvent(@NonNull MotionEvent event) {
    // First right-of-refusal goes the touch exploration helper.
    if (mTouchHelper.dispatchHoverEvent(event)) {
        return true;
    }
    return super.dispatchHoverEvent(event);
}
 
Example 27
Project: mpeg-encoder   File: GLTools.java   Source Code and License 5 votes vote down vote up
/**
 * @param config EGL config
 * @return the EGL config handle
 */
private static long getConfigHandle(@NonNull EGLConfig config) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return getConfigHandleLollipop(config);
    } else {
        return getConfigHandleBase(config);
    }
}
 
Example 28
Project: GitHub   File: MaterialDialog.java   Source Code and License 5 votes vote down vote up
public Builder customView(@NonNull View view, boolean wrapInScrollView) {
    if (this.content != null)
        throw new IllegalStateException("You cannot use customView() when you have content set.");
    else if (this.items != null)
        throw new IllegalStateException("You cannot use customView() when you have items set.");
    else if (this.inputCallback != null)
        throw new IllegalStateException("You cannot use customView() with an input dialog");
    else if (this.progress > -2 || this.indeterminateProgress)
        throw new IllegalStateException("You cannot use customView() with a progress dialog");
    if (view.getParent() != null && view.getParent() instanceof ViewGroup)
        ((ViewGroup) view.getParent()).removeView(view);
    this.customView = view;
    this.wrapCustomViewInScroll = wrapInScrollView;
    return this;
}
 
Example 29
Project: Programmers   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
    menuItem.setChecked(true);

    Fragment fragment = new PostsFragment();
    String title = getString(R.string.posts);

    switch (menuItem.getItemId()) {
        case R.id.action_home:
            setFABVisibility(true);
            break;
        case R.id.action_peoples:
            title = getString(R.string.users);

            setFABVisibility(false);
            fragment = new UsersFragment();
            break;
        case R.id.action_notifications:
            title = getString(R.string.notifications);
            setFABVisibility(false);
            fragment = new NotificationsFragment();
            break;
        case R.id.action_messages:
            title = getString(R.string.messages);
            setFABVisibility(false);
            fragment = new NotificationsFragment();
            break;
    }

    // change toolbar title
    setTitle(title);

    // Replace with the selected fragment
    IntentUtils.replaceFragment(R.id.frame_layout,
            getSupportFragmentManager(), fragment);
    return false;
}
 
Example 30
Project: GitHub   File: LceAnimator.java   Source Code and License 5 votes vote down vote up
/**
 * Show the loading view. No animations, because sometimes loading things is pretty fast (i.e.
 * retrieve data from memory cache).
 */
public static void showLoading(@NonNull View loadingView, @NonNull View contentView,
    @NonNull View errorView) {

  contentView.setVisibility(View.GONE);
  errorView.setVisibility(View.GONE);
  loadingView.setVisibility(View.VISIBLE);
}
 
Example 31
Project: shortcut-helper   File: ShortcutHelper.java   Source Code and License 5 votes vote down vote up
public ShortcutHelper createShortcut(@NonNull CharSequence shortLabel, @NonNull CharSequence longLabel, @NonNull int iconResource, @NonNull Intent intent) {
    if (Build.VERSION.SDK_INT < 25) {
        return this;
    }
    String shortcutId = shortLabel.toString().replaceAll("\\s+","").toLowerCase() + "_shortcut";
    ShortcutInfo shortcut = new ShortcutInfo.Builder(mActivity, shortcutId)
            .setShortLabel(shortLabel)
            .setLongLabel(longLabel)
            .setIcon(Icon.createWithResource(mActivity, iconResource))
            .setIntent(intent)
            .build();
    mShortcutInfos.add(shortcut);
    return this;
}
 
Example 32
Project: Cable-Android   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T extends View> T inflate(@NonNull   LayoutInflater inflater,
                                         @NonNull   ViewGroup      parent,
                                         @LayoutRes int            layoutResId)
{
  return (T)(inflater.inflate(layoutResId, parent, false));
}
 
Example 33
Project: Orin   File: TopAndRecentlyPlayedTracksLoader.java   Source Code and License 5 votes vote down vote up
@Nullable
public static Cursor makeRecentTracksCursorAndClearUpDatabase(@NonNull final Context context) {
    SortedLongCursor retCursor = makeRecentTracksCursorImpl(context);

    // clean up the databases with any ids not found
    if (retCursor != null) {
        ArrayList<Long> missingIds = retCursor.getMissingIds();
        if (missingIds != null && missingIds.size() > 0) {
            for (long id : missingIds) {
                HistoryStore.getInstance(context).removeSongId(id);
            }
        }
    }
    return retCursor;
}
 
Example 34
Project: NanoIconPack   File: ExtraUtil.java   Source Code and License 5 votes vote down vote up
public static int fetchColor(@NonNull Context context, int attrId) {
    TypedValue typedValue = new TypedValue();
    TypedArray a = context.obtainStyledAttributes(typedValue.data,
            new int[] { attrId });
    int color = a.getColor(0, 0);
    a.recycle();
    return color;
}
 
Example 35
Project: Reactive-Android-Programming   File: MainActivity.java   Source Code and License 5 votes vote down vote up
@NonNull
private Consumer<Throwable> showToastErrorNotification() {
    return error -> {
        Toast.makeText(this, "We couldn't reach internet - falling back to local data",
                Toast.LENGTH_SHORT)
                .show();
    };
}
 
Example 36
Project: Orin   File: AboutActivity.java   Source Code and License 5 votes vote down vote up
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        onBackPressed();
        return true;
    }
    return super.onOptionsItemSelected(item);
}
 
Example 37
Project: Bridge   File: ChooserItemViewHolder.java   Source Code and License 5 votes vote down vote up
@Override
public void onBind(@NonNull List<Object> payloads) {
    super.onBind(payloads);

    for (Object payload: payloads) {
        if (CHECK_SELECT_PAYLOAD.equals(payload)) {
            checkSelected();
        }
    }
}
 
Example 38
Project: Phoenix-for-VK   File: NewsFeedSearchPresenter.java   Source Code and License 5 votes vote down vote up
@Override
public void firePostClick(@NonNull Post post) {
    if (post.getPostType() == VKApiPost.Type.REPLY) {
        getView().openComments(getAccountId(), Commented.from(post), post.getVkid());
    } else {
        getView().openPost(getAccountId(), post);
    }
}
 
Example 39
Project: MultiItem   File: BaseItemAdapter.java   Source Code and License 4 votes vote down vote up
/**
 * 在指定位置添加Item
 */
public void addDataItem(int position, @NonNull Object item) {
    addDataItems(position, Collections.singletonList(item));
}
 
Example 40
Project: LucaHome-AndroidApplication   File: WirelessSwitchService.java   Source Code and License 4 votes vote down vote up
private void sendFailedWirelessSwitchToggleBroadcast(@NonNull String response) {
    if (response.length() == 0) {
        response = "Toggle for wireless switch failed!";
    }

    _broadcastController.SendSerializableBroadcast(
            WirelessSwitchToggleFinishedBroadcast,
            WirelessSwitchToggleFinishedBundle,
            new ObjectChangeFinishedContent(false, Tools.CompressStringToByteArray(response)));
}
 
Example 41
Project: PeSanKita-android   File: IdentityKeyUtil.java   Source Code and License 4 votes vote down vote up
private static IdentityKeyPair getLegacyIdentityKeyPair(@NonNull Context context,
                                                        @NonNull MasterSecret masterSecret)
{
  try {
    MasterCipher masterCipher   = new MasterCipher(masterSecret);
    byte[]       publicKeyBytes = Base64.decode(retrieve(context, IDENTITY_PUBLIC_KEY_CIPHERTEXT_LEGACY_PREF));
    IdentityKey  identityKey    = new IdentityKey(publicKeyBytes, 0);
    ECPrivateKey privateKey     = masterCipher.decryptKey(Base64.decode(retrieve(context, IDENTITY_PRIVATE_KEY_CIPHERTEXT_LEGACY_PREF)));

    return new IdentityKeyPair(identityKey, privateKey);
  } catch (IOException | InvalidKeyException e) {
    throw new AssertionError(e);
  }
}
 
Example 42
Project: TreebolicLib   File: AnimationTransforms.java   Source Code and License 4 votes vote down vote up
/**
 * Make animation with one transform only
 *
 * @param thisFrom        source point
 * @param thisTo          source point
 * @param thisTransformer transform generator
 * @param thisOrientation orientation
 * @return sequence of one transform
 */
@NonNull
static private Vector<HyperTransform> makeTransform1(@NonNull final Complex thisFrom, @NonNull final Complex thisTo, @NonNull final Transformer thisTransformer, @NonNull final Complex thisOrientation)
{
	final HyperTransform thisCurrentTransform = thisTransformer.getTransform();

	// final transform
	final HyperTransform thisFinalTransform = thisTransformer.makeTransform(thisFrom, thisTo, thisOrientation);

	// vector
	final Vector<HyperTransform> theseTransforms = new Vector<>(1);
	theseTransforms.addElement(new HyperTransform(thisCurrentTransform).compose(thisFinalTransform));
	return theseTransforms;
}
 
Example 43
Project: ultra-debugger   File: Utils.java   Source Code and License 4 votes vote down vote up
@NonNull
private static String getFileName() {
    String date = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault()).format(new Date());
    return date + LOG_FILE_EXTENSION;
}
 
Example 44
Project: Suas-Android   File: SettingsActivity.java   Source Code and License 4 votes vote down vote up
@Override
public void update(@NonNull TodoSettings settings) {
    backgroundColorPreview.setBackgroundColor(settings.getBackgroundColor());
    textColorPreview.setBackgroundColor(settings.getTextColor());
}
 
Example 45
Project: ContentPal   File: PhoneticNameData.java   Source Code and License 4 votes vote down vote up
public PhoneticNameData(@Nullable CharSequence firstName, @Nullable CharSequence middleName, @Nullable CharSequence lastName, @NonNull StructuredNameData delegate)
{
    mDelegate = delegate;
    mFirstName = firstName;
    mMiddleName = middleName;
    mLastName = lastName;
}
 
Example 46
Project: filepicker   File: ImageEditLayout.java   Source Code and License 4 votes vote down vote up
public ImageEditLayout(@NonNull Context context) {
    this(context, null);
}
 
Example 47
Project: XERUNG   File: MaterialAutoCompleteTextView.java   Source Code and License 4 votes vote down vote up
private Typeface getCustomTypeface(@NonNull String fontPath) {
  return Typeface.createFromAsset(getContext().getAssets(), fontPath);
}
 
Example 48
Project: letv   File: Fragment.java   Source Code and License 4 votes vote down vote up
public boolean shouldShowRequestPermissionRationale(@NonNull String permission) {
    if (this.mHost != null) {
        return this.mHost.onShouldShowRequestPermissionRationale(permission);
    }
    return false;
}
 
Example 49
Project: baselibrary-master   File: BaseFragment.java   Source Code and License 4 votes vote down vote up
/**
 * 淡入淡出加载网络图片
 *
 * @param imageview        图片控件
 * @param url              图片url
 * @param errorResId       加载失败时显示的图片资源id
 * @param placeholderResId 加载时的占位图资源id
 */
public void setImageUrl(@NonNull ImageView imageview, String url, @DrawableRes int errorResId, @DrawableRes int placeholderResId) {
    Glide.with(mContext)
            .load(url)
            .crossFade()
            .error(errorResId)
            .placeholder(placeholderResId)
            .into(imageview);
}
 
Example 50
Project: MusicX-music-player   File: ATEBase.java   Source Code and License 4 votes vote down vote up
public static <T extends View> void registerViewProcessor(@NonNull Class<T> viewCls, @NonNull ViewProcessor<T, ?> viewProcessor) {
    if (mViewProcessors == null)
        initViewProcessors();
    mViewProcessors.put(viewCls.getName(), viewProcessor);
}
 
Example 51
Project: Outlast   File: FragmentOutlast.java   Source Code and License 4 votes vote down vote up
public FragmentOutlast(@NonNull Fragment fragment,
                       @NonNull Outlasting.Creator<T> creator,
                       @Nullable Bundle savedInstanceState) {
    super(creator, savedInstanceState);
    this.fragment = fragment;
}
 
Example 52
Project: rapid-io-android   File: Message.java   Source Code and License 4 votes vote down vote up
@Override
protected void parseJsonBody(@NonNull JSONObject jsonBody) {
	super.parseJsonBody(jsonBody);

	mSubscriptionId = jsonBody.optString(ATTR_SUB_ID);
	mCollectionId = jsonBody.optString(ATTR_COL_ID);
	mDocument = jsonBody.optString(ATTR_DOC);
}
 
Example 53
Project: mvvm-template   File: ReactionsModel.java   Source Code and License 4 votes vote down vote up
@NonNull
public static List<ReactionsModel> getReaction(@Nullable List<PullRequestTimelineQuery.ReactionGroup1> reactions) {
    List<ReactionsModel> models = new ArrayList<>();
    if (reactions != null && !reactions.isEmpty()) {
        for (PullRequestTimelineQuery.ReactionGroup1 reaction : reactions) {
            ReactionsModel model = new ReactionsModel();
            model.setContent(reaction.content().name());
            model.setViewerHasReacted(reaction.viewerHasReacted());
            model.setTotal_count(reaction.users().totalCount());
            models.add(model);
        }
    }
    return models;
}
 
Example 54
Project: cwac-crossport   File: BaseTransientBottomBar.java   Source Code and License 4 votes vote down vote up
/**
   * Returns the {@link BaseTransientBottomBar}'s view.
   */
@NonNull
public View getView() {
  return mView;
}
 
Example 55
Project: permissions4m   File: SupportFragment.java   Source Code and License 4 votes vote down vote up
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[]
        grantResults) {
    Permissions4M.onRequestPermissionsResult(SupportFragment.this, requestCode, grantResults);
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
 
Example 56
Project: weex-uikit   File: BorderDrawable.java   Source Code and License 4 votes vote down vote up
private void updateFactor(@NonNull List<Float> list, float numerator, float denominator) {
  if (!FloatUtil.floatsEqual(denominator, 0)) {
    list.add(numerator / denominator);
  }
}
 
Example 57
Project: condom   File: PackageManagerWrapper.java   Source Code and License 4 votes vote down vote up
@RequiresApi(LOLLIPOP) @Override @NonNull public PackageInstaller getPackageInstaller() {
	return mBase.getPackageInstaller();
}
 
Example 58
Project: TreebolicLib   File: HyperTransform.java   Source Code and License 4 votes vote down vote up
@NonNull
@Override
public Complex map(@NonNull final Complex z)
{
	// <BOUTHIER>
	// rigid transformation of the hyperbolic plane
	// z = (z*theta+p)/(1+(~p)*z*theta)
	// </BOUTHIER>

	final Complex num = new Complex(z).mul(this.theRot).add(this.theXlat);
	final Complex denom = new Complex(this.theXlat).conj().mul(z).mul(this.theRot).add(Complex.ONE);
	return z.div(num, denom);

	// OPTIMIZED
	// see HTOptimizedTransform which does just this
	// factor out theta (1/theta = invtheta)
	// z = (z*theta+p)/(1+(~p)*theta*z)
	// z = theta(z+p*invtheta)/theta(invtheta+z*~p)
	// z = (z+p*invtheta)/(invtheta+z*~p)
	// invtheta can be precomputed
	// p*invtheta can be precomputed (pontheta)
	// z = (z+pontheta)/(invtheta+z*~p)
	// at runtime it boils down to :
	// -2 complex additions
	// -1 complex multiplication
	// -1 complex division
}
 
Example 59
Project: Taxi-Datalogger   File: MQTTPublisher.java   Source Code and License 4 votes vote down vote up
@Override
public void reconfigure(@NonNull CloudIotOptions newOptions) {
    if (newOptions.equals(cloudIotOptions)) {
        return;
    }
    mReady.set(false);
    try {
        close();
    } catch (MqttException e) {
        // empty
    }
    initialize(newOptions);
}
 
Example 60
Project: ContentPal   File: SyncParams.java   Source Code and License 4 votes vote down vote up
public SyncParams(@NonNull UriParams delegate)
{
    mDelegate = delegate;
}