Java Code Examples for androidx.annotation.Nullable

The following examples show how to use androidx.annotation.Nullable. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: MediaSDK   Source File: SimpleDecoderVideoRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets output buffer renderer.
 *
 * @param outputBufferRenderer Output buffer renderer.
 */
protected final void setOutputBufferRenderer(
    @Nullable VideoDecoderOutputBufferRenderer outputBufferRenderer) {
  if (this.outputBufferRenderer != outputBufferRenderer) {
    // The output has changed.
    this.outputBufferRenderer = outputBufferRenderer;
    if (outputBufferRenderer != null) {
      surface = null;
      outputMode = C.VIDEO_OUTPUT_MODE_YUV;
      if (decoder != null) {
        setDecoderOutputMode(outputMode);
      }
      onOutputChanged();
    } else {
      // The output has been removed. We leave the outputMode of the underlying decoder unchanged
      // in anticipation that a subsequent output will likely be of the same type.
      outputMode = C.VIDEO_OUTPUT_MODE_NONE;
      onOutputRemoved();
    }
  } else if (outputBufferRenderer != null) {
    // The output is unchanged and non-null.
    onOutputReset();
  }
}
 
Example 2
Source Project: arcusandroid   Source File: HoursMinutePickerFragment.java    License: Apache License 2.0 6 votes vote down vote up
@NonNull
public static HoursMinutePickerFragment newInstance(String modelID, String title, String zone,
                                                    List<StringPair> selections, @Nullable String selected) {
    HoursMinutePickerFragment fragment = new HoursMinutePickerFragment();

    ArrayList<StringPair> values;
    if (selections == null) {
        values = new ArrayList<>();
    }
    else {
        values = new ArrayList<>(selections);
    }
    Bundle data = new Bundle(5);
    data.putString(MODEL_ADDR, modelID);
    data.putString(TITLE, title);
    data.putString(ZONE, zone);
    data.putSerializable(SELECTIONS, values);
    data.putString(SELECTED, selected);
    fragment.setArguments(data);

    return fragment;
}
 
Example 3
Source Project: BaldPhone   Source File: VideoTutorialsActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    final RecyclerView recycler_view = findViewById(R.id.recycler_view);
    final DividerItemDecoration dividerItemDecoration =
            new DividerItemDecoration(recycler_view.getContext(), DividerItemDecoration.VERTICAL);
    dividerItemDecoration.setDrawable(getDrawable(R.drawable.ll_divider));
    recycler_view.addItemDecoration(dividerItemDecoration);
    final Resources resources = getResources();
    recycler_view.setAdapter(
            new HelpRecyclerViewAdapter(
                    this,
                    S.typedArrayToResArray(resources, R.array.yt_texts),
                    S.typedArrayToResArray(resources, R.array.yt_logos)));
}
 
Example 4
Source Project: mollyim-android   Source File: SmsDatabase.java    License: GNU General Public License v3.0 6 votes vote down vote up
public @Nullable RecipientId getOldestGroupUpdateSender(long threadId, long minimumDateReceived) {
  SQLiteDatabase db = databaseHelper.getReadableDatabase();

  String[] columns = new String[]{RECIPIENT_ID};
  String   query   = THREAD_ID + " = ? AND " + TYPE + " & ? AND " + DATE_RECEIVED + " >= ?";
  long     type    = Types.SECURE_MESSAGE_BIT | Types.PUSH_MESSAGE_BIT | Types.GROUP_UPDATE_BIT | Types.BASE_INBOX_TYPE;
  String[] args    = new String[]{String.valueOf(threadId), String.valueOf(type), String.valueOf(minimumDateReceived)};
  String   limit   = "1";

  try (Cursor cursor = db.query(TABLE_NAME, columns, query, args, null, null, limit)) {
    if (cursor.moveToFirst()) {
      return RecipientId.from(cursor.getLong(cursor.getColumnIndex(RECIPIENT_ID)));
    }
  }

  return null;
}
 
Example 5
Source Project: MediaSDK   Source File: CacheUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Queries the cache to obtain the request length and the number of bytes already cached for a
 * given {@link DataSpec}.
 *
 * @param dataSpec Defines the data to be checked.
 * @param cache A {@link Cache} which has the data.
 * @param cacheKeyFactory An optional factory for cache keys.
 * @return A pair containing the request length and the number of bytes that are already cached.
 */
