Search in sources :

Example 11 with SuppressLint

use of android.annotation.SuppressLint in project Android-ParallaxHeaderViewPager by kmshack.

the class PagerSlidingTabStrip method notifyDataSetChanged.

public void notifyDataSetChanged() {
    tabsContainer.removeAllViews();
    tabCount = pager.getAdapter().getCount();
    for (int i = 0; i < tabCount; i++) {
        if (pager.getAdapter() instanceof IconTabProvider) {
            addIconTab(i, ((IconTabProvider) pager.getAdapter()).getPageIconResId(i));
        } else {
            addTextTab(i, pager.getAdapter().getPageTitle(i).toString());
        }
    }
    updateTabStyles();
    getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @SuppressWarnings("deprecation")
        @SuppressLint("NewApi")
        @Override
        public void onGlobalLayout() {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                getViewTreeObserver().removeGlobalOnLayoutListener(this);
            } else {
                getViewTreeObserver().removeOnGlobalLayoutListener(this);
            }
            currentPosition = pager.getCurrentItem();
            scrollToChild(currentPosition, 0);
        }
    });
}
Also used : OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint)

Example 12 with SuppressLint

use of android.annotation.SuppressLint in project android-gif-drawable by koral--.

the class ReLinker method loadLibrary.

/**
	 * Utilizes the regular system call to attempt to load a native library. If a failure occurs,
	 * then the function extracts native .so library out of the app's APK and attempts to load it.
	 * <p/>
	 * <strong>Note: This is a synchronous operation</strong>
	 */
//intended fallback of System#loadLibrary()
@SuppressLint("UnsafeDynamicallyLoadedCode")
static void loadLibrary(Context context) {
    synchronized (ReLinker.class) {
        final File workaroundFile = unpackLibrary(context);
        System.load(workaroundFile.getAbsolutePath());
    }
}
Also used : File(java.io.File) ZipFile(java.util.zip.ZipFile) SuppressLint(android.annotation.SuppressLint)

Example 13 with SuppressLint

use of android.annotation.SuppressLint in project TwinklingRefreshLayout by lcodecorex.

the class WebActivity method onCreate.

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_web);
    TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) findViewById(R.id.refreshLayout);
    ProgressLayout header = new ProgressLayout(this);
    refreshLayout.setHeaderView(header);
    refreshLayout.setFloatRefresh(true);
    refreshLayout.setOverScrollRefreshShow(false);
    refreshLayout.setHeaderHeight(140);
    refreshLayout.setMaxHeadHeight(240);
    refreshLayout.setOverScrollHeight(200);
    refreshLayout.setEnableLoadmore(false);
    header.setColorSchemeResources(R.color.Blue, R.color.Orange, R.color.Yellow, R.color.Green);
    //        header.setColorSchemeColors(0xff4674e7,0xff0ba62c);
    mWebView = (WebView) findViewById(R.id.webView);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.loadUrl("https://dribbble.com/shots");
    refreshLayout.startRefresh();
    refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {

        @Override
        public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    refreshLayout.finishRefreshing();
                }
            }, 4000);
        }
    });
}
Also used : TwinklingRefreshLayout(com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout) RefreshListenerAdapter(com.lcodecore.tkrefreshlayout.RefreshListenerAdapter) Handler(android.os.Handler) ProgressLayout(com.lcodecore.tkrefreshlayout.header.progresslayout.ProgressLayout) SuppressLint(android.annotation.SuppressLint)

Example 14 with SuppressLint

use of android.annotation.SuppressLint in project Shuttle by timusus.

the class EqualizerActivity method onCreate.

