Merge branch '2.2' of https://git.oschina.net/dreamhua/GH-ASSISTv1.45 into 2.2
Conflicts: app/src/main/java/com/gh/gamecenter/adapter/MessageDetailAdapter.java
This commit is contained in:
@ -34,7 +34,6 @@ import com.gh.gamecenter.manager.SystemBarTintManager.SystemBarConfig;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.sharesdk.framework.ShareSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
public class BaseActivity extends Activity implements OnCallBackListener {
|
||||
@ -142,8 +141,6 @@ public class BaseActivity extends Activity implements OnCallBackListener {
|
||||
//如果是游戏分享,newsTitle默认为空
|
||||
public void showShare(String url, String gameName, String icon, String newsTitle, ArrayList<String> tag, String entrance, String type) {
|
||||
|
||||
ShareSDK.initSDK(this);
|
||||
|
||||
//判断是否是官方版
|
||||
boolean isPlugin = false;
|
||||
if (tag != null){
|
||||
|
||||
@ -33,7 +33,6 @@ import com.gh.gamecenter.manager.SystemBarTintManager.SystemBarConfig;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.sharesdk.framework.ShareSDK;
|
||||
import de.greenrobot.event.EventBus;
|
||||
|
||||
public class BaseFragmentActivity extends FragmentActivity {
|
||||
@ -134,8 +133,6 @@ public class BaseFragmentActivity extends FragmentActivity {
|
||||
//如果是游戏分享,newsTitle默认为空
|
||||
public void showShare(String url, String gameName, String icon, String newsTitle, ArrayList<String> tag, String entrance, String type) {
|
||||
|
||||
ShareSDK.initSDK(this);
|
||||
|
||||
//判断是否是官方版
|
||||
boolean isPlugin = false;
|
||||
if (tag != null){
|
||||
|
||||
77
app/src/main/java/com/gh/common/util/AccessTokenKeeper.java
Normal file
77
app/src/main/java/com/gh/common/util/AccessTokenKeeper.java
Normal file
@ -0,0 +1,77 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/11/24.
|
||||
* 该类定义了微博授权时所需要的参数。
|
||||
*/
|
||||
public class AccessTokenKeeper {
|
||||
private static final String PREFERENCES_NAME = "com_weibo_sdk_android";
|
||||
|
||||
private static final String KEY_UID = "uid";
|
||||
private static final String KEY_ACCESS_TOKEN = "access_token";
|
||||
private static final String KEY_EXPIRES_IN = "expires_in";
|
||||
private static final String KEY_REFRESH_TOKEN = "refresh_token";
|
||||
|
||||
/**
|
||||
* 保存 Token 对象到 SharedPreferences。
|
||||
*
|
||||
* @param context 应用程序上下文环境
|
||||
* @param token Token 对象
|
||||
*/
|
||||
public static void writeAccessToken(Context context, Oauth2AccessToken token) {
|
||||
if (null == context || null == token) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
editor.putString(KEY_UID, token.getUid());
|
||||
editor.putString(KEY_ACCESS_TOKEN, token.getToken());
|
||||
editor.putString(KEY_REFRESH_TOKEN, token.getRefreshToken());
|
||||
editor.putLong(KEY_EXPIRES_IN, token.getExpiresTime());
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 SharedPreferences 读取 Token 信息。
|
||||
*
|
||||
* @param context 应用程序上下文环境
|
||||
*
|
||||
* @return 返回 Token 对象
|
||||
*/
|
||||
public static Oauth2AccessToken readAccessToken(Context context) {
|
||||
if (null == context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Oauth2AccessToken token = new Oauth2AccessToken();
|
||||
SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
|
||||
token.setUid(pref.getString(KEY_UID, ""));
|
||||
token.setToken(pref.getString(KEY_ACCESS_TOKEN, ""));
|
||||
token.setRefreshToken(pref.getString(KEY_REFRESH_TOKEN, ""));
|
||||
token.setExpiresTime(pref.getLong(KEY_EXPIRES_IN, 0));
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空 SharedPreferences 中 Token信息。
|
||||
*
|
||||
* @param context 应用程序上下文环境
|
||||
*/
|
||||
public static void clear(Context context) {
|
||||
if (null == context) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences pref = context.getSharedPreferences(PREFERENCES_NAME, Context.MODE_APPEND);
|
||||
SharedPreferences.Editor editor = pref.edit();
|
||||
editor.clear();
|
||||
editor.commit();
|
||||
}
|
||||
}
|
||||
@ -144,9 +144,9 @@ public class DialogUtils {
|
||||
}
|
||||
|
||||
public static void showPluginDialog(Context context, final ConfiremListener listener) {
|
||||
Spanned spanned = Html.fromHtml("您将进行插件化安装以实现插件功能,此过程将"
|
||||
Spanned spanned = Html.fromHtml("您将进行插件化安装以实现插件功能,此过程将"
|
||||
+ "<font color=\"#ff0000\">卸载</font>" + "当前使用的版本并"
|
||||
+ "<font color=\"#ff0000\">安装插件版本</font>" + "。");
|
||||
+ "<font color=\"#ff0000\">安装插件版本</font>");
|
||||
showWarningDialog(context, "插件化安装", spanned, listener);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.gh.common.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
@ -265,21 +266,33 @@ public class MessageShareUtils {
|
||||
private void wechatSahre(){
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
|
||||
api = WXAPIFactory.createWXAPI(context, "wx3ffd0785fad18111"); //初始化微信分享
|
||||
//官方分享
|
||||
// WXImageObject imgObj = new WXImageObject();
|
||||
// imgObj.setImagePath(context.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
|
||||
// WXMediaMessage msg = new WXMediaMessage();
|
||||
// msg.mediaObject = imgObj;
|
||||
//
|
||||
// SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
// req.transaction = buildTransaction("img");
|
||||
// req.message = msg;
|
||||
// req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
//
|
||||
// Bitmap compressBp = compressBitmap(shareBm);
|
||||
// msg.thumbData = Util.bmpToByteArray(compressBp, true);
|
||||
// api.sendReq(req);
|
||||
|
||||
WXImageObject imgObj = new WXImageObject();
|
||||
imgObj.setImagePath(context.getExternalCacheDir().getPath() + "/ShareImg/" + picName);
|
||||
WXMediaMessage msg = new WXMediaMessage();
|
||||
msg.mediaObject = imgObj;
|
||||
|
||||
SendMessageToWX.Req req = new SendMessageToWX.Req();
|
||||
req.transaction = buildTransaction("img");
|
||||
req.message = msg;
|
||||
req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
|
||||
Bitmap compressBp = compressBitmap(shareBm);
|
||||
msg.thumbData = Util.bmpToByteArray(compressBp, true);
|
||||
api.sendReq(req);
|
||||
//调用手机系统分享
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||
intent.setType("image/*");
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + context.getExternalCacheDir().getPath() + "/ShareImg/" + picName));
|
||||
intent.setComponent(new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI"));
|
||||
context.startActivity(intent);
|
||||
} catch (Exception e) {
|
||||
Utils.toast(context,"分享失败!请检查是否已安装微信");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (popupWindow == null) return;
|
||||
popupWindow.dismiss();
|
||||
|
||||
@ -3,12 +3,14 @@ package com.gh.common.util;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.support.v7.widget.GridLayoutManager;
|
||||
@ -28,6 +30,7 @@ import com.facebook.datasource.DataSource;
|
||||
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
|
||||
import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WeiBoShareActivity;
|
||||
import com.tencent.connect.share.QQShare;
|
||||
import com.tencent.connect.share.QzoneShare;
|
||||
import com.tencent.mm.sdk.openapi.IWXAPI;
|
||||
@ -42,15 +45,8 @@ import com.tencent.tauth.UiError;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import cn.sharesdk.framework.Platform;
|
||||
import cn.sharesdk.framework.PlatformActionListener;
|
||||
import cn.sharesdk.framework.ShareSDK;
|
||||
import cn.sharesdk.sina.weibo.SinaWeibo;
|
||||
import cn.sharesdk.system.text.ShortMessage;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/9/4.
|
||||
*/
|
||||
@ -346,71 +342,37 @@ public class ShareUtils {
|
||||
|
||||
//新浪微博分享
|
||||
private void sinaWeiboSahre(){
|
||||
SinaWeibo.ShareParams sinaWeiboParams = new SinaWeibo.ShareParams();
|
||||
handler = new Handler();
|
||||
Intent intent = new Intent(context, WeiBoShareActivity.class);
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("shareNewsTitle", shareNewsTitle);
|
||||
bundle.putString("shareIcon", shareIcon);
|
||||
bundle.putString("shareGameName", shareGameName);
|
||||
bundle.putString("shareUrl", shareUrl);
|
||||
bundle.putBoolean("isPlugin",isPlugin);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
sinaWeiboParams.setText(shareNewsTitle + " " + shareUrl);
|
||||
}else {
|
||||
if (isPlugin){
|
||||
sinaWeiboParams.setText("向你推荐:" + shareGameName + "(光环加速版) " + shareUrl);
|
||||
}else {
|
||||
sinaWeiboParams.setText("向你推荐:" + shareGameName + " " + shareUrl);
|
||||
}
|
||||
}
|
||||
sinaWeiboParams.setImageUrl(shareIcon);
|
||||
sharePlatform(sinaWeiboParams, SinaWeibo.NAME);
|
||||
handler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.toast(context, "分享成功");
|
||||
}
|
||||
}, 3000);
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
|
||||
//短信分享
|
||||
private void shortMessageSahre(){
|
||||
ShortMessage.ShareParams shortMessageParams = new ShortMessage.ShareParams();
|
||||
|
||||
String smsBody;
|
||||
if (shareNewsTitle != null){
|
||||
shortMessageParams.setText(shareNewsTitle + shareUrl);
|
||||
smsBody = shareNewsTitle + shareUrl;
|
||||
}else {
|
||||
if (isPlugin){
|
||||
shortMessageParams.setText("向你推荐:" + shareGameName + "(光环加速版)" + shareUrl);
|
||||
smsBody = "向你推荐:" + shareGameName + "(光环加速版)" + shareUrl;
|
||||
}else {
|
||||
shortMessageParams.setText("向你推荐:" + shareGameName + shareUrl);
|
||||
smsBody = "向你推荐:" + shareGameName + shareUrl;
|
||||
}
|
||||
}
|
||||
shortMessageParams.setUrl(shareUrl);
|
||||
shortMessageParams.setTitleUrl(shareUrl);
|
||||
|
||||
sharePlatform(shortMessageParams, ShortMessage.NAME);
|
||||
}
|
||||
Intent sendIntent = new Intent(Intent.ACTION_VIEW, Uri.parse( "smsto:" ));
|
||||
sendIntent.putExtra( "sms_body", smsBody);
|
||||
sendIntent.setType( "vnd.android-dir/mms-sms" );
|
||||
context.startActivity(sendIntent);
|
||||
|
||||
//分享平台回调
|
||||
private void sharePlatform(Platform.ShareParams params, String name) {
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
Platform platform = ShareSDK.getPlatform(name);
|
||||
if (platform.getName().equals(SinaWeibo.NAME)){
|
||||
platform.SSOSetting(true);
|
||||
}
|
||||
platform.setPlatformActionListener(new PlatformActionListener() {
|
||||
@Override
|
||||
public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
|
||||
Utils.log("分享成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Platform platform, int i, Throwable throwable) {
|
||||
Utils.log("分享失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(Platform platform, int i) {
|
||||
Utils.log("取消分享");
|
||||
}
|
||||
});
|
||||
platform.share(params);
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
|
||||
@ -445,7 +407,7 @@ public class ShareUtils {
|
||||
}
|
||||
|
||||
//添加背景,防止图片格式为PNG的图片分享出现黑框问题
|
||||
private Bitmap addBackGround(Bitmap result) {
|
||||
public Bitmap addBackGround(Bitmap result) {
|
||||
Bitmap bgBitmap;
|
||||
int[] colors = new int[result.getWidth()*result.getHeight()];
|
||||
for (int i = 0; i < colors.length; i++) {
|
||||
|
||||
@ -139,14 +139,19 @@ public class GameDetailActivity extends BaseDetailActivity implements View.OnCli
|
||||
String url = "http://www.ghzhushou.com/game/" + adapter.getGameDetailEntity().getShareCode();
|
||||
showShare(url, gameEntity.getName(), gameEntity.getIcon(), null, gameEntity.getTag(), entrance, "游戏");
|
||||
} else if (v == actionbar_rl_back) {
|
||||
DialogUtils.showWarningDialog(GameDetailActivity.this, "退出提示",
|
||||
"素材更新还在检测中,如果强行退出会中断所有进度,确定退出?",
|
||||
"取消", "强行退出", new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
finish();
|
||||
}
|
||||
}, null);
|
||||
if (InitChangeSkinUtils.isChecking) {
|
||||
DialogUtils.showWarningDialog(GameDetailActivity.this, "退出提示",
|
||||
"素材更新还在检测中,如果强行退出会中断所有进度,确定退出?",
|
||||
"取消", "强行退出", new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
finish();
|
||||
}
|
||||
}, null);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1175,7 +1175,7 @@ public class MainActivity extends BaseFragmentActivity implements OnClickListene
|
||||
if ("EVERY_TIME_OPEN".equals(appEntity.getAlert())) {
|
||||
// 每次都提示
|
||||
showUpdateDialog(updateMD5);
|
||||
} else {
|
||||
} else if (!"NEVER".equals(appEntity.getAlert())){
|
||||
// 一天提示一次
|
||||
String showUpdateTime = sp.getString("show_update_tiem", null);
|
||||
SimpleDateFormat format = new SimpleDateFormat(
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
@ -9,11 +12,12 @@ import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.volley.VolleyError;
|
||||
import com.android.volley.toolbox.DiskBasedCache;
|
||||
@ -21,6 +25,7 @@ import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.gh.base.AppController;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
import com.gh.common.util.GzipUtils;
|
||||
import com.gh.common.util.PostCommentUtils;
|
||||
import com.gh.common.util.TimestampUtils;
|
||||
@ -48,7 +53,7 @@ import butterknife.OnTouch;
|
||||
* Created by khy on 2016/11/8.
|
||||
* 消息详情界面
|
||||
*/
|
||||
public class MessageDetailActivity extends BaseActivity {
|
||||
public class MessageDetailActivity extends BaseActivity implements MessageDetailAdapter.OnCommentCallBackListener{
|
||||
|
||||
@BindView(R.id.message_detail_rv) RecyclerView mMessageDetailRv;
|
||||
@BindView(R.id.message_detail_user_rl) RelativeLayout mMessageDetailUserRl;
|
||||
@ -58,6 +63,8 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
@BindView(R.id.comment_send) TextView mMessageDetailCommentSend;
|
||||
@BindView(R.id.message_detail_comment_et) EditText mMessageDetailEt;
|
||||
@BindView(R.id.message_detail_comment_hint) TextView mMessageDetailCommentHint;
|
||||
@BindView(R.id.message_detail_sv) ScrollView mMessageDetailSv;
|
||||
@BindView(R.id.message_detail_hint_line) View mMessageDetailLine;
|
||||
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
|
||||
@ -65,7 +72,7 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private Toast mToast;
|
||||
private Dialog mSendingDialog;
|
||||
|
||||
private CommentDao mCommentDao;
|
||||
|
||||
@ -88,7 +95,7 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
|
||||
mCommentDao = new CommentDao(this);
|
||||
|
||||
adapter = new MessageDetailAdapter(this, mCommentDao);
|
||||
adapter = new MessageDetailAdapter(this, mCommentDao, mMessageDetailRv);
|
||||
mLayoutManager = new LinearLayoutManager(this);
|
||||
mMessageDetailRv.setLayoutManager(mLayoutManager);
|
||||
mMessageDetailRv.setAdapter(adapter);
|
||||
@ -131,6 +138,22 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
mMessageDetailUserNameTv.setText(sp.getString("user_name", "光环用户"));
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= 19) {
|
||||
//解决透明沉浸栏和软键盘冲突(重置ScrollView高度)
|
||||
final View decorView=getWindow().getDecorView();
|
||||
decorView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
Rect rect=new Rect();
|
||||
decorView.getWindowVisibleDisplayFrame(rect);
|
||||
int screenHeight = decorView.getRootView().getHeight();
|
||||
int heightDifference = screenHeight-rect.bottom;//计算软键盘占有的高度 = 屏幕高度 - 视图可见高度
|
||||
RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) mMessageDetailSv.getLayoutParams();
|
||||
layoutParams.setMargins(0,0,0,heightDifference);//设置ScrollView的marginBottom的值为软键盘占有的高度即可
|
||||
mMessageDetailSv.requestLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -163,22 +186,12 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
|
||||
@OnClick(R.id.message_detail_comment_hint)
|
||||
public void OnHintClikListener() {
|
||||
mMessageDetailCommentHint.setVisibility(View.GONE);
|
||||
mMessageDetailCommentRl.setVisibility(View.VISIBLE);
|
||||
mMessageDetailUserRl.setVisibility(View.VISIBLE);
|
||||
mMessageDetailEt.setFocusable(true);
|
||||
mMessageDetailEt.setFocusableInTouchMode(true);
|
||||
mMessageDetailEt.requestFocus();
|
||||
setSoftInput(true);
|
||||
}
|
||||
|
||||
@OnTouch(R.id.message_detail_rv)
|
||||
public boolean OnRecyclerTouchListener() {
|
||||
if (mMessageDetailCommentRl.getVisibility() == View.VISIBLE) {
|
||||
mMessageDetailCommentHint.setVisibility(View.VISIBLE);
|
||||
mMessageDetailCommentRl.setVisibility(View.GONE);
|
||||
mMessageDetailUserRl.setVisibility(View.GONE);
|
||||
mMessageDetailEt.setText("");
|
||||
setSoftInput(false);
|
||||
}
|
||||
return false;
|
||||
@ -192,8 +205,8 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
Utils.toast(MessageDetailActivity.this, "评论内容不能为空!");
|
||||
return;
|
||||
}
|
||||
mToast = Toast.makeText(MessageDetailActivity.this, "正在提交评论", Toast.LENGTH_SHORT);
|
||||
mToast.show();
|
||||
|
||||
mSendingDialog = DialogUtils.showWaitDialog(this, "正在提交");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
@ -208,11 +221,8 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
new PostCommentUtils.PostCommentListener() {
|
||||
@Override
|
||||
public void postSucced(JSONObject response) {
|
||||
mToast.cancel();
|
||||
mSendingDialog.dismiss();
|
||||
Utils.toast(MessageDetailActivity.this, "发表成功");
|
||||
mMessageDetailCommentHint.setVisibility(View.VISIBLE);
|
||||
mMessageDetailCommentRl.setVisibility(View.GONE);
|
||||
mMessageDetailUserRl.setVisibility(View.GONE);
|
||||
mMessageDetailEt.setText("");
|
||||
setSoftInput(false);
|
||||
|
||||
@ -247,9 +257,10 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public void postFailed(VolleyError error) {
|
||||
mToast.cancel();
|
||||
mSendingDialog.dismiss();
|
||||
|
||||
if (error.networkResponse == null) {
|
||||
Utils.log("评论错误返回为空======");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -263,9 +274,6 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
Utils.toast(MessageDetailActivity.this, "账号状态异常,暂时无法发表评论");
|
||||
} else if ("article blocked".equals(detail)) {
|
||||
Utils.toast(MessageDetailActivity.this, "文章异常,无法发表评论");
|
||||
mMessageDetailCommentHint.setVisibility(View.VISIBLE);
|
||||
mMessageDetailCommentRl.setVisibility(View.GONE);
|
||||
mMessageDetailUserRl.setVisibility(View.GONE);
|
||||
setSoftInput(false);
|
||||
} else if ("illegal".equals(detail)) {
|
||||
Utils.toast(MessageDetailActivity.this, "评论内容可能包括敏感信息,请修改后再发表");
|
||||
@ -314,9 +322,26 @@ public class MessageDetailActivity extends BaseActivity {
|
||||
if (isShow){
|
||||
imm.showSoftInputFromInputMethod(mMessageDetailEt.getWindowToken(), 0);
|
||||
imm.toggleSoftInputFromWindow(mMessageDetailEt.getWindowToken(), 0, InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
mMessageDetailCommentHint.setVisibility(View.GONE);
|
||||
mMessageDetailLine.setVisibility(View.GONE);
|
||||
mMessageDetailCommentRl.setVisibility(View.VISIBLE);
|
||||
mMessageDetailUserRl.setVisibility(View.VISIBLE);
|
||||
mMessageDetailEt.setFocusable(true);
|
||||
mMessageDetailEt.setFocusableInTouchMode(true);
|
||||
mMessageDetailEt.requestFocus();
|
||||
|
||||
} else {
|
||||
imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0);
|
||||
mMessageDetailCommentHint.setVisibility(View.VISIBLE);
|
||||
mMessageDetailLine.setVisibility(View.VISIBLE);
|
||||
mMessageDetailCommentRl.setVisibility(View.GONE);
|
||||
mMessageDetailUserRl.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showSoftInput() {
|
||||
setSoftInput(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
163
app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java
Normal file
163
app/src/main/java/com/gh/gamecenter/WeiBoShareActivity.java
Normal file
@ -0,0 +1,163 @@
|
||||
package com.gh.gamecenter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.facebook.common.references.CloseableReference;
|
||||
import com.facebook.datasource.DataSource;
|
||||
import com.facebook.imagepipeline.datasource.BaseBitmapDataSubscriber;
|
||||
import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.gh.common.util.AccessTokenKeeper;
|
||||
import com.gh.common.util.ImageUtils;
|
||||
import com.gh.common.util.ShareUtils;
|
||||
import com.gh.common.util.Utils;
|
||||
import com.sina.weibo.sdk.api.ImageObject;
|
||||
import com.sina.weibo.sdk.api.TextObject;
|
||||
import com.sina.weibo.sdk.api.WebpageObject;
|
||||
import com.sina.weibo.sdk.api.WeiboMultiMessage;
|
||||
import com.sina.weibo.sdk.api.share.BaseResponse;
|
||||
import com.sina.weibo.sdk.api.share.IWeiboHandler;
|
||||
import com.sina.weibo.sdk.api.share.IWeiboShareAPI;
|
||||
import com.sina.weibo.sdk.api.share.SendMultiMessageToWeiboRequest;
|
||||
import com.sina.weibo.sdk.api.share.WeiboShareSDK;
|
||||
import com.sina.weibo.sdk.auth.AuthInfo;
|
||||
import com.sina.weibo.sdk.auth.Oauth2AccessToken;
|
||||
import com.sina.weibo.sdk.auth.WeiboAuthListener;
|
||||
import com.sina.weibo.sdk.constant.WBConstants;
|
||||
import com.sina.weibo.sdk.exception.WeiboException;
|
||||
import com.sina.weibo.sdk.utils.Utility;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/11/23.
|
||||
*
|
||||
* 微博分享
|
||||
*/
|
||||
public class WeiBoShareActivity extends Activity implements IWeiboHandler.Response{
|
||||
|
||||
private String shareUrl;
|
||||
private String shareGameName;
|
||||
private String shareIcon;
|
||||
private String shareNewsTitle; // shareNewsTitle不为空就是新闻分享,否则是游戏分享
|
||||
|
||||
private boolean isPlugin;
|
||||
|
||||
private IWeiboShareAPI mWeiboShareAPI;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Bundle extras = getIntent().getExtras();
|
||||
shareUrl = extras.getString("shareUrl");
|
||||
shareGameName = extras.getString("shareGameName");
|
||||
shareIcon = extras.getString("shareIcon");
|
||||
shareNewsTitle = extras.getString("shareNewsTitle");
|
||||
isPlugin = extras.getBoolean("isPlugin");
|
||||
|
||||
Utils.toast(this, "分享跳转中...");
|
||||
|
||||
mWeiboShareAPI = WeiboShareSDK.createWeiboAPI(this, "1723629218");
|
||||
mWeiboShareAPI.registerApp();
|
||||
|
||||
weiboLoadBitMap(shareIcon);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
mWeiboShareAPI.handleWeiboResponse(intent, this); //当前应用唤起微博分享后,返回当前应用
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onResponse(BaseResponse baseResponse) {
|
||||
switch (baseResponse.errCode) {
|
||||
case WBConstants.ErrorCode.ERR_OK:
|
||||
Toast.makeText(this, "分享成功", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case WBConstants.ErrorCode.ERR_CANCEL:
|
||||
Toast.makeText(this, "分享取消", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
case WBConstants.ErrorCode.ERR_FAIL:
|
||||
Toast.makeText(this, "分享失败", Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
private void weiboLoadBitMap( String iconUrl){
|
||||
ImageUtils.getInstance().display(this, iconUrl, new BaseBitmapDataSubscriber() {
|
||||
@Override
|
||||
protected void onNewResultImpl(Bitmap bitmap) {
|
||||
Utils.log("分享获取bitmap成功,准备分享");
|
||||
|
||||
Bitmap bgBitmap = ShareUtils.getInstance(getApplication()).addBackGround(bitmap);
|
||||
|
||||
TextObject textObject = new TextObject();
|
||||
if (shareNewsTitle != null){
|
||||
textObject.text = shareNewsTitle + "@光环助手";
|
||||
}else {
|
||||
if (isPlugin){
|
||||
textObject.text ="向你推荐:" + shareGameName + "(光环加速版)" + " @光环助手 ";
|
||||
}else {
|
||||
textObject.text ="向你推荐:" + shareGameName + " @光环助手 " ;
|
||||
}
|
||||
}
|
||||
|
||||
ImageObject imageObject = new ImageObject();
|
||||
imageObject.setImageObject(bgBitmap);//设置缩略图。 注意:最终压缩过的缩略图大小不得超过 32kb。
|
||||
|
||||
WebpageObject webObject = new WebpageObject();
|
||||
webObject.identify = Utility.generateGUID();
|
||||
webObject.title = "";
|
||||
webObject.description = "光环助手";
|
||||
webObject.defaultText = "光环助手";
|
||||
webObject.actionUrl = shareUrl;
|
||||
webObject.setThumbImage(bgBitmap);
|
||||
|
||||
WeiboMultiMessage weiboMessage = new WeiboMultiMessage();//初始化微博的分享消息
|
||||
weiboMessage.textObject = textObject;
|
||||
weiboMessage.imageObject = imageObject;
|
||||
weiboMessage.mediaObject = webObject;
|
||||
SendMultiMessageToWeiboRequest request = new SendMultiMessageToWeiboRequest();
|
||||
request.transaction = String.valueOf(System.currentTimeMillis());
|
||||
request.multiMessage = weiboMessage;
|
||||
|
||||
AuthInfo authInfo = new AuthInfo(WeiBoShareActivity.this, "1723629218", "https://api.weibo.com/oauth2/default.html", "");
|
||||
Oauth2AccessToken accessToken = AccessTokenKeeper.readAccessToken(WeiBoShareActivity.this);
|
||||
String token = "";
|
||||
if (accessToken != null) {
|
||||
token = accessToken.getToken();
|
||||
}
|
||||
|
||||
mWeiboShareAPI.sendRequest(WeiBoShareActivity.this, request, authInfo, token, new WeiboAuthListener() {
|
||||
// 微博web端
|
||||
@Override
|
||||
public void onWeiboException( WeiboException arg0 ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete( Bundle bundle ) {
|
||||
// Oauth2AccessToken newToken = Oauth2AccessToken.parseAccessToken(bundle);
|
||||
// AccessTokenKeeper.writeAccessToken(getApplicationContext(), newToken);
|
||||
// Toast.makeText(getApplicationContext(), "onAuthorizeComplete token = " + newToken.getToken(), 0).show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> dataSource) {
|
||||
Utils.log("分享获取bitmap失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.Html;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -61,6 +62,8 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
/**
|
||||
* Created by khy on 2016/11/8.
|
||||
@ -72,6 +75,10 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
private ConcernEntity mConcernEntity;
|
||||
|
||||
private OnCommentCallBackListener mCallBackListener;
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
|
||||
private List<CommentEntity> mHotCommentList;
|
||||
private List<CommentEntity> mNormalCommentList;
|
||||
|
||||
@ -86,14 +93,18 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
private boolean isOver;
|
||||
private boolean isLoading;
|
||||
private boolean isNetworkError;
|
||||
private boolean isRefreshPosition;
|
||||
|
||||
private static final int ITEM_TOP = 100;
|
||||
private static final int ITEM_TITLE = 101;
|
||||
private static final int ITEM_COMMENT = 102;
|
||||
private static final int ITEM_FOOTER = 103;
|
||||
|
||||
public MessageDetailAdapter(MessageDetailActivity context, CommentDao commentDao) {
|
||||
public MessageDetailAdapter(MessageDetailActivity context, CommentDao commentDao, RecyclerView messageDetailRv) {
|
||||
this.mContext = context;
|
||||
this.mRecyclerView = messageDetailRv;
|
||||
|
||||
mCallBackListener = context;
|
||||
|
||||
mVoteDao = new VoteDao(context);
|
||||
mCommentDao = commentDao;
|
||||
@ -106,13 +117,19 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
isOver = false;
|
||||
isLoading = false;
|
||||
isNetworkError = false;
|
||||
isRefreshPosition = true;
|
||||
|
||||
mHotCommentList = new ArrayList<>();
|
||||
mNormalCommentList = new ArrayList<>();
|
||||
|
||||
mConcernEntity = (ConcernEntity) AppController.get("ConcernEntity", true);
|
||||
|
||||
addHotComment(0);
|
||||
if (mConcernEntity.getCommentnum() != 0) {
|
||||
addHotComment(0);
|
||||
} else {
|
||||
notifyItemChanged(1);
|
||||
mCallBackListener.showSoftInput();
|
||||
}
|
||||
}
|
||||
|
||||
private void addHotComment(int offset) {
|
||||
@ -228,6 +245,16 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (isRefreshPosition) {
|
||||
Timer timer = new Timer(); // 延迟半秒,防止出现闪屏现象
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
mRecyclerView.smoothScrollBy(0, mConcernEntity.getItemHeight()); //定位到评论顶部
|
||||
}
|
||||
}, 500);
|
||||
isRefreshPosition = false;
|
||||
}
|
||||
if (holder instanceof NewsDigestViewHolder) {
|
||||
initNewsDigestViewHolder((NewsDigestViewHolder) holder);
|
||||
} else if (holder instanceof CommentViewHolder) {
|
||||
@ -260,24 +287,41 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
|
||||
private void initFooterViewHolder(final FooterViewHolder viewHolder) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
LinearLayout.LayoutParams params;
|
||||
int height = 0;
|
||||
if (mRecyclerView.getChildCount() != 1 ) {
|
||||
for (int i = 0; i < mRecyclerView.getChildCount(); i++) {
|
||||
if ( i != 0 ){
|
||||
height = height + mRecyclerView.getChildAt(i).getHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mRecyclerView.getHeight() - height < 100) {
|
||||
params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
} else {
|
||||
params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mRecyclerView.getHeight() - height);
|
||||
}
|
||||
viewHolder.itemView.setLayoutParams(params);
|
||||
((LinearLayout)viewHolder.itemView).setGravity(Gravity.CENTER_HORIZONTAL);
|
||||
|
||||
if (!isOver) {
|
||||
viewHolder.hint.setText("加载中...");
|
||||
viewHolder.loading.setVisibility(View.VISIBLE);
|
||||
} else if (isNetworkError || mNormalCommentList.size() == 0 && mHotCommentList.size() == 0) {
|
||||
viewHolder.loading.setVisibility(View.GONE);
|
||||
params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, DisplayUtils.dip2px(mContext, 185));
|
||||
if (isNetworkError) {
|
||||
viewHolder.hint.setText("网络错误,点击重试!");
|
||||
} else {
|
||||
viewHolder.itemView.setLayoutParams(params);
|
||||
viewHolder.itemView.setPadding(0, DisplayUtils.dip2px(mContext, 20), 0, 0);
|
||||
viewHolder.hint.setText("目前还没有评论");
|
||||
}
|
||||
} else {
|
||||
viewHolder.hint.setText("没有更多评论啦..");
|
||||
if (mNormalCommentList.size() > 10) {
|
||||
viewHolder.hint.setText("没有更多评论啦");
|
||||
} else {
|
||||
viewHolder.hint.setText("");
|
||||
}
|
||||
viewHolder.loading.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@ -397,6 +441,13 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.comment.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mCallBackListener.showSoftInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initCommentViewHolder(final CommentViewHolder holder, int position) {
|
||||
@ -622,4 +673,8 @@ public class MessageDetailAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
public boolean isOver() {
|
||||
return isOver;
|
||||
}
|
||||
|
||||
public interface OnCommentCallBackListener {
|
||||
void showSoftInput();
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +155,6 @@ public class PluginAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
|
||||
viewHolder.home1_game_order.setVisibility(View.GONE);
|
||||
|
||||
// ImageUtils.getInstance(context).display(gameEntity.getIcon(), viewHolder.gameThumb);
|
||||
viewHolder.gameThumb.setImageURI(gameEntity.getIcon());
|
||||
if (gameEntity.isPluggable()) {
|
||||
viewHolder.gameNameAndSize.setText(gameEntity.getName() + " - " +
|
||||
|
||||
@ -254,8 +254,10 @@ public class SubjectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
|
||||
});
|
||||
} else if (isRemove) {
|
||||
viewHolder.loading.setVisibility(View.GONE);
|
||||
viewHolder.hint.setText("加载完毕");
|
||||
viewHolder.hint.setText("加载完毕~");
|
||||
viewHolder.itemView.setClickable(false);
|
||||
viewHolder.lineLeft.setVisibility(View.VISIBLE);
|
||||
viewHolder.lineRight.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
viewHolder.loading.setVisibility(View.VISIBLE);
|
||||
viewHolder.hint.setText("加载中...");
|
||||
|
||||
@ -34,7 +34,7 @@ public class SkinConfig {
|
||||
+ GAME_ID + "/skin/data?per_page=" + perPage + "&page=";
|
||||
|
||||
// ewan.anfeng 安峰
|
||||
public static String patchVersion = "com.netease.ma.ewan.anfeng";
|
||||
public static String patchVersion = "com.netease.ma.uc";
|
||||
// public static String patchVersion = "com.netease.ma.bili";
|
||||
|
||||
}
|
||||
|
||||
@ -35,6 +35,16 @@ public class ConcernEntity {
|
||||
|
||||
private int commentnum;
|
||||
|
||||
private int itemHeight;
|
||||
|
||||
public int getItemHeight() {
|
||||
return itemHeight;
|
||||
}
|
||||
|
||||
public void setItemHeight(int itemHeight) {
|
||||
this.itemHeight = itemHeight;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -538,6 +538,7 @@ public class News1FragmentAdapter extends RecyclerView.Adapter<RecyclerView.View
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
skipPosition = viewHolder.getPosition();
|
||||
concernEntity.setItemHeight(viewHolder.itemView.getHeight());
|
||||
AppController.put("ConcernEntity", concernEntity);
|
||||
Intent intent = new Intent(context, MessageDetailActivity.class);
|
||||
intent.putExtra("entrance", "(资讯-关注)");
|
||||
|
||||
Reference in New Issue
Block a user