public static Pair<Long, Long> getCached(
    DataSpec dataSpec, Cache cache, @Nullable CacheKeyFactory cacheKeyFactory) {
  String key = buildCacheKey(dataSpec, cacheKeyFactory);
  long position = dataSpec.absoluteStreamPosition;
  long requestLength = getRequestLength(dataSpec, cache, key);
  long bytesAlreadyCached = 0;
  long bytesLeft = requestLength;
  while (bytesLeft != 0) {
    long blockLength =
        cache.getCachedLength(
            key, position, bytesLeft != C.LENGTH_UNSET ? bytesLeft : Long.MAX_VALUE);
    if (blockLength > 0) {
      bytesAlreadyCached += blockLength;
    } else {
      blockLength = -blockLength;
      if (blockLength == Long.MAX_VALUE) {
        break;
      }
    }
    position += blockLength;
    bytesLeft -= bytesLeft == C.LENGTH_UNSET ? 0 : blockLength;
  }
  return Pair.create(requestLength, bytesAlreadyCached);
}
 
Example 6
Source Project: MediaSDK   Source File: SinglePeriodTimeline.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Creates a timeline with one period, and a window of known duration starting at a specified
 * position in the period.
 *
 * @param presentationStartTimeMs The start time of the presentation in milliseconds since the
 *     epoch.
 * @param windowStartTimeMs The window's start time in milliseconds since the epoch.
 * @param periodDurationUs The duration of the period in microseconds.
 * @param windowDurationUs The duration of the window in microseconds.
 * @param windowPositionInPeriodUs The position of the start of the window in the period, in
 *     microseconds.
 * @param windowDefaultStartPositionUs The default position relative to the start of the window at
 *     which to begin playback, in microseconds.
 * @param isSeekable Whether seeking is supported within the window.
 * @param isDynamic Whether the window may change when the timeline is updated.
 * @param isLive Whether the window is live.
 * @param manifest The manifest. May be {@code null}.
 * @param tag A tag used for {@link Timeline.Window#tag}.
 */
public SinglePeriodTimeline(
    long presentationStartTimeMs,
    long windowStartTimeMs,
    long periodDurationUs,
    long windowDurationUs,
    long windowPositionInPeriodUs,
    long windowDefaultStartPositionUs,
    boolean isSeekable,
    boolean isDynamic,
    boolean isLive,
    @Nullable Object manifest,
    @Nullable Object tag) {
  this.presentationStartTimeMs = presentationStartTimeMs;
  this.windowStartTimeMs = windowStartTimeMs;
  this.periodDurationUs = periodDurationUs;
  this.windowDurationUs = windowDurationUs;
  this.windowPositionInPeriodUs = windowPositionInPeriodUs;
  this.windowDefaultStartPositionUs = windowDefaultStartPositionUs;
  this.isSeekable = isSeekable;
  this.isDynamic = isDynamic;
  this.isLive = isLive;
  this.manifest = manifest;
  this.tag = tag;
}
 
Example 7
Source Project: MediaSDK   Source File: MediaCodecRenderer.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param trackType The track type that the renderer handles. One of the {@code C.TRACK_TYPE_*}
 *     constants defined in {@link C}.
 * @param mediaCodecSelector A decoder selector.
 * @param drmSessionManager For use with encrypted media. May be null if support for encrypted
 *     media is not required.
 * @param playClearSamplesWithoutKeys Encrypted media may contain clear (un-encrypted) regions.
 *     For example a media file may start with a short clear region so as to allow playback to
 *     begin in parallel with key acquisition. This parameter specifies whether the renderer is
 *     permitted to play clear regions of encrypted media files before {@code drmSessionManager}
 *     has obtained the keys necessary to decrypt encrypted regions of the media.
 * @param enableDecoderFallback Whether to enable fallback to lower-priority decoders if decoder
 *     initialization fails. This may result in using a decoder that is less efficient or slower
 *     than the primary decoder.
 * @param assumedMinimumCodecOperatingRate A codec operating rate that all codecs instantiated by
 *     this renderer are assumed to meet implicitly (i.e. without the operating rate being set
 *     explicitly using {@link MediaFormat#KEY_OPERATING_RATE}).
 */
public MediaCodecRenderer(
    int trackType,
    MediaCodecSelector mediaCodecSelector,
    @Nullable DrmSessionManager<FrameworkMediaCrypto> drmSessionManager,
    boolean playClearSamplesWithoutKeys,
    boolean enableDecoderFallback,
    float assumedMinimumCodecOperatingRate) {
  super(trackType);
  this.mediaCodecSelector = Assertions.checkNotNull(mediaCodecSelector);
  this.drmSessionManager = drmSessionManager;
  this.playClearSamplesWithoutKeys = playClearSamplesWithoutKeys;
  this.enableDecoderFallback = enableDecoderFallback;
  this.assumedMinimumCodecOperatingRate = assumedMinimumCodecOperatingRate;
  buffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_DISABLED);
  flagsOnlyBuffer = DecoderInputBuffer.newFlagsOnlyInstance();
  formatQueue = new TimedValueQueue<>();
  decodeOnlyPresentationTimestamps = new ArrayList<>();
  outputBufferInfo = new MediaCodec.BufferInfo();
  codecReconfigurationState = RECONFIGURATION_STATE_NONE;
  codecDrainState = DRAIN_STATE_NONE;
  codecDrainAction = DRAIN_ACTION_NONE;
  codecOperatingRate = CODEC_OPERATING_RATE_UNSET;
  rendererOperatingRate = 1f;
  renderTimeLimitMs = C.TIME_UNSET;
}
 
Example 8
Source Project: mollyim-android   Source File: Contact.java    License: GNU General Public License v3.0 6 votes vote down vote up
PostalAddress(@JsonProperty("type")         @NonNull  Type   type,
              @JsonProperty("label")        @Nullable String label,
              @JsonProperty("street")       @Nullable String street,
              @JsonProperty("poBox")        @Nullable String poBox,
              @JsonProperty("neighborhood") @Nullable String neighborhood,
              @JsonProperty("city")         @Nullable String city,
              @JsonProperty("region")       @Nullable String region,
              @JsonProperty("postalCode")   @Nullable String postalCode,
              @JsonProperty("country")      @Nullable String country)
{
  this.type         = type;
  this.label        = label;
  this.street       = street;
  this.poBox        = poBox;
  this.neighborhood = neighborhood;
  this.city         = city;
  this.region       = region;
  this.postalCode   = postalCode;
  this.country      = country;
  this.selected     = true;
}
 
Example 9
ConversationAdapter(@NonNull GlideRequests glideRequests,
                    @NonNull Locale locale,
                    @Nullable ItemClickListener clickListener,
                    @NonNull Recipient recipient)
{
  super(new DiffCallback());

  this.glideRequests       = glideRequests;
  this.locale              = locale;
  this.clickListener       = clickListener;
  this.recipient           = recipient;
  this.selected            = new HashSet<>();
  this.fastRecords         = new ArrayList<>();
  this.releasedFastRecords = new HashSet<>();
  this.calendar            = Calendar.getInstance();
  this.digest              = getMessageDigestOrThrow();

  setHasStableIds(true);
}
 
Example 10
Source Project: BaldPhone   Source File: PillTimeSetterActivity.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reminder_time_setter);
    hour = findViewById(R.id.chooser_hours);
    minute = findViewById(R.id.chooser_minutes);
    multipleSelection = findViewById(R.id.multiple_selection);
    multipleSelection.addSelection(R.string.morning, R.string.afternoon, R.string.evening);
    applyChoosers();

    multipleSelection.setOnItemClickListener(i -> applyChoosers());

    final View.OnClickListener onClickListener =
            v -> BPrefs.setHourAndMinute(
                    this,
                    multipleSelection.getSelection(),
                    hour.getNumber(),
                    minute.getNumber());
    hour.setOnClickListener(onClickListener);
    minute.setOnClickListener(onClickListener);

}
 
