Merge branch 'dev_4.0.1' of gitlab.ghzs.com:halo/assistant-android into dev_4.0.1

This commit is contained in:
kehaoyuan
2020-05-18 16:17:13 +08:00
10 changed files with 78 additions and 14 deletions

View File

@ -3,7 +3,6 @@ package com.gh.base;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Menu;
@ -12,7 +11,6 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import android.widget.TextView;
@ -52,6 +50,8 @@ public abstract class ToolBarActivity extends BaseActivity implements ToolbarCon
@Nullable
private PackageViewModel mPackageViewModel;
protected RelativeLayout mToolbarContainer;
protected Toolbar mToolbar;
protected TextView mTitleTv;
@ -88,6 +88,7 @@ public abstract class ToolBarActivity extends BaseActivity implements ToolbarCon
}
private void initToolbar() {
mToolbarContainer = findViewById(R.id.normal_toolbar_container);
mToolbar = findViewById(R.id.normal_toolbar);
mTitleTv = findViewById(R.id.normal_title);
if (mToolbar != null) {
@ -253,4 +254,11 @@ public abstract class ToolBarActivity extends BaseActivity implements ToolbarCon
protected boolean showDownloadMenu() {
return false;
}
@Override
public void hideToolbar(boolean isHide) {
if (mToolbarContainer != null) {
mToolbarContainer.setVisibility(isHide ? View.GONE : View.VISIBLE);
}
}
}

View File

@ -219,6 +219,8 @@ object DirectUtils {
"anliwall" -> directToAmway(context, fixedTopAmwayCommentId = null, entrance = entrance, path = path)
"h5_game_center" -> directLetoGameCenter(context)
"" -> {
// do nothing
}

View File

@ -16,7 +16,7 @@ import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.Response
import tv.danmaku.ijk.media.exo2.ExoSourceManager
import tv.danmaku.ijk.media.exo2.source.GSYExoHttpDataSource
import tv.danmaku.ijk.media.exo2.source.GSYDefaultHttpDataSource
import tv.danmaku.ijk.media.exo2.source.GSYExoHttpDataSourceFactory
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.atomic.AtomicBoolean
@ -44,8 +44,8 @@ object ExoCacheManager {
val simpleCache = ExoSourceManager.getCacheSingleInstance(HaloApp.getInstance().application, null)
val dataSourceFactory = GSYExoHttpDataSourceFactory(Util.getUserAgent(HaloApp.getInstance().application,
"ExoCacheManager"), DefaultBandwidthMeter.Builder(HaloApp.getInstance().application).build(),
GSYExoHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
GSYExoHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, false)
GSYDefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
GSYDefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, false)
val cacheDataSource = CacheDataSource(simpleCache, dataSourceFactory.createDataSource())
try {
CacheUtil.cache(dataSpec, simpleCache, CacheUtil.DEFAULT_CACHE_KEY_FACTORY, cacheDataSource, CacheUtil.ProgressListener { requestLength, bytesCached, newBytesCached ->

View File

@ -7,11 +7,11 @@ import android.text.TextUtils;
import android.view.MenuItem;
import android.view.MotionEvent;
import androidx.fragment.app.Fragment;
import com.gh.base.ToolBarActivity;
import com.gh.gamecenter.normal.NormalFragment;
import androidx.fragment.app.Fragment;
/**
* Created by khy on 17/10/17.
*/

View File

@ -1,9 +1,10 @@
package com.gh.gamecenter.normal;
import android.view.MenuItem;
import androidx.annotation.IdRes;
import androidx.annotation.MenuRes;
import androidx.annotation.StringRes;
import android.view.MenuItem;
/**
* Created by khy on 17/10/17.
@ -19,4 +20,6 @@ public interface ToolbarController {
// 注意 先initMenu 在getMenuItem
MenuItem getMenuItem(@IdRes int res);
void hideToolbar(boolean isHide);
}

View File

@ -16,8 +16,6 @@ import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.gh.base.BaseActivity;
import com.gh.common.AppExecutor;
import com.gh.common.DefaultJsApi;
@ -27,6 +25,7 @@ import com.gh.common.constant.Constants;
import com.gh.common.util.CheckLoginUtils;
import com.gh.common.util.CollectionUtils;
import com.gh.common.util.DialogHelper;
import com.gh.common.util.DisplayUtils;
import com.gh.common.util.EntranceUtils;
import com.gh.common.util.GsonUtils;
import com.gh.common.util.MtaHelper;
@ -41,6 +40,7 @@ import com.gh.gamecenter.entity.WebShareEntity;
import com.gh.gamecenter.eventbus.EBReuse;
import com.gh.gamecenter.message.MessageDetailFragment;
import com.gh.gamecenter.normal.NormalFragment;
import com.gh.gamecenter.normal.ToolbarController;
import com.gh.gamecenter.personal.PersonalFragment;
import com.gh.gamecenter.retrofit.Response;
import com.gh.gamecenter.retrofit.RetrofitManager;
@ -52,6 +52,7 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.HashMap;
import java.util.List;
import androidx.annotation.Nullable;
import butterknife.BindView;
import butterknife.OnClick;
import io.reactivex.android.schedulers.AndroidSchedulers;
@ -84,6 +85,8 @@ public class WebFragment extends NormalFragment {
TextView webComment;
@BindView(R.id.news_bottom)
RelativeLayout newsBottom;
@BindView(R.id.closeBtn)
RelativeLayout closeBtn;
MenuItem mMenuShare;
MenuItem mMenuCollect;
@ -123,7 +126,19 @@ public class WebFragment extends NormalFragment {
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initMenu();
if (TextUtils.isEmpty(mGameName)) {
initMenu();
} else {
if (requireActivity() instanceof ToolbarController) {
((ToolbarController) requireActivity()).hideToolbar(true);
DisplayUtils.transparentStatusBar(requireActivity());
closeBtn.setVisibility(View.VISIBLE);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) closeBtn.getLayoutParams();
params.topMargin = params.topMargin + DisplayUtils.getStatusBarHeight(getResources());
closeBtn.setLayoutParams(params);
closeBtn.setOnClickListener(v -> onBackPressed());
}
}
}
private void initMenu() {
@ -415,13 +430,15 @@ public class WebFragment extends NormalFragment {
@Override
public void onResume() {
super.onResume();
mWebView.callHandler("videoPlay", retValue -> {});
mWebView.callHandler("videoPlay", retValue -> {
});
}
@Override
public void onPause() {
super.onPause();
mWebView.callHandler("videoPause", retValue -> {});
mWebView.callHandler("videoPause", retValue -> {
});
}
class ShareNativeCallback {