@SuppressLint("InlinedApi")
@TargetApi(Build.VERSION_CODES.GINGERBREAD)
@Override
public void onCreate(Bundle savedInstanceState) {
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    ThemeUtils.setTheme(this);
    if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        mTintManager = new SystemBarTintManager(this);
    }
    if (!ShuttleUtils.hasKitKat()) {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    }
    if (SettingsManager.getInstance().canTintNavBar()) {
        getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
    }
    super.onCreate(savedInstanceState);
    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    setContentView(R.layout.activity_equalizer);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ThemeUtils.themeActionBar(this);
    ThemeUtils.themeStatusBar(this, mTintManager);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setTitle(getResources().getString(R.string.equalizer));
    try {
        //Query available effects
        final AudioEffect.Descriptor[] effects = AudioEffect.queryEffects();
        //Determine available/supported effects
        if (effects != null && effects.length != 0) {
            for (final AudioEffect.Descriptor effect : effects) {
                //Equalizer
                if (effect.type.equals(UUID.fromString(EFFECT_TYPE_EQUALIZER))) {
                    mEqualizerSupported = true;
                } else if (effect.type.equals(UUID.fromString(EFFECT_TYPE_BASS_BOOST))) {
                    mBassBoostSupported = true;
                } else if (effect.type.equals(UUID.fromString(EFFECT_TYPE_VIRTUALIZER))) {
                    mVirtualizerSupported = true;
                }
            }
        }
    } catch (NoClassDefFoundError ignored) {
    //The user doesn't have the AudioEffect/AudioEffect.Descriptor class. How sad.
    }
    mSpinner = (Spinner) findViewById(R.id.eqSpinner);
    mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mEqPreset = position;
            equalizerSetPreset(position);
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    setupPresets();
    if (mSpinnerAdapter != null && mSpinnerAdapter.getCount() > mEqPreset) {
        mSpinner.setSelection(mEqPreset);
    }
    //Initialize the equalizer elements
    View eqContainer = findViewById(R.id.eqContainer);
    mNumberEqualizerBands = Integer.parseInt(mPrefs.getString("equalizer.number_of_bands", "5"));
    final int[] centerFreqs = getCenterFreqs();
    final int[] bandLevelRange = getBandLevelRange();
    for (int band = 0; band < mNumberEqualizerBands; band++) {
        //Unit conversion from mHz to Hz and use k prefix if necessary to display
        float centerFreqHz = centerFreqs[band] / 1000;
        String unitPrefix = "";
        if (centerFreqHz >= 1000) {
            centerFreqHz = centerFreqHz / 1000;
            unitPrefix = "k";
        }
        (eqContainer.findViewById(eqViewElementIds[band][0])).setVisibility(View.VISIBLE);
        (eqContainer.findViewById(eqViewTextElementIds[band][0])).setVisibility(View.VISIBLE);
        (eqContainer.findViewById(eqViewElementIds[band][1])).setVisibility(View.VISIBLE);
        (eqContainer.findViewById(eqViewTextElementIds[band][1])).setVisibility(View.VISIBLE);
        ((TextView) eqContainer.findViewById(eqViewElementIds[band][0])).setText(format("%.0f ", centerFreqHz) + unitPrefix + "Hz");
        mEqualizerSeekBar[band] = (SizableSeekBar) eqContainer.findViewById(eqViewElementIds[band][1]);
        ThemeUtils.themeSeekBar(this, mEqualizerSeekBar[band]);
        mEqualizerSeekBar[band].setMax((bandLevelRange[1] / 100) - (bandLevelRange[0] / 100));
        mEqualizerSeekBar[band].setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
                if (fromUser) {
                    //Determine which band changed
                    int seekbarId = seekBar.getId();
                    int band = 0;
                    for (int i = 0; i < eqViewElementIds.length; i++) {
                        if (eqViewElementIds[i][1] == seekbarId) {
                            band = i;
                        }
                    }
                    if (mEqPreset != mEqCustomPresetPosition) {
                        equalizerCopyToCustom();
                        if (mSpinnerAdapter != null && mSpinnerAdapter.getCount() > mEqCustomPresetPosition) {
                            mSpinner.setSelection(mEqCustomPresetPosition);
                        }
                    } else {
                        int level = getBandLevelRange()[0] + (progress * 100);
                        equalizerBandUpdate(band, level);
                    }
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
            }
        });
    }
    // Set the SeekBar listener.
    if (mBassBoostSupported) {
        final SizableSeekBar seekbar = (SizableSeekBar) findViewById(R.id.bb_strength);
        ThemeUtils.themeSeekBar(this, seekbar);
        seekbar.setMax(OpenSLESConstants.BASSBOOST_MAX_STRENGTH - OpenSLESConstants.BASSBOOST_MIN_STRENGTH);
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
                // set parameter and state
                if (fromUser) {
                    mPrefs.edit().putBoolean("audiofx.bass.enable", true).apply();
                    mPrefs.edit().putString("audiofx.bass.strength", String.valueOf(progress)).apply();
                    mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
                }
            }

            // If slider pos was 0 when starting re-enable effect
            @Override
            public void onStartTrackingTouch(final SeekBar seekBar) {
                if (seekBar.getProgress() == 0) {
                    mPrefs.edit().putBoolean("audiofx.bass.enable", true).apply();
                    mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
                }
            }

            // If slider pos = 0 when stopping disable effect
            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                if (seekBar.getProgress() == 0) {
                    // disable
                    mPrefs.edit().putBoolean("audiofx.bass.enable", false).apply();
                    mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
                }
            }
        });
    }
    // Set the SeekBar listener.
    if (mVirtualizerSupported) {
        final SizableSeekBar seekbar = (SizableSeekBar) findViewById(R.id.virtualizer_strength);
        ThemeUtils.themeSeekBar(this, seekbar);
        seekbar.setMax(OpenSLESConstants.VIRTUALIZER_MAX_STRENGTH - OpenSLESConstants.VIRTUALIZER_MIN_STRENGTH);
        seekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override
            public void onProgressChanged(final SeekBar seekBar, final int progress, final boolean fromUser) {
                // set parameter and state
                if (fromUser) {
                    mPrefs.edit().putBoolean("audiofx.virtualizer.enable", true).apply();
                    mPrefs.edit().putString("audiofx.virtualizer.strength", String.valueOf(progress)).apply();
                    mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
                }
            }

            // If slider pos was 0 when starting re-enable effect
            @Override
            public void onStartTrackingTouch(final SeekBar seekBar) {
                if (seekBar.getProgress() == 0) {
                    mPrefs.edit().putBoolean("audiofx.virtualizer.enable", true).apply();
                    mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
                }
            }

            // If slider pos = 0 when stopping disable effect
            @Override
            public void onStopTrackingTouch(final SeekBar seekBar) {
                if (seekBar.getProgress() == 0) {
                    // disable
                    mPrefs.edit().putBoolean("audiofx.virtualizer.enable", false).apply();
                    mHandler.sendEmptyMessage(MSG_UPDATE_SERVICE);
                }
            }
        });
    }
}
Also used : SizableSeekBar(com.simplecity.amp_library.ui.views.SizableSeekBar) SeekBar(android.widget.SeekBar) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) SizableSeekBar(com.simplecity.amp_library.ui.views.SizableSeekBar) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar) AudioEffect(android.media.audiofx.AudioEffect) SuppressLint(android.annotation.SuppressLint) TargetApi(android.annotation.TargetApi)