Example 11
/**
 * Makes a best-effort guess about which navigation bar color will be used when the Trusted Web
 * Activity is launched. Returns null if not possible to predict.
 */
@Nullable
Integer getExpectedNavbarColor(Context context, String providerPackage,
        TrustedWebActivityIntentBuilder builder) {
    Intent intent = builder.buildCustomTabsIntent().intent;
    if (providerSupportsNavBarColorCustomization(context, providerPackage)) {
        if (providerSupportsColorSchemeParams(context, providerPackage)) {
            int colorScheme = getExpectedColorScheme(context, builder);
            CustomTabColorSchemeParams params = CustomTabsIntent.getColorSchemeParams(intent,
                    colorScheme);
            return params.navigationBarColor;
        }
        Bundle extras = intent.getExtras();
        return extras == null ? null :
                (Integer) extras.get(CustomTabsIntent.EXTRA_NAVIGATION_BAR_COLOR);
    }
    if (ChromeLegacyUtils.usesWhiteNavbar(providerPackage)) {
        return Color.WHITE;
    }
    return null;
}
 
Example 12
Source Project: candybar   Source File: UrlHelper.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
public static Drawable getSocialIcon(@NonNull Context context, @NonNull Type type) {
    int color = ConfigurationHelper.getSocialIconColor(context, CandyBarApplication.getConfiguration().getSocialIconColor());
    switch (type) {
        case EMAIL:
            return getTintedDrawable(context, R.drawable.ic_toolbar_email, color);
        case BEHANCE:
            return getTintedDrawable(context, R.drawable.ic_toolbar_behance, color);
        case DRIBBBLE:
            return getTintedDrawable(context, R.drawable.ic_toolbar_dribbble, color);
        case FACEBOOK:
            return getTintedDrawable(context, R.drawable.ic_toolbar_facebook, color);
        case GITHUB:
            return getTintedDrawable(context, R.drawable.ic_toolbar_github, color);
        case INSTAGRAM:
            return getTintedDrawable(context, R.drawable.ic_toolbar_instagram, color);
        case PINTEREST:
            return getTintedDrawable(context, R.drawable.ic_toolbar_pinterest, color);
        case TWITTER:
            return getTintedDrawable(context, R.drawable.ic_toolbar_twitter, color);
        case TELEGRAM:
            return getTintedDrawable(context, R.drawable.ic_toolbar_telegram, color);
        default:
            return getTintedDrawable(context, R.drawable.ic_toolbar_website, color);
    }
}
 
