Search in sources :

Example 21 with TargetApi

use of android.annotation.TargetApi in project SeriesGuide by UweTrottmann.

the class DataLiberationFragment method onActivityResult.

@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode != Activity.RESULT_OK || !isAdded() || data == null) {
        return;
    }
    if (requestCode == REQUEST_CODE_SHOWS_EXPORT_URI || requestCode == REQUEST_CODE_SHOWS_IMPORT_URI || requestCode == REQUEST_CODE_LISTS_EXPORT_URI || requestCode == REQUEST_CODE_LISTS_IMPORT_URI || requestCode == REQUEST_CODE_MOVIES_EXPORT_URI || requestCode == REQUEST_CODE_MOVIES_IMPORT_URI) {
        Uri uri = data.getData();
        // try to persist read and write permission for this URI across device reboots
        try {
            getContext().getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        } catch (SecurityException e) {
            Timber.e(e, "Could not persist r/w permission for backup file URI.");
        }
        if (requestCode == REQUEST_CODE_SHOWS_EXPORT_URI) {
            BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_SHOWS_EXPORT_URI, uri);
        } else if (requestCode == REQUEST_CODE_SHOWS_IMPORT_URI) {
            BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_SHOWS_IMPORT_URI, uri);
        } else if (requestCode == REQUEST_CODE_LISTS_EXPORT_URI) {
            BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_LISTS_EXPORT_URI, uri);
        } else if (requestCode == REQUEST_CODE_LISTS_IMPORT_URI) {
            BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_LISTS_IMPORT_URI, uri);
        } else if (requestCode == REQUEST_CODE_MOVIES_EXPORT_URI) {
            BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_MOVIES_EXPORT_URI, uri);
        } else {
            BackupSettings.storeFileUri(getContext(), BackupSettings.KEY_MOVIES_IMPORT_URI, uri);
        }
        updateFileViews();
    }
}
Also used : Uri(android.net.Uri) TargetApi(android.annotation.TargetApi)

Example 22 with TargetApi

use of android.annotation.TargetApi in project SeriesGuide by UweTrottmann.

the class MoviesSearchActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_movies_search);
    setupNavDrawer();
    int linkId = getIntent().getIntExtra(EXTRA_ID_LINK, MoviesDiscoverAdapter.DISCOVER_LINK_DEFAULT.id);
    MoviesDiscoverLink link = MoviesDiscoverLink.fromId(linkId);
    showSearchView = link == MoviesDiscoverAdapter.DISCOVER_LINK_DEFAULT;
    if (savedInstanceState != null) {
        showSearchView = savedInstanceState.getBoolean(STATE_SEARCH_VISIBLE, showSearchView);
    }
    ButterKnife.bind(this);
    setupActionBar(link);
    if (savedInstanceState == null) {
        if (showSearchView) {
            Utils.showSoftKeyboardOnSearchView(this, searchView);
        }
        getSupportFragmentManager().beginTransaction().add(R.id.containerMoviesSearchFragment, MoviesSearchFragment.newInstance(link)).commit();
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            postponeEnterTransition();
            containerMoviesSearchFragment.post(new Runnable() {

                @TargetApi(Build.VERSION_CODES.LOLLIPOP)
                @Override
                public void run() {
                    // allow the adapter to repopulate during the next layout pass
                    // before starting the transition animation
                    startPostponedEnterTransition();
                }
            });
        }
    }
}
Also used : MoviesDiscoverLink(com.battlelancer.seriesguide.enums.MoviesDiscoverLink) TargetApi(android.annotation.TargetApi)

Example 23 with TargetApi

use of android.annotation.TargetApi in project Signal-Android by WhisperSystems.

the class AttachmentTypeSelector method animateWindowOutCircular.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void animateWindowOutCircular(@Nullable View anchor, @NonNull View contentView) {
    Pair<Integer, Integer> coordinates = getClickOrigin(anchor, contentView);
    Animator animator = ViewAnimationUtils.createCircularReveal(getContentView(), coordinates.first, coordinates.second, Math.max(getContentView().getWidth(), getContentView().getHeight()), 0);
    animator.setDuration(ANIMATION_DURATION);
    animator.addListener(new Animator.AnimatorListener() {

        @Override
        public void onAnimationStart(Animator animation) {
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            AttachmentTypeSelector.super.dismiss();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
        }
    });
    animator.start();
}
Also used : Animator(android.animation.Animator) TargetApi(android.annotation.TargetApi)

Example 24 with TargetApi

use of android.annotation.TargetApi in project lottie-android by airbnb.

the class MergePathsContent method opFirstPathWithRest.

@TargetApi(Build.VERSION_CODES.KITKAT)
private void opFirstPathWithRest(Path.Op op) {
    remainderPath.reset();
    firstPath.reset();
    for (int i = pathContents.size() - 1; i >= 1; i--) {
        PathContent content = pathContents.get(i);
        if (content instanceof ContentGroup) {
            List<PathContent> pathList = ((ContentGroup) content).getPathList();
            for (int j = pathList.size() - 1; j >= 0; j--) {
                Path path = pathList.get(j).getPath();
                path.transform(((ContentGroup) content).getTransformationMatrix());
                this.remainderPath.addPath(path);
            }
        } else {
            remainderPath.addPath(content.getPath());
        }
    }
    PathContent lastContent = pathContents.get(0);
    if (lastContent instanceof ContentGroup) {
        List<PathContent> pathList = ((ContentGroup) lastContent).getPathList();
        for (int j = 0; j < pathList.size(); j++) {
            Path path = pathList.get(j).getPath();
            path.transform(((ContentGroup) lastContent).getTransformationMatrix());
            this.firstPath.addPath(path);
        }
    } else {
        firstPath.set(lastContent.getPath());
    }
    path.op(firstPath, remainderPath, op);
}
Also used : Path(android.graphics.Path) TargetApi(android.annotation.TargetApi)

Example 25 with TargetApi

use of android.annotation.TargetApi in project Carbon by ZieIony.

the class RippleDrawableFroyo method getOutline.

/**
     * Populates <code>outline</code> with the first available layer outline,
     * excluding the mask layer.
     *
     * @param outline Outline in which to place the first available layer outline
     */
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void getOutline(@NonNull Outline outline) {
    final LayerState state = mLayerState;
    final ChildDrawable[] children = state.mChildren;
    final int N = state.mNum;
    for (int i = 0; i < N; i++) {
        if (children[i].mId != R.id.carbon_mask) {
            children[i].mDrawable.getOutline(outline);
            if (!outline.isEmpty())
                return;
        }
    }
}
Also used : Paint(android.graphics.Paint) TargetApi(android.annotation.TargetApi)

Aggregations

TargetApi (android.annotation.TargetApi)1367 Intent (android.content.Intent)153 View (android.view.View)148 Test (org.junit.Test)119 SuppressLint (android.annotation.SuppressLint)115 Uri (android.net.Uri)70 ArrayList (java.util.ArrayList)68 Animator (android.animation.Animator)67 Point (android.graphics.Point)64 Window (android.view.Window)56 TextView (android.widget.TextView)56 IOException (java.io.IOException)56 ViewGroup (android.view.ViewGroup)54 Matchers.anyString (org.mockito.Matchers.anyString)53 SharedPreferences (android.content.SharedPreferences)44 File (java.io.File)44 Field (java.lang.reflect.Field)44 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)43 Bitmap (android.graphics.Bitmap)43 ImageView (android.widget.ImageView)40