Commit b5a6f627 authored by linfeng's avatar linfeng

我的发布删除

parent 2bb34864
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="com.xxfc.rv.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<!-- 暂时不用 --> <!-- 暂时不用 -->
<!-- <uses-permission android:name="android.permission.BLUETOOTH" /> --> <!-- <uses-permission android:name="android.permission.BLUETOOTH" /> -->
...@@ -257,9 +260,7 @@ ...@@ -257,9 +260,7 @@
<activity <activity
android:name="com.rv.home.rv.module.ui.main.home.order.EvaluationActivity" android:name="com.rv.home.rv.module.ui.main.home.order.EvaluationActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name="com.rv.home.rv.module.ui.main.home.ShareImageActivity"
android:screenOrientation="portrait" />
<activity <activity
android:name="com.rv.home.rv.module.ui.main.home.order.CancelTheTripActivity" android:name="com.rv.home.rv.module.ui.main.home.order.CancelTheTripActivity"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
...@@ -394,7 +395,7 @@ ...@@ -394,7 +395,7 @@
<!-- Since JCore2.0.0 Required SDK核心功能--> <!-- Since JCore2.0.0 Required SDK核心功能-->
<!-- 这个Service要继承JCommonService --> <!-- 这个Service要继承JCommonService -->
<service <service
android:name=".other.PushService" android:name="com.ruiwenliu.wrapper.other.PushService"
android:process=":pushcore"> android:process=":pushcore">
<intent-filter> <intent-filter>
<action android:name="cn.jiguang.user.service.action" /> <action android:name="cn.jiguang.user.service.action" />
...@@ -402,7 +403,7 @@ ...@@ -402,7 +403,7 @@
</service> </service>
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调--> <!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调-->
<receiver android:name=".other.MyJPushMessageReceiver"> <receiver android:name="com.ruiwenliu.wrapper.other.MyJPushMessageReceiver">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" /> <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="com.xxfc.rv"></category> <category android:name="com.xxfc.rv"></category>
......
package com.xxfc.rv; package com.xxfc.rv;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Notification;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
...@@ -48,6 +49,7 @@ import com.rv.tourism.TourismFragment; ...@@ -48,6 +49,7 @@ import com.rv.tourism.TourismFragment;
import com.rv.version.bean.VersionCheckBean; import com.rv.version.bean.VersionCheckBean;
import com.rv.version.util.DownloadAppUtils; import com.rv.version.util.DownloadAppUtils;
import com.rv.version.util.UpdateAppUtils; import com.rv.version.util.UpdateAppUtils;
import com.squareup.haha.perflib.Main;
import com.xxfc.discovery.DiscoveryFragment; import com.xxfc.discovery.DiscoveryFragment;
import com.yuyife.okgo.OkGoUtil; import com.yuyife.okgo.OkGoUtil;
...@@ -59,6 +61,9 @@ import java.util.Map; ...@@ -59,6 +61,9 @@ import java.util.Map;
import butterknife.BindView; import butterknife.BindView;
import butterknife.OnClick; import butterknife.OnClick;
import cn.jpush.android.api.BasicPushNotificationBuilder;
import cn.jpush.android.api.CustomPushNotificationBuilder;
import cn.jpush.android.api.JPushInterface;
public class MainActivity extends BaseActivity<CommonPresenter> { public class MainActivity extends BaseActivity<CommonPresenter> {
...@@ -124,6 +129,7 @@ public class MainActivity extends BaseActivity<CommonPresenter> { ...@@ -124,6 +129,7 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
viewPager.setOffscreenPageLimit(5); viewPager.setOffscreenPageLimit(5);
setCurrent(TYPE_HOME_PAGE); setCurrent(TYPE_HOME_PAGE);
registerNetWorkListener(); registerNetWorkListener();
initNotification();
SwitchFragment.setFragmentSelected(postion -> setCurrent(postion)); SwitchFragment.setFragmentSelected(postion -> setCurrent(postion));
if (!isGpsOpen()) { if (!isGpsOpen()) {
...@@ -140,6 +146,24 @@ public class MainActivity extends BaseActivity<CommonPresenter> { ...@@ -140,6 +146,24 @@ public class MainActivity extends BaseActivity<CommonPresenter> {
} }
} }
private void initNotification() {
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(mActivity);
builder.statusBarDrawable = R.drawable.logo_title;
builder.notificationFlags =Notification.FLAG_AUTO_CANCEL
| Notification.FLAG_SHOW_LIGHTS; //设置为自动消失和呼吸灯闪烁
builder.notificationDefaults = Notification.DEFAULT_SOUND
| Notification.DEFAULT_VIBRATE
| Notification.DEFAULT_LIGHTS; // 设置为铃声、震动、呼吸灯闪烁都要
JPushInterface.setPushNotificationBuilder(1, builder);
JPushInterface.setDefaultPushNotificationBuilder(builder);
// CustomPushNotificationBuilder builder2 = new CustomPushNotificationBuilder(mActivity, R.layout.customer_notitfication_layout, R.id.icon, R.id.title, R.id.text,R.id.time);
// builder2.statusBarDrawable = R.drawable.logo_title;
// builder2.layoutIconDrawable = R.mipmap.logo;
// builder2.developerArg0 = "developerArg2";
// JPushInterface.setPushNotificationBuilder(2, builder2);
}
private boolean isGpsOpen() { private boolean isGpsOpen() {
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
......
package com.xxfc.rv.other;
import android.content.Context;
import android.util.Log;
import cn.jpush.android.api.CustomMessage;
import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.api.NotificationMessage;
import cn.jpush.android.service.JPushMessageReceiver;
/**
* 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
* */
public class MyJPushMessageReceiver extends JPushMessageReceiver {
private static final String TAG = "JIGUANG";
/**
* TODO 连接极光服务器
*/
@Override
public void onConnected(Context context, boolean b) {
super.onConnected(context, b);
Log.e(TAG, "onConnected");
}
/**
* TODO 注册极光时的回调
*/
@Override
public void onRegister(Context context, String s) {
super.onRegister(context, s);
Log.e(TAG, "onRegister" + s);
}
/**
* TODO 注册以及解除注册别名时回调
*/
@Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
super.onAliasOperatorResult(context, jPushMessage);
Log.e(TAG, jPushMessage.toString());
}
/**
* TODO 接收到推送下来的通知
* 可以利用附加字段(notificationMessage.notificationExtras)来区别Notication,指定不同的动作,附加字段是个json字符串
* 通知(Notification),指在手机的通知栏(状态栏)上会显示的一条通知信息
*/
@Override
public void onNotifyMessageArrived(Context context, NotificationMessage notificationMessage) {
super.onNotifyMessageArrived(context, notificationMessage);
Log.e(TAG, notificationMessage.toString());
}
/**
* TODO 打开了通知
* notificationMessage.notificationExtras(附加字段)的内容处理代码
* 比如打开新的Activity, 打开一个网页等..
*/
@Override
public void onNotifyMessageOpened(Context context, NotificationMessage notificationMessage) {
super.onNotifyMessageOpened(context, notificationMessage);
Log.e(TAG, notificationMessage.notificationExtras);
}
/**
* TODO 接收到推送下来的自定义消息
* 自定义消息不是通知,默认不会被SDK展示到通知栏上,极光推送仅负责透传给SDK。其内容和展示形式完全由开发者自己定义。
* 自定义消息主要用于应用的内部业务逻辑和特殊展示需求
*/
@Override
public void onMessage(Context context, CustomMessage customMessage) {
super.onMessage(context, customMessage);
Log.e(TAG, "onMessage");
}
}
package com.xxfc.rv.other; package com.xxfc.rv.other;
import android.app.ActivityManager;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -7,24 +8,28 @@ import android.os.Bundle; ...@@ -7,24 +8,28 @@ import android.os.Bundle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import com.rv.home.rv.module.ui.main.home.order.OrderListActivity;
import com.rv.rvmine.traveler.CollectionActivity;
import com.rv.share.ShareActivity;
import com.xxfc.rv.MainActivity; import com.xxfc.rv.MainActivity;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
/** /**
* 自定义接收器 * 自定义接收器
* * <p>
* 如果不定义这个 Receiver,则: * 如果不定义这个 Receiver,则:
* 1) 默认用户会打开主界面 * 1) 默认用户会打开主界面
* 2) 接收不到自定义消息 * 2) 接收不到自定义消息
*/ */
public class MyReceiver extends BroadcastReceiver { public class MyReceiver extends BroadcastReceiver {
private static final String TAG = "JIGUANG-Example"; private static final String TAG = "tagtag";
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
...@@ -48,24 +53,61 @@ public class MyReceiver extends BroadcastReceiver { ...@@ -48,24 +53,61 @@ public class MyReceiver extends BroadcastReceiver {
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) { } else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 用户点击打开了通知"); Log.d(TAG, "[MyReceiver] 用户点击打开了通知");
// //打开自定义的Activity //获取推送消息的方法
// Intent i = new Intent(context, TestActivity.class); String extra = bundle.getString(JPushInterface.EXTRA_EXTRA);
// i.putExtras(bundle); JSONObject jsonObject = new JSONObject(extra);
// //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String onclickType = jsonObject.getString("onclickType");
// i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP ); if (isAppRunning(context, "com.xxfc.rv")) { //判断App是否在运行
// context.startActivity(i); Intent intent2 = new Intent();
intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
switch (onclickType) {
case "1":
intent2.setClass(context, OrderListActivity.class);
context.startActivity(intent2);
break;
case "2":
intent2.setClass(context, CollectionActivity.class);
context.startActivity(intent2);
break;
case "3":
intent2.setClass(context, ShareActivity.class);
context.startActivity(intent2);
break;
}
} else {
Intent intent3 = new Intent();
intent3.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
Intent intent4 = new Intent();
intent4.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent4.setClass(context, MainActivity.class);
switch (onclickType) {
case "1":
intent3.setClass(context, OrderListActivity.class);
context.startActivity(intent3);
break;
case "2":
intent3.setClass(context, CollectionActivity.class);
context.startActivity(intent3);
break;
case "3":
intent3.setClass(context, ShareActivity.class);
context.startActivity(intent3);
break;
}
}
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) { } else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
Log.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA)); Log.d(TAG, "[MyReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等.. //在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..
} else if(JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) { } else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(intent.getAction())) {
boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false); boolean connected = intent.getBooleanExtra(JPushInterface.EXTRA_CONNECTION_CHANGE, false);
Log.w(TAG, "[MyReceiver]" + intent.getAction() +" connected state change to "+connected); Log.w(TAG, "[MyReceiver]" + intent.getAction() + " connected state change to " + connected);
} else { } else {
Log.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction()); Log.d(TAG, "[MyReceiver] Unhandled intent - " + intent.getAction());
} }
} catch (Exception e){ } catch (Exception e) {
} }
...@@ -77,7 +119,7 @@ public class MyReceiver extends BroadcastReceiver { ...@@ -77,7 +119,7 @@ public class MyReceiver extends BroadcastReceiver {
for (String key : bundle.keySet()) { for (String key : bundle.keySet()) {
if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) { if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
sb.append("\nkey:" + key + ", value:" + bundle.getInt(key)); sb.append("\nkey:" + key + ", value:" + bundle.getInt(key));
}else if(key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)){ } else if (key.equals(JPushInterface.EXTRA_CONNECTION_CHANGE)) {
sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key)); sb.append("\nkey:" + key + ", value:" + bundle.getBoolean(key));
} else if (key.equals(JPushInterface.EXTRA_EXTRA)) { } else if (key.equals(JPushInterface.EXTRA_EXTRA)) {
if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) { if (TextUtils.isEmpty(bundle.getString(JPushInterface.EXTRA_EXTRA))) {
...@@ -92,7 +134,7 @@ public class MyReceiver extends BroadcastReceiver { ...@@ -92,7 +134,7 @@ public class MyReceiver extends BroadcastReceiver {
while (it.hasNext()) { while (it.hasNext()) {
String myKey = it.next(); String myKey = it.next();
sb.append("\nkey:" + key + ", value: [" + sb.append("\nkey:" + key + ", value: [" +
myKey + " - " +json.optString(myKey) + "]"); myKey + " - " + json.optString(myKey) + "]");
} }
} catch (JSONException e) { } catch (JSONException e) {
Log.e(TAG, "Get message extra JSON error!"); Log.e(TAG, "Get message extra JSON error!");
...@@ -104,4 +146,27 @@ public class MyReceiver extends BroadcastReceiver { ...@@ -104,4 +146,27 @@ public class MyReceiver extends BroadcastReceiver {
} }
return sb.toString(); return sb.toString();
} }
/**
* 方法描述:判断某一应用是否正在运行
*
* @param context 上下文
* @param packageName 应用的包名
* @return true 表示正在运行,false 表示没有运行
*/
public static boolean isAppRunning(Context context, String packageName) {
ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> list = am.getRunningTasks(100);
if (list.size() <= 0) {
return false;
}
for (ActivityManager.RunningTaskInfo info : list) {
if (info.baseActivity.getPackageName().equals(packageName)) {
return true;
}
}
return false;
}
} }
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape_rv_bg_translucent_black_half"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingTop="@dimen/size_5"
android:paddingBottom="@dimen/size_5">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/size_5"
android:src="@mipmap/logo" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2222"
android:textColor="#000000"
android:textSize="16sp" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="444444444444444444"
android:textColor="#000000"
android:textSize="14sp" />
</LinearLayout>
<DateTimeView
android:id="@+id/time"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:maxLines="1"
android:textColor="#000000" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
...@@ -9,6 +9,16 @@ android { ...@@ -9,6 +9,16 @@ android {
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
flavorDimensions "default" flavorDimensions "default"
manifestPlaceholders = [
JPUSH_PKGNAME : "com.xxfc.rv",
JPUSH_APPKEY : "530b223034b92715e0295047", //JPush 上注册的包名对应的 Appkey.
JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
]
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips", 'arm64-v8a'
}
} }
buildTypes { buildTypes {
...@@ -71,4 +81,7 @@ dependencies { ...@@ -71,4 +81,7 @@ dependencies {
implementation 'com.alibaba:fastjson:1.2.21' implementation 'com.alibaba:fastjson:1.2.21'
implementation project(':component_utils') implementation project(':component_utils')
implementation files('libs/tbs_sdk_thirdapp_v3.6.0.1310_43612_sharewithdownload_withoutGame_obfs_20180706_163319.jar') implementation files('libs/tbs_sdk_thirdapp_v3.6.0.1310_43612_sharewithdownload_withoutGame_obfs_20180706_163319.jar')
api 'cn.jiguang.sdk:jpush:3.3.4' // 此处以JPush 3.3.4 版本为例。
api 'cn.jiguang.sdk:jcore:2.1.2' // 此处以JCore 2.1.2 版本为例。
} }
package com.ruiwenliu.wrapper.other;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.jpush.android.api.JPushInterface;
public class ExampleUtil {
public static final String PREFS_NAME = "JPUSH_EXAMPLE";
public static final String PREFS_DAYS = "JPUSH_EXAMPLE_DAYS";
public static final String PREFS_START_TIME = "PREFS_START_TIME";
public static final String PREFS_END_TIME = "PREFS_END_TIME";
public static final String KEY_APP_KEY = "JPUSH_APPKEY";
public static boolean isEmpty(String s) {
if (null == s)
return true;
if (s.length() == 0)
return true;
if (s.trim().length() == 0)
return true;
return false;
}
/**
* 只能以 “+” 或者 数字开头;后面的内容只能包含 “-” 和 数字。
* */
private final static String MOBILE_NUMBER_CHARS = "^[+0-9][-0-9]{1,}$";
public static boolean isValidMobileNumber(String s) {
if(TextUtils.isEmpty(s)) return true;
Pattern p = Pattern.compile(MOBILE_NUMBER_CHARS);
Matcher m = p.matcher(s);
return m.matches();
}
// 校验Tag Alias 只能是数字,英文字母和中文
public static boolean isValidTagAndAlias(String s) {
Pattern p = Pattern.compile("^[\u4E00-\u9FA50-9a-zA-Z_!@#$&*+=.|]+$");
Matcher m = p.matcher(s);
return m.matches();
}
// 取得AppKey
public static String getAppKey(Context context) {
Bundle metaData = null;
String appKey = null;
try {
ApplicationInfo ai = context.getPackageManager().getApplicationInfo(
context.getPackageName(), PackageManager.GET_META_DATA);
if (null != ai)
metaData = ai.metaData;
if (null != metaData) {
appKey = metaData.getString(KEY_APP_KEY);
if ((null == appKey) || appKey.length() != 24) {
appKey = null;
}
}
} catch (NameNotFoundException e) {
}
return appKey;
}
// 取得版本号
public static String GetVersion(Context context) {
try {
PackageInfo manager = context.getPackageManager().getPackageInfo(
context.getPackageName(), 0);
return manager.versionName;
} catch (NameNotFoundException e) {
return "Unknown";
}
}
public static void showToast(final String toast, final Context context)
{
new Thread(new Runnable() {
@Override
public void run() {
Looper.prepare();
Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
Looper.loop();
}
}).start();
}
public static boolean isConnected(Context context) {
ConnectivityManager conn = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = conn.getActiveNetworkInfo();
return (info != null && info.isConnected());
}
@SuppressLint("MissingPermission")
public static String getImei(Context context, String imei) {
String ret = null;
try {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
ret = telephonyManager.getDeviceId();
} catch (Exception e) {
Log.e(ExampleUtil.class.getSimpleName(), e.getMessage());
}
if (isReadableASCII(ret)){
return ret;
} else {
return imei;
}
}
private static boolean isReadableASCII(CharSequence string){
if (TextUtils.isEmpty(string)) return false;
try {
Pattern p = Pattern.compile("[\\x20-\\x7E]+");
return p.matcher(string).matches();
} catch (Throwable e){
return true;
}
}
public static String getDeviceId(Context context) {
return JPushInterface.getUdid(context);
}
}
package com.ruiwenliu.wrapper.other;
import android.content.Context;
import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.service.JPushMessageReceiver;
/**
* 自定义JPush message 接收器,包括操作tag/alias的结果返回(仅仅包含tag/alias新接口部分)
* */
public class MyJPushMessageReceiver extends JPushMessageReceiver {
@Override
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onTagOperatorResult(context,jPushMessage);
super.onTagOperatorResult(context, jPushMessage);
}
@Override
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
TagAliasOperatorHelper.getInstance().onCheckTagOperatorResult(context,jPushMessage);
super.onCheckTagOperatorResult(context, jPushMessage);
}
@Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onAliasOperatorResult(context,jPushMessage);
super.onAliasOperatorResult(context, jPushMessage);
}
@Override
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
TagAliasOperatorHelper.getInstance().onMobileNumberOperatorResult(context,jPushMessage);
super.onMobileNumberOperatorResult(context, jPushMessage);
}
}
package com.xxfc.rv.other; package com.ruiwenliu.wrapper.other;
import cn.jpush.android.service.JCommonService; import cn.jpush.android.service.JCommonService;
......
package com.ruiwenliu.wrapper.other;
import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.util.SparseArray;
import java.util.Locale;
import java.util.Set;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.JPushMessage;
/**
* 处理tagalias相关的逻辑
* */
public class TagAliasOperatorHelper {
private static final String TAG = "JIGUANG-TagAliasHelper";
public static int sequence = 1;
/**增加*/
public static final int ACTION_ADD = 1;
/**覆盖*/
public static final int ACTION_SET = 2;
/**删除部分*/
public static final int ACTION_DELETE = 3;
/**删除所有*/
public static final int ACTION_CLEAN = 4;
/**查询*/
public static final int ACTION_GET = 5;
public static final int ACTION_CHECK = 6;
public static final int DELAY_SEND_ACTION = 1;
public static final int DELAY_SET_MOBILE_NUMBER_ACTION = 2;
private Context context;
private static TagAliasOperatorHelper mInstance;
private TagAliasOperatorHelper(){
}
public static TagAliasOperatorHelper getInstance(){
if(mInstance == null){
synchronized (TagAliasOperatorHelper.class){
if(mInstance == null){
mInstance = new TagAliasOperatorHelper();
}
}
}
return mInstance;
}
public void init(Context context){
if(context != null) {
this.context = context.getApplicationContext();
}
}
private SparseArray<Object> setActionCache = new SparseArray<Object>();
public Object get(int sequence){
return setActionCache.get(sequence);
}
public Object remove(int sequence){
return setActionCache.get(sequence);
}
public void put(int sequence,Object tagAliasBean){
setActionCache.put(sequence,tagAliasBean);
}
private Handler delaySendHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
switch (msg.what){
case DELAY_SEND_ACTION:
if(msg.obj !=null && msg.obj instanceof TagAliasBean){
Log.i(TAG,"on delay time");
sequence++;
TagAliasBean tagAliasBean = (TagAliasBean) msg.obj;
setActionCache.put(sequence, tagAliasBean);
if(context!=null) {
handleAction(context, sequence, tagAliasBean);
}else{
Log.e(TAG,"#unexcepted - context was null");
}
}else{
Log.w(TAG,"#unexcepted - msg obj was incorrect");
}
break;
case DELAY_SET_MOBILE_NUMBER_ACTION:
if(msg.obj !=null && msg.obj instanceof String) {
Log.i(TAG, "retry set mobile number");
sequence++;
String mobileNumber = (String) msg.obj;
setActionCache.put(sequence, mobileNumber);
if(context !=null) {
handleAction(context, sequence, mobileNumber);
}else {
Log.e(TAG, "#unexcepted - context was null");
}
}else{
Log.w(TAG,"#unexcepted - msg obj was incorrect");
}
break;
}
}
};
public void handleAction(Context context,int sequence,String mobileNumber){
put(sequence,mobileNumber);
Log.d(TAG,"sequence:"+sequence+",mobileNumber:"+mobileNumber);
JPushInterface.setMobileNumber(context,sequence,mobileNumber);
}
/**
* 处理设置tag
* */
public void handleAction(Context context,int sequence, TagAliasBean tagAliasBean){
init(context);
if(tagAliasBean == null){
Log.w(TAG,"tagAliasBean was null");
return;
}
put(sequence,tagAliasBean);
if(tagAliasBean.isAliasAction){
switch (tagAliasBean.action){
case ACTION_GET:
JPushInterface.getAlias(context,sequence);
break;
case ACTION_DELETE:
JPushInterface.deleteAlias(context,sequence);
break;
case ACTION_SET:
JPushInterface.setAlias(context,sequence,tagAliasBean.alias);
break;
default:
Log.w(TAG,"unsupport alias action type");
return;
}
}else {
switch (tagAliasBean.action) {
case ACTION_ADD:
JPushInterface.addTags(context, sequence, tagAliasBean.tags);
break;
case ACTION_SET:
JPushInterface.setTags(context, sequence, tagAliasBean.tags);
break;
case ACTION_DELETE:
JPushInterface.deleteTags(context, sequence, tagAliasBean.tags);
break;
case ACTION_CHECK:
//一次只能check一个tag
String tag = (String)tagAliasBean.tags.toArray()[0];
JPushInterface.checkTagBindState(context,sequence,tag);
break;
case ACTION_GET:
JPushInterface.getAllTags(context, sequence);
break;
case ACTION_CLEAN:
JPushInterface.cleanTags(context, sequence);
break;
default:
Log.w(TAG,"unsupport tag action type");
return;
}
}
}
private boolean RetryActionIfNeeded(int errorCode,TagAliasBean tagAliasBean){
if(!ExampleUtil.isConnected(context)){
Log.w(TAG,"no network");
return false;
}
//返回的错误码为6002 超时,6014 服务器繁忙,都建议延迟重试
if(errorCode == 6002 || errorCode == 6014){
Log.d(TAG,"need retry");
if(tagAliasBean!=null){
Message message = new Message();
message.what = DELAY_SEND_ACTION;
message.obj = tagAliasBean;
delaySendHandler.sendMessageDelayed(message,1000*60);
String logs =getRetryStr(tagAliasBean.isAliasAction, tagAliasBean.action,errorCode);
// ExampleUtil.showToast(logs, context);
return true;
}
}
return false;
}
private boolean RetrySetMObileNumberActionIfNeeded(int errorCode,String mobileNumber){
if(!ExampleUtil.isConnected(context)){
Log.w(TAG,"no network");
return false;
}
//返回的错误码为6002 超时,6024 服务器内部错误,建议稍后重试
if(errorCode == 6002 || errorCode == 6024){
Log.d(TAG,"need retry");
Message message = new Message();
message.what = DELAY_SET_MOBILE_NUMBER_ACTION;
message.obj = mobileNumber;
delaySendHandler.sendMessageDelayed(message,1000*60);
String str = "Failed to set mobile number due to %s. Try again after 60s.";
str = String.format(Locale.ENGLISH,str,(errorCode == 6002 ? "timeout" : "server internal error”"));
// ExampleUtil.showToast(str, context);
return true;
}
return false;
}
private String getRetryStr(boolean isAliasAction,int actionType,int errorCode){
String str = "Failed to %s %s due to %s. Try again after 60s.";
str = String.format(Locale.ENGLISH,str,getActionStr(actionType),(isAliasAction? "alias" : " tags") ,(errorCode == 6002 ? "timeout" : "server too busy"));
return str;
}
private String getActionStr(int actionType){
switch (actionType){
case ACTION_ADD:
return "add";
case ACTION_SET:
return "set";
case ACTION_DELETE:
return "delete";
case ACTION_GET:
return "get";
case ACTION_CLEAN:
return "clean";
case ACTION_CHECK:
return "check";
}
return "unkonw operation";
}
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
int sequence = jPushMessage.getSequence();
Log.i(TAG,"action - onTagOperatorResult, sequence:"+sequence+",tags:"+jPushMessage.getTags());
Log.i(TAG,"tags size:"+jPushMessage.getTags().size());
init(context);
//根据sequence从之前操作缓存中获取缓存记录
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
if(tagAliasBean == null){
// ExampleUtil.showToast("获取缓存记录失败", context);
return;
}
if(jPushMessage.getErrorCode() == 0){
Log.i(TAG,"action - modify tag Success,sequence:"+sequence);
setActionCache.remove(sequence);
String logs = getActionStr(tagAliasBean.action)+" tags success";
Log.i(TAG,logs);
// ExampleUtil.showToast(logs, context);
}else{
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags";
if(jPushMessage.getErrorCode() == 6018){
//tag数量超过限制,需要先清除一部分再add
logs += ", tags is exceed limit need to clean";
}
logs += ", errorCode:" + jPushMessage.getErrorCode();
Log.e(TAG, logs);
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
// ExampleUtil.showToast(logs, context);
}
}
}
public void onCheckTagOperatorResult(Context context, JPushMessage jPushMessage){
int sequence = jPushMessage.getSequence();
Log.i(TAG,"action - onCheckTagOperatorResult, sequence:"+sequence+",checktag:"+jPushMessage.getCheckTag());
init(context);
//根据sequence从之前操作缓存中获取缓存记录
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
if(tagAliasBean == null){
// ExampleUtil.showToast("获取缓存记录失败", context);
return;
}
if(jPushMessage.getErrorCode() == 0){
Log.i(TAG,"tagBean:"+tagAliasBean);
setActionCache.remove(sequence);
String logs = getActionStr(tagAliasBean.action)+" tag "+jPushMessage.getCheckTag() + " bind state success,state:"+jPushMessage.getTagCheckStateResult();
Log.i(TAG,logs);
// ExampleUtil.showToast(logs, context);
}else{
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" tags, errorCode:" + jPushMessage.getErrorCode();
Log.e(TAG, logs);
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
// ExampleUtil.showToast(logs, context);
}
}
}
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
int sequence = jPushMessage.getSequence();
Log.i(TAG,"action - onAliasOperatorResult, sequence:"+sequence+",alias:"+jPushMessage.getAlias());
init(context);
//根据sequence从之前操作缓存中获取缓存记录
TagAliasBean tagAliasBean = (TagAliasBean)setActionCache.get(sequence);
if(tagAliasBean == null){
// ExampleUtil.showToast("获取缓存记录失败", context);
return;
}
if(jPushMessage.getErrorCode() == 0){
Log.i(TAG,"action - modify alias Success,sequence:"+sequence);
setActionCache.remove(sequence);
String logs = getActionStr(tagAliasBean.action)+" alias success";
Log.i(TAG,logs);
// ExampleUtil.showToast(logs, context);
}else{
String logs = "Failed to " + getActionStr(tagAliasBean.action)+" alias, errorCode:" + jPushMessage.getErrorCode();
Log.e(TAG, logs);
if(!RetryActionIfNeeded(jPushMessage.getErrorCode(),tagAliasBean)) {
// ExampleUtil.showToast(logs, context);
}
}
}
//设置手机号码回调
public void onMobileNumberOperatorResult(Context context, JPushMessage jPushMessage) {
int sequence = jPushMessage.getSequence();
Log.i(TAG,"action - onMobileNumberOperatorResult, sequence:"+sequence+",mobileNumber:"+jPushMessage.getMobileNumber());
init(context);
if(jPushMessage.getErrorCode() == 0){
Log.i(TAG,"action - set mobile number Success,sequence:"+sequence);
setActionCache.remove(sequence);
}else{
String logs = "Failed to set mobile number, errorCode:" + jPushMessage.getErrorCode();
Log.e(TAG, logs);
if(!RetrySetMObileNumberActionIfNeeded(jPushMessage.getErrorCode(),jPushMessage.getMobileNumber())){
// ExampleUtil.showToast(logs, context);
}
}
}
public static class TagAliasBean{
public int action;
public Set<String> tags;
public String alias;
public boolean isAliasAction;
@Override
public String toString() {
return "TagAliasBean{" +
"action=" + action +
", tags=" + tags +
", alias='" + alias + '\'' +
", isAliasAction=" + isAliasAction +
'}';
}
}
}
...@@ -20,7 +20,7 @@ public class BottomDeleteDialog extends BaseDialog { ...@@ -20,7 +20,7 @@ public class BottomDeleteDialog extends BaseDialog {
@Override @Override
public int getViewLayout() { public int getViewLayout() {
return R.layout.dialog_prompt_bottom; return R.layout.dialog_delete_bottom;
} }
} }
...@@ -129,9 +129,15 @@ public class ApiConfig { ...@@ -129,9 +129,15 @@ public class ApiConfig {
//我的发布 //我的发布
public static String RVENTHUSIAST_GETBYUSERID_LIST = RvFrameConfig.HOST + "/api/im/msg/getByUserId"; public static String RVENTHUSIAST_GETBYUSERID_LIST = RvFrameConfig.HOST + "/api/im/msg/getByUserId";
//删除消息
public static String RVENTHUSIAST_MSG_DELETE = RvFrameConfig.IMA_BASEUSRL + "/b/circle/msg/delete";
//会员信息 //会员信息
public static String RVENTHUSIAST_GETUSERMEMBER = RvFrameConfig.HOST + "/api/admin/baseUserMember/app/getUserMember"; public static String RVENTHUSIAST_GETUSERMEMBER = RvFrameConfig.HOST + "/api/admin/baseUserMember/app/getUserMember";
//im登录
public static String DISCOVERY_IM_LOGIN = RvFrameConfig.HOST + "/api/auth/jwt/imi/login";
/** /**
* 检查token是否有效 * 检查token是否有效
*/ */
......
...@@ -12,6 +12,7 @@ import com.frame.base.bus.RxBus; ...@@ -12,6 +12,7 @@ import com.frame.base.bus.RxBus;
import com.frame.rv.config.RvFrameConfig; import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.SPConstance; import com.ruiwenliu.wrapper.SPConstance;
import com.ruiwenliu.wrapper.base.BaseStatusActivity; import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.other.TagAliasOperatorHelper;
import com.ruiwenliu.wrapper.presenter.MvpPresenter; import com.ruiwenliu.wrapper.presenter.MvpPresenter;
import com.ruiwenliu.wrapper.util.UtilsManager; import com.ruiwenliu.wrapper.util.UtilsManager;
import com.ruiwenliu.wrapper.weight.TitleView; import com.ruiwenliu.wrapper.weight.TitleView;
...@@ -30,6 +31,9 @@ import com.yuyife.okgo.OkGoUtil; ...@@ -30,6 +31,9 @@ import com.yuyife.okgo.OkGoUtil;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import static com.ruiwenliu.wrapper.other.TagAliasOperatorHelper.ACTION_SET;
import static com.ruiwenliu.wrapper.other.TagAliasOperatorHelper.sequence;
/** /**
* Created :Auser * Created :Auser
* Date: 2019/5/15. * Date: 2019/5/15.
...@@ -151,6 +155,17 @@ public abstract class BaseLoginActivity<P extends MvpPresenter> extends BaseStat ...@@ -151,6 +155,17 @@ public abstract class BaseLoginActivity<P extends MvpPresenter> extends BaseStat
// finish(); // finish();
// break; // break;
// } // }
boolean isAliasAction = true;
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
tagAliasBean.action = ACTION_SET;
sequence++;
if (isAliasAction) {
tagAliasBean.alias = registeredBean.getData().getUserId();
} else {
tagAliasBean.tags = null;
}
tagAliasBean.isAliasAction = isAliasAction;
TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), sequence, tagAliasBean);
RxBus.post(new LoginSuccessfulEvent()); RxBus.post(new LoginSuccessfulEvent());
finish(); finish();
......
...@@ -46,6 +46,8 @@ public class MyReleasePatAdapter extends BaseQuickAdapter<MyReleaseBean.DataBean ...@@ -46,6 +46,8 @@ public class MyReleasePatAdapter extends BaseQuickAdapter<MyReleaseBean.DataBean
} else { } else {
helper.setGone(R.id.iv_isvideo, false); helper.setGone(R.id.iv_isvideo, false);
} }
helper.addOnLongClickListener(R.id.ll_item_rv_enthusiast);
} }
} }
} }
...@@ -49,6 +49,8 @@ public class MyReleaseVideoAdapter extends BaseQuickAdapter<MyReleaseBean.DataBe ...@@ -49,6 +49,8 @@ public class MyReleaseVideoAdapter extends BaseQuickAdapter<MyReleaseBean.DataBe
} else { } else {
helper.setGone(R.id.iv_isvideo, false); helper.setGone(R.id.iv_isvideo, false);
} }
helper.addOnLongClickListener(R.id.ll_item_rv_enthusiast);
} }
} }
} }
package com.rv.rvmine.bean;
import com.ruiwenliu.wrapper.base.BaseBean;
public class MyReleaseIMTokenBean extends BaseBean {
private String data;
private boolean rel;
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
}
...@@ -29,6 +29,7 @@ import com.rv.rvmine.R; ...@@ -29,6 +29,7 @@ import com.rv.rvmine.R;
import com.rv.rvmine.R2; import com.rv.rvmine.R2;
import com.rv.rvmine.adapter.MyReleasePatAdapter; import com.rv.rvmine.adapter.MyReleasePatAdapter;
import com.rv.rvmine.bean.MyReleaseBean; import com.rv.rvmine.bean.MyReleaseBean;
import com.rv.rvmine.bean.MyReleaseIMTokenBean;
import com.rv.rvmine.traveler.MyReleaseActivity; import com.rv.rvmine.traveler.MyReleaseActivity;
import com.xxrv.coupon.fragment.ExpiredCouponFragment; import com.xxrv.coupon.fragment.ExpiredCouponFragment;
import com.yuyife.okgo.OkGoUtil; import com.yuyife.okgo.OkGoUtil;
...@@ -49,7 +50,8 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen ...@@ -49,7 +50,8 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen
SimpleRefreshLayout mSimpleRefreshLayout; SimpleRefreshLayout mSimpleRefreshLayout;
private int countPage; private int countPage;
private int mPage; private int mPage;
private String deleteMsgId;
private int deletePosition;
private MyReleasePatAdapter mAdapter; private MyReleasePatAdapter mAdapter;
public static MyReleasePatFragment getInstance(int type) { public static MyReleasePatFragment getInstance(int type) {
...@@ -111,21 +113,20 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen ...@@ -111,21 +113,20 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen
}); });
mAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() { mAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() {
@Override
public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
return true;
}
});
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override @Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) { public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
int id = view.getId();
deletePosition = position;
MyReleaseBean.DataBeanX.DataBean dataBean = (MyReleaseBean.DataBeanX.DataBean) adapter.getItem(position);
deleteMsgId = dataBean.getMsgId();
if (id == R.id.ll_item_rv_enthusiast) {
showDeleteDialgo(); showDeleteDialgo();
} }
return false;
}
}); });
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() { mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override @Override
public void onLoadMoreRequested() { public void onLoadMoreRequested() {
...@@ -159,7 +160,13 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen ...@@ -159,7 +160,13 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen
case 0: case 0:
processData((MyReleaseBean) result); processData((MyReleaseBean) result);
break; break;
case 1:
deleteData((MyReleaseIMTokenBean) result);
break;
case 2:
mAdapter.remove(deletePosition);
mAdapter.notifyItemChanged(deletePosition);
break;
} }
} }
...@@ -216,6 +223,7 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen ...@@ -216,6 +223,7 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen
public void onClick(View v) { public void onClick(View v) {
int i = v.getId(); int i = v.getId();
if (i == R.id.ll_item_delete) { if (i == R.id.ll_item_delete) {
getImToken();
dismiss(); dismiss();
} }
} }
...@@ -224,6 +232,21 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen ...@@ -224,6 +232,21 @@ public class MyReleasePatFragment extends BaseFragment<CommonPresenter> implemen
}.show(); }.show();
} }
private void getImToken() {
if (OkGoUtil.getToken() != null) {
Map<String, Object> headMap = new LinkedHashMap<>();
headMap.put("Authorization", OkGoUtil.getToken());
mPresenter.postData(RvFrameConfig.HOST, 1, ApiConfig.DISCOVERY_IM_LOGIN, MyReleaseIMTokenBean.class, headMap, headMap, true);
}
}
private void deleteData(MyReleaseIMTokenBean imTokenBean) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("messageId", deleteMsgId);
map.put("access_token", imTokenBean.getData());
mPresenter.getData(RvFrameConfig.HOST, 2, ApiConfig.RVENTHUSIAST_MSG_DELETE, BaseBean.class, map, true);
}
public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration { public class AbSpacesItemDecoration extends RecyclerView.ItemDecoration {
private int left; private int left;
......
...@@ -13,8 +13,10 @@ import com.frame.rv.config.RvFrameConfig; ...@@ -13,8 +13,10 @@ import com.frame.rv.config.RvFrameConfig;
import com.ruiwenliu.wrapper.base.BaseBean; import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseFragment; import com.ruiwenliu.wrapper.base.BaseFragment;
import com.ruiwenliu.wrapper.base.presenter.CommonPresenter; import com.ruiwenliu.wrapper.base.presenter.CommonPresenter;
import com.ruiwenliu.wrapper.util.ViewHolder;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout; import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshLayout;
import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView; import com.ruiwenliu.wrapper.weight.refresh.SimpleRefreshView;
import com.rv.component.dialog.BottomDeleteDialog;
import com.rv.home.rv.module.ApiConfig; import com.rv.home.rv.module.ApiConfig;
import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean; import com.rv.home.rv.module.ui.main.home.bean.HomeRecommendBean;
import com.rv.rvmine.R; import com.rv.rvmine.R;
...@@ -22,6 +24,7 @@ import com.rv.rvmine.R2; ...@@ -22,6 +24,7 @@ import com.rv.rvmine.R2;
import com.rv.rvmine.adapter.MyReleasePatAdapter; import com.rv.rvmine.adapter.MyReleasePatAdapter;
import com.rv.rvmine.adapter.MyReleaseVideoAdapter; import com.rv.rvmine.adapter.MyReleaseVideoAdapter;
import com.rv.rvmine.bean.MyReleaseBean; import com.rv.rvmine.bean.MyReleaseBean;
import com.rv.rvmine.bean.MyReleaseIMTokenBean;
import com.yuyife.okgo.OkGoUtil; import com.yuyife.okgo.OkGoUtil;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
...@@ -40,6 +43,8 @@ public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implem ...@@ -40,6 +43,8 @@ public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implem
SimpleRefreshLayout mSimpleRefreshLayout; SimpleRefreshLayout mSimpleRefreshLayout;
private int countPage; private int countPage;
private int mPage; private int mPage;
private String deleteMsgId;
private int deletePosition;
private MyReleaseVideoAdapter mAdapter; private MyReleaseVideoAdapter mAdapter;
...@@ -102,6 +107,21 @@ public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implem ...@@ -102,6 +107,21 @@ public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implem
}); });
mAdapter.setOnItemChildLongClickListener(new BaseQuickAdapter.OnItemChildLongClickListener() {
@Override
public boolean onItemChildLongClick(BaseQuickAdapter adapter, View view, int position) {
deletePosition = position;
MyReleaseBean.DataBeanX.DataBean dataBean = (MyReleaseBean.DataBeanX.DataBean) adapter.getItem(position);
deleteMsgId = dataBean.getMsgId();
int id = view.getId();
if (id == R.id.ll_item_rv_enthusiast) {
showDeleteDialgo();
}
return false;
}
});
mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() { mAdapter.setOnLoadMoreListener(new BaseQuickAdapter.RequestLoadMoreListener() {
@Override @Override
public void onLoadMoreRequested() { public void onLoadMoreRequested() {
...@@ -135,10 +155,51 @@ public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implem ...@@ -135,10 +155,51 @@ public class MyReleaseVideoFragment extends BaseFragment<CommonPresenter> implem
case 0: case 0:
processData((MyReleaseBean) result); processData((MyReleaseBean) result);
break; break;
case 1:
deleteData((MyReleaseIMTokenBean) result);
break;
case 2:
mAdapter.remove(deletePosition);
mAdapter.notifyItemChanged(deletePosition);
break;
}
}
public void showDeleteDialgo() {
new BottomDeleteDialog(_mActivity) {
@Override
public void helper(ViewHolder helper) {
super.helper(helper);
helper.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int i = v.getId();
if (i == R.id.ll_item_delete) {
getImToken();
dismiss();
}
}
}, R.id.ll_item_delete);
}
}.show();
}
private void getImToken() {
if (OkGoUtil.getToken() != null) {
Map<String, Object> headMap = new LinkedHashMap<>();
headMap.put("Authorization", OkGoUtil.getToken());
mPresenter.postData(RvFrameConfig.HOST, 1, ApiConfig.DISCOVERY_IM_LOGIN, MyReleaseIMTokenBean.class, headMap, headMap, true);
} }
} }
private void deleteData(MyReleaseIMTokenBean imTokenBean) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("messageId", deleteMsgId);
map.put("access_token", imTokenBean.getData());
mPresenter.getData(RvFrameConfig.HOST, 2, ApiConfig.RVENTHUSIAST_MSG_DELETE, BaseBean.class, map, true);
}
private void processData(MyReleaseBean bean) { private void processData(MyReleaseBean bean) {
if (mPage == 1) { if (mPage == 1) {
countPage = bean.getData().getPageSize(); countPage = bean.getData().getPageSize();
......
...@@ -12,6 +12,7 @@ import android.widget.Toast; ...@@ -12,6 +12,7 @@ import android.widget.Toast;
import com.ruiwenliu.wrapper.base.BaseBean; import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity; import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.other.TagAliasOperatorHelper;
import com.ruiwenliu.wrapper.util.UtilsManager; import com.ruiwenliu.wrapper.util.UtilsManager;
import com.ruiwenliu.wrapper.weight.TitleView; import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.component.utils.Cookie; import com.rv.component.utils.Cookie;
...@@ -32,6 +33,10 @@ import butterknife.BindView; ...@@ -32,6 +33,10 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import static com.ruiwenliu.wrapper.other.TagAliasOperatorHelper.ACTION_DELETE;
import static com.ruiwenliu.wrapper.other.TagAliasOperatorHelper.ACTION_SET;
import static com.ruiwenliu.wrapper.other.TagAliasOperatorHelper.sequence;
/** /**
* 设置 * 设置
*/ */
...@@ -129,6 +134,19 @@ public class SettingActivity extends BaseStatusActivity<CommonPresenter> { ...@@ -129,6 +134,19 @@ public class SettingActivity extends BaseStatusActivity<CommonPresenter> {
} else if (id == R.id.tv_out_sign) { } else if (id == R.id.tv_out_sign) {
//退出登录 //退出登录
boolean isAliasAction = true;
TagAliasOperatorHelper.TagAliasBean tagAliasBean = new TagAliasOperatorHelper.TagAliasBean();
tagAliasBean.action = ACTION_DELETE;
sequence++;
// if (isAliasAction) {
// tagAliasBean.alias = registeredBean.getData().getUserId();
// } else {
// tagAliasBean.tags = null;
// }
tagAliasBean.isAliasAction = isAliasAction;
TagAliasOperatorHelper.getInstance().handleAction(getApplicationContext(), sequence, tagAliasBean);
UtilsManager.getInstance(mActivity).clearShareData("city_json"); UtilsManager.getInstance(mActivity).clearShareData("city_json");
UtilsManager.getInstance(mActivity).setShNull(); UtilsManager.getInstance(mActivity).setShNull();
RvCache.getInstance(getApplicationContext()).clear(); RvCache.getInstance(getApplicationContext()).clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment