Merge branch 'dev' of gitlab.ghzhushou.com:halo/assistant-android into dev
This commit is contained in:
@ -42,7 +42,6 @@ public class Config {
|
||||
public static final String UMENG_MESSAGE_SECRET = BuildConfig.UMENG_MESSAGE_SECRET;
|
||||
public static final String BUGLY_APPID = BuildConfig.BUGLY_APPID;
|
||||
public static final String PATCH_VERSION_NAME = BuildConfig.PATCH_VERSION_NAME; // 补丁包版本 对应关于->版本号
|
||||
public static final String QIYU_SERVICE_APPKEY = BuildConfig.QIYU_SERVICE_APPKEY;
|
||||
// http://www.ghzs666.com/article/${articleId}.html
|
||||
public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // TODO ghzs/ghzs666 统一
|
||||
public static final String PATCHES = "patches";
|
||||
|
||||
@ -1,110 +0,0 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.facebook.common.executors.UiThreadImmediateExecutorService;
|
||||
import com.facebook.common.references.CloseableReference;
|
||||
import com.facebook.datasource.DataSource;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.imagepipeline.common.ResizeOptions;
|
||||
import com.facebook.imagepipeline.core.ImagePipeline;
|
||||
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
|
||||
import com.facebook.imagepipeline.image.CloseableBitmap;
|
||||
import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.facebook.imagepipeline.request.ImageRequest;
|
||||
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
||||
import com.qiyukf.unicorn.api.ImageLoaderListener;
|
||||
import com.qiyukf.unicorn.api.UnicornImageLoader;
|
||||
|
||||
public class QiYuImageLoader implements UnicornImageLoader {
|
||||
private Context context;
|
||||
|
||||
public QiYuImageLoader(Context context) {
|
||||
this.context = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadImageSync(String uri, int width, int height) {
|
||||
Bitmap resultBitmap = null;
|
||||
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
||||
boolean inMemoryCache = imagePipeline.isInBitmapMemoryCache(ImageRequest.fromUri(uri));
|
||||
if (inMemoryCache) {
|
||||
ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri));
|
||||
if (width > 0 && height > 0) {
|
||||
builder.setResizeOptions(new ResizeOptions(width, height));
|
||||
}
|
||||
ImageRequest imageRequest = builder.build();
|
||||
DataSource<CloseableReference<CloseableImage>> dataSource =
|
||||
imagePipeline.fetchImageFromBitmapCache(imageRequest, context);
|
||||
CloseableReference<CloseableImage> imageReference = dataSource.getResult();
|
||||
try {
|
||||
if (imageReference != null) {
|
||||
CloseableImage closeableImage = imageReference.get();
|
||||
if (closeableImage != null && closeableImage instanceof CloseableBitmap) {
|
||||
Bitmap underlyingBitmap = ((CloseableBitmap) closeableImage).getUnderlyingBitmap();
|
||||
if (underlyingBitmap != null && !underlyingBitmap.isRecycled()) {
|
||||
resultBitmap = underlyingBitmap.copy(Bitmap.Config.RGB_565, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
dataSource.close();
|
||||
CloseableReference.closeSafely(imageReference);
|
||||
}
|
||||
}
|
||||
return resultBitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadImage(String uri, int width, int height, final ImageLoaderListener listener) {
|
||||
ImageRequestBuilder builder = ImageRequestBuilder.newBuilderWithSource(Uri.parse(uri));
|
||||
if (width > 0 && height > 0) {
|
||||
builder.setResizeOptions(new ResizeOptions(width, height));
|
||||
}
|
||||
ImageRequest imageRequest = builder.build();
|
||||
|
||||
ImagePipeline imagePipeline = Fresco.getImagePipeline();
|
||||
DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(imageRequest, context);
|
||||
|
||||
BaseBitmapDataSubscriber subscriber = new BaseBitmapDataSubscriber() {
|
||||
@Override
|
||||
public void onNewResultImpl(@Nullable Bitmap bitmap) {
|
||||
if (listener != null) {
|
||||
new AsyncTask<Bitmap, Void, Bitmap>() {
|
||||
@Override
|
||||
protected Bitmap doInBackground(Bitmap... params) {
|
||||
Bitmap bitmap = params[0];
|
||||
Bitmap result = null;
|
||||
if (bitmap != null && !bitmap.isRecycled()) {
|
||||
result = bitmap.copy(Bitmap.Config.RGB_565, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Bitmap bitmap) {
|
||||
if (bitmap != null) {
|
||||
listener.onLoadComplete(bitmap);
|
||||
} else {
|
||||
listener.onLoadFailed(null);
|
||||
}
|
||||
}
|
||||
}.execute(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailureImpl(DataSource dataSource) {
|
||||
if (listener != null) {
|
||||
listener.onLoadFailed(dataSource.getFailureCause());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
dataSource.subscribe(subscriber, UiThreadImmediateExecutorService.getInstance());
|
||||
}
|
||||
}
|
||||
@ -86,9 +86,6 @@ import com.lightgame.download.DownloadStatus;
|
||||
import com.lightgame.download.FileUtils;
|
||||
import com.lightgame.utils.Util_System_Phone_State;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.qiyukf.nimlib.sdk.NimIntent;
|
||||
import com.qiyukf.unicorn.api.ConsultSource;
|
||||
import com.qiyukf.unicorn.api.Unicorn;
|
||||
import com.tencent.bugly.beta.tinker.TinkerManager;
|
||||
import com.tencent.bugly.crashreport.CrashReport;
|
||||
|
||||
@ -749,31 +746,11 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
// 执行跳转事件
|
||||
handler.postDelayed(skipRun, 500);
|
||||
|
||||
skipQiYuService(getIntent());
|
||||
}
|
||||
|
||||
// 跳转客服回话页面
|
||||
private void skipQiYuService(Intent intent) {
|
||||
if (intent.hasExtra(NimIntent.EXTRA_NOTIFY_CONTENT)) {
|
||||
startServiceActivity(this);
|
||||
setIntent(new Intent()); // 最好将intent清掉,以免从堆栈恢复时又打开客服窗口
|
||||
}
|
||||
}
|
||||
|
||||
// 打开客服窗口
|
||||
public static void startServiceActivity(Context context) {
|
||||
String title = "聊天窗口的标题";
|
||||
ConsultSource source = new ConsultSource("source--Url", "source--Title", "custom--information--string");
|
||||
Unicorn.openServiceActivity(context, title, source);
|
||||
|
||||
Unicorn.queryLastMessage(); // 刷新未读消息
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
skipQiYuService(intent);
|
||||
}
|
||||
|
||||
private void getGhzsSettings() {
|
||||
|
||||
@ -61,8 +61,6 @@ import com.halo.assistant.HaloApp;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.lightgame.config.CommonDebug;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.qiyukf.unicorn.api.Unicorn;
|
||||
import com.qiyukf.unicorn.api.UnreadCountChangeListener;
|
||||
import com.tencent.connect.common.Constants;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@ -120,8 +118,6 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
View mIconHint;
|
||||
@BindView(R.id.personal_ask)
|
||||
View mPersonalAsk;
|
||||
@BindView(R.id.personal_service_unread)
|
||||
TextView mServiceUnread;
|
||||
@BindView(R.id.personal_home_fans_hint)
|
||||
TextView mFansHint;
|
||||
// @BindView(R.id.personal_game_rv)
|
||||
@ -234,8 +230,6 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
GetLoginDataUtils.getInstance(getActivity()).WCLogin(this);
|
||||
}
|
||||
});
|
||||
|
||||
setServiceUnread();
|
||||
}
|
||||
|
||||
|
||||
@ -262,7 +256,7 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
|
||||
@OnClick({R.id.personal_login_qq, R.id.personal_login_weibo, R.id.personal_user_icon,
|
||||
R.id.personal_user_name, R.id.personal_game, R.id.personal_share, R.id.personal_suggestion,
|
||||
R.id.personal_setting, R.id.personal_ask, R.id.personal_service, R.id.personal_home})
|
||||
R.id.personal_setting, R.id.personal_ask, R.id.personal_home})
|
||||
public void onViewClicked(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.personal_login_qq:
|
||||
@ -322,9 +316,6 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
DataUtils.onEvent(getActivity(), "我的光环", "我的问答");
|
||||
CheckLoginUtils.checkLogin(getContext(), () -> startActivity(MyAskActivity.getIntent(getContext())));
|
||||
break;
|
||||
case R.id.personal_service:
|
||||
MainActivity.startServiceActivity(getContext());
|
||||
break;
|
||||
case R.id.personal_home:
|
||||
CheckLoginUtils.checkLogin(getContext(), () -> {
|
||||
PersonalHomeActivity.startTargetActivity(getContext(), UserManager.getInstance().getUserId());
|
||||
@ -333,39 +324,14 @@ public class PersonalFragment extends BaseFragment implements Observer<ApiRespon
|
||||
}
|
||||
}
|
||||
|
||||
private UnreadCountChangeListener listener = new UnreadCountChangeListener() {
|
||||
@Override
|
||||
public void onUnreadCountChange(int count) {
|
||||
// 在此更新界面, count 为当前未读数,
|
||||
// 也可以用 Unicorn.getUnreadCount() 获取总的未读数
|
||||
setServiceUnread();
|
||||
}
|
||||
};
|
||||
|
||||
public void setServiceUnread() {
|
||||
int unreadCount = Unicorn.getUnreadCount();
|
||||
if (unreadCount > 0) {
|
||||
mServiceUnread.setVisibility(View.VISIBLE);
|
||||
mServiceUnread.setText(String.valueOf(unreadCount));
|
||||
} else {
|
||||
mServiceUnread.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void addUnreadCountChangeListener(boolean add) {
|
||||
Unicorn.addUnreadCountChangeListener(listener, add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
addUnreadCountChangeListener(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
addUnreadCountChangeListener(true);
|
||||
}
|
||||
|
||||
private boolean isCanSign(long time) {
|
||||
|
||||
@ -9,16 +9,10 @@ import android.util.Log;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.gh.base.GHActivityLifecycleCallbacksImpl;
|
||||
import com.gh.common.PushManager;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.exposure.ExposureManager;
|
||||
import com.gh.common.util.DataUtils;
|
||||
import com.gh.common.util.QiYuImageLoader;
|
||||
import com.gh.gamecenter.Injection;
|
||||
import com.gh.gamecenter.MainActivity;
|
||||
import com.leon.channel.helper.ChannelReaderUtil;
|
||||
import com.qiyukf.unicorn.api.StatusBarNotificationConfig;
|
||||
import com.qiyukf.unicorn.api.Unicorn;
|
||||
import com.qiyukf.unicorn.api.YSFOptions;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -103,14 +97,6 @@ public class HaloApp extends TinkerAppLike {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 网易七鱼
|
||||
Unicorn.init(getApplication(), Config.QIYU_SERVICE_APPKEY, options(), new QiYuImageLoader(getApplication()));
|
||||
}
|
||||
|
||||
private YSFOptions options() {
|
||||
YSFOptions options = new YSFOptions();
|
||||
options.statusBarNotificationConfig = new StatusBarNotificationConfig();
|
||||
options.statusBarNotificationConfig.notificationEntrance = MainActivity.class;
|
||||
return options;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user