处理一部分activity的toolbar,已经处理完毕的标记为Deprecated,为了保持MTA数据上报兼容性,暂时未删除对应的Activity

This commit is contained in:
CsHeng
2017-12-14 17:56:54 +08:00
parent e0b70b26f3
commit bf7b0b0a82
67 changed files with 2251 additions and 2495 deletions

View File

@ -16,6 +16,8 @@ import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.gamecenter.eventbus.EBKaiFuReset;
import com.gh.gamecenter.kaifu.KaiFuFragment;
import com.gh.gamecenter.kaifu.KaiFuWrapperFragment;
import com.halo.assistant.ui.IntentFactory;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
@ -25,97 +27,16 @@ import butterknife.BindView;
/**
* Created by khy on 18/08/17.
*/
public class KaiFuActivity extends BaseActivity {
@BindView(R.id.reuse_actionbar)
RelativeLayout mReuseActionbar;
private TextView mResetTv;
private KaiFuFragment mKaiFuFragment;
private KaiFuFragment mGameKaiFuFragment;
public static final String SINGLE_GAME_KAIFU = "SINGLE_GAME_KAIFU";
public static final String ALL_GAME_KAIFU = "ALL_GAME_KAIFU";
@Deprecated
public class KaiFuActivity extends CommonActivity {
@NonNull
public static Intent getIntent(Context context, String entrance) {
Intent intent = new Intent(context, KaiFuActivity.class);
intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
return intent;
}
@Override
protected int getLayoutId() {
return R.layout.activity_kaifu;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setNavigationTitle("开服表");
mResetTv = new TextView(this);
mResetTv.setText("重置");
mResetTv.setTextColor(ContextCompat.getColor(this, R.color.title));
mResetTv.setGravity(Gravity.CENTER);
mResetTv.setVisibility(View.GONE);
mResetTv.setBackgroundResource(R.drawable.border_black_bg);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
DisplayUtils.dip2px(this, 48), DisplayUtils.dip2px(this, 28));
params.addRule(RelativeLayout.CENTER_VERTICAL);
params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
params.setMargins(0, 0, DisplayUtils.dip2px(this, 8), 0);
mReuseActionbar.addView(mResetTv, params);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
mKaiFuFragment = new KaiFuFragment();
fragmentTransaction.add(R.id.layout_fragment_content, mKaiFuFragment);
fragmentTransaction.commit();
mResetTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resetFragment();
}
});
}
private void resetFragment() {
mKaiFuFragment.setCurPage(mGameKaiFuFragment.getCurPage());
mResetTv.setVisibility(View.GONE);
mKaiFuFragment.onResume(); // 启动观察者
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.remove(mGameKaiFuFragment);
fragmentTransaction.show(mKaiFuFragment);
fragmentTransaction.commit();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMainThread(EBKaiFuReset reset) {
if (SINGLE_GAME_KAIFU.equals(reset.getControl())) {
mResetTv.setVisibility(View.VISIBLE);
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.hide(mKaiFuFragment);
mKaiFuFragment.onPause();
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_GAMEID, reset.getGameId());
args.putInt("curPage", mKaiFuFragment.getCurPage());
mGameKaiFuFragment = new KaiFuFragment();
mGameKaiFuFragment.setArguments(args);
fragmentTransaction.add(R.id.layout_fragment_content, mGameKaiFuFragment, KaiFuFragment.class.getSimpleName());
fragmentTransaction.commit();
} else if (ALL_GAME_KAIFU.equals(reset.getControl())) {
resetFragment();
}
Bundle args = new Bundle();
args.putString(EntranceUtils.KEY_ENTRANCE, entrance);
return new IntentFactory.Builder(context)
.setActivity(KaiFuActivity.class)
.setFragment(KaiFuWrapperFragment.class).setArgs(args).build();
}
}