处理一部分activity的toolbar,已经处理完毕的标记为Deprecated,为了保持MTA数据上报兼容性,暂时未删除对应的Activity
This commit is contained in:
@ -0,0 +1,90 @@
|
||||
package com.gh.gamecenter.collection;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.gh.base.fragment.BaseFragment_ViewPager_Checkable;
|
||||
import com.gh.common.util.DisplayUtils;
|
||||
import com.gh.common.util.RandomUtils;
|
||||
import com.gh.gamecenter.R;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import butterknife.BindView;
|
||||
|
||||
/**
|
||||
* Created by khy on 18/07/17.
|
||||
*
|
||||
* 我的收藏viewpager页面
|
||||
*
|
||||
*/
|
||||
public class CollectionWrapperFragment extends BaseFragment_ViewPager_Checkable {
|
||||
|
||||
public static final int INDEX_TOOL = 0;
|
||||
public static final int INDEX_ARTICLE = 1;
|
||||
|
||||
@BindView(R.id.slidebar_line)
|
||||
View mSlideLine;
|
||||
|
||||
private LinearLayout.LayoutParams mLayoutParams;
|
||||
private int mWindowWidth;
|
||||
|
||||
public static CollectionWrapperFragment newInstance(int checkedIndex) {
|
||||
final Bundle args = new Bundle(1);
|
||||
args.putInt(ARGS_INDEX, checkedIndex);
|
||||
final CollectionWrapperFragment fragment = new CollectionWrapperFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getSmoothScroll() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getCheckableGroupId() {
|
||||
return R.id.lightgame_tab_container;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getViewPagerId() {
|
||||
return R.id.lightgame_tab_viewpager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initFragmentList(List<Fragment> fragments) {
|
||||
fragments.add(new ToolsFragment());
|
||||
fragments.add(new ArticleFragment());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setNavigationTitle("我的收藏");
|
||||
DisplayMetrics outMetrics = new DisplayMetrics();
|
||||
getActivity().getWindowManager().getDefaultDisplay().getMetrics(outMetrics);
|
||||
mWindowWidth = outMetrics.widthPixels / 2;
|
||||
mLayoutParams = new LinearLayout.LayoutParams(mWindowWidth / 2, DisplayUtils.dip2px(getContext(), 2));
|
||||
mLayoutParams.leftMargin = RandomUtils.getInt(mWindowWidth / 4f);
|
||||
mSlideLine.setLayoutParams(mLayoutParams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
|
||||
if (positionOffset != 0) {
|
||||
double i = mWindowWidth * (position + positionOffset + 0.25);
|
||||
mLayoutParams.leftMargin = RandomUtils.getInt(i);
|
||||
mSlideLine.setLayoutParams(mLayoutParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user