Search in sources :

Example 1 with PagerTitleStrip

use of android.support.v4.view.PagerTitleStrip in project Talon-for-Twitter by klinker24.

the class ProfilePager method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);
    mCache = App.getInstance(this).getBitmapCache();
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
    // Ignore
    }
    if (getIntent().getBooleanExtra("from_widget", false) || ((settings.advanceWindowed && !getIntent().getBooleanExtra("long_click", false)) || !settings.advanceWindowed && getIntent().getBooleanExtra("long_click", false))) {
        setUpWindow();
    }
    setUpTheme();
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }
    getFromIntent();
    setContentView(R.layout.tweet_pager);
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    ProfilePagerAdapter mPagerAdapter = new ProfilePagerAdapter(getFragmentManager(), context, name, screenName, proPic, tweetId, isRetweet, isMyProfile);
    pager.setAdapter(mPagerAdapter);
    pager.setOffscreenPageLimit(3);
    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);
        if (!settings.showTitleStrip) {
            strip.setVisibility(View.GONE);
        }
    }
    Utils.setActionBar(context, !settings.advanceWindowed);
    // set it to the profile
    pager.setCurrentItem(1);
}
Also used : ViewConfiguration(android.view.ViewConfiguration) Field(java.lang.reflect.Field) PagerTitleStrip(android.support.v4.view.PagerTitleStrip) ProfilePagerAdapter(com.klinker.android.twitter.adapters.ProfilePagerAdapter) ViewPager(android.support.v4.view.ViewPager) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Point(android.graphics.Point)

Example 2 with PagerTitleStrip

use of android.support.v4.view.PagerTitleStrip in project UltimateAndroid by cymcsg.

the class PagerTitleStrip method onAttachedToWindow.

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    final ViewParent parent = getParent();
    if (!(parent instanceof ViewPager)) {
        throw new IllegalStateException("PagerTitleStrip must be a direct child of a ViewPager.");
    }
    final ViewPager pager = (ViewPager) parent;
    final PagerAdapter adapter = pager.getAdapter();
    pager.setInternalPageChangeListener(mPageListener);
    pager.setOnAdapterChangeListener(mPageListener);
    mPager = pager;
    updateAdapter(mWatchingAdapter != null ? mWatchingAdapter.get() : null, adapter);
}
Also used : ViewParent(android.view.ViewParent) PagerAdapter(android.support.v4.view.PagerAdapter)

Example 3 with PagerTitleStrip

use of android.support.v4.view.PagerTitleStrip in project Talon-for-Twitter by klinker24.

the class DiscoverPager method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    context = this;
    sharedPrefs = context.getSharedPreferences("com.klinker.android.twitter_world_preferences", 0);
    settings = AppSettings.getInstance(this);
    requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
    setUpTheme();
    setContentView(R.layout.trends_activity);
    setUpDrawer(0, getResources().getString(R.string.trends));
    actionBar = getActionBar();
    actionBar.setTitle(getResources().getString(R.string.trends));
    if (!settings.isTwitterLoggedIn) {
        Intent login = new Intent(context, LoginActivity.class);
        startActivity(login);
        finish();
    }
    mSectionsPagerAdapter = new TrendsPagerAdapter(getFragmentManager(), context);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOverScrollMode(ViewPager.OVER_SCROLL_NEVER);
    mViewPager.setOffscreenPageLimit(3);
    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);
    }
}
Also used : PagerTitleStrip(android.support.v4.view.PagerTitleStrip) Intent(android.content.Intent) TrendsPagerAdapter(com.klinker.android.twitter.adapters.TrendsPagerAdapter)

Example 4 with PagerTitleStrip

use of android.support.v4.view.PagerTitleStrip in project Talon-for-Twitter by klinker24.