Example 13
Source Project: android-browser-helper   Source File: TwaLauncher.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Same as above, but also accepts a session id. This allows to launch multiple TWAs in the same
 * task.
 */
public TwaLauncher(Context context, @Nullable String providerPackage, int sessionId,
                   TokenStore tokenStore) {
    mContext = context;
    mSessionId = sessionId;
    mTokenStore = tokenStore;
    if (providerPackage == null) {
        TwaProviderPicker.Action action =
                TwaProviderPicker.pickProvider(context.getPackageManager());
        mProviderPackage = action.provider;
        mLaunchMode = action.launchMode;
    } else {
        mProviderPackage = providerPackage;
        mLaunchMode = TwaProviderPicker.LaunchMode.TRUSTED_WEB_ACTIVITY;
    }
}
 
Example 14
public @Nullable PreKeyRecord getPreKey(int keyId) {
  SQLiteDatabase database = databaseHelper.getReadableDatabase();

  try (Cursor cursor = database.query(TABLE_NAME, null, KEY_ID + " = ?",
                                      new String[] {String.valueOf(keyId)},
                                      null, null, null))
  {
    if (cursor != null && cursor.moveToFirst()) {
      try {
        ECPublicKey  publicKey  = Curve.decodePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PUBLIC_KEY))), 0);
        ECPrivateKey privateKey = Curve.decodePrivatePoint(Base64.decode(cursor.getString(cursor.getColumnIndexOrThrow(PRIVATE_KEY))));

        return new PreKeyRecord(keyId, new ECKeyPair(publicKey, privateKey));
      } catch (InvalidKeyException | IOException e) {
        Log.w(TAG, e);
      }
    }
  }

  return null;
}
 
Example 15
Source Project: MediaSDK   Source File: DownloadManager.java    License: Apache License 2.0 6 votes vote down vote up
private void onDownloadTaskStopped(Download download, @Nullable Throwable finalError) {
  download =
      new Download(
          download.request,
          finalError == null ? STATE_COMPLETED : STATE_FAILED,
          download.startTimeMs,
          /* updateTimeMs= */ System.currentTimeMillis(),
          download.contentLength,
          download.stopReason,
          finalError == null ? FAILURE_REASON_NONE : FAILURE_REASON_UNKNOWN,
          download.progress);
  // The download is now in a terminal state, so should not be in the downloads list.
  downloads.remove(getDownloadIndex(download.request.id));
  // We still need to update the download index and main thread.
  try {
    downloadIndex.putDownload(download);
  } catch (IOException e) {
    Log.e(TAG, "Failed to update index.", e);
  }
  DownloadUpdate update =
      new DownloadUpdate(download, /* isRemove= */ false, new ArrayList<>(downloads));
  mainHandler.obtainMessage(MSG_DOWNLOAD_UPDATE, update).sendToTarget();
}
 
