use of com.klinker.android.twitter.adapters.TweetPagerAdapter 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);
}
}
}
Aggregations