Example 15 with SuppressLint

use of android.annotation.SuppressLint in project Shuttle by timusus.

the class MainActivity method onCreate.

@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
    if (!ShuttleUtils.isUpgraded() && !ShuttleUtils.isAmazonBuild()) {
        IabManager.getInstance();
    }
    ThemeUtils.setTheme(this);
    if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
        getWindow().setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
        mTintManager = new SystemBarTintManager(this);
    }
    if (ShuttleUtils.hasLollipop()) {
        getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    if (SettingsManager.getInstance().canTintNavBar()) {
        getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
    }
    supportRequestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    // Now call super to ensure the theme was properly set
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mIsSlidingEnabled = getResources().getBoolean(R.bool.isSlidingEnabled);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mDummyStatusBar = (FrameLayout) findViewById(R.id.dummyStatusBar);
    if (ShuttleUtils.hasKitKat()) {
        mDummyStatusBar.setVisibility(View.VISIBLE);
        mDummyStatusBar.setBackgroundColor(ColorUtils.getPrimaryColorDark(this));
        LinearLayout.LayoutParams statusBarParams = new LinearLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, (int) ActionBarUtils.getStatusBarHeight(this));
        mDummyStatusBar.setLayoutParams(statusBarParams);
    }
    setSupportActionBar(mToolbar);
    ThemeUtils.themeStatusBar(this, mTintManager);
    mNavigationDrawerFragment = (NavigationDrawerFragment) getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
    mTitle = getString(R.string.library_title);
    mDrawerLayout = (CustomDrawerLayout) findViewById(R.id.drawer_layout);
    if (ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    mDrawerLayout.setStatusBarBackgroundColor(ShuttleUtils.hasLollipop() ? ColorUtils.getPrimaryColorDark(this) : ColorUtils.getPrimaryColor());
    mNavigationDrawerFragment.setup((DrawerLayout) findViewById(R.id.drawer_layout));
    if (mIsSlidingEnabled) {
        mSlidingUpPanelLayout = (SlidingUpPanelLayout) findViewById(R.id.container);
        setDragView(null, false);
        //The second panel slide offset is mini player height + toolbar height + status bar height.
        //This gets our 'up next' sitting snugly underneath the toolbar
        int offset = (int) (ActionBarUtils.getActionBarHeight(this) + (ShuttleUtils.hasKitKat() ? ActionBarUtils.getStatusBarHeight(this) : 0) - getResources().getDimension(R.dimen.mini_player_height));
        mSlidingUpPanelLayout.setSlidePanelOffset(-offset);
        mSlidingUpPanelLayout.hidePanel();
        mSlidingUpPanelLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {

            @Override
            public void onPanelSlide(View panel, float slideOffset) {
                setActionBarAlpha(slideOffset, false);
                boolean canChangeElevation = true;
                Fragment playingFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
                if (playingFragment != null) {
                    Fragment childFragment = playingFragment.getChildFragmentManager().findFragmentById(R.id.queue_container);
                    if (childFragment != null && childFragment instanceof QueueFragment) {
                        canChangeElevation = false;
                    }
                }
                if (canChangeElevation) {
                    getSupportActionBar().setElevation(ResourceUtils.toPixels(4) * slideOffset);
                }
                mNavigationDrawerFragment.animateDrawerToggle(slideOffset);
            }

            @Override
            public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
                switch(newState) {
                    case COLLAPSED:
                        {
                            setDragView(null, false);
                            mTitle = getString(R.string.library_title);
                            supportInvalidateOptionsMenu();
                            toggleQueue(false);
                            mNavigationDrawerFragment.toggleDrawerLock(false);
                            break;
                        }
                    case EXPANDED:
                        {
                            Fragment playerFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
                            if (playerFragment != null && playerFragment instanceof PlayerFragment) {
                                setDragView(((PlayerFragment) playerFragment).getDragView(), true);
                                if (((PlayerFragment) playerFragment).isQueueShowing()) {
                                    toggleQueue(true);
                                }
                            }
                            mTitle = getString(R.string.nowplaying_title);
                            supportInvalidateOptionsMenu();
                            mNavigationDrawerFragment.toggleDrawerLock(true);
                            break;
                        }
                }
            }
        });
    }
    if (savedInstanceState != null && mIsSlidingEnabled) {
        if (savedInstanceState.getBoolean(ARG_EXPANDED, false)) {
            final ActionBar actionBar = getSupportActionBar();
            //If the sliding panel was previously expanded, expand it again.
            mSlidingUpPanelLayout.post(() -> {
                mSlidingUpPanelLayout.setPanelState(SlidingUpPanelLayout.PanelState.EXPANDED, false);
                setActionBarAlpha(1f, false);
            });
            mTitle = getString(R.string.nowplaying_title);
            if (actionBar != null) {
                actionBar.setTitle(mTitle);
            }
            Fragment playingFragment = getSupportFragmentManager().findFragmentById(R.id.player_container);
            if (playingFragment != null) {
                Fragment childFragment = playingFragment.getChildFragmentManager().findFragmentById(R.id.queue_container);
                if (childFragment != null && childFragment instanceof QueueFragment) {
                    toggleQueue(true);
                }
            }
        }
    }
    if (savedInstanceState == null) {
        getSupportFragmentManager().beginTransaction().add(R.id.main_container, MainFragment.newInstance()).commit();
        getSupportFragmentManager().beginTransaction().add(R.id.mini_player_container, MiniPlayerFragment.newInstance()).commit();
        if (mIsSlidingEnabled) {
            getSupportFragmentManager().beginTransaction().add(R.id.player_container, PlayerFragment.newInstance()).commit();
        }
    }
    themeTaskDescription();
    handleIntent(getIntent());
}
Also used : SlidingUpPanelLayout(com.sothree.slidinguppanel.SlidingUpPanelLayout) SystemBarTintManager(com.readystatesoftware.systembartint.SystemBarTintManager) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) View(android.view.View) FolderFragment(com.simplecity.amp_library.ui.fragments.FolderFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) PlayerFragment(com.simplecity.amp_library.ui.fragments.PlayerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) AlbumArtistFragment(com.simplecity.amp_library.ui.fragments.AlbumArtistFragment) NavigationDrawerFragment(com.simplecity.amp_library.ui.fragments.NavigationDrawerFragment) PlaylistFragment(com.simplecity.amp_library.ui.fragments.PlaylistFragment) GenreFragment(com.simplecity.amp_library.ui.fragments.GenreFragment) DetailFragment(com.simplecity.amp_library.ui.fragments.DetailFragment) SuggestedFragment(com.simplecity.amp_library.ui.fragments.SuggestedFragment) MainFragment(com.simplecity.amp_library.ui.fragments.MainFragment) AlbumFragment(com.simplecity.amp_library.ui.fragments.AlbumFragment) MiniPlayerFragment(com.simplecity.amp_library.ui.fragments.MiniPlayerFragment) SuppressLint(android.annotation.SuppressLint) LinearLayout(android.widget.LinearLayout) ActionBar(android.support.v7.app.ActionBar) PlayerFragment(com.simplecity.amp_library.ui.fragments.PlayerFragment) MiniPlayerFragment(com.simplecity.amp_library.ui.fragments.MiniPlayerFragment) SuppressLint(android.annotation.SuppressLint)

Aggregations

SuppressLint (android.annotation.SuppressLint)739 View (android.view.View)168 TextView (android.widget.TextView)106 Intent (android.content.Intent)86 Paint (android.graphics.Paint)63 ImageView (android.widget.ImageView)44 File (java.io.File)42 LayoutInflater (android.view.LayoutInflater)37 WebView (android.webkit.WebView)37 Uri (android.net.Uri)35 ArrayList (java.util.ArrayList)34 Context (android.content.Context)33 Bitmap (android.graphics.Bitmap)31 ViewGroup (android.view.ViewGroup)30 ListView (android.widget.ListView)30 Bundle (android.os.Bundle)27 IOException (java.io.IOException)26 AlertDialog (android.app.AlertDialog)25 DialogInterface (android.content.DialogInterface)25 AdapterView (android.widget.AdapterView)25