Example 16
Source Project: arcusandroid   Source File: SceneActionSelectionFragment.java    License: Apache License 2.0 6 votes vote down vote up
/**
 *
 * Updates, or adds, the provided context to the list of context variables for this template.
 * Returns a list of remaining settings to set on the scene model and commit to the platform.
 *
 * If the provided list is null, it will remove it from the context.
 *
 * @return
 */
private List<Map<String, Object>> updateActions(@Nullable Map<String, Map<String, Object>> context) {
    SceneModel model = getController().getSceneModel();
    if (model == null) {
        return new ArrayList<>();
    }

    List<Map<String, Object>> newValues = new LinkedList<>();
    if (context != null && !context.isEmpty()) { // Still have stuff to save?
        Action action = new Action();
        action.setTemplate(getController().getActionTemplate().getId());
        action.setName(getController().getActionTemplate().getName());
        action.setContext(context);
        newValues.add(action.toMap());
    }

    for (Map<String, Object> actionsModel : model.getActions()) { // Rebuild save list
        Action actionName = new Action(actionsModel);
        if (!getController().getActionTemplate().getId().equals(actionName.getTemplate())) {
            newValues.add(actionName.toMap());
        }
    }

    return newValues;
}
 
Example 17
Source Project: arcusandroid   Source File: CareActivityFragment.java    License: Apache License 2.0 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);
    if (view == null) {
        return null;
    }

    filterDetailText = (TextView) view.findViewById(R.id.care_activity_filter_details);

    careFilterContainer = view.findViewById(R.id.care_filter_container);
    if (careFilterContainer != null) {
        careFilterContainer.setOnClickListener(this);
    }

    careSelectedDayTV = (TextView) view.findViewById(R.id.care_activity_current_day);
    if (careSelectedDayTV != null) {
        careSelectedDayTV.setOnClickListener(this);
    }

    careZoomIV = view.findViewById(R.id.care_activity_zoom);
    if (careZoomIV != null) {
        careZoomIV.setOnClickListener(this);
    }

    activityEventView = (ActivityEventView) view.findViewById(R.id.care_half_activity_graph);
    historyView = (ListView) view.findViewById(R.id.care_activity_history);
    return view;
}
 
Example 18
Source Project: MediaSDK   Source File: DashManifestParser.java    License: Apache License 2.0 5 votes vote down vote up
@C.RoleFlags
protected int parseDashRoleSchemeValue(@Nullable String value) {
  if (value == null) {
    return 0;
  }
  switch (value) {
    case "main":
      return C.ROLE_FLAG_MAIN;
    case "alternate":
      return C.ROLE_FLAG_ALTERNATE;
    case "supplementary":
      return C.ROLE_FLAG_SUPPLEMENTARY;
    case "commentary":
      return C.ROLE_FLAG_COMMENTARY;
    case "dub":
      return C.ROLE_FLAG_DUB;
    case "emergency":
      return C.ROLE_FLAG_EMERGENCY;
    case "caption":
      return C.ROLE_FLAG_CAPTION;
    case "subtitle":
      return C.ROLE_FLAG_SUBTITLE;
    case "sign":
      return C.ROLE_FLAG_SIGN;
    case "description":
      return C.ROLE_FLAG_DESCRIBES_VIDEO;
    case "enhanced-audio-intelligibility":
      return C.ROLE_FLAG_ENHANCED_DIALOG_INTELLIGIBILITY;
    default:
      return 0;
  }
}
 
Example 19
void bind(@NonNull  Recipient     contactResult,
          @NonNull  GlideRequests glideRequests,
          @NonNull  EventListener eventListener,
          @NonNull  Locale        locale,
          @Nullable String        query)
{
  root.bind(contactResult, glideRequests, locale, query);
  root.setOnClickListener(view -> eventListener.onContactClicked(contactResult));
}
 
