284 lines
10 KiB
Java
284 lines
10 KiB
Java
//package com.gh.gamecenter;
|
|
//
|
|
//import android.content.Context;
|
|
//import android.content.Intent;
|
|
//import android.os.Bundle;
|
|
//import android.text.TextUtils;
|
|
//import android.view.View;
|
|
//import android.view.inputmethod.EditorInfo;
|
|
//import android.widget.EditText;
|
|
//import android.widget.LinearLayout;
|
|
//import android.widget.TextView;
|
|
//
|
|
//import com.gh.gamecenter.common.callback.OnRequestCallBackListener;
|
|
//import com.gh.gamecenter.common.base.activity.ToolBarActivity;
|
|
//import com.gh.common.util.EntranceUtils;
|
|
//import com.gh.gamecenter.core.utils.MtaHelper;
|
|
//import com.gh.gamecenter.common.utils.TextHelper;
|
|
//import com.gh.gamecenter.core.utils.UrlFilterUtils;
|
|
//import com.gh.gamecenter.common.view.VerticalItemDecoration;
|
|
//import com.gh.gamecenter.adapter.ToolBoxRvAdapter;
|
|
//import com.gh.gamecenter.common.entity.ToolBoxEntity;
|
|
//import com.gh.gamecenter.retrofit.Response;
|
|
//import com.gh.gamecenter.retrofit.RetrofitManager;
|
|
//import com.gh.gamecenter.common.entity.SuggestType;
|
|
//import com.google.android.material.appbar.AppBarLayout;
|
|
//import com.lightgame.utils.Util_System_Keyboard;
|
|
//import com.lightgame.utils.Utils;
|
|
//
|
|
//import java.util.List;
|
|
//
|
|
//import androidx.annotation.NonNull;
|
|
//import androidx.annotation.Nullable;
|
|
//import androidx.recyclerview.widget.LinearLayoutManager;
|
|
//import androidx.recyclerview.widget.RecyclerView;
|
|
//import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
//import butterknife.BindView;
|
|
//import butterknife.OnClick;
|
|
//import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
//import io.reactivex.schedulers.Schedulers;
|
|
//
|
|
///**
|
|
// * Created by khy on 24/05/17.
|
|
// */
|
|
//
|
|
//public class ToolBoxActivity extends ToolBarActivity implements SwipeRefreshLayout.OnRefreshListener, OnRequestCallBackListener {
|
|
//
|
|
// @BindView(R.id.et_search)
|
|
// public EditText searchEt;
|
|
// @BindView(R.id.tv_search)
|
|
// public TextView searchTv;
|
|
// @BindView(R.id.tv_back)
|
|
// public View backTv;
|
|
// @BindView(R.id.toolbox_appbar)
|
|
// AppBarLayout mAppBar;
|
|
// @BindView(R.id.toolbox_rv)
|
|
// RecyclerView mToolboxRv;
|
|
// @BindView(R.id.reuse_none_data)
|
|
// LinearLayout mNoneData;
|
|
// @BindView(R.id.reuse_tv_none_data)
|
|
// TextView mNoneDataTv;
|
|
// @BindView(R.id.reuse_no_connection)
|
|
// LinearLayout mNoConnection;
|
|
// @BindView(R.id.toolbox_refresh)
|
|
// SwipeRefreshLayout mRefresh;
|
|
// @BindView(R.id.reuse_ll_loading)
|
|
// View mLoading;
|
|
//
|
|
// private LinearLayoutManager mLayoutManager;
|
|
// private ToolBoxRvAdapter mRvAdapter;
|
|
// private ToolBoxRvAdapter mNormalRvAdapter;
|
|
//
|
|
// private boolean mIsSearch; // 记录页面状态 搜索页面/普通页面
|
|
// private String mSearchKey; // 记录搜索关键字
|
|
//
|
|
// Runnable runnable = () -> changeAdapter(true);
|
|
//
|
|
// @NonNull
|
|
// public static Intent getIntent(Context context, String entrance) {
|
|
// Intent intent = new Intent(context, ToolBoxActivity.class);
|
|
// intent.putExtra(EntranceUtils.KEY_ENTRANCE, entrance);
|
|
// return intent;
|
|
// }
|
|
//
|
|
// @Override
|
|
// protected int getLayoutId() {
|
|
// return R.layout.activity_toolbox;
|
|
// }
|
|
//
|
|
// @Override
|
|
// protected void onCreate(Bundle savedInstanceState) {
|
|
// super.onCreate(savedInstanceState);
|
|
// setNavigationTitle("光环工具箱");
|
|
//
|
|
// mRefresh.setColorSchemeResources(R.color.theme);
|
|
// mRefresh.setOnRefreshListener(this);
|
|
//
|
|
// // 跳转到工具箱 https://gitlab.ghzs.com/pm/halo-app-issues/issues/636
|
|
// String gameId = getIntent().getStringExtra(EntranceUtils.KEY_GAMEID);
|
|
// String targetUrl = getIntent().getStringExtra(EntranceUtils.KEY_URL);
|
|
// if (!TextUtils.isEmpty(targetUrl) && !TextUtils.isEmpty(gameId)) {
|
|
// findGameAndOpenItsToolboxWebview(gameId, targetUrl);
|
|
// }
|
|
//
|
|
// mLayoutManager = new LinearLayoutManager(this);
|
|
// mToolboxRv.setLayoutManager(mLayoutManager);
|
|
// mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, mSearchKey);
|
|
// mToolboxRv.addItemDecoration(new VerticalItemDecoration(this, 8, false));
|
|
// mToolboxRv.setAdapter(mRvAdapter);
|
|
//
|
|
// mNormalRvAdapter = mRvAdapter;
|
|
//
|
|
// mToolboxRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
// @Override
|
|
// public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
// super.onScrollStateChanged(recyclerView, newState);
|
|
// if (newState == RecyclerView.SCROLL_STATE_IDLE && mLayoutManager.findLastVisibleItemPosition() + 1 == mRvAdapter
|
|
// .getItemCount()) {
|
|
// if (!mRvAdapter.isOver() && !mRvAdapter.isLoading() && !mRvAdapter.isNetworkError()) {
|
|
// mRvAdapter.loadData();
|
|
// }
|
|
// }
|
|
// }
|
|
// });
|
|
//
|
|
// mAppBar.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
|
|
// if (verticalOffset == 0) {
|
|
// mRefresh.setEnabled(true);
|
|
// } else {
|
|
// mRefresh.setEnabled(false);
|
|
// }
|
|
// int totalScrollRange = appBarLayout.getTotalScrollRange();
|
|
// if (totalScrollRange == -verticalOffset) {
|
|
// Util_System_Keyboard.hideSoftKeyboard(this);
|
|
// }
|
|
// });
|
|
//
|
|
// initSearch();
|
|
// }
|
|
//
|
|
// private void findGameAndOpenItsToolboxWebview(String gameId, String url) {
|
|
// RetrofitManager.getInstance()
|
|
// .getApi()
|
|
// .getGameToolBoxData(1, UrlFilterUtils.getFilterQuery("game_id", gameId))
|
|
// .subscribeOn(Schedulers.io())
|
|
// .observeOn(AndroidSchedulers.mainThread())
|
|
// .subscribe(new Response<List<ToolBoxEntity>>() {
|
|
// @Override
|
|
// public void onResponse(@Nullable List<ToolBoxEntity> response) {
|
|
// if (response == null) return;
|
|
//
|
|
// for (ToolBoxEntity toolbox : response) {
|
|
// if (url.equals(toolbox.getUrl())) {
|
|
// Intent intent = WebActivity.getWebByCollectionTools(ToolBoxActivity.this, toolbox, false);
|
|
// startActivity(intent);
|
|
// }
|
|
// }
|
|
// }
|
|
// });
|
|
// }
|
|
//
|
|
// private void initSearch() {
|
|
// backTv.setOnClickListener(v -> search(false, ""));
|
|
//
|
|
// TextHelper.limitTheLengthOfEditText(searchEt, 20, () -> {
|
|
// Utils.toast(this, "最多输入20字");
|
|
// });
|
|
//
|
|
// searchTv.setOnClickListener(v -> {
|
|
// MtaHelper.onEvent("我的光环_新", "工具箱", "点击搜索");
|
|
// if (TextUtils.isEmpty(searchEt.getText().toString())) {
|
|
// Utils.toast(this, R.string.search_hint);
|
|
// return;
|
|
// }
|
|
// Util_System_Keyboard.hideSoftKeyboard(this,searchEt);
|
|
// search(true, searchEt.getText().toString());
|
|
// });
|
|
//
|
|
// searchEt.setOnFocusChangeListener((v, hasFocus) -> {
|
|
// if (!hasFocus) {
|
|
// Util_System_Keyboard.hideSoftKeyboard(this, searchEt);
|
|
// }
|
|
// });
|
|
//
|
|
// searchEt.setOnEditorActionListener((v, actionId, event) -> {
|
|
// if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
|
// searchTv.performClick();
|
|
// }
|
|
// return false;
|
|
// });
|
|
// }
|
|
//
|
|
//
|
|
// @OnClick({R.id.reuse_no_connection, R.id.reuse_none_data})
|
|
// public void onClick(View view) {
|
|
// if (view.getId() == R.id.reuse_no_connection) {
|
|
// mLoading.setVisibility(View.VISIBLE);
|
|
// mNoConnection.setVisibility(View.GONE);
|
|
// mLoading.postDelayed(runnable, 1000);
|
|
// } else if (view.getId() == R.id.reuse_none_data) {
|
|
// if (mIsSearch) {
|
|
// // TODO反馈
|
|
// MtaHelper.onEvent("我的光环_新", "工具箱", "点击反馈");
|
|
// SuggestionActivity.startSuggestionActivity(this, SuggestType.functionSuggest, null, null);
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void loadDone() {
|
|
// mRefresh.setRefreshing(false);
|
|
// mNoneData.setVisibility(View.GONE);
|
|
// mNoConnection.setVisibility(View.GONE);
|
|
// mLoading.setVisibility(View.GONE);
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void loadDone(Object obj) {
|
|
//
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void loadEmpty() {
|
|
// mRefresh.setRefreshing(false);
|
|
// mNoneData.setVisibility(View.VISIBLE);
|
|
// mNoConnection.setVisibility(View.GONE);
|
|
// mLoading.setVisibility(View.GONE);
|
|
// if (mIsSearch) {
|
|
// mNoneDataTv.setText("未找到结果,点我反馈");
|
|
// } else {
|
|
// mNoneDataTv.setText(getResources().getString(R.string.game_empty));
|
|
// }
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void loadError() {
|
|
// mRefresh.setRefreshing(false);
|
|
// mNoneData.setVisibility(View.GONE);
|
|
// mNoConnection.setVisibility(View.VISIBLE);
|
|
// mLoading.setVisibility(View.GONE);
|
|
// }
|
|
//
|
|
// @Override
|
|
// public void onRefresh() {
|
|
// mRefresh.postDelayed(runnable, 1000);
|
|
// }
|
|
//
|
|
// public void search(boolean isSearch, String searchKey) {
|
|
// if (mNoneData.getVisibility() == View.VISIBLE) {
|
|
// mNoneData.setVisibility(View.GONE);
|
|
// }
|
|
// if (isSearch) {
|
|
// mLoading.setVisibility(View.VISIBLE);
|
|
// }
|
|
// mIsSearch = isSearch;
|
|
// mSearchKey = searchKey;
|
|
// changeAdapter(false);
|
|
// }
|
|
//
|
|
// private void changeAdapter(boolean isRefresh) {
|
|
// if (mIsSearch) {
|
|
// mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, mSearchKey);
|
|
// } else {
|
|
// if (mNormalRvAdapter != null && !isRefresh) {
|
|
// mRvAdapter = mNormalRvAdapter;
|
|
// } else {
|
|
// mRvAdapter = new ToolBoxRvAdapter(this, this, mIsSearch, null);
|
|
// mNormalRvAdapter = mRvAdapter;
|
|
// }
|
|
// }
|
|
// mToolboxRv.setAdapter(mRvAdapter);
|
|
//
|
|
// if (mSearchKey != null) {
|
|
// searchEt.setText(mSearchKey);
|
|
// searchEt.setSelection(searchEt.getText().length());
|
|
// }
|
|
//
|
|
// if (mIsSearch) {
|
|
// backTv.setVisibility(View.VISIBLE);
|
|
// } else {
|
|
// backTv.setVisibility(View.GONE);
|
|
// }
|
|
// }
|
|
//}
|