@SuppressWarnings("unchecked") @Override public void processFinish(Object[] output) { generateMenu(); if (output instanceof String[]) { Toast.makeText(this, "" + output[0], Toast.LENGTH_SHORT).show(); ((TextView) findViewById(R.id.TextoEmptyContent)) .setText(getString(R.string.connect_error_content)); } else { MyFragmentPagerAdapter mMyFragmentPagerAdapter = new MyFragmentPagerAdapter( getSupportFragmentManager(), this, (List<DiarioCategoriaObject>) output[0], idAdserver); ViewPager pager = (ViewPager) findViewById(R.id.viewpager); pager.setAdapter(mMyFragmentPagerAdapter); TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.titlesIndicator); titleIndicator.setViewPager(pager); if (!isShowContent) { isShowContent = true; hideLoading(); } } }
/** {@inheritDoc} */ @Override public View onCreateView( final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { // The View for the fragment's UI final ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.fragment_music_browser_phone, container, false); // Initialize the adapter mPagerAdapter = new PagerAdapter(getActivity()); final MusicFragments[] mFragments = MusicFragments.values(); for (final MusicFragments mFragment : mFragments) { mPagerAdapter.add(mFragment.getFragmentClass(), null); } // Initialize the ViewPager mViewPager = (ViewPager) rootView.findViewById(R.id.fragment_home_phone_pager); // Attch the adapter mViewPager.setAdapter(mPagerAdapter); // Offscreen pager loading limit mViewPager.setOffscreenPageLimit(mPagerAdapter.getCount() - 1); // Start on the last page the user was on mViewPager.setCurrentItem(mPreferences.getStartPage()); // Initialze the TPI final TitlePageIndicator pageIndicator = (TitlePageIndicator) rootView.findViewById(R.id.fragment_home_phone_pager_titles); // Attach the ViewPager pageIndicator.setViewPager(mViewPager); // Scroll to the current artist, album, or song pageIndicator.setOnCenterItemClickListener(this); return rootView; }
/** Sets the color for the ViewPager title indicator to match the account color */ private void setTitleIndicatorColor() { // Basically, if we are in a top level account, use the default title color. // but propagate a parent account's title color to children who don't have own color String colorCode = mAccountsDbAdapter.getAccountColorCode(mAccountId); if (colorCode != null) { sLastTitleColor = Color.parseColor(colorCode); } mTitlePageIndicator.setSelectedColor(sLastTitleColor); mTitlePageIndicator.setTextColor(sLastTitleColor); mTitlePageIndicator.setFooterColor(sLastTitleColor); mSectionHeaderTransactions.setBackgroundColor(sLastTitleColor); }
private void refreshUi() { synchronized (channelsLock) { setContentView(R.layout.main); setIndeterminateProgressBarVisibility(!progressBarVisibility); // hack setIndeterminateProgressBarVisibility(!progressBarVisibility); ViewPager pager = (ViewPager) findViewById(R.id.pager); if (adapter == null) { adapter = new MessagePagerAdapter(getLayoutInflater()); } if (channels != null) { adapter.setChannels(channels); } pager.setAdapter(adapter); TitlePageIndicator titleIndicator = (TitlePageIndicator) findViewById(R.id.titles); titleIndicator.setViewPager(pager); titleIndicator.setOnPageChangeListener( new OnPageChangeListener() { public void onPageSelected(int arg0) { if (channels != null) { Channel ch = channels.get(arg0); if (ch != null) { channelToView = ch.getName(); } } } public void onPageScrolled(int arg0, float arg1, int arg2) {} public void onPageScrollStateChanged(int arg0) {} }); if (channelToView != null && channels != null) { for (int i = 0; i < channels.size(); i++) { if (channels.get(i).getName().equalsIgnoreCase(channelToView)) { pager.setCurrentItem(i); break; } } } if (channelToView == null) { channelToView = FEED; } } }
@Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.pagerlayout_activity_attitude, container, false); TitlePageIndicator indicator = (TitlePageIndicator) layout.findViewById(R.id.indicator); ViewPager pager = (ViewPager) layout.findViewById(R.id.pager); pager.setAdapter(new AttitudePagerAdapter(getFragmentManager())); indicator.setViewPager(pager); return layout; }
@Override public void onNewIntent(Intent intent) { if (D) Log.e(TAG, "+++ NEW INTENT +++"); // Set up the window layout requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); setContentView(R.layout.main); getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title); // Set up the custom title mTitle = (TextView) findViewById(R.id.title_left_text); mTitle.setText(R.string.right_title); mTitle = (TextView) findViewById(R.id.title_right_text); Intent intent1 = getIntent(); TCPAddress = intent1.getStringExtra("TCPAddress"); AndroiDAQTCPAdapter adapter = new AndroiDAQTCPAdapter(this); pager = (ViewPager) findViewById(R.id.viewpager); pager.setOffscreenPageLimit(6); indicator = (TitlePageIndicator) findViewById(R.id.indicator); pager.setAdapter(adapter); indicator.setViewPager(pager); mWaveform = (WaveFormView) findViewById(R.id.WaveformArea); // indicator.setOnPageChangeListener(this); }
@Override public void onActivityCreated(final Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); viewpagerHolder = getActivity().findViewById(R.id.viewpager_holder); fragmentHolder = getActivity().findViewById(R.id.frame_for_fragment); pager = (ViewPager) viewpagerHolder.findViewById(R.id.pager); if (pager.getAdapter() == null) { fragmentAdapter = new MovieFragmentAdapter(getSupportFragmentManager(), 0); pager.setAdapter(fragmentAdapter); indicator = (TitlePageIndicator) viewpagerHolder.findViewById(R.id.indicator); indicator.setViewPager(pager); decoreIndicator(); setIndicatorListener(); } fragmentHolder.setVisibility(View.GONE); viewpagerHolder.setVisibility(View.VISIBLE); }
private void initChapters(ArrayList<Chapter> chapters) { addChapters(chapters); Chapter chapter = null; if (getIntent().hasExtra(EXTRA_GROUP_ID)) { String chapterId = getIntent().getStringExtra(EXTRA_GROUP_ID); for (Chapter c : chapters) { if (c.getGplusId().equals(chapterId)) { chapter = c; break; } } if (chapter == null) chapter = chapters.get(0); } else { chapter = chapters.get(0); } getSupportActionBar().setSelectedNavigationItem(mSpinnerAdapter.getPosition(chapter)); mViewPager.setAdapter(mViewPagerAdapter); mViewPager.setOffscreenPageLimit(2); mIndicator.setViewPager(mViewPager); if (SECTION_EVENTS.equals(getIntent().getStringExtra(EXTRA_SECTION))) { mHandler.postDelayed( new Runnable() { @Override public void run() { mViewPager.setCurrentItem(2, true); } }, 500); } }
/** Refreshes the fragments currently in the transactions activity */ @Override public void refresh(long accountId) { for (int i = 0; i < mFragmentPageReferenceMap.size(); i++) { mFragmentPageReferenceMap.valueAt(i).refresh(accountId); } mTitlePageIndicator.notifyDataSetChanged(); }
private void decoreIndicator() { float density = getResources().getDisplayMetrics().density; indicator.setBackgroundColor(Color.WHITE); indicator.setFooterColor(Color.BLACK); indicator.setFooterLineHeight(1 * density); indicator.setFooterIndicatorHeight(1 * density); indicator.setFooterIndicatorStyle(IndicatorStyle.Underline); indicator.setTextColor(0xAA000000); indicator.setSelectedColor(0xFF000000); indicator.setSelectedBold(true); }
@Subscribe public void onUserRetrieved(UserRetrievedEvent event) { CWUser u = event.getUser(); if (event.isTaskOver()) UserFragment.this.setRefresh(false); if (event.getError() != null) { Toast.makeText(getSherlockActivity(), event.getError().getMessage(), Toast.LENGTH_LONG) .show(); return; } else if (u == null) return; if (UserFragment.this.username == null) { UserFragment.this.username = u.getUsername(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getSherlockActivity()); prefs.edit().putString(Constants.PREF_USERNAME, u.getUsername()).commit(); } UserFragment.this.u = u; refreshNavigationListAdapter(); if (pagerAdapter == null || viewPager.getAdapter() == null) { viewPager.setAdapter(pagerAdapter = new PagerUserAdapter(getFragmentManager(), u)); pageIndicator.setViewPager(viewPager); pageIndicator.setOnPageChangeListener(UserFragment.this); pageIndicator.setBackgroundColor(getResources().getColor(R.color.coderwall_blue)); pageIndicator.setFooterColor(Color.WHITE); pageIndicator.setFooterIndicatorStyle(IndicatorStyle.Triangle); pageIndicator.setFooterLineHeight(0); } else pagerAdapter.refreshUser(u); }
@Override public void onCreate(Bundle savedInstanceState) { // it is necessary to set the view first before calling super because of the nav drawer in // BaseDrawerActivity setContentView(R.layout.activity_accounts); super.onCreate(savedInstanceState); final Intent intent = getIntent(); handleOpenFileIntent(intent); init(); mPager = (ViewPager) findViewById(R.id.pager); mTitlePageIndicator = (TitlePageIndicator) findViewById(R.id.titles); String action = intent.getAction(); if (action != null && action.equals(Intent.ACTION_INSERT_OR_EDIT)) { // enter account creation/edit mode if that was specified mPager.setVisibility(View.GONE); mTitlePageIndicator.setVisibility(View.GONE); String accountUID = intent.getStringExtra(UxArgument.SELECTED_ACCOUNT_UID); if (accountUID != null) showEditAccountFragment(accountUID); else { String parentAccountUID = intent.getStringExtra(UxArgument.PARENT_ACCOUNT_UID); showAddAccountFragment(parentAccountUID); } } else { // show the simple accounts list PagerAdapter mPagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager()); mPager.setAdapter(mPagerAdapter); mTitlePageIndicator.setViewPager(mPager); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); int lastTabIndex = preferences.getInt(LAST_OPEN_TAB_INDEX, INDEX_TOP_LEVEL_ACCOUNTS_FRAGMENT); int index = intent.getIntExtra(EXTRA_TAB_INDEX, lastTabIndex); mPager.setCurrentItem(index); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_transactions); ViewPager pager = (ViewPager) findViewById(R.id.pager); mTitlePageIndicator = (TitlePageIndicator) findViewById(R.id.titles); mSectionHeaderTransactions = (TextView) findViewById(R.id.section_header_transactions); if (sLastTitleColor == -1) // if this is first launch of app. Previous launches would have set the color already sLastTitleColor = getResources().getColor(R.color.title_green); mAccountId = getIntent().getLongExtra(UxArgument.SELECTED_ACCOUNT_ID, -1); mAccountsDbAdapter = new AccountsDbAdapter(this); setupActionBarNavigation(); if (getIntent().getAction().equals(Intent.ACTION_INSERT_OR_EDIT)) { pager.setVisibility(View.GONE); mTitlePageIndicator.setVisibility(View.GONE); initializeCreateOrEditTransaction(); } else { // load the transactions list mSectionHeaderTransactions.setVisibility(View.GONE); PagerAdapter pagerAdapter = new AccountViewPagerAdapter(getSupportFragmentManager()); pager.setAdapter(pagerAdapter); mTitlePageIndicator.setViewPager(pager); pager.setCurrentItem(INDEX_TRANSACTIONS_FRAGMENT); } // done creating, activity now running mActivityRunning = true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.modify_user); actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); mViewPager = (ViewPager) findViewById(R.id.modify_pager); titlePageIndicator = (TitlePageIndicator) findViewById(R.id.modify_indicator); titlePageIndicator.setTextColor(Color.BLACK); titlePageIndicator.setSelectedColor(Color.BLACK); userFunctions = new UserFunctions(getApplicationContext()); boolean isLogined = userFunctions.isUserLoggedIn(getApplicationContext()); if (!isLogined) { Toast.makeText( getApplicationContext(), getResources().getString(R.string.modify_userNotLogin), Toast.LENGTH_SHORT) .show(); finish(); } uID = String.valueOf(userFunctions.getUserUid(getApplicationContext())); setUpViewPager(); }
private void setUpViewPager() { ModifyDataPager modifyDataPager = new ModifyDataPager(this); mViewPager.setAdapter(modifyDataPager); mViewPager.setOffscreenPageLimit(2); titlePageIndicator.setViewPager(mViewPager); titlePageIndicator.setOnPageChangeListener( new OnPageChangeListener() { @Override public void onPageSelected(int position) { page = position; } @Override public void onPageScrolled( int position, float positionOffset, int positionOffsetPixels) {} @Override public void onPageScrollStateChanged(int state) {} }); phoneNumPage1 = (TextView) modifyDataPager.findViewById(0, R.id.modify_phoneNumberLocked); phoneNumPage2 = (TextView) modifyDataPager.findViewById(1, R.id.modify_p2_phoneNumberLocked); edt_email = (EditText) modifyDataPager.findViewById(0, R.id.modify_email); edt_nickName = (EditText) modifyDataPager.findViewById(0, R.id.modify_nickname); radGroup_sex = (RadioGroup) modifyDataPager.findViewById(0, R.id.modify_radiogroup); radBtn_female = (RadioButton) modifyDataPager.findViewById(0, R.id.modify_female); radBtn_male = (RadioButton) modifyDataPager.findViewById(0, R.id.modify_male); radBtn_xgender = (RadioButton) modifyDataPager.findViewById(0, R.id.modify_xgender); edt_newPassword = (EditText) modifyDataPager.findViewById(1, R.id.modify_password); edt_newPasswordAgain = (EditText) modifyDataPager.findViewById(1, R.id.modify_passwordAgain); radGroup_sex.setOnCheckedChangeListener(radioGroup_listener); radBtn_female.setOnClickListener(radio_animation); radBtn_male.setOnClickListener(radio_animation); radBtn_xgender.setOnClickListener(radio_animation); GetUserInformation getUserInformation = new GetUserInformation(); getUserInformation.execute(uID); }
private void initSpinner() { Collections.sort(mPulseTargets); mPulseTargets.add(0, "Global"); mViewPagerAdapter.setSelectedPulseTarget(mPulseTargets.get(0)); mSpinnerAdapter.clear(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSpinnerAdapter.addAll(mPulseTargets); } else { for (String item : mPulseTargets) { mSpinnerAdapter.add(item); } } mViewPager.setAdapter(mViewPagerAdapter); mIndicator.setViewPager(mViewPager); }
private void setIndicatorListener() { indicator.setOnPageChangeListener( new OnPageChangeListener() { private int previousPosition = -1; @Override public void onPageSelected(final int position) {} @Override public void onPageScrolled( final int position, final float positionOffset, final int positionOffsetPixels) { if (positionOffsetPixels == 0) { fragmentAdapter.updateData(position, previousPosition); previousPosition = position; } } @Override public void onPageScrollStateChanged(final int state) {} }); }
/** * Called when the activity is first created. * * @param savedInstanceState If the activity is being re-initialized after previously being shut * down then this Bundle contains the data it most recently supplied in * onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b> */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Timber.i("onCreate"); setContentView(R.layout.activity_main); mClient = new GroupDirectory(); mLocationComparator = new ChapterComparator(mPreferences); mIndicator.setOnPageChangeListener(this); mViewPagerAdapter = new MyAdapter(this, getSupportFragmentManager()); mSpinnerAdapter = new ChapterAdapter(MainActivity.this, android.R.layout.simple_list_item_1); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, MainActivity.this); mFetchChaptersTask = mClient.getDirectory( new Response.Listener<Directory>() { @Override public void onResponse(final Directory directory) { getSupportActionBar() .setListNavigationCallbacks(mSpinnerAdapter, MainActivity.this); App.getInstance() .getModelCache() .putAsync( "chapter_list", directory, DateTime.now().plusDays(1), new ModelCache.CachePutListener() { @Override public void onPutIntoCache() { ArrayList<Chapter> chapters = directory.getGroups(); initChapters(chapters); } }); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Crouton.makeText( MainActivity.this, getString(R.string.fetch_chapters_failed), Style.ALERT) .show(); Timber.e("Could'nt fetch chapter list", volleyError); } }); if (savedInstanceState == null) { if (Utils.isOnline(this)) { App.getInstance() .getModelCache() .getAsync( "chapter_list", new ModelCache.CacheListener() { @Override public void onGet(Object item) { Directory directory = (Directory) item; initChapters(directory.getGroups()); } @Override public void onNotFound(String key) { mFetchChaptersTask.execute(); } }); } else { App.getInstance() .getModelCache() .getAsync( "chapter_list", false, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Directory directory = (Directory) item; initChapters(directory.getGroups()); } @Override public void onNotFound(String key) { Crouton.makeText( MainActivity.this, getString(R.string.offline_alert), Style.ALERT) .show(); } }); } } else { if (savedInstanceState.containsKey("chapters")) { ArrayList<Chapter> chapters = savedInstanceState.getParcelableArrayList("chapters"); mSpinnerAdapter.clear(); mSpinnerAdapter.addAll(chapters); if (savedInstanceState.containsKey("selected_chapter")) { Chapter selectedChapter = savedInstanceState.getParcelable("selected_chapter"); selectChapter(selectedChapter); } else { mViewPagerAdapter.setSelectedChapter(chapters.get(0)); } mViewPager.setAdapter(mViewPagerAdapter); mIndicator.setViewPager(mViewPager); } else { mFetchChaptersTask.execute(); } } Intent intent = getIntent(); if (intent != null && intent.getAction() != null && intent.getAction().equals("finish_first_start")) { Timber.d("Completed FirstStartWizard"); if (mPreferences.getBoolean(Const.SETTINGS_SIGNED_IN, false)) { mFirstStart = true; } Chapter homeGdgd = getIntent().getParcelableExtra("selected_chapter"); getSupportActionBar().setSelectedNavigationItem(mSpinnerAdapter.getPosition(homeGdgd)); mViewPagerAdapter.setSelectedChapter(homeGdgd); } Time now = new Time(); now.setToNow(); if ((mPreferences.getInt(Const.SETTINGS_SEASONS_GREETINGS, now.year - 1) < now.year) && (now.yearDay >= 354 && now.yearDay <= 366)) { mPreferences.edit().putInt(Const.SETTINGS_SEASONS_GREETINGS, now.year).commit(); SeasonsGreetingsFragment seasonsGreetings = new SeasonsGreetingsFragment(); seasonsGreetings.show(getSupportFragmentManager(), "dialog"); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(LOG_TAG, "onCreate"); setContentView(R.layout.activity_pulse); getSupportActionBar().setLogo(R.drawable.ic_logo_pulse); mClient = new GroupDirectory(); mIndicator.setOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) {} @Override public void onPageSelected(int i) { Log.d(LOG_TAG, "onPageSelected()"); trackViewPagerPage(i); } @Override public void onPageScrollStateChanged(int i) {} }); mPulseTargets = new ArrayList<String>(); mViewPagerAdapter = new MyAdapter(this, getSupportFragmentManager()); mSpinnerAdapter = new ArrayAdapter<String>(PulseActivity.this, android.R.layout.simple_list_item_1); getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter, PulseActivity.this); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mFetchGlobalPulseTask = mClient.getPulse( new Response.Listener<Pulse>() { @Override public void onResponse(final Pulse pulse) { getSupportActionBar() .setListNavigationCallbacks(mSpinnerAdapter, PulseActivity.this); App.getInstance() .getModelCache() .putAsync( "pulse_global", pulse, DateTime.now().plusDays(1), new ModelCache.CachePutListener() { @Override public void onPutIntoCache() { mPulseTargets.addAll(pulse.keySet()); initSpinner(); } }); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Crouton.makeText( PulseActivity.this, getString(R.string.fetch_chapters_failed), Style.ALERT) .show(); Log.e(LOG_TAG, "Could'nt fetch chapter list", volleyError); } }); App.getInstance() .getModelCache() .getAsync( "pulse_global", true, new ModelCache.CacheListener() { @Override public void onGet(Object item) { Pulse pulse = (Pulse) item; mPulseTargets.addAll(pulse.keySet()); initSpinner(); } @Override public void onNotFound(String key) { mFetchGlobalPulseTask.execute(); } }); }