Example 20
Source Project: arcusandroid   Source File: BaseFragment.java    License: Apache License 2.0 5 votes vote down vote up
public void updateHubConnection(@Nullable final String hubState) {
    Activity activity = getActivity();
    if (activity == null) {
        return; // If we've become detached, called before we're attached, or activity is destroyed.
    }

    BannerManager.in(activity).removeBanner(NoConnectionBanner.class);
    BannerManager.in(activity).removeBanner(NoHubConnectionBanner.class);
    BannerManager.in(activity).removeBanner(InvitationBanner.class);
    BannerManager.in(activity).removeBanner(RunningOnBatteryBanner.class);

    if (Hub.STATE_DOWN.equals(hubState)) {
        if (this instanceof HomeFragment) {
            displayHubNoConnectionBanner();
        }
        else {
            displayNoConnectionBanner();
            updateBackground(false);
        }
    } else if (Hub.STATE_NORMAL.equals(hubState)) {
        // If the hub just came back online, check power source in case
        // line power was lost while it was down, or line power
        // was restored while the hub went offline while on battery
        checkHubPower();

    } else if (HubPower.SOURCE_BATTERY.equals(hubState)){
        displayRunOnBatteryBanner();
    } else {
        if (!(this instanceof HomeFragment)) {
            updateBackground(true);
        }
    }
}
 
Example 21
Source Project: arcusandroid   Source File: SceneActionSelectionFragment.java    License: Apache License 2.0 5 votes vote down vote up
private @Nullable SceneDefaultSelectorAdapter getSceneAdapter() {
    Adapter adapter = deviceListView.getAdapter();
    if (adapter == null || !(adapter instanceof SceneDefaultSelectorAdapter)) {
        return null;
    }

    return (SceneDefaultSelectorAdapter) adapter;
}
 
Example 22
Source Project: bitgatt   Source File: BitgattLeScanner.java    License: Mozilla Public License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.O)
@Override
public int startScan(@Nullable List<ScanFilter> filters, @Nullable ScanSettings settings, @NonNull PendingIntent callbackIntent) {
    if(leScanner == null || !FitbitGatt.atLeastSDK(Build.VERSION_CODES.O)) {
        Timber.w("The scanner was null, context or adapter was null");
        return ScanCallback.SCAN_FAILED_INTERNAL_ERROR;
    }
    return leScanner.startScan(filters, settings, callbackIntent);
}
 
Example 23
Source Project: arcusandroid   Source File: ButtonActionController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Attempts to delete the rule associated with the given action from the selected device and
 * button.
 *
 * @param action
 */
private void deleteButtonAction(@NonNull final ButtonAction action, @Nullable final ButtonActionDeletionListener listener) {
    logger.debug("Removing action {} from button {} of device {}.", action, selectedButton, selectedButtonDevice);

    RuleModelProvider
            .instance()
            .getRules()
            .onSuccess(Listeners.runOnUiThread(rules -> {
                logger.debug("Loaded rules; got {} rule instances.", rules.size());

                RuleModel rule = getRuleAttachedToAction(rules, action, selectedButton, selectedDeviceAddress);

                if (rule != null) {

                    fireOnLoading();
                    rule.delete().onSuccess(new Listener<Rule.DeleteResponse>() {
                        @Override
                        public void onEvent(Rule.DeleteResponse deleteResponse) {
                            logger.debug("Successfully removed action rule {} from button {} of device {}.", action, selectedButton, selectedButtonDevice);
                            if (listener != null) {
                                listener.onButtonActionDeleted();
                            }
                        }
                    }).onFailure(new Listener<Throwable>() {
                        @Override
                        public void onEvent(Throwable throwable) {
                            logger.debug("An error occured removing action {} from button {} of device {}.", action, selectedButton, selectedButtonDevice);
                            fireOnError(throwable);
                        }
                    });
                } else {
                    logger.error("Failed to remove action {} from button {} of device {} because the action could not be resolved to a rule. This button may have multiple actions attached to it.", action, selectedButton, selectedButtonDevice);
                }
            }))
            .onFailure(Listeners.runOnUiThread(throwable -> {
                logger.error("Failed to load rules due to: {}. Button action not deleted; this button may have multiple actions attached to it.", throwable.getMessage());
                fireOnError(throwable);
            }));
}
 
Example 24
Source Project: arcusandroid   Source File: ImageLocator.java    License: Apache License 2.0 5 votes vote down vote up
@Nullable
private String getSceneActionTemplateUrl (String actionTypeHint) {
    String encodedActionTypeHint = StringUtils.sanitize(actionTypeHint);
    try {
        return getBaseUrl() + "/o/actions/" + encodedActionTypeHint + "/" + encodedActionTypeHint + "_small-and-" + ImageUtils.getScreenDensity() + ".png";
    } catch (IOException e) {
        return null;
    }
}
 
