/* * * * Copyright 2015 Van Shu * * * * Licensed under the Apache License, Version 2.0 (the "License"); * * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * * * * http://www.apache.org/licenses/LICENSE-2.0 * * * * Unless required by applicable law or agreed to in writing, software * * distributed under the License is distributed on an "AS IS" BASIS, * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * * See the License for the specific language governing permissions and * * limitations under the License. * */ package com.mobimvp.cliques.ui; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.widget.Toolbar; import android.view.View; import com.astuetz.PagerSlidingTabStrip; import com.mobimvp.cliques.R; import com.mobimvp.cliques.ui.fragment.profile.FollowerProfileFragment; import com.mobimvp.cliques.util.AnalyticsManager; import static com.mobimvp.cliques.util.LogUtils.LOGD; import static com.mobimvp.cliques.util.LogUtils.makeLogTag; /** * Created by Van on 2015/2/15. */ public class FollowerProfileActivity extends BaseActivity { private static final String TAG = makeLogTag(FollowerProfileActivity.class); private ViewPager mViewPager; private ViewPagerAdapter mViewPagerAdapter; private String[] mTitle = new String[]{"FOLLOWER", "FOLLOWING"}; public static final int FOLLOWER=0x000001; public static final int FOLLOWEE=0X000002; public String userId; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int type=getIntent().getIntExtra("TYPE",0); userId=getIntent().getStringExtra("userId"); setContentView(R.layout.activity_follower_profile); Toolbar toolbar = getActionBarToolbar(); toolbar.setNavigationIcon(R.drawable.ic_up); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPagerAdapter = new ViewPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mViewPagerAdapter); PagerSlidingTabStrip mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); mTabs.setViewPager(mViewPager); overridePendingTransition(0, 0); if(type==FOLLOWER){ mViewPager.setCurrentItem(0); }else if(type==FOLLOWEE){ mViewPager.setCurrentItem(1); } } @Override public void onStart() { super.onStart(); } @Override protected void onResume() { super.onResume(); invalidateOptionsMenu(); } @Override public void onStop() { super.onStop(); } public class ViewPagerAdapter extends FragmentPagerAdapter { public ViewPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int i) { switch (i) { case 0: FollowerProfileFragment followerProfileFragment = new FollowerProfileFragment(); Bundle followerBundle = new Bundle(); followerBundle.putInt(FollowerProfileFragment.PROFILE_FRAGMENT_TYPE, FollowerProfileFragment.FOLLOWER_PROFILE_FRAGMENT); followerBundle.putString("userId",userId); followerProfileFragment.setArguments(followerBundle); return followerProfileFragment; case 1: FollowerProfileFragment followingProfileFragment = new FollowerProfileFragment(); Bundle followingBundle = new Bundle(); followingBundle.putInt(FollowerProfileFragment.PROFILE_FRAGMENT_TYPE, FollowerProfileFragment.FOLLOWING_PROFILE_FRAGMENT); followingBundle.putString("userId",userId); followingProfileFragment.setArguments(followingBundle); return followingProfileFragment; } return null; } @Override public int getCount() { return mTitle.length; } @Override public CharSequence getPageTitle(int position) { return mTitle[position]; } } }