Search in sources :

Example 86 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class HexagonTools method buildAccountService.

/**
     * Creates and returns a new instance for this hexagon service or null if not signed in.
     */
@Nullable
public synchronized Account buildAccountService() {
    GoogleAccountCredential credential = getAccountCredential(true);
    if (credential.getSelectedAccount() == null) {
        return null;
    }
    Account.Builder builder = new Account.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential);
    return CloudEndpointUtils.updateBuilder(app, builder).build();
}
Also used : GoogleSignInAccount(com.google.android.gms.auth.api.signin.GoogleSignInAccount) Account(com.uwetrottmann.seriesguide.backend.account.Account) GoogleAccountCredential(com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential) Nullable(android.support.annotation.Nullable)

Example 87 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class TvdbTools method searchSeries.

@Nullable
public List<SearchResult> searchSeries(@NonNull String query, @Nullable final String language) throws TvdbException {
    retrofit2.Response<SeriesResultsResponse> response;
    try {
        response = tvdbSearch.get().series(query, null, null, language).execute();
    } catch (IOException e) {
        throw new TvdbException("searchSeries: " + e.getMessage(), e);
    }
    if (response.code() == 404) {
        // API returns 404 if there are no search results
        return null;
    }
    ensureSuccessfulResponse(response.raw(), "searchSeries: ");
    List<Series> tvdbResults = response.body().data;
    if (tvdbResults == null || tvdbResults.size() == 0) {
        // no results from tvdb
        return null;
    }
    // parse into our data format
    List<SearchResult> results = new ArrayList<>(tvdbResults.size());
    for (Series tvdbResult : tvdbResults) {
        SearchResult result = new SearchResult();
        result.tvdbid = tvdbResult.id;
        result.title = tvdbResult.seriesName;
        result.overview = tvdbResult.overview;
        result.language = language;
        results.add(result);
    }
    return results;
}
Also used : TheTvdbSeries(com.uwetrottmann.thetvdb.services.TheTvdbSeries) Series(com.uwetrottmann.thetvdb.entities.Series) SeriesResultsResponse(com.uwetrottmann.thetvdb.entities.SeriesResultsResponse) ArrayList(java.util.ArrayList) SearchResult(com.battlelancer.seriesguide.items.SearchResult) IOException(java.io.IOException) Nullable(android.support.annotation.Nullable)

Example 88 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class AboutSettingsFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_about, container, false);
    unbinder = ButterKnife.bind(this, v);
    // display version number and database version
    textVersion.setText(Utils.getVersionString(getActivity()));
    buttonWebsite.setOnClickListener(urlButtonClickListener);
    buttonTvdbTerms.setOnClickListener(urlButtonClickListener);
    buttonCreativeCommons.setOnClickListener(urlButtonClickListener);
    buttonTmdbTerms.setOnClickListener(urlButtonClickListener);
    buttonTmdbApiTerms.setOnClickListener(urlButtonClickListener);
    buttonTraktTerms.setOnClickListener(urlButtonClickListener);
    buttonCredits.setOnClickListener(urlButtonClickListener);
    return v;
}
Also used : BindView(butterknife.BindView) TextView(android.widget.TextView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 89 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class LanguageTools method getMovieLanguageData.

/**
     * Returns the string representation and index of the given two letter ISO 639-1 language code
     * plus an extra ISO-3166-1 region tag used by TMDB currently set by {@link
     * DisplaySettings#getMoviesLanguage(Context)}.
     */
@Nullable
public static LanguageData getMovieLanguageData(Context context) {
    String languageCodeCurrent = DisplaySettings.getMoviesLanguage(context);
    String[] languageCodes = context.getResources().getStringArray(R.array.languageCodesMovies);
    for (int i = 0; i < languageCodes.length; i++) {
        String languageCode = languageCodes[i];
        if (languageCode.equals(languageCodeCurrent)) {
            String languageDisplayName = new Locale(languageCode.substring(0, 2), languageCode.substring(3)).getDisplayName();
            return new LanguageData(i, languageCode, languageDisplayName);
        }
    }
    return null;
}
Also used : Locale(java.util.Locale) Nullable(android.support.annotation.Nullable)

Example 90 with Nullable

use of android.support.annotation.Nullable in project SeriesGuide by UweTrottmann.

the class ShowTools method getShowTvdbIdsAndPosters.

/**
     * Returns a set of the TVDb ids of all shows in the local database mapped to their poster path
     * (null if there is no poster).
     *
     * @return null if there was an error, empty list if there are no shows.
     */
@Nullable
public static SparseArrayCompat<String> getShowTvdbIdsAndPosters(Context context) {
    SparseArrayCompat<String> existingShows = new SparseArrayCompat<>();
    Cursor shows = context.getContentResolver().query(SeriesGuideContract.Shows.CONTENT_URI, new String[] { SeriesGuideContract.Shows._ID, SeriesGuideContract.Shows.POSTER }, null, null, null);
    if (shows == null) {
        return null;
    }
    while (shows.moveToNext()) {
        existingShows.put(shows.getInt(0), shows.getString(1));
    }
    shows.close();
    return existingShows;
}
Also used : Cursor(android.database.Cursor) SparseArrayCompat(android.support.v4.util.SparseArrayCompat) Nullable(android.support.annotation.Nullable)

Aggregations

Nullable (android.support.annotation.Nullable)582 View (android.view.View)315 TextView (android.widget.TextView)163 RecyclerView (android.support.v7.widget.RecyclerView)85 BindView (butterknife.BindView)57 ImageView (android.widget.ImageView)52 ArrayList (java.util.ArrayList)43 IOException (java.io.IOException)36 Bundle (android.os.Bundle)35 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)35 Intent (android.content.Intent)32 ViewGroup (android.view.ViewGroup)32 Cursor (android.database.Cursor)29 Uri (android.net.Uri)27 File (java.io.File)24 AdapterView (android.widget.AdapterView)22 List (java.util.List)20 NonNull (android.support.annotation.NonNull)19 Context (android.content.Context)15 Bitmap (android.graphics.Bitmap)15