Example 25
protected IncomingTextMessage(@NonNull Address sender, @Nullable Address groupId) {
    this.message = "";
    this.sender = sender;
    this.senderDeviceId = SignalServiceAddress.DEFAULT_DEVICE_ID;
    this.protocol = 31338;
    this.serviceCenterAddress = "Outgoing";
    this.replyPathPresent = true;
    this.pseudoSubject = "";
    this.sentTimestampMillis = System.currentTimeMillis();
    this.groupId = groupId;
    this.push = true;
    this.subscriptionId = -1;
    this.expiresInMillis = 0;
}
 
Example 26
Source Project: MediaSDK   Source File: SimpleExoPlayer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setVideoTextureView(@Nullable TextureView textureView) {
  verifyApplicationThread();
  removeSurfaceCallbacks();
  if (textureView != null) {
    clearVideoDecoderOutputBufferRenderer();
  }
  this.textureView = textureView;
  if (textureView == null) {
    setVideoSurfaceInternal(/* surface= */ null, /* ownsSurface= */ true);
    maybeNotifySurfaceSizeChanged(/* width= */ 0, /* height= */ 0);
  } else {
    if (textureView.getSurfaceTextureListener() != null) {
      Log.w(TAG, "Replacing existing SurfaceTextureListener.");
    }
    textureView.setSurfaceTextureListener(componentListener);
    SurfaceTexture surfaceTexture =
        textureView.isAvailable() ? textureView.getSurfaceTexture() : null;
    if (surfaceTexture == null) {
      setVideoSurfaceInternal(/* surface= */ null, /* ownsSurface= */ true);
      maybeNotifySurfaceSizeChanged(/* width= */ 0, /* height= */ 0);
    } else {
      setVideoSurfaceInternal(new Surface(surfaceTexture), /* ownsSurface= */ true);
      maybeNotifySurfaceSizeChanged(textureView.getWidth(), textureView.getHeight());
    }
  }
}
 
Example 27
Source Project: MediaSDK   Source File: DashMediaSource.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new factory for {@link DashMediaSource}s.
 *
 * @param chunkSourceFactory A factory for {@link DashChunkSource} instances.
 * @param manifestDataSourceFactory A factory for {@link DataSource} instances that will be used
 *     to load (and refresh) the manifest. May be {@code null} if the factory will only ever be
 *     used to create create media sources with sideloaded manifests via {@link
 *     #createMediaSource(DashManifest, Handler, MediaSourceEventListener)}.
 */
public Factory(
    DashChunkSource.Factory chunkSourceFactory,
    @Nullable DataSource.Factory manifestDataSourceFactory) {
  this.chunkSourceFactory = Assertions.checkNotNull(chunkSourceFactory);
  this.manifestDataSourceFactory = manifestDataSourceFactory;
  drmSessionManager = DrmSessionManager.getDummyDrmSessionManager();
  loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy();
  livePresentationDelayMs = DEFAULT_LIVE_PRESENTATION_DELAY_MS;
  compositeSequenceableLoaderFactory = new DefaultCompositeSequenceableLoaderFactory();
}
 
Example 28
Source Project: MediaSDK   Source File: DownloadService.java    License: Apache License 2.0 5 votes vote down vote up
/** @deprecated Use {@link #DownloadService(int, long, String, int, int)}. */
@Deprecated
protected DownloadService(
    int foregroundNotificationId,
    long foregroundNotificationUpdateInterval,
    @Nullable String channelId,
    @StringRes int channelNameResourceId) {
  this(
      foregroundNotificationId,
      foregroundNotificationUpdateInterval,
      channelId,
      channelNameResourceId,
      /* channelDescriptionResourceId= */ 0);
}
 
Example 29
@NonNull
@Override
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
  Dialog dialog = super.onCreateDialog(savedInstanceState);
  dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
  return dialog;
}
 
Example 30
Source Project: MediaSDK   Source File: HlsChunkSource.java    License: Apache License 2.0 5 votes vote down vote up
public EncryptionKeyChunk(
    DataSource dataSource,
    DataSpec dataSpec,
    Format trackFormat,
    int trackSelectionReason,
    @Nullable Object trackSelectionData,
    byte[] scratchSpace) {
  super(dataSource, dataSpec, C.DATA_TYPE_DRM, trackFormat, trackSelectionReason,
      trackSelectionData, scratchSpace);
}