the class TweetPager method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);
    try {
        getWindow().requestFeature(Window.FEATURE_PROGRESS);
    } catch (Exception e) {
    }
    context = this;
    settings = AppSettings.getInstance(this);
    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
    // Ignore
    }
    getFromIntent();
    mSectionsPagerAdapter = new TweetPagerAdapter(getFragmentManager(), context, name, screenName, tweet, time, retweeter, webpage, proPic, tweetId, picture, users, hashtags, otherLinks, isMyTweet, isMyRetweet, secondAcc, animatedGif);
    // methods for advancing windowed
    boolean settingsVal = settings.advanceWindowed;
    boolean fromWidget = getIntent().getBooleanExtra("from_widget", false);
    final boolean youtube;
    youtube = mSectionsPagerAdapter.getHasYoutube() || mSectionsPagerAdapter.getHasGif() || mSectionsPagerAdapter.hasVine();
    if (fromWidget || settingsVal) {
        setUpWindow(youtube);
    }
    setUpTheme();
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }
    if (getIntent().getBooleanExtra("clicked_youtube", false)) {
        IntentFilter i = new IntentFilter("com.klinker.android.twitter.YOUTUBE_READY");
        registerReceiver(new BroadcastReceiver() {

            @Override
            public void onReceive(Context context, Intent intent) {
                TweetYouTubeFragment.resume();
                context.unregisterReceiver(this);
            }
        }, i);
    }
    setContentView(R.layout.tweet_pager);
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(mSectionsPagerAdapter);
    pager.setOffscreenPageLimit(5);
    final int numberOfPages = mSectionsPagerAdapter.getCount();
    pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int i, float v, int i2) {
        }

        @Override
        public void onPageSelected(int i) {
            if (youtube) {
                try {
                    switch(numberOfPages) {
                        case 3:
                        case 4:
                            if (i != 0) {
                                TweetYouTubeFragment.pause();
                            } else {
                                TweetYouTubeFragment.resume();
                            }
                            break;
                        case 5:
                            if (i != 1) {
                                TweetYouTubeFragment.pause();
                            } else {
                                TweetYouTubeFragment.resume();
                            }
                            break;
                    }
                } catch (Exception e) {
                }
            }
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });
    switch(numberOfPages) {
        case 2:
            if (settings.pageToOpen == AppSettings.PAGE_CONVO) {
                pager.setCurrentItem(1);
            } else {
                pager.setCurrentItem(0);
            }
            break;
        case 3:
            if (mSectionsPagerAdapter.getHasWebpage()) {
                switch(settings.pageToOpen) {
                    case AppSettings.PAGE_CONVO:
                        pager.setCurrentItem(2);
                        break;
                    case AppSettings.PAGE_WEB:
                        pager.setCurrentItem(0);
                        break;
                    default:
                        pager.setCurrentItem(1);
                        break;
                }
            } else {
                // no web page
                switch(settings.pageToOpen) {
                    case AppSettings.PAGE_CONVO:
                        pager.setCurrentItem(2);
                        break;
                    default:
                        pager.setCurrentItem(1);
                        break;
                }
            }
            break;
        case // webpage and youtube
        4:
            switch(settings.pageToOpen) {
                case AppSettings.PAGE_CONVO:
                    pager.setCurrentItem(3);
                    break;
                case AppSettings.PAGE_WEB:
                    pager.setCurrentItem(1);
                    break;
                default:
                    pager.setCurrentItem(0);
                    break;
            }
            break;
    }
    if (getIntent().getBooleanExtra("clicked_youtube", false)) {
        pager.setCurrentItem(0);
    }
    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);
        if (!settings.showTitleStrip) {
            strip.setVisibility(View.GONE);
        }
    }
}
Also used : TweetPagerAdapter(com.klinker.android.twitter.adapters.TweetPagerAdapter) PendingIntent(android.app.PendingIntent) ViewPager(android.support.v4.view.ViewPager) Point(android.graphics.Point) Field(java.lang.reflect.Field) PagerTitleStrip(android.support.v4.view.PagerTitleStrip)

Example 5 with PagerTitleStrip

use of android.support.v4.view.PagerTitleStrip in project Talon-for-Twitter by klinker24.

the class ViewUsersPopup method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    overridePendingTransition(R.anim.activity_slide_up, R.anim.activity_slide_down);
    Utils.setUpPopupTheme(this, AppSettings.getInstance(this));
    setUpWindow();
    setContentView(R.layout.search_pager);
    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setPadding(0, 0, 0, 0);
    UserListPagerAdapter adapter = new UserListPagerAdapter(getFragmentManager(), this, getIntent().getLongExtra("id", 0l));
    mViewPager.setAdapter(adapter);
    mViewPager.setOffscreenPageLimit(2);
    AppSettings settings = AppSettings.getInstance(this);
    if (settings.addonTheme) {
        PagerTitleStrip strip = (PagerTitleStrip) findViewById(R.id.pager_title_strip);
        strip.setBackgroundColor(settings.pagerTitleInt);
    }
}
Also used : AppSettings(com.klinker.android.twitter.settings.AppSettings) PagerTitleStrip(android.support.v4.view.PagerTitleStrip) UserListPagerAdapter(com.klinker.android.twitter.adapters.UserListPagerAdapter) ViewPager(android.support.v4.view.ViewPager)

Aggregations

PagerTitleStrip (android.support.v4.view.PagerTitleStrip)5 ViewPager (android.support.v4.view.ViewPager)3 Field (java.lang.reflect.Field)3 Point (android.graphics.Point)2 ViewConfiguration (android.view.ViewConfiguration)2 PendingIntent (android.app.PendingIntent)1 Intent (android.content.Intent)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 PagerAdapter (android.support.v4.view.PagerAdapter)1 View (android.view.View)1 ViewParent (android.view.ViewParent)1 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 SearchView (android.widget.SearchView)1 ProfilePagerAdapter (com.klinker.android.twitter.adapters.ProfilePagerAdapter)1 SearchPagerAdapter (com.klinker.android.twitter.adapters.SearchPagerAdapter)1 TrendsPagerAdapter (com.klinker.android.twitter.adapters.TrendsPagerAdapter)1 TweetPagerAdapter (com.klinker.android.twitter.adapters.TweetPagerAdapter)1 UserListPagerAdapter (com.klinker.android.twitter.adapters.UserListPagerAdapter)1 AppSettings (com.klinker.android.twitter.settings.AppSettings)1